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() {
# When you use any non-standard directories with apache you need to also edit /etc/apache2/apache2.conf, and add in a <Directory /bla/bla> stanza so that apache knows it is OK to access the area.
<Directory /user/directory/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
usermod -a -G www-data $USER
sudo chown -R www-data:www-data $HOME/www/
# chgrp -R www-data $HOME/www
@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 / Linux.Users.list_categorised.sh
Created January 11, 2017 12:38
Linux.Users.list_categorised.sh
#!/bin/bash
# Name: listusers.bash
# Purpose: List all normal user and system accounts in the system. Tested on RHEL / Debian Linux
# Author: Vivek Gite <www.cyberciti.biz>, under GPL v2.0+
# -----------------------------------------------------------------------------------
_l="/etc/login.defs"
_p="/etc/passwd"
## get mini UID limit ##
l=$(grep "^UID_MIN" $_l)
@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;
# from https://anvileight.com/blog/2016/03/20/simple-http-server-with-python/
import BaseHTTPServer, SimpleHTTPServer
import ssl
httpd = BaseHTTPServer.HTTPServer(('localhost', 443),
SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket,
keyfile="path/tp/key.pem",
@xctheo
xctheo / gist:31f3e2b6731c3374ab015b7a5c99256b
Last active June 7, 2016 01:36
Python 3 HTTPS server
#from https://anvileight.com/blog/2016/03/20/simple-http-server-with-python/
from http.server import HTTPServer, BaseHTTPRequestHandler
import ssl
httpd = HTTPServer(('localhost', 4443), BaseHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket,
keyfile="path/to/key.pem",
certfile='path/to/cert.pem', server_side=True)