Skip to content

Instantly share code, notes, and snippets.

View pstaender's full-sized avatar
👾
extra terrestrial

Philipp Staender pstaender

👾
extra terrestrial
  • Cologne, Germany
View GitHub Profile
Json2Html = (o) ->
if typeof o is 'object' and o isnt null
if o.constructor is Array
parts = for part in o
"<li class=\"#{typeof part}\">#{new Json2Html(part).toString()}</li>"
@html += "<ol class=\"array\">#{parts.join('')}</ol>"
else
parts = for attr of o
"<li class=\"#{typeof attr}\"><span class=\"attribute\">#{attr}</span><span class=\"value\">#{new Json2Html(o[attr]).toString()}</span></li>"
@html += "<ul class=\"object\">#{parts.join('')}</ul>"
@pstaender
pstaender / display_library.sh
Created January 2, 2014 22:29
Make Library folder visible in MacOSX
#!/bin/sh
chflags nohidden ~/Library
@pstaender
pstaender / mysqldump-backup.sh
Last active January 2, 2016 08:59 — forked from tony4d/mysqldump-backup.sh
MySQL Backup Script
#!/bin/bash
FREQUENCY=${1:-daily}
DB_BACKUP_DIR_ROOT="/root/mysqlbackups/$FREQUENCY"
DB_BACKUP_DIR_TODAY="$DB_BACKUP_DIR_ROOT/`date +%Y-%m-%d`"
DATESTRING=$(date +%Y.%m.%dT%H-%M-%S)
# Create the backup directory
mkdir -p $DB_BACKUP_DIR_TODAY
@pstaender
pstaender / iso_utf8_converter.php
Last active January 4, 2016 13:49
Converts Umlauts from ?iso8859-1? to utf8…
<?php
/*
* Converts Umlauts from iso8859-1? to utf8
* by philipp staender <philipp.staender@gmail.com>
* Usage: `php iso_utf8_converter.php fromfile.txt > tofile.txt`
*/
$map = array(
"Â" => "",
"Ã́" => "ô",
.cms .cms-content-fields, .cms .cms-content {
background: #eee;
}
.cms-menu {
background: #eee;
box-shadow: rgba(0, 0, 0, 0.2) 0 0 10px;
}
.cms-menu-list li a {
background: none;
border: 0px solid #888;
@pstaender
pstaender / error503.html
Last active August 29, 2015 14:00
503 Temporarily Offline Page »database servers are currently overloaded« in 12 different languages (seen on last.fm)
<!DOCTYPE html>
<html lang="en-GB"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Temporarily Offline</title>
<style type="text/css" media="screen">
html,
body {
height: 100%;
margin: 0;
#!/usr/bin/ruby
require 'net/http'
require 'net/smtp'
# Brian Wigginton
# http://www.bwigg.com/2008/10/ruby-script-to-check-site-availability/
# 10/7/2008
#
# Check's availabilty of a website. Needs to be run via a cron job.
__BEGIN__
*vimtips.txt* For Vim version 7.3.
------------------------------------------------------------------------------
" new items marked [N] , corrected items marked [C]
" *best-searching*
/joe/e : cursor set to End of match
3/joe/e+1 : find 3rd joe cursor set to End of match plus 1 [C]
/joe/s-2 : cursor set to Start of match minus 2
/joe/+3 : find joe move cursor 3 lines down
/^joe.*fred.*bill/ : find joe AND fred AND Bill (Joe at start of line)
I have marked with a * those which I think are absolutely essential
Items for each section are sorted by oldest to newest. Come back soon for more!
BASH
* In bash, 'ctrl-r' searches your command history as you type
- Input from the commandline as if it were a file by replacing
'command < file.in' with 'command <<< "some input text"'
- '^' is a sed-like operator to replace chars from last command
'ls docs; ^docs^web^' is equal to 'ls web'. The second argument can be empty.
* '!!:n' selects the nth argument of the last command, and '!$' the last arg
@pstaender
pstaender / backup_mysql.php
Created July 17, 2014 08:14
Simple script that creates a MySQL dump of a database. Helpful if you don't have direct access to the database and don't want to use phpmyadmin or the like…
<?php
backup_tables('localhost', 'user', 'passw', 'databasename', '*', true);
/* backup the db OR just a table */
function backup_tables($host, $user, $pass, $name, $tables = '*', $filename = null) {
$return = "";
$link = mysqli_connect($host, $user, $pass, $name);