Skip to content

Instantly share code, notes, and snippets.

View NoMan2000's full-sized avatar

Michael Ryan Soileau NoMan2000

  • Surge Forward
  • Reno, Nevada
View GitHub Profile
@NoMan2000
NoMan2000 / jsVirtual.js
Created October 30, 2015 14:50
JavaScript create a virtual object
var Foo = function(){
this.par = 3;
this.sub = new(function(t){ //using virtual function to create sub object and pass parent object via 't'
this.p = t;
this.subFunction = function(){
alert(this.p.par);
}
})(this);
}
@NoMan2000
NoMan2000 / optionalArguments.js
Created August 20, 2015 13:04
Testing for optional arguments.
function sum(a, b, c, d) {
// Note: no `break` needed
switch (arguments.length) {
case 0: a = 1;
case 1: b = 2;
case 2: c = 3;
case 3: d = 4;
}
return a + b + c + d;
}
<?php
/**
* GitHub webhook handler template.
*
* @see https://developer.github.com/webhooks/
* @author Miloslav Hůla (https://github.com/milo)
*/
$hookSecret = 's.e.c.r.e.t'; # set NULL to disable check
@NoMan2000
NoMan2000 / apache ssh keys
Last active August 29, 2015 14:27 — forked from phedoreanu/apache ssh keys
Setting up automatic php git pulls
sudo mkdir -m 0700 /var/www/.ssh
sudo chown -R ubuntu:www-data /var/www/.ssh
# one problem here is I do not know who the exec command is executing as.
sudo -u ubuntu ssh-keygen (empty passphrase)
sudo -u ubuntu ssh -T [email protected]
# this adds git to the recognized list of /var/www/.ssh/known_hosts
# paste public key into repo manager
cd (git repo)
sudo -u apache git pull origin branch
@NoMan2000
NoMan2000 / phplint.sh
Created July 17, 2015 04:11
Command line php Linting
php -n -l -d display_errors -d display_startup_errors path/to/your/phpfile.php
# https://github.com/causes/scss-lint/tree/master/lib/scss_lint/linter
exclude: 'app/assets/stylesheets/settings/*'
linters:
BorderZero:
enabled: true
ColorKeyword:
enabled: false
Comment:
@NoMan2000
NoMan2000 / objectCreate.js
Created June 13, 2015 21:17
Creating an object in javaScript: The Pain
// Code goes here
(function testInheritance(global, doc, $) {
"use strict";
var MyFunc = Object.create({}, {
_foo: {
value: null,
writable: true,
enumerable: true
},
<?php
/**
* Class CachedPDOStatement
*
* CachingIterator for a PDOStatement
*/
class CachedPDOStatement extends CachingIterator
{
private $index;
@NoMan2000
NoMan2000 / Negative One or 0
Created April 22, 2015 01:31
Convert from -1 to 0 with ~
Works in javascript or PHP.
var foo = "foo";
if (~foo.indexOf("f")) {
console.log(~foo.indexOf("f"));
console.log("Found it!");
}
@NoMan2000
NoMan2000 / Conf.conf
Last active August 29, 2015 14:18
Apache mod Conf
SSLEngine on
SSLProtocol -ALL +TLSv1.2
SSLHonorCipherOrder On
SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:EECDH+AES:EDH+AES:AESGCM:AES:-SSLv3:EECDH+AES:EECDH+3DES:kRSA+AES:EDH+AES:EDH+3DES:3DES:!NULL:!ADH:!kECDH:!DSS:!MD5:!PSK:!aNULL:!SRP:!DES:!EXP:!RC4
SSLCompression off