Skip to content

Instantly share code, notes, and snippets.

View leto's full-sized avatar
🐉
The Blocks Must Flow

Duke Leto leto

🐉
The Blocks Must Flow
View GitHub Profile
@leto
leto / NaN madness
Created August 28, 2009 10:25
NaN spec in ieee754-2008
8. Infinity, NaNs, and sign bit 8.0
8.1 Infinity arithmetic
Infinity arithmetic shall be construed as the limiting case of real arithmetic with operands of arbitrarily large
magnitude, when such a limit exists. Infinities shall be interpreted in the affine sense, that is, –∞< (every finite number) < +∞.
Operations on infinite operands are usually exact and therefore signal no exceptions. The exceptions that do
pertain to infinities are signaled only when:
∞ is an invalid operand (see 9.2),
∞ is created from finite operands by overflow (see 9.4) or division by zero (see 9.3), remainder(subnormal, ∞) signals underflow,
nextAfter(x, ∞) signals underflow and inexact if the result would be subnormal,
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active March 8, 2024 02:11
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
cxgn=# select now()-query_start, current_query from pg_stat_activity where usename = 'web_usr' and current_query not like '<IDLE>%';
?column? | current_query
-----------------+---------------------------------------------------------------------------------------------
00:00:31.513223 | select distinct stock_id FROM public.stockprop
: JOIN public.stock USING (stock_id)
: JOIN public.cvterm ON cvterm.cvterm_id = stockprop.type_id
: JOIN phenome.allele on allele.allele_id = (cast(stockprop.value as numeric ) )
: WHERE cvterm.name = $1 AND locus_id = $2 AND allele.obsolete = $3
00:00:39.178288 | select distinct stock_id FROM public.stockprop
: JOIN public.stock USING (stock_id)
@schacon
schacon / gist:942899
Created April 26, 2011 19:19
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
@cotto
cotto / goto_value.m0
Created June 9, 2011 15:59
m0 gotos as values
.version 0
.chunk "hello"
.constants
0 "at start"
1 "at end: goto worked!"
2 "at end: goto failed :("
.metadata
.bytecode
set_imm I0, 0, 0
set_imm S0, 0, 0
@jessevondoom
jessevondoom / gist:1017117
Created June 9, 2011 16:31
Quickly grabs a list of all files from a repo, queues them in an array, then mirrors the repo locally via PHP copy
$repo = json_decode(file_get_contents('https://github.com/api/v2/json/blob/all/cashmusic/DIY/master'));
$files = array_keys((array)$repo->blobs);
foreach ($files as $file) {
$path = pathinfo($file);
if (!is_dir('./source/'.$path['dirname'])) mkdir('./source/'.$path['dirname'],0777,true);
copy('https://raw.github.com/cashmusic/DIY/master/'.$file,'./source/'.$file);
}
@an0maly
an0maly / gist:1081878
Created July 14, 2011 03:14
panda doesn't build with rakudo
bkurle@lapple-too ~/src/panda $ sh bootstrap.sh
--2011-07-13 19:53:33-- http://feather.perl6.nl:3000/list
Resolving feather.perl6.nl... 2a02:2308:10::f:1, 193.200.132.135
Connecting to feather.perl6.nl|2a02:2308:10::f:1|:3000... failed: No route to host.
Connecting to feather.perl6.nl|193.200.132.135|:3000... connected.
HTTP request sent, awaiting response... 302 Found
Location: projects.json [following]
--2011-07-13 19:53:34-- http://feather.perl6.nl:3000/projects.json
Connecting to feather.perl6.nl|193.200.132.135|:3000... connected.
HTTP request sent, awaiting response... 200 OK
@cdleary
cdleary / gdb_watch_segment.c
Created July 29, 2011 21:55
Watch a whole memory segment in GDB.
static int values[1024] = {
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
@boucher
boucher / gist:1750368
Created February 6, 2012 07:07 — forked from saikat/gist:1084146
Stripe sample checkout form
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Stripe Sample Form</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js"></script>
<script type="text/javascript" src="https://js.stripe.com/v1/"></script>
<script type="text/javascript">
@boucher
boucher / gist:1750375
Created February 6, 2012 07:09 — forked from siddarth/gist:1379745
Stripe PHP simple example
<?php
require 'path-to-Stripe.php';
if ($_POST) {
Stripe::setApiKey("YOUR-API-KEY");
$error = '';
$success = '';
try {
if (!isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");