users
table:
[
{
id: 123,
things: [1, 2, 3]
}
]
r.db('crap').table('junk') | |
.get(2) | |
.update({ | |
'revisions': r.row('revisions').append(r.row('revisions').nth(-1).do(function(row) { | |
return row.merge({ | |
v: row('v').add(1) | |
}) | |
})) | |
}) |
r.db('test').table('crap').get("dd3badb0-9c30-4ef5-978a-c034461d58ca").update({ | |
unit_data: r.literal(r.row('unit_data').without('state')) | |
}) |
// Index: | |
r.table("heroes").indexCreate("idEquipment", function(doc) { | |
return doc("equipment").map(function(equipment) { | |
return [doc("id"), equipment] | |
}) | |
}, {multi: true}).run(conn, callback) | |
// Query | |
r.table("heroes").getAll([1, "boots"], {index: "idEquipment"}).run(conn, callback) |
var bignum = require('bignum'); | |
var crypto = require('crypto'); | |
var randomBignum = function() { return bignum.fromBuffer(crypto.pseudoRandomBytes(8)); } | |
var avg = randomBignum(); | |
var avg_len = avg.bitLength(); | |
var lengths = {}; | |
for (var i = 0; i < 1e6; i++) { |
users
table:
[
{
id: 123,
things: [1, 2, 3]
}
]
tl;dr: The problems inherent in jQuery dependency should not be resolved by not depending on jQuery or some other $
-providing library. Rather, library authors should write library code that expects a $
will be injected that meets the library's needs.
In the front-end JS world, there is a movement to be dependency-free, and specifically to be jQuery dependency free. This problem seems to be the result of a pre-package management mindset. But those days are long gone, or, they should be.
The result of this mindset, however, tends to not be pretty: library authors write their own, often minimally tested, DOM manipulation and utility belt routines. If you come to depend on multiple or many such libraries, your code, via their code, then comes to contain dozens of diverse implementations of similarly or identically-purposed functions.
# Observations about binary and binary operations: | |
* Bitshifting by 1 either adds or subtracts a multiple of 2 from each factor of 2. | |
** Take, for example, the number 10 (decimal) | |
** 10 = 8 + 2 = 1*(2^3) + 0*(2^2) + 1*(2^1) + 0*(2^0), or 1010 in binary. | |
** If you shift each of these bits to the left by 1, you get 10100. | |
** This took each of the 1 bits (multiples of 2) in the binary representation and multplied each by 2: | |
*** 10100 is 1*(2^4) + 0*(2^3) + 1*(2^2) + 0*(2^1) + 0*(2^0) = 16 + 0 + 4 + 0 + 0 = 20. | |
*** Notice that 20 = 16 + 4 = 2*8 + 2*2 = 2*(8 + 2). |
# MAC manipulators | |
alias random_mac='sudo ifconfig en0 ether `openssl rand -hex 6 | sed "s/\(..\)/\1:/g; s/.$//"`' | |
alias restore_mac='sudo ifconfig en0 ether YOUR_ORIGINAL_MAC_ADDRESS_GOES_HERE' |
from django.db import models | |
from django.utils.decorators import wraps | |
from django.core.exceptions import ValidationError | |
def constraint(func): | |
@wraps(func) | |
def inner(*args, **kwargs): | |
func._is_constraint = True | |
return func(*args, **kwargs) | |
return inner |