Blog Spot!


Temporarily switch working copy to a specific Git commit

Top Answer!

If you are at a certain branch mybranch, just go ahead and git checkout commit_hash. Then you can return to your branch by git checkout mybranch. I had the same game bisecting a bug today :)

Also, you should know about git bisect.

github

Added on 08.May.2015
Tags: git branching commit branch

Upgrade Node.js via NPM

I could just hit nodejs.org and get the new image, but figured there had to be an easier way. It turns out there is -- you can upgrade your local Node.js with NPM:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

The n package represents a Node helper, and running the last command upgrades node to the latest stable version. Instead of using stable, you could specify a desired version:

sudo n 0.12.2

Once your install is complete, you can confirm you version with another command:

node -v

Added on 06.May.2015
Tags: npm node nodejs update

Git Branching and Merging

You’ve decided that you’re going to work on issue #53 in whatever issue-tracking system your company uses. To create a branch and switch to it at the same time, you can run the git checkout command with the -b switch:

$ git checkout -b iss53
Switched to a new branch "iss53"

This is shorthand for:

$ git branch iss53
$ git checkout iss53

Switch back to your master branch:

$ git checkout master
Switched to branch 'master'

Next, you have a hotfix to make. Let’s create a hotfix branch on which to work until it’s completed:

$ git checkout -b hotfix
Switched to a new branch 'hotfix'
$ vim index.html
$ git commit -a -m 'fixed the broken email address'
[hotfix 1fb7853] fixed the broken email address
 1 file changed, 2 insertions(+)

You can run your tests, make sure the hotfix is what you want, and merge it back into your master branch to deploy to production. You do this with the git merge command:

$ git checkout master
$ git merge hotfix
Updating f42c576..3a0874c
Fast-forward
 index.html | 2 ++
 1 file changed, 2 insertions(+)

After your super-important fix is deployed, you’re ready to switch back to the work you were doing before you were interrupted. However, first you’ll delete the hotfix branch, because you no longer need it – the master branch points at the same place. You can delete it with the -d option to git branch:

$ git branch -d hotfix
Deleted branch hotfix (3a0874c).

To remove a remote branch (if you know what you are doing!)

git push origin :hotfix

more at git-scm.com

Added on 06.May.2015
Tags: git branching merging branch checkout merge

Get list of all 'input' objects using JavaScript.

Get list of all 'input' objects using JavaScript, without accessing a 'form' object.

function getFormData(formID) {
    var container, inputs, len, index, data = {};

    // get the container element
    container = document.getElementById(formID);

    // find it's child 'input' elements
    inputs = container.getElementsByTagName('input');
    for(index = 0, len = inputs.length; index < len;  index++) {
        if(inputs[index].name) {
            data[inputs[index].name] = inputs[index].value;
        }    
    }

    return data;
}

Test with this.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
    <form action="" id='my-form'>
        <input type="text" name="user" id="user" value="tommy" />
        <input type="text" name="pass" id="pass" value="qwerty" />
        <input type="submit" value="GO">
    </form>
</body>
</html>

Added on 26.Apr.2015
Tags: js form input select field

SSL Self-Signed Certificates

selfsignedcertificate.com

Apache Configuration

You need the following ssl configuration in your VirtualHost:

<VirtualHost donvercety.tk:443>
    ServerName donvercety.tk

    SSLEngine on
    SSLCertificateKeyFile /etc/apache2/ssl/donvercety.tk.key
    SSLCertificateFile /etc/apache2/ssl/donvercety.tk.cert
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown

    # ...
</VirtualHost>

You will also need all the settings and sections required for a regular HTTP host, such as DocumentRoot and . You must also enable apache to listen on port 443, which is done using the directive Listen 443.

You can create a key and certificate yourself instead of downloading them from this page. This makes your key more secure. To generate a key:

openssl genrsa -out donvercety.tk.key 2048

And the certificate:

openssl req -new -x509 -key donvercety.tk.key -out donvercety.tk.cert -days 3650 -subj /CN=donvercety.tk

Added on 20.Apr.2015
Tags: ssl certificate self-signed

Search


PHP Libraries


Carbon lib / docs
Idiorm lib / docs
Image Workshop lib / docs
lorenzos/Minixed lib / docs
Parsedown lib / docs
PHP Paginator lib / docs
PHP Redis lib / docs
QrCode lib / docs
Requests lib / docs
Slim lib / docs
Spyc lib / docs
TWIG lib / docs
Upload lib / docs
Validation lib / docs
Zebra Image lib / docs

JS Libraries


AJV lib / docs
BackboneJS lib / docs
Bootstrap Notify lib / docs
C3.js lib / docs
ChartJS lib / docs
FastMD5 lib / docs
HighlightJS lib / docs
jQuery-Storage lib / docs
JS-Cookie lib / docs
Leaflet JS lib / docs
LowDB lib / docs
Marked lib / docs
NeedlyJS lib / docs
ParcelJS lib / docs
RequireJS lib / docs
Swig lib / docs
Toastr lib / docs
Underscore lib / docs
ValidateJS lib / docs
top