Skip to content

Instantly share code, notes, and snippets.

@zahna
zahna / repo_feeds.txt
Created May 18, 2012 15:38 — forked from rubiojr/repo_feeds.txt
RPM Repo Feeds for Fedora/RHEL
#
# Compilation of Yum Repositories for RHEL/Fedora
#
#
# RBEL
#
http://rbel.frameos.org/stable/el5/i386, rbel5-i386, rhel-5
http://rbel.frameos.org/stable/el5/x86_64, rbel5-x86_64, rhel-5
@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.
#!/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
#!/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
# 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/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
@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:b302ee6d150405e5430855e53d5771ee
Last active August 8, 2017 13:05
render any number of recaptchas that are on a single page
In the page somewhere:
<script type="text/javascript" defer>
var gcRender = function() {
var sitekey, gcs, i, rcks, len;
sitekey = '';
// Render all .g-recaptcha's on the page
gcs = document.getElementsByClassName('g-recaptcha');
len = gcs.length;
for (i = 0; i < len; i++) {
@zahna
zahna / gist:3450f3de83454fd266082bc009e87574
Last active August 8, 2017 13:05
tengine (nginx) backend process healthcheck in lua
location /health.pgrep {
default_type text/plain;
access_log off;
content_by_lua '
local io = require "io"
if (ngx.var.arg_q ~= nil and ngx.var.arg_q ~= "") then
-- Note: Testing this over 127.0.0.1 will always succeed.
local arg_q = ngx.var.arg_q:gsub("[;&|/\\\\ ]", "")
local c = assert(io.popen("/usr/bin/pgrep -f "..arg_q))
@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) {