This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
"use strict"; | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Person = (function() { | |
var persons = []; // class variable | |
function Person(name) { | |
this.name = name; // normal instance variable | |
this._password = "secret"; // poor-mans private variable | |
} | |
Person.prototype.sayHello = function() { // instance method | |
var _this = this; // save 'this' for callback functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Debug function | |
// print_r with pre tags | |
// optionally exit program | |
function pr($var, $exit=false) { | |
echo '<pre>'; | |
print_r($var); | |
echo '</pre>'; | |
if( $exit ) exit(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lib = (function(window) { | |
"use strict"; | |
var lib = {}; | |
lib.array = (function() { | |
var a = {}; | |
a.select = function arraySelect(arr, callback) { | |
var newArr = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arrayEach(arr, callback) { | |
for (var i = 0; i < arr.length; i++) { | |
callback(arr[i], i); | |
} | |
} | |
function arraySelect(arr, callback) { | |
var newArr = []; | |
for (var i = 0; i < arr.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var b,d; | |
// d = {}; // 5 | |
// d.size = 0; // 5 | |
// d.size = 22; // 22 | |
b = d && d.size || 5; | |
console.log(b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# PM2 Startup script | |
# Source: https://0x0a14.de/pm2-startup-script-for-freebsd/ | |
# Made by: Johannes Tonn | |
# | |
# Download this file | |
# cd /usr/local/etc/rc.d && fetch https://gist.github.com/457769f2090c6b69cd9d | |
# | |
# Make the file executable with: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i, elem, b = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; | |
for(i = 0; elem = b[i],i < b.length; i++) { | |
console.log(elem); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# portmaster need to be installed in all jails | |
jls | grep -v JID | tr -s " " | cut -d' ' -f2 | xargs -I {} sh -c 'echo {} && jexec -U root {} portmaster -L | grep New | cut -d: -f2' | |
# jls # list jails | |
# grep -v JID # get all lines without JID in it (-v is negation) | |
# tr -s " " # replace multiple newlines with one | |
# cut -d' ' -f2 # split string on newlines and select part 2 | |
# xargs -I {} sh -c '' # split string on newlines and spaces into argument list, then use {} as argument placeholder, then execute sh -c command | |
# sh -c '' # execute sub-shell with commands in string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# for finding changes in UPDATING | |
PKGQUERY=`pkg query %t | sort | tail -n1` | |
echo "####################################" | |
echo "# Updating ports collection (Host) #" | |
echo "####################################" | |
portsnap fetch update |
OlderNewer