Skip to content

Instantly share code, notes, and snippets.

View czarpino's full-sized avatar

Czar Pino czarpino

View GitHub Profile
#!/bin/sh
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(php -r "echo hash_file('SHA384', 'composer-setup.php');")"
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi
@czarpino
czarpino / how-to.txt
Created September 10, 2018 16:02 — forked from simonw/how-to.md
How to create a tarball of a git repository using "git archive"
git archive --format=tar.gz -o /tmp/my-repo.tar.gz --prefix=my-repo/ master

Assignment by reference

By default in most assignments, PHP uses assignment by value. When a variable is assigned value from another variable, the latter's value is assigned to the former.

$breakfast = "eggs";
$lunch = $breakfast;		// Assignment by value

// Print meals. Outputs:

Hello World

A journey of a thousand lines begins with a “Hello world!”. - Czar

This exercise aims to introduce you to PHP via the customary "Hello world!".

Unlike most programming languages, PHP is a scripting language originally design as a templating language for C. This is why it can easily embedded HTML codes. On the other hand, this has resulted in PHP having quite a unique syntax as compared to most other languages. For example, a PHP script must always start with <?php. Anything outside the opening and closing PHP tags then become treated as output (usually HTML).

Here is how PHP mixed with HTML looks like:

@czarpino
czarpino / pldt-home-fibr-an5506-04-fa-rp2616-advanced-settings.md
Created May 18, 2018 14:07 — forked from kleo/backspace.md
PLDT HOME FIBR AN5506-04-FA RP2616 Advanced Settings

PLDT HOME FIBR AN5506-04-FA RP2616 Advanced Settings

By default the PLDT HOME FIBR AN5506-04-FA RP2616 comes only with limited settings.

Hidden from the web interface are the rest of the router's capabilities and advanced settings.

We just need to enter the right url for the settings you're looking for.

We need to be logged in before we can do anything else, use your defined password if you already set the admin password.

@czarpino
czarpino / bullcrap-articles.csv
Created March 26, 2017 06:30
List of bullcrap articles for posterity's sake
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
http://www.inspireactachieve.com/consciousness/respected-scientist-claims-he-has-found-definitive-proof-that-god-exists/
@czarpino
czarpino / Number.php
Created January 29, 2015 08:39
Number class for git demonstration
<?php
/**
* Number helper class.
*/
class NumberHelper
{

A simple JS event dispatcher that relies on a common key for the handler and data to dispatch actions.

var eventDispatcher = (function (eventDispatcher) {
    var eventHandlers = {};
    
    var eventDispatcher.register = function (key, handler) {
        eventHandlers[key] = handler;
    };

eventDispatcher.dispatch = function (data) {

@czarpino
czarpino / requirejs-separate-config.md
Last active February 22, 2017 10:28
RequireJS - Separating config from logic

RequireJS - Separating config and main module

The idea is to identify, from the same script tag that loads RequireJS, the appropriate main logic module to be loaded. This is done by adding a data-id and a data-logic attribute to the RequireJS script tag.

The data-id attribute is used to identify the RequireJS script tag while the data-logic is used to specify the main logic module to load. Using data-id over id attribute is preferred simply because of technical correctness as scripts do not have an id attribute.

Say we have the following dir structure:

web/

@czarpino
czarpino / vhost-https-how-to.md
Last active August 29, 2015 13:56
Virtual host, HTTPS, SSL/TLS, How to

Windows

Look for httpd.conf and add the following line at the bottom:

IncludeOptional "c:/amp/vhosts/*"

Now, go to c:/amp/vhosts and create a file named vhosts.conf.