Skip to content

Instantly share code, notes, and snippets.

@yfix
yfix / cc.py
Created December 2, 2011 09:16 — forked from anonymous/cc.py
Useless C subset compiler
#!/usr/bin/env python
import sys
class Lexer:
NUM, ID, IF, ELSE, WHILE, DO, LBRA, RBRA, LPAR, RPAR, PLUS, MINUS, LESS, \
EQUAL, SEMICOLON, EOF = range(16)
SYMBOLS = { '{': LBRA, '}': RBRA, '=': EQUAL, ';': SEMICOLON, '(': LPAR,

Multiple PHP version under Ubuntu 14.04

Update your machine

apt-get update
apt-get upgrade

Install some dependencies

apt-get install build-essential

#!/bin/bash
# Functions ==============================================
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
@yfix
yfix / teamcity
Last active August 29, 2015 14:06 — forked from AlainODea/teamcity
#!/bin/bash
#
# chkconfig: 235 10 90
# description: TeamCity startup script
#
TEAMCITY_USER=teamcity
TEAMCITY_DIR=/home/teamcity/TeamCity/
TEAMCITY_SERVER=bin/teamcity-server.sh
@yfix
yfix / bash_source.sh
Last active August 29, 2015 14:07 — forked from gipi/bash_source.sh
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@yfix
yfix / README.md
Last active August 29, 2015 14:20 — forked from magnetikonline/README.md

Nginx FastCGI cache

Example /etc/nginx/nginx.conf using FastCGI (e.g. to PHP-FPM) with FastCGI cache enabled. This will capture returned data and persist it to a disk based cache store for a configurable amount of time, great for robust full page caching.

Will need to create a directory to hold cache files, for the example given here that would be:

$ sudo mkdir -p /var/cache/nginxfastcgi
$ chown www-data: /var/cache/nginxfastcgi
@yfix
yfix / Simple Encryption.md
Created October 2, 2015 10:02 — forked from sstephenson/Simple Encryption.md
Simple file/stream encryption using OpenSSL

Simple file/stream encryption using OpenSSL

Create and store a 512-byte random encryption key named secret:

$ mkkey secret

Encrypt the contents of file with the secret key and write it to file.enc:

$ encrypt secret < file > file.enc
@yfix
yfix / super.bash
Created October 2, 2015 10:44 — forked from sstephenson/super.bash
`super` in Bash
#!/usr/bin/env bash
source super.bash
foo() {
echo hello
}
super_function foo
foo() {
#!/usr/bin/env bash
#
# Wraps curl with a custom-drawn progress bar. Use it just like curl:
#
# $ curl-progress -O http://example.com/file.tar.gz
# $ curl-progress http://example.com/file.tar.gz > file.tar.gz
#
# All arguments to the program are passed directly to curl. Define your
# custom progress bar in the `print_progress` function.
#
@yfix
yfix / README.md
Created October 2, 2015 11:10 — forked from obfusk/README.md
dnsmasq for internal network

Install on dev server

$ aptitude install dnsmasq

Wildcards

$ cat >> /etc/dnsmasq.d/dev  # choose any name
address=/dev.example.com/192.168.1.2
^D