Skip to content

Instantly share code, notes, and snippets.

View koenpunt's full-sized avatar
:octocat:
...

Koen Punt koenpunt

:octocat:
...
View GitHub Profile
@jhollinger
jhollinger / dropbox.css
Created July 27, 2012 05:27
Dropbox - async, ajax uploads with HTML5 in Sinatra
#dropbox {
position: relative;
}
#dropbox > input {
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
@ack
ack / rdbg
Created August 7, 2012 19:28
gdb-ruby
apt-get install -qqy gdb
cat > ~/.gdbinit <<EOF
define eval
call(rb_p(rb_eval_string_protect(\$arg0,(int*)0)))
end
define redirect_stdout
call rb_eval_string("\$_old_stdout, \$stdout = \$stdout, File.open('/tmp/ruby-debug.' + Process.pid.to_s, 'a'); \$stdout.sync = true")
@rnapier
rnapier / fix-xcode
Last active October 31, 2024 13:54
Links Xcode SDKs from the /SDKs directory (which you maintain yourself)
#!/usr/bin/python
# fix-xcode
# Rob Napier <[email protected]>
# Script to link in all your old SDKs every time you upgrade Xcode
# Create a directory called /SDKs (or modify source_path).
# Under it, put all the platform directories:
# MacOSX.platform iPhoneOS.platform iPhoneSimulator.platform
# Under those, store the SDKs:
@basvandorst
basvandorst / Zend_Mail_InlineImages.php
Created August 21, 2012 13:48
Zend_Mail inline images in e-mail: CID attachment (tested in Gmail, Outlook.com, Outlook 2010)
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
@spinogrizz
spinogrizz / UIImage+Trim.m
Created August 31, 2012 07:37
Trim transparent pixels around UIImage
- (UIImage *) imageByTrimmingTransparentPixels {
int rows = self.size.height;
int cols = self.size.width;
int bytesPerRow = cols*sizeof(uint8_t);
if ( rows < 2 || cols < 2 ) {
return self;
}
//allocate array to hold alpha channel
@basuke
basuke / drive.py
Created September 2, 2012 22:49
Create the GPX file from origin and destination using the GoogleMap Direction API. You can use this output for simulate the location apps in Xcode.
#
# python drive.py "origin" ["waypoint" ... ] "destination"
#
# i.e. python drive.py "Union Square, San Francisco" "Ferry Building, San Francisco" 'Bay Bridge' SFO
import sys, json, urllib2, md5, os.path, pprint
from math import radians, sin, cos, atan2, pow, sqrt
from urllib import quote_plus
from xml.sax.saxutils import escape
from optparse import OptionParser
@nikic
nikic / password_hashing_api.md
Created September 12, 2012 15:04
The new Secure Password Hashing API in PHP 5.5

The new Secure Password Hashing API in PHP 5.5

The [RFC for a new simple to use password hashing API][rfc] has just been accepted for PHP 5.5. As the RFC itself is rather technical and most of the sample codes are something you should not use, I want to give a very quick overview of the new API:

Why do we need a new API?

Everybody knows that you should be hashing their passwords using bcrypt, but still a surprising number of developers uses insecure md5 or sha1 hashes (just look at the recent password leaks). One of the reasons for this is that the crypt() API is ridiculously hard to use and very prone to programming mistakes.

@geta6
geta6 / partial.coffee
Created September 27, 2012 10:13
response partial content in node.js
#
# blob : Object from MongoDB
#
# blob.body: Buffer
# blob.size: length of buffer, substitute for blob.body.length
# blob.type: MIME (Eg. audio/x-wav)
#
# req : Object from http
# res : Object from http
# _ : Object from underscore
@bazilio91
bazilio91 / gist:3910116
Created October 18, 2012 06:00
PhpUnit image assert function
protected function assertImage($expected, $actual, $message = '')
{
$descriptors = array(
array('pipe', 'r'),
array('pipe', 'w'),
array('pipe', 'w'),
);
$command = 'compare -metric RMSE ' . escapeshellarg($expected) . ' ' . escapeshellarg($actual) . ' /dev/null';
$proc = proc_open($command, $descriptors, $pipes);
@koenpunt
koenpunt / basename.conf
Created October 29, 2012 16:38
Quick Server Setup
# Gets the basename of the original request
map $request_uri $request_basename {
~/(?<captured_request_basename>[^/?]*)(?:\?|$) $captured_request_basename;
}
# Gets the basename of the current uri
map $uri $basename {
~/(?<captured_basename>[^/]*)$ $captured_basename;
}