Skip to content

Instantly share code, notes, and snippets.

@thinkjson
thinkjson / getCluster.js
Created April 9, 2019 14:45 — forked from CaptainJiNX/getCluster.js
Example of auto discovery for aws elasticache
const Memcached = require('memcached');
const configClient = new Memcached('xyz123.cfg.cache.amazonaws.com:11211');
configClient.command(configGetCluster);
function configGetCluster() {
return {
command: 'config get cluster',
callback: handleClusterResponse
@thinkjson
thinkjson / list.md
Last active February 27, 2021 02:02 — forked from notwaldorf/list.md
Meownica's packing list

Meownica's thinkjson's packing list

From Monica: I travel a lot so I'm down to like 30 minutes of packing per any kind of trip. I always bring one carry-on suitcase for any trips up to 2 weeks (that I never check in unless forced) -- I have an Away suitcase because it's got a built-in (removable) battery, and amazing wheels.

🚨

  • 🆔Wallet & Passport
  • 💧Travel water bottle
  • 📖A book
  • 💊Melatonin/Benadryl to sleep on planes
import requests # `pip install requests`; DO IT!
import time
import sys
class ComfortSweet:
LAST_ATTEMPT = 0
def main(self):
import requests # `pip install requests`; DO IT!
import time
import sys
class ComfortSweet:
LAST_ATTEMPT = 0
def main(self):
@thinkjson
thinkjson / mysql.php
Created September 10, 2012 12:22
Getting double the ammount I should on value $v
$new_array = array();
$ret_html = "<table><tr><th>DMA</th><th>Leads</th></tr>";
while ($row = mysql_fetch_array($result))
foreach ($row as $key => $value) {
if (isset($new_array["$value"]))
$new_array["$value"]++;
else
$new_array["$value"]++;
@thinkjson
thinkjson / evolving_music.js
Created September 2, 2012 18:45
evolving music
var baudio = require('baudio');
var b = baudio();
b.push((function () {
// randomly evolving melody
var freqs = [
0, 0, 1600, 1600,
0, 0, 2000, 2000,
0, 1400, 0, 1400,
@thinkjson
thinkjson / couch-transform.js
Created January 14, 2012 07:26 — forked from max-mapper/couch-transform.js
streaming functional transformer for couchdb using node
var request = require('request').defaults({json: true}),
transfuse = require('transfuse'),
JSONStream = require('JSONStream');
function transform(couchdb, funcString, headers) {
var down = request({url: couchdb + '/_all_docs?include_docs=true'}),
up = request({url: couchdb + '/_bulk_docs', method: "POST", headers: headers}),
tr = transfuse(['rows', /./, 'doc'], funcString, JSONStream.stringify("{\"docs\":[\n", "\n,\n", "\n]}\n"));
down.pipe(tr)
tr.pipe(up)
@thinkjson
thinkjson / gist:1603326
Created January 12, 2012 21:41 — forked from snsparrish/gist:1603065
Remove field from all docs in a CouchDB database
console.log("Fetching docs...");
var j = 0;
var docs = [];
var startdoc = '0';
function fetchdocs(){
nano.list({ stale: "ok", startkey:startdoc, limit:2000, include_docs:true}, function(err, data, headers){
console.log("Updating " + data.rows.length + " docs...");
for (var i = 0; i < data.rows.length; i++) {
var doc = data.rows[i].doc;
//console.log(doc);
@thinkjson
thinkjson / gist:1603157
Created January 12, 2012 21:14 — forked from snsparrish/gist:1603065
Remove field from all docs in a CouchDB database
console.log("Fetching docs...");
var j = 0;
var docs = [];
var ids = [];
nano.list({ stale: "ok" }, function(err, data, headers){
console.log("Updating " + data.rows.length + " docs...");
for (var i = 0; i < data.rows.length; i++) {
ids.push(data.rows[i].id);
}
});
@thinkjson
thinkjson / gist:1563609
Created January 5, 2012 03:45 — forked from nagoodman/gist:1563401
sample sql luciddb
select 'Last 30 Days', sum(measure1)
from time t, fact f
where f.timeid = t.timeid
and
f.date between applib.add_days(current_date, -30) and current_date
UNION ALL
select 'Current Month', sum(measure1)
from time t, fact f
where f.timeid = t.timeid
and t.month = applib.extract_timestamp(current_timestamp, 'MONTH')+1