Skip to content

Instantly share code, notes, and snippets.

View jwerle's full-sized avatar
🔨
Working on @socketsupply/socket

Joseph Werle jwerle

🔨
Working on @socketsupply/socket
View GitHub Profile
@jwerle
jwerle / example.js
Created April 9, 2014 15:45
Grep a function's source body
function beep () {
var b = 2;
var c = 10;
var foo = 'foo';
var biz = foo;
var str = foo +' '+ biz;
var sum = b + c;
return [str, sum];
}
@jwerle
jwerle / output
Last active August 29, 2015 14:01
C struct initializations
$ cc s-struct-initalization.c && ./a.out
foo 1 bar
biz 2 baz
beep 3 boop
jwerle:~/repos/libhttp ☂ (modifications) master
× clib install hash
fetch : https://raw.github.com/clibs/hash/master/package.json
fetch : https://raw.github.com/clibs/hash/master/hash.c
save : ./deps/hash/hash.c
fetch : https://raw.github.com/clibs/hash/master/hash.h
error : unable to fetch https://raw.github.com/clibs/hash/master/hash.h
clib-install(72753,0x7fff7d37f310) malloc: *** error for object 0x7fa619501b20: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
@jwerle
jwerle / out.php
Created May 21, 2014 14:32
php interpolated buffer values
<? $a = array(); ?>
// should yield `null'
"unset element in array" = <?= json_encode($a['foo']); ?>
// should yield nothing
"false" = <?= false; ?>
// should yield `1'
"true" = <?= true; ?>
function b (fn) {
var str = fn.toString();
var buf = "";
var ch = 0;
var len = str.length;
var i = 0;
var inBody = false;
while (len--) {
ch = str[i++];
function s (fn, args) {
var code = null;
var f = null;
args = args.map(function (a) {
return 'function' == typeof a ? a.toString() : a;
});
args = JSON.stringify(args);
code = '(' + fn.toString() +').apply(null,'+ args + ')';
f = new Function(code);
#define X(n) \
if (isset($opts[ # n ])) { \
self::$ n = $opts[ # n]; \
}
import foo from A; // - this just declares the identifier `foo'
console.log(foo); // undefined - (but doesn't throw ?)
console.log(A.foo); // [Function: foo] - (maybe this is available due to the `import' statement)
console.log(B.bar); // [Function: bar] - (I guess not, there is no need for an `import' statement for the `B' module?)
/**
* The following will throw:
*
curl -s https://ws.spotify.com/search/1/track.json?q=portugal+the+man | bpkg json -b | grep tracks | grep href | grep spotify:track | awk '{print $2}' | tr -d '"' | tr -d 'spotify:track:'
files.items
.filter(function (file) {
// search parents array looking for atleast once
// parent that has the id you are looking for
return file.parents.some(function (parent) {
return PARENT_ID_YOU_CARE_ABOUT == parent.id
});
})
.forEach(function (file) {
// do stuff with each file after filtering here...