Skip to content

Instantly share code, notes, and snippets.

Bran van der Meer branneman

Block or report user

Report or block branneman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Struct.php
<?php
class Struct
{
/**
* Define a new struct object, a blueprint object with only empty properties.
*/
public static function factory()
{
$struct = new self;
foreach (func_get_args() as $value) {
View example-mod-wsgi.py
def application(environ, start_response):
import sys
path = 'YOUR_WWW_ROOT_DIRECTORY'
if path not in sys.path:
sys.path.append(path)
from pyinfo import pyinfo
output = pyinfo()
start_response('200 OK', [('Content-type', 'text/html')])
return [output]
@branneman
branneman / gist:951833
Created May 2, 2011
Timing script execution at high-precision
View gist:951833
<?php
$time1 = explode(' ', microtime());
$time1 = $time1[1] . substr($time1[0], 1, -2);
// your code
$time2 = explode(' ', microtime());
$time2 = $time2[1] . substr($time2[0], 1, -2);
@branneman
branneman / gist:951844
Created May 2, 2011
Remove Excel Password
View gist:951844
Public Sub AllInternalPasswords()
Const DBLSPACE As String = vbNewLine & vbNewLine
Const AUTHORS As String = DBLSPACE & vbNewLine & _
"Adapted from Bob McCormick base code by" & _
"Norman Harker and JE McGimpsey"
Const HEADER As String = "AllInternalPasswords User Message"
Const VERSION As String = DBLSPACE & "Version 1.1.1 2003-Apr-04"
Const REPBACK As String = DBLSPACE & "Please report failure " & _
"to the microsoft.public.excel.programming newsgroup."
Const ALLCLEAR As String = DBLSPACE & "The workbook should " & _
@branneman
branneman / gist:951847
Last active Jun 3, 2019
array_find() - A case insensitive array_search() with partial matches
View gist:951847
<?php
/**
* Case in-sensitive array_search() with partial matches
*
* @param string $needle The string to search for.
* @param array $haystack The array to search in.
*
* @author Bran van der Meer <branmovic@gmail.com>
* @since 29-01-2010
*/
@branneman
branneman / gist:951858
Created May 2, 2011
Split a array into semi-equal sized chunks
View gist:951858
<?php
/**
* Split a array into semi-equal sized chunks.
* A so-called 'columnizer'
*
* @param array $array The array to split
* @param array $numberOfChunks The number of chunks
* @param bool $vertical Whether to order vertically or horizonally
*
* @return array Array with $numberOfColumns nodes with items of $array
View changepassword.bat
@echo off
@echo This batchfile changes your password 30 times into a temporary password, and finally into your given password.
@echo This way, you can use your 'old' password, when you are forced to change it ;)
SET /P user=username:
SET /P pwd=password:
echo username: %user%
net user %user% C6us4deSAf /domain
@branneman
branneman / mixin-before-after.scss
Last active Dec 16, 2015
SASS Mixin — Single/double colon generated content
View mixin-before-after.scss
@mixin before-after {
@if $old-ie {
&:before, &:after {
@content;
}
} @else {
&::before, &::after {
@content;
}
}
@branneman
branneman / server.js
Created Jun 13, 2013
Node.js — Serve generated PNG from SVG, specifying dimensions in the url/filename. This node.js express server generates 'checkmark.svg.107x94.png' from 'checkmark.svg' with Inkscape CLI
View server.js
var fs = require('fs'),
exec = require('child_process').exec,
express = require('express'),
app = express();
app.get('/static/img/*.svg.*.png', function(req, res) {
var pngFile = 'src' + req.url,
svgFile = pngFile.substring(0, pngFile.indexOf('.svg') + 4);
if (!fs.existsSync(svgFile)) {
return res.render('404', {
@branneman
branneman / call-apply-bind-proxy.js
Last active Jun 7, 2019
JavaScript call() vs apply() vs bind() vs $.proxy()
View call-apply-bind-proxy.js
var fn = function(arg1, arg2) {
var str = '<p>aap ' + this.noot + ' ' + arg1 + ' ' + arg2 + '</p>';
document.body.innerHTML += str;
};
var context = {
'noot': 'noot'
};
var args = ['mies', 'wim'];
// Calls a function with a given 'this' value and arguments provided individually.
You can’t perform that action at this time.