Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Phillip Brink binki

View GitHub Profile
View PHP Sort by Scripture (Bible)
<?php
function _scripturebooks() {
return array("Genesis", "Exodus", "Leviticus", "Numbers", "Deuteronomy", "Joshua", "Judges", "Ruth", "1 Samuel", "2 Samuel", "1 Kings", "2 Kings", "1 Chronicles", "2 Chronicles", "Ezra", "Nehemiah", "Esther", "Job", "Psalm", "Proverbs", "Ecclesiastes", "Song of Solomon", "Isaiah", "Jeremiah", "Lamentations", "Ezekiel", "Daniel", "Hosea", "Joel", "Amos", "Obadiah", "Jonah", "Micah", "Nahum", "Habakkuk", "Zephaniah", "Haggai", "Zechariah", "Malachi", "Matthew", "Mark", "Luke", "John", "Acts", "Romans", "1 Corinthians", "2 Corinthians", "Galatians", "Ephesians", "Philippians", "Colossians", "1 Thessalonians", "2 Thessalonians", "1 Timothy", "2 Timothy", "Titus", "Philemon", "Hebrews", "James", "1 Peter", "2 Peter", "1 John", "2 John", "3 John", "Jude", "Revelation");
}
function scripturesort($a, $b) {
if ($a == $b) {return 0;}
$order=_scripturebooks();
View .sql
SET ANSI_NULLS ON
SELECT a, b, CASE WHEN a!>b THEN 1 ELSE 0 END "a!>b", CASE WHEN a<=b THEN 1 ELSE 0 END "a<=b" FROM (SELECT 0 a, 0 b UNION SELECT 0, 1 UNION SELECT 0, NULL UNION SELECT 1, 0 UNION SELECT 1, 1 UNION SELECT 1, NULL UNION SELECT NULL, 0 UNION SELECT NULL, 1 UNION SELECT NULL, NULL) _;
SET ANSI_NULLS OFF
SELECT a, b, CASE WHEN a!>b THEN 1 ELSE 0 END "a!>b", CASE WHEN a<=b THEN 1 ELSE 0 END "a<=b" FROM (SELECT 0 a, 0 b UNION SELECT 0, 1 UNION SELECT 0, NULL UNION SELECT 1, 0 UNION SELECT 1, 1 UNION SELECT 1, NULL UNION SELECT NULL, 0 UNION SELECT NULL, 1 UNION SELECT NULL, NULL) _;
View gist:b841f5f5904109f6fc8f
NathanPhillip@dcxt540p ~/AeroFS/repos/initials
$ /c/Program\ Files/JDK_64_bit/bin/java initials
NNNN NNNNNN BBBBBBBBBB
NNN NN BBBB BBBB
NNN N BBB BBB
NNNN N BBB BBB
N NNN N BBB BBB
N NN N BBB BBB
N NNN N BBB BBB
N NNN N BBBBBBBBBBB
View gist:ae2ddd809fdc73256b63
ohnobinki@ohnopublishing ~ $ python
Python 2.7.1 (r271:86832, May 14 2011, 10:43:48)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> range(0,2)
[0, 1]
>>> range(*[0,2])
[0, 1]
View gist:556f2c90952739e7e3ae
>>> def is_int(x):
... try:
... int(x)
... return True
... except:
... pass
... return False
...
>>> [int(x) if is_int(x) else x for x in 'asdf asdf 23'.split(' ')]
['asdf', 'asdf', 23]
View fixed-precision.cxx
#include <sstream>
#include <iostream>
int main(int argc, const char *const argv [])
{
std::stringstream ss;
ss.precision(2);
int rounded_value = 4;
ss << std::fixed << (double)rounded_value;
std::string s = ss.str();
@binki
binki / output.txt
Last active Aug 29, 2015
Selecting multiple sublists that compose a more complex object in T-SQL
View output.txt
(5 row(s) affected)
Id Name Network Good
----------- --------- -------------- -----------
1 honestbot anarchyirc.com 0
2 derpbot anarchyirc.com 1
3 logbot anarchyirc.com 1
4 goat anarchyirc.com 0
5 CHANFIX efnet.org 1
View Add to <Project> in.csproj
<Import Project="Neko2k.RandomBuildString.targets"/>
View gist:a4bc4b6bc0044798802c
Load(128)=00:00:00.0611875
LoadParallel(128)=00:00:00.0285670
LoadAsync(128)=00:00:00.0378507
LoadAsyncParallel(128)=00:00:00.0404540
Load(1024)=00:00:00.3576118
LoadParallel(1024)=00:00:00.1329359
LoadAsync(1024)=00:00:00.1684256
LoadAsyncParallel(1024)=00:00:00.2744572
@binki
binki / output
Created Jan 16, 2015
Returning 0 rows does not always mean NULL…
View output
(1 row(s) affected)
Id Name
----------- ----
1 asdf
(1 row(s) affected)
x
------------