This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Implementation by Groxx, with absolutely no guarantees, so don't complain to me if it breaks stuff. | |
Feel free to use it for awesome, as needed. Apply liberally, and induce vomiting if you ingest large doses. | |
Note from #0d15eb: BREAKING CHANGE FROM #1d1057: this is now a generic storage, storing pointers to data. Manage your memory accordingly. | |
Note: now stores the "next" pointer prior to processing, allowing you to process and pop the first item in the list in one pass without losing your place in the queue (and possibly other shenanigans, this one was just handy for my uses so I changed it). | |
*/ | |
typedef void * queue_data_type; | |
struct queue_item { | |
queue_data_type contents; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "AppleScript Editor" | |
set d to document 1 | |
set str to "set d to document 1 of AppleScript Editor, and watch the shenanigans. | |
" | |
set str to str & ("d is equal to d == " & (d is equal to d) as text) & " | |
" | |
set str to (str & "d is equal to (contents of d) == " & (d is equal to (contents of d)) as text) & " | |
" | |
set str to str & "d is equal to (contents of (contents of d)) == " & (d is equal to (contents of (contents of d))) as text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code | |
array = [0,1,2,3,4,5,6,7,8,9] | |
array[3..7] = array[3..7].reverse | |
puts array.inspect | |
# Results in this output | |
# [0, 1, 2, 7, 6, 5, 4, 3, 8, 9] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
# Returns a portion of an array in which the left-most numbers | |
# match the prefix. If 0 (or less) is passed, matches all | |
# single-digit numbers (same as [0..8]). | |
# | |
# === Warning | |
# This deals with the n-th items, <i><b>NOT</b></i> the n-th | |
# <i>indexes</i> (ie, it's 1 based, not 0 based), because it | |
# serves my needs currently, and allows zero to match all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
gmail.com | |
youtube.com | |
blogspot.com | |
google-analytics.com/urchin.js | |
google-analytics.com/ga.js | |
googlesyndication.com | |
show_ads.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Time.now # Tue Aug 17 21:37:22 -0500 2010 | |
class Time | |
def self.now # "self." makes it class-level - ie, you can call "Time." to use. | |
"WIN" | |
end | |
end | |
Time.now # "WIN" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var db = openDatabase("short_name" // actual database name. Opens existing or creates. | |
, "1" // version number. *Must* be correct. | |
, "a long descriptiony thing" // I do not know where this is useful. Nothing seems to see it... | |
, 10 * 1024*1024); // for 10 megabytes | |
// also: db.readTransaction(); identical to below, but read-only access to the database. | |
db.transaction(function(tx){ | |
tx.executeSql("select * from your_table where aColumn = ?" | |
, ["aParameter"] // ? + [data] guards against injection, and is the *only* safe way to do so. One data item per ?, in order. | |
, function(tx, results) { // success callback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var api = { | |
calls: 0 | |
, requests: 0 | |
, buildRequest: function buildRequest(methodName, args) { | |
if (args === undefined){args = [];} | |
var request = {jsonrpc: "2.0", method: methodName, params: []}; | |
// Build a request based on a method. | |
// First non-value in args is assumed to be a success callback (so a fail callback can be specified without a success callback. just pass null.) | |
// Second function (and all subsequent) in args is assumed to be an error callback |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcc simvm.c | |
time ./a.out | |
857419840 | |
real 0m0.374s | |
user 0m0.359s | |
sys 0m0.003s | |
------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.cstring | |
LC0: | |
.ascii "%d\12\0" | |
.text | |
.align 4,0x90 | |
.globl _vm | |
_vm: | |
LFB14: | |
pushq %rbp | |
LCFI0: |
OlderNewer