Skip to content

Instantly share code, notes, and snippets.

@monkyz
monkyz / gist:3886705
Created October 14, 2012 00:15
NPM commands guide (on going)
// uninstalling global packages(express in this example):
npm uninstall [pkg] -g
//view info about a certain package:
npm view [pkg]
//check globally installed npm modules
npm -g ls
@monkyz
monkyz / gist:3881752
Created October 12, 2012 21:50
error with mysql
hexdump sqldump.sql | head
0000000 6157 6e72 6e69 3a67 5420 6568 6f20 7470
0000010 6f69 206e 2d27 612d 6c6c 2027 7369 6420
0000020 7065 6572 6163 6574 2064 6e61 2064 6977
0000030 6c6c 6220 2065 6572 6f6d 6576 2064 6e69
0000040 6120 6620 7475 7275 2065 6572 656c 7361
0000050 2e65 5020 656c 7361 2065 7375 2065 2d2d
0000060 7263 6165 6574 6f2d 7470 6f69 736e 6920
0000070 736e 6574 6461 0a2e 2d2d 4d20 5379 4c51
0000080 6420 6d75 2070 3031 312e 2033 4420 7369
@monkyz
monkyz / gist:3850614
Created October 8, 2012 03:45
silverstripe nginx vhost
# a better nginx config
02
# author @dnoiz1
03
04
server {
05
root /var/www/mysite.tld/;
06
@monkyz
monkyz / linux_ssh_bastion
Created October 7, 2012 20:48
Creating a transparent SSH tunnel through a bastion host
source article:
http://backdrift.org/transparent-proxy-with-ssh
Creating a transparent SSH tunnel through a bastion host using the ProxyCommand configuration parameter
Tags: linux, ssh, unix
Like most users out there (I think) my systems are usually configured to allow ssh connections from a small handfull of trusted hosts or a bastion host. This is decent security practice but is a total pain when you want to scp a file or grab the stdout of a command from a host outside the trusted area. Or perhaps you have a number of hosts on a private subnet and only one routable host to get in through. I was able to set up a method which allows for transparent access to a host while behind the scenes tunneling through a trusted bastion host involving some pretty minor adjustments to the .ssh/config file.
Here’s how it works:
@monkyz
monkyz / gist:3798058
Created September 28, 2012 05:19
nginx vhost taken from chat
# Server configuration for example.com
server {
# Require HTTP authentication.
#auth_basic "Restricted";
#auth_basic_user_file /home/example/.htpasswd;
# Limit each user to 20 max connections.
limit_conn default 20;
server {
server_name domain.tld;
root /var/www/drupal6; ## <-- Your only path reference.
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
@monkyz
monkyz / gist:3791032
Created September 26, 2012 22:28
nginx + fast cgi vhost for drupal
server {
listen 80;
server_name subdomain.domain.com;
access_log /home/user/drupal/logs/access.log;
error_log /home/user/drupal/logs/error.log;
client_max_body_size 6M;
@monkyz
monkyz / qsort.js
Created September 22, 2012 04:20 — forked from guipn/qsort.js
Simple quicksort implementations
// The simplest implementation I can write.
function qsort(array) {
var lower, upper, pivot;
if (array.length <= 1) {
return array;
}
@monkyz
monkyz / gist:3765052
Created September 22, 2012 03:48
function quicksort
Simple version
In simple pseudocode, the algorithm might be expressed as this:
function quicksort('array')
if length('array') ≤ 1
return 'array' // an array of zero or one elements is already sorted
select and remove a pivot value 'pivot' from 'array'
create empty lists 'less' and 'greater'
for each 'x' in 'array'