Skip to content

Instantly share code, notes, and snippets.

View franz-josef-kaiser's full-sized avatar

Franz Josef Kaiser franz-josef-kaiser

View GitHub Profile
@miki725
miki725 / .bash_prompt.sh
Last active April 2, 2025 13:32
Custom bash prompt which displays: (virtualenv) user:/path (git-branch)
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch of the current git/mercurial repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@mhawksey
mhawksey / gist:9199459
Last active February 16, 2022 11:13
Google Apps Script snippet to send tracking data to Google Analytics using the Measurement Protocol
function onOpen(){
// example send for Sheets
sendGAMP("UA-XXXX-1", SpreadsheetApp.getActiveSpreadsheet().getUrl());
// example send for Documents
//sendGAMP("UA-XXXX-1", DocumentApp.getActiveDocument().getUrl());
// example send for Forms *NOTE* getUrl not implemented yet in New Sheets
//sendGAMP("UA-XXXX-1", FormApp.getActiveForm().getUrl());
}
@james2doyle
james2doyle / slugify.php
Last active January 12, 2022 13:19
Simple slugify function for PHP. Creates a slug for the passed string, taking into account international characters as well.
<?php
function slugify($string, $replace = array(), $delimiter = '-') {
// https://github.com/phalcon/incubator/blob/master/Library/Phalcon/Utils/Slug.php
if (!extension_loaded('iconv')) {
throw new Exception('iconv module not loaded');
}
// Save the old locale and set the new locale to UTF-8
$oldLocale = setlocale(LC_ALL, '0');
setlocale(LC_ALL, 'en_US.UTF-8');
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
@jbroadway
jbroadway / Dockerfile
Last active February 4, 2016 02:00
Dockerfile for Nginx + PHP server.
FROM ubuntu:13.04
MAINTAINER Johnny Broadway "[email protected]"
RUN apt-get update
RUN apt-get install -y wget git vim postfix nginx sqlite
RUN apt-get install -y mysql-server mysql-client
RUN apt-get install -y php5-cli php5-common php5-mysql php5-sqlite php5-curl php5-fpm
RUN wget -O /etc/nginx/sites-available/default https://gist.github.com/jbroadway/6369183/raw/682a1ed8078cc39f59c3624f460b128addff95db/nginx-default
@Rarst
Rarst / class-opera-bookmarks-parser.php
Last active September 30, 2017 07:54
Parser for Opera's native bookmarks.adr format.
<?php
/**
* Parse Opera's bookmarks.adr file.
*/
class Opera_Bookmarks_Parser {
/** @var string path to bookmarks.adr */
public $adr;
@Rarst
Rarst / readme.md
Last active January 28, 2020 02:51
Walker class for WordPress custom menu integration in Twitter Bootstrap navbar
@chrisguitarguy
chrisguitarguy / iframe-widget.php
Created February 7, 2012 02:52
Embed your recent posts anywhere as an iframe!
<?php
/*
Plugin Name: iFrame Your WP
Description: Allow people to embed your latest posts in an iFrame
Author: Christopher Davis
Author URI: http://www.christopherguitar.me
License: GPL2
*/
register_activation_hook( __FILE__ , 'wpse32725_activation' );
@scribu
scribu / test-list-tables.php
Created January 24, 2012 12:43
WP Admin List Tables hooks
<?php
//////////////////
// Screens
//////////////////
// Posts
foreach ( array(
'posts', 'pages', 'recipe_posts',
'edit-post', 'edit-page', 'edit-recipe',
@gerardpaapu
gerardpaapu / tests.js
Created December 9, 2011 11:45
UTF-8 encoding in javascript
var assert = require('assert'),
toBytes = require('./utf8.js').toBytes,
toUTF8Bytes = require('./utf8.js').toUTF8Bytes,
fromUTF8Bytes = require('./utf8.js').fromUTF8Bytes;
assert.deepEqual(toBytes(0x0), [0]);
assert.deepEqual(toBytes(0xff), [0xff]);
assert.deepEqual(toBytes(0x01ff), [0x01, 0xff]);
assert.deepEqual(toBytes(0xffff), [0xff, 0xff]);
@Rarst
Rarst / nice-labels.php
Last active May 3, 2017 06:43
"Nice numbers" implementation for pretty range of numerical labels on graph
<?php
// @link http://books.google.com/books?id=fvA7zLEFWZgC&pg=PA61&lpg=PA61#v=onepage&q&f=false
function nice_labels( $min, $max, $ticks = 5 ) {
$range = nice_number( $max, false );
$d = nice_number( $range / ( $ticks - 1 ) );
$graphmin = floor( $min / $d ) * $d;
$graphmax = ceil( $max / $d ) * $d;
$nfrac = max( array( - floor( log( $d, 10 ) ), 0 ) );