Skip to content

Instantly share code, notes, and snippets.

@zahna
zahna / gist:daecc195f8fdf1c73a90971948e9e403
Last active August 8, 2017 13:06
submitting a form with js
<form id="donate_form" method="POST" action="/stripe/submit_form">
<input type="button" id="submit" value="Submit >" onclick="submit_payment('form#donate_form')">
</form>
function submit_payment(form) {
var $form = $(form);
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
      if (xhr.readyState === XMLHttpRequest.DONE) {
@zahna
zahna / gist:da8f242c82484fd5b36e5ea2d4d5af78
Last active August 8, 2017 13:07
enforcing group "users" in my Music directory on NFS
sudo chgrp -R users Music
sudo chmod g+s Music
sudo setfacl -d -m g::rwx Music
@zahna
zahna / gist:945ba4c63c66f16127bea869f2bdf4ef
Created April 13, 2017 17:15
clean url fastcgi apache
I forget this snippet too much...
DirectoryIndex index.html index.php
AcceptPathInfo On
SuexecUserGroup user group
RewriteEngine On
# FastCGI PHP
<Files *.php>
SetHandler fcgid-script
#AddHandler fcgid-script .php
@zahna
zahna / gist:63783dba265269ea09a6c75e4d7bad62
Last active August 8, 2017 13:08
initializing my ansible dynamic inventory data structure
# Initialize the inventory
inventory = {}
inventory['all'] = {'hosts': [], 'vars': {}}
inventory['_meta'] = {'hostvars': {}}
# Add localhost to inventory
inventory['all']['hosts'].append('localhost')
inventory['_meta']['hostvars']['localhost'] = {}
inventory['_meta']['hostvars']['localhost']['ansible_host'] = 'localhost'
inventory['_meta']['hostvars']['localhost']['ec2_public_dns_name'] = 'localhost'
inventory['_meta']['hostvars']['localhost']['ec2_public_ip_address'] = '127.0.0.1'
#!/bin/sh
# This is run by a cron job. It periodically checks our repository and triggers a new jenkins run.
cd /var/www/bg/current
output=$(git pull)
if [ "$output" != "Already up-to-date." ]; then
curl -sS http://127.0.0.1:8080/job/BG5/build?token=bg5isthecoolest
fi
#!/bin/sh
# Source function library.
. /etc/rc.d/init.d/functions
setsid java -jar /opt/ci/selenium-server-standalone-2.35.0.jar 2>&1 > /var/log/selenium.log &
#!/bin/bash
XVFB=/usr/bin/Xvfb
XVFBARGS=":0 -screen 0 1280x1024x8 -fbdir /var/run"
PIDFILE=/var/run/xvfb.pid
# Source function library.
. /etc/rc.d/init.d/functions
case "$1" in
#!/bin/sh
# This script ensures that Xvnc is running
vncserver :0 -depth 8 -geometry 1280x1024 -PasswordFile /opt/ci/passwd
setsid mwm 2>&1 > /dev/null
@zahna
zahna / waf.lua
Last active June 24, 2018 18:01
-- https://github.com/openresty/lua-nginx-module#nginx-api-for-lua
-- https://www.nginx.com/resources/wiki/modules/lua/
-- http://www.staticshin.com/programming/definitely-an-open-resty-guide/
-- access_by_lua_file /path/to/waf.lua;
-- examine request
ngx.req.read_body()
local request_method = ngx.req.get_method()
local get_args = ngx.req.get_uri_args()
local post_args, err = ngx.req.get_post_args()
@zahna
zahna / gist:34fa18c40acb4d5692fc
Last active October 29, 2015 15:47
daemonizing in shell (to help me remember)
# my quick and dirty method:
setsid /bin/sh -c "cd /; $@ 2>&1 < /dev/null | logger -t $1 &"
# or the full proper method, found online:
# full daemonization of external command with setsid
daemonize() {
( # 1. fork
# 2.1. redirect stdin/stdout/stderr before setsid. redirect tty fds to /dev/null.