Skip to content

Instantly share code, notes, and snippets.

View themasch's full-sized avatar

Mark Schmale themasch

  • SMF GmbH & Co. KG
  • Germany
View GitHub Profile
@themasch
themasch / bla.html
Created December 5, 2012 14:30
security questions made easy (with bootstrap)
<a href="/delete/stuff" class="btn btn-delete" data-sure-text="sure?"> delete </a>
@themasch
themasch / gist:4069769
Created November 14, 2012 01:57
idea: javascript annotation powered controllers (for express)
Controller.create('Test', {
/**
* @Route('/')
*/
indexAction: function(req, res)
{
},
@themasch
themasch / build.sh
Created October 26, 2012 18:28
Simple build script. Who needs autoconf?
#!/bin/bash
######## defaults
EXECUTABLE_NAME="a.out"
LIBS=""
LOG_FILE="/tmp/$(basename $0).$RANDOM.log"
COMPILE_OPTS=""
LINK_OPTS=""
if [ "$1" == "debug" ]
@themasch
themasch / index.php
Created October 14, 2012 23:26
CMS in 10 Zeilen
<htmlzeugsblafoo>
<?php
$request = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['REQUEST_URI'];
$dirname = __DIR__ . '/';
$request = preg_replace('(^'.$dirname.')', '', $request);
$page = trim($request, '/');
$path = './content/' . $page . '.html';
$allowed = array_merge(glob('./content/*.html'), glob('./content/*/*.html'));
if(in_array($path, $allowed)) include $path;
else include './content/home.html';
@themasch
themasch / CoolStringClass.php
Created September 18, 2012 16:28
it workz!
<?php
class CoolStringClass
{
public function __construct($content)
{
$this->contents = $content;
}
public function __toString()
@themasch
themasch / status.php
Created December 27, 2011 02:04
simple swtor server status (incl. controller boilerplate)
<?php
class ServerStatus
{
private $cachePath = './status.cache';
private $cacheLifetime = 60; // in sekunden
private $statusUrl = 'http://www.swtor.com/de/server-status';
public function dispatch($url)
{
@themasch
themasch / image_rotation.php
Created November 18, 2011 02:03
rotate an image to the correct orientation
$exif = (int)$image->getImageProperty("exif:Orientation");
switch($exif) {
case 2:
$image->flopImage();
break;
case 3:
$image->rotateImage('black', 180);
break;
case 4:
$image->flipImage();
@themasch
themasch / mix.js
Created November 6, 2011 16:52
a tiny javascript "colorpicker". use it as a bookmarklet
(function() {
document.cE = document.createElement;
var s = [], div = document.cE('div');
var text = document.cE('input');
var col = [0, 0, 0];
var aE = "attachEvent", oc = "onchange", ok = "onkeyup";
var uB = function() {
var c = text.value.match(/\w\w?/g), n, i;
for(i in c) {
s[i].value = col[i] = parseInt(c[i], 16) || 0;
@themasch
themasch / upper.c
Created August 9, 2011 15:13
upper stdin
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/stat.h>
#include <fcntl.h>
#define MAXLINE 4096
@themasch
themasch / getar
Created May 23, 2011 12:25
simple shell script to download a tar archive and extract it directly
#!/bin/sh
CURL=`which curl`
TAR=`which tar`
path=$1
shift
params=$*
$CURL $path | $TAR -x $params