Skip to content

Instantly share code, notes, and snippets.

@xctheo
xctheo / global-variables-are-bad.js
Created April 30, 2017 05:13 — forked from hallettj/global-variables-are-bad.js
How and why to avoid global variables in JavaScript
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// Because if you don't, the become global variables.
(function() {
@xctheo
xctheo / apache-vhost-dev.sh
Last active May 12, 2017 01:49 — forked from MauJFernandez/addwebsite
Apache auto-vhost
#!/bin/sh
WEBROOT="$HOME/www/"
VHOSTDIR="/etc/apache2/sites-available/"
NGINXDIR="/etc/nginx/sites-available/"
NGINXENABLEDDIR="/etc/nginx/sites-available/"
EXTENSION=".conf"
RESTARTCMD="/usr/bin/sudo service apache2 reload"
RESTARTCMD_NGINX="/usr/bin/sudo service nginx reload"
if [ "$1" != '' ]; then
if [ ! -f "$VHOSTDIR$1.conf" ]; then
@xctheo
xctheo / curl.md
Created December 17, 2016 03:30 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@xctheo
xctheo / Finance.excel.rate.js
Created December 1, 2016 21:47 — forked from kucukharf/Finance.excel.rate.js
Excel RATE() Javascript Function
RATE = function(periods, payment, present, future, type, guess) {
guess = (guess === undefined) ? 0.01 : guess;
future = (future === undefined) ? 0 : future;
type = (type === undefined) ? 0 : type;
// Set maximum epsilon for end of iteration
var epsMax = 1e-10;
// Set maximum number of iterations
var iterMax = 10;
@xctheo
xctheo / RATE.js
Created December 1, 2016 21:45 — forked from ghalimi/RATE.js
RATE Function
// Copyright (c) 2012 Sutoiku, Inc. (MIT License)
function RATE(periods, payment, present, future, type, guess) {
// Credits: rabugento
// Initialize guess
var guess = (typeof guess === 'undefined') ? 0.01 : guess;
// Initialize future
var future = (typeof future === 'undefined') ? 0 : future;