Skip to content

Instantly share code, notes, and snippets.

@ptz0n
ptz0n / gist:1646171
Created January 20, 2012 08:43
Recursive merge of arrays with integer keys
<?php
/**
* Merge two dimensional arrays my way
*
* Will merge keys even if they are of type int
*
* @param array $array1 Initial array to merge.
* @param array ... Variable list of arrays to recursively merge.
*
@azsromej
azsromej / archives.html
Created March 7, 2012 18:19
Jekyll generator plugin to group posts by month for archives page
---
layout: default
title: Archives
---
<h1>{{ page.title }}</h1>
<div class="archives">
{% for month in page.months %}
<h2>{{ month | date:"%B" }} <small>{{ month | date:"%Y" }}</small></h2>
<ul>
{% for post in page.posts_by_month[month] %}
@xeoncross
xeoncross / Requests.php
Created April 11, 2012 21:44
cURL asynchronous requests using curl_multi and callbacks
<?php
/**
* Make asynchronous requests to different resources as fast as possible and process the results as they are ready.
*/
class Requests
{
public $handle;
public function __construct()
{
@masak
masak / explanation.md
Last active February 10, 2025 17:29
How is git commit sha1 formed

Ok, I geeked out, and this is probably more information than you need. But it completely answers the question. Sorry. ☺

Locally, I'm at this commit:

$ git show
commit d6cd1e2bd19e03a81132a23b2025920577f84e37
Author: jnthn <[email protected]>
Date:   Sun Apr 15 16:35:03 2012 +0200

When I added FIRST/NEXT/LAST, it was idiomatic but not quite so fast. This makes it faster. Another little bit of masak++'s program.

@kritzikratzi
kritzikratzi / Assembler.java
Created September 19, 2012 15:29
Re-assembling the "click and drag" xkcd comic
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),
@getify
getify / 1.js
Created November 13, 2012 00:19
illustrating some potential issues with adding `let` to code which already has `var` used in it...
// var: poor stylistic form, but no leakage
function foo() {
bar = 3;
if (true) {
var bar = 5;
}
}
// let: will leak an auto-global
function foo() {
@atdt
atdt / obs.py
Created November 23, 2012 21:10
log observer
from flask import *
app = Flask(__name__)
@app.route('/event.gif')
def log_event():
event = request.args
model = event.get('_id', '')
# pull model from meta
# validate model
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active February 18, 2025 18:20
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@ramnathv
ramnathv / README.md
Last active September 9, 2022 02:41
Upload Directory of Files using Gist API

This is a short set of functions that use the httr package to upload a directory of files as a gist. The post_gist function uploads an anonymous gist, which can only be deleted within a short time of being uploaded. So be cautious in what you upload using this function.