This file contains hidden or 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
(defn pluralize | |
"Takes an integer and a string and returns a string of '%d %s' where %s is pluralized based on %d. | |
Assumes x >= 1 and s is singular." | |
([x s] (pluralize x s nil)) | |
([x s ss] | |
(format "%d %s" x | |
(if (= 1 x) s | |
(or ss (condp re-matches s | |
#".*(x|[^aeiou]o|ch|s)" (str s "es") | |
#".*[^aeiou]y" (str (apply str (drop-last s)) "ies") |
This file contains hidden or 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 is a weird LightTable REPL session trying to understand how to actually use the concepts outlined | |
;; in http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded and the related talk he gave at | |
;; Clojure West. | |
;; The following code does NOT make sense when run in order as I was evaluating things on the fly with LightTable. | |
(defn system [] | |
{:db {:conn nil | |
:collection "collection"}}) | |
(defn start [system] |
This file contains hidden or 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
import matplotlib.pyplot as plt | |
import matplotlib.animation as anim | |
from collections import deque | |
import random | |
MAX_X = 100 #width of graph | |
MAX_Y = 1000 #height of graph | |
# intialize line to horizontal line on 0 | |
line = deque([0.0]*MAX_X, maxlen=MAX_X) |
This file contains hidden or 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 Promise = require('bluebird') | |
var Api = require('mikronode'); | |
var colors = require('colors') | |
var con, api | |
var BluebirdMikrotik = function(a,debug){ | |
console.log(a) | |
this.api = new Api(a.host,a.user,a.password); | |
} |
This file contains hidden or 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
BluebirdMikrotik.prototype.connect = function () { | |
var p = new Promise.defer(); | |
//console.log('intentando conexion') | |
this.api.connect(function(c) { | |
console.log(c) | |
this.con=c | |
console.log('.') | |
console.log(this.con) | |
p.resolve() | |
}.bind(this)); //*********************** BIND |
This file contains hidden or 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 Promise = require('bluebird'); | |
function Micro (id) { | |
this.id = id; | |
} | |
Micro.prototype.connect = function () { | |
return new Promise(function (fulfill, reject) { | |
setTimeout(function() { | |
if (Math.random() > 0.5) |
This file contains hidden or 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
function without(o) { | |
var props = Array.prototype.slice.call(arguments, 1); | |
var r = {}; | |
for (var k in o) { | |
if (o.hasOwnProperty(k) && props.indexOf(k) === -1) | |
r[k] = o[k]; | |
} | |
return r; | |
} |
This file contains hidden or 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
app.get('/', function (req, res) { | |
//tell varnish not to cache: | |
setHeaders(res, 32); | |
console.log(req.headers); | |
res.send('Hello World!<p /><p />Welcome to unrecoverable.pw, running on node.js.'); | |
db.getCollectionNames(function (err, results) { | |
res.send(JSON.stringify(results)); | |
}); | |
}); |
This file contains hidden or 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
[ | |
{"keys": ["ctrl+/"], "command": "undo"}, | |
{"keys": ["ctrl+;"], "command": "toggle_comment", "args": {"block": false}}, | |
{"keys": ["ctrl+x", ";"], "command": "show_overlay", "args": {"overlay": "goto", "text": "#"}}, | |
{"keys": ["ctrl+p"], "command": "move", "args": {"by": "lines", "forward": false}}, | |
{"keys": ["ctrl+n"], "command": "move", "args": {"by": "lines", "forward": true}}, | |
{"keys": ["ctrl+f"], "command": "move", "args": {"by": "characters", "forward": true}}, | |
{"keys": ["ctrl+b"], "command": "move", "args": {"by": "characters", "forward": false}}, | |
{"keys": ["ctrl+a"], "command": "move_to", "args": {"extend": false, "to": "hardbol"}}, | |
{"keys": ["ctrl+e"], "command": "move_to", "args": {"extend": false, "to": "hardeol"}}, |
This file contains hidden or 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 React = require('react'); | |
var { RouteHandler } = require('react-router'); | |
var UserSearchResults = require('../components/UserSearchResults'); | |
var actions = require('../actions/actions'); | |
var SearchStore = require('../stores/SearchStore'); | |
var Reflux = require('reflux'); | |
var Search = React.createClass({ | |
mixins: [Reflux.connect(SearchStore, 'search')], |
OlderNewer