Skip to content

Instantly share code, notes, and snippets.

View abits's full-sized avatar

Christoph Martel abits

  • Stuttgart, Germany
View GitHub Profile
@abits
abits / exit-notice.html
Created July 13, 2012 22:12
Do stuff when user exits site.
<!-- This is a short demo how js could detect whether a user wants to leave the site.
Tested with Firefox and Chrome. (c) Christoph Martel <chris@codeways.org> -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
#!/usr/bin/env python
"""Custom reST_ directive for ditaa_ integration.
.. _reST: http://docutils.sourceforge.net/rst.html
.. _ditaa: http://ditaa.sourceforge.net/
"""
import os
import tempfile
from zlib import adler32
---
- name: Commmon | MailUtils
apt: pkg=mailutils state=latest
- name: Commmon | sqlite3
apt: pkg=sqlite3 state=latest
- name: Commmon | libsqlite3-dev
apt: pkg=libsqlite3-dev state=latest
@abits
abits / flac2mp3.sh
Created February 16, 2014 21:51
flac to mp3
#!/bin/bash
shnsplit -o flac -f *.cue *.flac
cuetag.sh *.cue split*.flac
for a in split*.flac; do
# give output correcit extension
OUTF="${a[@]/%flac/mp3}"
# get the tags
@abits
abits / nginx.conf
Created February 27, 2014 21:10 — forked from leon/nginx.conf
server {
listen 80;
server_name localhost;
root /home/website/web;
rewrite ^/app\.php/?(.*)$ /$1 permanent;
try_files $uri @rewriteapp;
location @rewriteapp {
This gist contains two files for simple indexing of PDF files.
== requirements ==
First you need to install Solr (which requires a Java JDK): Download a tar or zipfile at http://www.apache.org/dyn/closer.cgi/lucene/solr/ and unpack it to a directory of your choice. Go into this directory and start solr running in jetty by:
$ cd example
$ java -jar start.jar
Then locate your browser to http://localhost:8983/solr/
@abits
abits / Castle.xml
Created June 27, 2014 20:03 — forked from kwmt/Castle.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Data>
<Series>
<id>83462</id>
<Actors>|Nathan Fillion|Stana Katic|Molly C. Quinn|Jon Huertas|Seamus Dever|Tamala Jones|Susan Sullivan|Ruben Santiago-Hudson|Monet Mazur|</Actors>
<Airs_DayOfWeek>Monday</Airs_DayOfWeek>
<Airs_Time>10:00 PM</Airs_Time>
<ContentRating>TV-PG</ContentRating>
<FirstAired>2009-03-09</FirstAired>
<Genre>|Drama|</Genre>
--langdef=js
--langmap=js:.js
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\{/\5/,object/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*function[ \t]*\(/\5/,function/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\[/\5/,array/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[^"]'[^']*/\5/,string/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*(true|false)/\5/,boolean/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[0-9]+/\5/,number/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*.+([,;=]|$)/\5/,variable/
--regex-js=/(,|(;|^)[ \t]*(var|let|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*[ \t]*([,;]|$)/\5/,variable/
'''
Credit to Adam Presley, who's ftpsyncing fabfile I used as a starting point
http://adampresley.com/#!post/2013/04/how-i-deployed-a-php-app-via-ftp-using-fabric-and-git
'''
import fabric
import ftplib
import re
import os
from git import *
from ftplib import FTP
@abits
abits / gist:60423cf31d3a55c455b7
Created March 27, 2015 22:35
post-receive hook with build task
#!/sbin/sh
GIT_WORK_TREE=/srv/http/www.hjkl.org git checkout -f
cd /srv/http/www.hjkl.org && make html