Skip to content

Instantly share code, notes, and snippets.

View rtt's full-sized avatar
🚍
' DROP TABLE user_statuses; --

Rich Taylor rtt

🚍
' DROP TABLE user_statuses; --
View GitHub Profile
> db.foo.aggregate([{$unwind: '$sub'}, {$match: {start: {$lte: 3}, end: {$gte: 6} }}])
{
"result" : [
{
"_id" : ObjectId("522da57d186b82d5279cb35c"),
"start" : 3,
"end" : 6,
"sub" : {
"start" : 3,
"end" : 6
@rtt
rtt / gist:6593790
Last active December 23, 2015 06:28
#!/usr/bin/python
import sys
from collections import Counter
try:
with open(sys.argv[1], 'r') as f:
c = Counter(l.rstrip('\r\n') for l in f.readlines())
except IndexError:
print "Usage: ./count.py [infile]"
except IOError:
#!/usr/bin/python
import sys
from collections import Counter
try:
with open(sys.argv[1], 'r') as f:
c = Counter(l.rstrip('\r\n') for l in f.readlines())
except IndexError:
print "Usage: ./count.py [infile]"
except IOError:
set: function (collection) {
// returns a set (as a list...) from a collection
// in other words, uniques
var o = {}, r = [], l = collection.length, i = 0;
for (; i < l; i++) {
if (!(collection[i] in o)) {
o[collection[i]] = true;
r.push(collection[i]);
}
}
@rtt
rtt / gist:7234236
Last active December 26, 2015 23:59
unique_bind: function (els, e, lambda) {
// binds an event function to an element or set of elements
// but only if the event is not already registered on the element
$.LS.Log('onetime binding {0} els'.format(els.length));
$.each(els, function (ix, el) {
var x = $._data($(el).get(0), 'events');
if (typeof x === 'undefined' || x[e] === 'undefined') {
$(el).bind(e, function (event) {
lambda();
});
> ~ dig @8.8.8.8 a spode.me
; <<>> DiG 9.8.5-P1 <<>> @8.8.8.8 a spode.me
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21871
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
g++ `pkg-config --cflags --libs opencv` ./libopencv_facerec.a -o out facerec.cpp -I ../include -lopencv_core -lopencv_highgui -lopencv_imgproc
//--------------------------------------------------------------------------------------------------
//
// stage 2 of 3
//
// challenge:
// reveal the solution within VM.mem
//
// disclaimer:
// tested in ie 9, firefox 6, chrome 14 and v8 shell (http://code.google.com/apis/v8/build.html),
// other javascript implementations may or may not work.
{
"action": "search",
"result": true,
"data": [{
"oid": "10412366819",
"can_view": false,
"looking_for_type_id": [1, 2, 3, 4, 5],
"familystatus_": 0,
"sexuality_": 1,
"smoker_": 0,
> ~ curl -H 'content-type: multipart/form-data; boundary=55e83917fc41113113c39888e4954' https://ed.uniformdating.com/mobile_application.php\?action\=login -X POST --data-binary @ud.txt
{
"action": "login",
"result": true,
"data": {
"oid": "10741323098",
"looking_for_type_id": [],
"familystatus_": 1,
"sexuality_": 1,