Skip to content

Instantly share code, notes, and snippets.

@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@hacknightly
hacknightly / riffwave.js
Created September 24, 2012 15:20
riffwave.js
/*
* RIFFWAVE.js v0.03 - Audio encoder for HTML5 <audio> elements.
* Copyleft 2011 by Pedro Ladaria <pedro.ladaria at Gmail dot com>
*
* Public Domain
*
* Changelog:
*
* 0.01 - First release
* 0.02 - New faster base64 encoding
@zorbash
zorbash / scanlines.css
Created November 7, 2012 16:05
scanlines background
.scanlines {
background-image: linear-gradient(90deg,
#223 25%, #450 25%, #410 50%,
#230 50%, #210 75%, #200 75%, #190);
background-size:6px 6px;
}
@cybear
cybear / raspberry_pi_optimization.md
Last active January 27, 2023 22:17
I read up a little on performance optimization for the Raspberry Pi, and gathered the links before they disappear from my short term memory.

Raspberry Pi general optimization

  • Use a class 10 SD card for best speed. The USB bus can't come much higher than 30MB/s so you don't have to buy any extremely fast ones though. Not all cards are compatible, check the compatibility list: http://elinux.org/RPi_SD_cards
  • Use the HardFloat version of Raspbian instead of the SoftFloat. HF has much faster floating point operations - however SF is required for running Java. So it's either Java or performance, like normal.
  • The official Raspbian image gives low network speeds: http://elinux.org/RPi_Performance#NIC
  • A graphics driver by Simon / teh_orph is using hardware acceleration for some instructions: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=63&t=28294 installation instructions: http://elinux.org/RPi_Xorg_rpi_Driver
  • The firmware can be upgraded which gives, among other things, better GPU performance.
@killercup
killercup / pandoc.css
Created July 3, 2013 11:31
Add this to your Pandoc HTML documents using `--css pandoc.css` to make them look more awesome. (Tested with Markdown and LaTeX.)
/*
* I add this to html files generated with pandoc.
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
@lsauer
lsauer / parseInt.py
Last active April 3, 2022 09:11
Python: JavaScript like parseInt function in one line
#lsauer.com, 2013
#Note: -)for convenience the function uses the re-module, but can be rewritten to fit into a lambda expression
# -)choose any other, more-expressive return type such as NumPy's `nan` over None if you like
#demonstrative-version:
def parseInt(sin):
import re
return int(''.join([c for c in re.split(r'[,.]',str(sin))[0] if c.isdigit()])) if re.match(r'\d+', str(sin), re.M) and not callable(sin) else None
#via a simple regex:
@fredley
fredley / Holiday
Created March 13, 2014 10:23
Holiday Pebble App
#include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"
PBL_APP_INFO(MY_UUID, "Holiday", "Tom Medley", 1, 1 /* App version */, RESOURCE_ID_IMAGE_MENU_ICON, APP_INFO_WATCH_FACE);
Window window;
TextLayer text_time_layer;
@devi
devi / chacha20.js
Last active July 6, 2016 22:06
chacha20.js
/* chacha20 - 256 bits */
// Written in 2014 by Devi Mandiri. Public domain.
//
// Implementation derived from chacha-ref.c version 20080118
// See for details: http://cr.yp.to/chacha/chacha-20080128.pdf
var Chacha20KeySize = 32;
var Chacha20NonceSize = 8;
@marcellodesales
marcellodesales / formatted.sh
Last active November 14, 2023 19:22
One-liner REST server using netcat - nc
rm -f out
mkfifo out
trap "rm -f out" EXIT
while true
do
cat out | nc -w1 -l 1500 > >( # parse the netcat output, to build the answer redirected to the pipe "out".
export REQUEST=
while read line
do
line=$(echo "$line" | tr -d '[\r\n]')
@0xabad1dea
0xabad1dea / banned.h
Last active December 27, 2015 19:46
banning macros
/* include this file AFTER your standard includes */
/* clang -Weverything -Wno-unused-macros */
/* SIGNED ARITHMETIC IS THE ENEMY. (use "signed" for main, etc.) */
#define int BANNED
/* THESE OTHER THINGS ARE ALSO THE ENEMY. */
#ifdef strcpy
#undef strcpy
#endif
#define strcpy BANNED