Skip to content

Instantly share code, notes, and snippets.

View gasi's full-sized avatar

Daniel Gasienica gasi

View GitHub Profile
// cURL: http://php.net/manual/en/book.curl.php
// cURL Options: http://www.php.net/manual/en/function.curl-setopt.php
// @param $url URL of the request, e.g. https://www.sandbox.paypal.com/cgi-bin/webscr
// @param $data URL encoded request data as array, e.g. $data = array('cmd' => '_notify-validate');
function urlopen($url, $data)
{
$curl_handler = curl_init();
$options = array(CURLOPT_URL => $url,
CURLOPT_FAILONERROR => true,
CURLOPT_RETURNTRANSFER => true,
import base64
import hashlib
import hmac
import simplejson as json
def base64_url_decode(inp):
padding_factor = (4 - len(inp) % 4) % 4
inp += "="*padding_factor
return base64.b64decode(unicode(inp).translate(dict(zip(map(ord, u'-_'), u'+/'))))
@aseemk
aseemk / app-dev.js
Created July 6, 2011 23:39
Handler for efficiently caching compiled Coffee and/or Streamline files.
// app-dev.js
// Helper script to register CoffeeScript and Streamline extension handlers
// before running an app during development.
//
// Uses https://github.com/aseemk/coffee-streamline for efficient require(),
// caching compiled files between runs. Sweet!
//
// Usage: instead of `_coffee app`, just do `node app-dev app`.
//
// Also works great w/ node-dev <https://github.com/fgnass/node-dev>:
@somebox
somebox / gh-like.css
Created July 14, 2011 14:55
github markdown css+script with syntax highlighting. Works with http://markedapp.com
/*
Some simple Github-like styles, with syntax highlighting CSS via Pygments.
*/
body{
font-family: helvetica, arial, freesans, clean, sans-serif;
color: #333;
background-color: #fff;
border: none;
line-height: 1.5;
margin: 2em 3em;
@benvanik
benvanik / pyramiddemo.html
Created December 14, 2011 06:06
Simple Image Pyramid Demo
<!DOCTYPE html>
<html>
<head>
<title>Image Pyramid Demo</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0,user-scalable=no">
<script src="pyramiddemo.js"></script>
<style>
body {
@rauchg
rauchg / ms.md
Created December 21, 2011 00:25
Milliseconds conversion utility.
@indexzero
indexzero / v8-0412.js
Created January 3, 2012 05:30
Properties of Error instances in the latest V8 included by node@0.6.6 are not enumerable. And thus cannot be serialized through JSON.stringify
> var err = new Error('wtf?');
> JSON.stringify(err)
'{"stack":"Error: wtf?\\n at [object Context]:1:11\\n at Interface.<anonymous> (repl.js:179:22)\\n at Interface.emit (events.js:64:17)\\n at Interface._onLine (readline.js:153:10)\\n at Interface._line (readline.js:408:8)\\n at Interface._ttyWrite (readline.js:585:14)\\n at ReadStream.<anonymous> (readline.js:73:12)\\n at ReadStream.emit (events.js:81:20)\\n at ReadStream._emitKey (tty_posix.js:307:10)\\n at ReadStream.onData (tty_posix.js:70:12)","message":"wtf?"}'
> Object.keys(err);
[ 'stack', 'arguments', 'type', 'message' ]
> Object.getOwnPropertyDescriptor(err, 'stack');
{ get: [Function], set: [Function], enumerable: true, configurable: true }
> process.versions.v8
'3.1.8.26'
@jimbojsb
jimbojsb / gist:1630790
Created January 18, 2012 03:52
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

@gasi
gasi / akamai.js
Created February 17, 2012 17:31
Purge Akamai CDN using Node.js
var request = require('request');
var settings = {
AKAMAI_USER: 'test',
AKAMAI_PASSWORD: '...',
AKAMAI_NOTIFICATION_EMAIL: ''
};
var akamai = exports;
var SOAP_URL = 'https://ccuapi.akamai.com:443/soap/servlet/soap/purge';
@theconektd
theconektd / github.css
Created April 30, 2012 02:11
Github Markdown CSS - for Markdown Editor Preview
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {