Skip to content

Instantly share code, notes, and snippets.

import os
import sys
def DOUBLE_FORK():
"""Perform a UNIX double-fork to detach, and re attach process to init so it's not a child of web worker"""
# do the UNIX double-fork magic, see Stevens' "Advanced
# Programming in the UNIX Environment" for details (ISBN 0201563177)
try:
pid = os.fork()
if pid > 0:
@winterz
winterz / setup-travis.sh
Last active May 25, 2017 01:10
travis CI setup script
#/bin/sh -f
# things to do for travis-ci in the before_install section
if ( test "`uname -s`" = "Darwin" )
then
#cmake v2.8.12 is installed on the Mac workers now
#brew update
#brew install cmake
echo
@astrotars
astrotars / languages.json
Created January 25, 2017 20:41
Programming Languages
["A# .NET","A# (Axiom)","A-0 System","A+","A++","ABAP","ABC","ABC ALGOL","ABLE","ABSET","ABSYS","ACC","Accent","Ace DASL","ACL2","ACT-III","Action!","ActionScript","Ada","Adenine","Agda","Agilent VEE","Agora","AIMMS","Alef","ALF","ALGOL 58","ALGOL 60","ALGOL 68","ALGOL W","Alice","Alma-0","AmbientTalk","Amiga E","AMOS","AMPL","APL","App Inventor for Android's visual block language","AppleScript","Arc","ARexx","Argus","AspectJ","Assembly language","ATS","Ateji PX","AutoHotkey","Autocoder","AutoIt","AutoLISP / Visual LISP","Averest","AWK","Axum","B","Babbage","Bash","BASIC","bc","BCPL","BeanShell","Batch (Windows/Dos)","Bertrand","BETA","Bigwig","Bistro","BitC","BLISS","Blue","Bon","Boo","Boomerang","Bourne shell","bash","ksh","BREW","BPEL","C","C--","C++","C#","C/AL","Caché ObjectScript","C Shell","Caml","Candle","Cayenne","CDuce","Cecil","Cel","Cesil","Ceylon","CFEngine","CFML","Cg","Ch","Chapel","CHAIN","Charity","Charm","Chef","CHILL","CHIP-8","chomski","ChucK","CICS","Cilk","CL","Claire","Clarion","Clean",
@jbarham
jbarham / ipv6octal.py
Created May 29, 2012 23:40
Converts an IPv6 address to octal format for tinydns
# This function is a translation of the PHP function described at
# http://thisisnotajoke.com/2011/07/12/aaaa-for-tinydns-php-function/
def ipv6octal(ipv6):
while len(ipv6.split(':')) < 8:
ipv6 = ipv6.replace('::', ':::')
octets = []
for part in ipv6.split(':'):
if not part:
octets.extend([0, 0])
else:
@hissohathair
hissohathair / blogger-import-master.xml
Created November 5, 2012 11:41
Perl code to convert RSS to Atom for importing into Blogger
<?xml version='1.0' encoding='UTF-8'?>
<feed>
<!-- Easiest way to generate this file is to create a new blog in the template you want,
export a blank Atom dump for it, and add the string "INSERT HERE" between XML comments
just before the closing feed tag -->
<!-- Like this: -->
<!-- INSERT HERE -->
</feed>
@rocraj
rocraj / humans.json
Last active October 25, 2017 12:32
List of Human identifications
[
"Damn",
"Crazy",
"Singing",
"Noisy",
"Music",
"Loving",
"Broken",
"Happy",
"Depressed",
@sasa1977
sasa1977 / conway.ex
Last active November 12, 2017 14:31
Conway's Game of Life in Elixir
# Works on Elixir 1.0.x
# Usage: just paste to `iex` shell, or run `elixir conway.ex`
defmodule Sum do
defstruct value: 0
def value(%Sum{value: value}), do: value
def add(%Sum{value: value} = sum, x) do
%Sum{sum | value: value + x}
@stuartbreckenridge
stuartbreckenridge / feed.json
Last active December 8, 2017 06:49
JSON Feed for Jekyll
---
sitemap: false
---
{
"version": "https://jsonfeed.org/version/1",
"title": "{{ site.title }}",
"home_page_url": "{{ site.url }}/",
"feed_url": "{{ site.url }}/feed.json",
@avivo
avivo / diigo-oneclick-bookmarklet.js
Created March 20, 2011 21:02
A bookmarklet to make a diigo bookmark with a default tag with one click.
javascript:
/* Usage:
Copy the contents of this file and paste into the url of a new bookmark to make the bookmarklet.
Click the bookmarklet to make a Diigo bookmark to the current page with the tag 'oneclick'. It will bring up a popup, which will close 2 seconds after you click anywhere on the bookmarked page, or after you leave the bookmarked page.
Feel free to edit and improve, this was just a quick hack.
*/
(function(){
var path = 'https://secure.diigo.com/api/v2/bookmarks';
var params = {
@Zequez
Zequez / rotate.bookmarklet.js
Created March 9, 2016 04:08
Rotate screen bookmarklet for those times when someone publishes a rotated picture or anything like that and you don't want to break your neck
javascript:!function(){___rotate=window.___rotate||0,___rotate++,___rotate>3&&(___rotate=0);var t=document.documentElement,o=t.clientWidth,e=t.clientHeight,r=document.body,i=r.style;0===___rotate?(i.transform="",i.position="",i.width="",i.height="",i.left="",i.top=""):1===___rotate?(i.transform="rotate(90deg)",i.transformOrigin="top left",i.position="absolute",i.width=e+"px",i.height=o+"px",i.left="100%",i.top="0"):2===___rotate?(i.transform="rotate(180deg)",i.transformOrigin="top left",i.position="absolute",i.width=o+"px",i.height=e+"px",i.left="100%",i.top="100%"):3===___rotate&&(i.transform="rotate(270deg)",i.transformOrigin="top left",i.position="absolute",i.width=e+"px",i.height=o+"px",i.left="0",i.top="100%")}();