Skip to content

Instantly share code, notes, and snippets.

View venil7's full-sized avatar
turning coffee into code

Art Deineka venil7

turning coffee into code
View GitHub Profile
process.stdin.setEncoding('utf8');
// becomes readable on every [enter] keystroke
process.stdin.on('readable', function(chunk) {
var chunk = process.stdin.read();
if (chunk !== null) {
console.log(chunk
.split('')
.map(function(c) {
return String.fromCharCode(c.charCodeAt(0)-1);
@venil7
venil7 / em.js
Last active January 2, 2016 08:09
emphasis function js
var em = function(str, pattern, el) {
if (!(str && pattern)) return "";
pattern = pattern.toString().replace((/[^a-zA-Z1-9 ]/ig), "").split(" ").reduce(function(prev, curr){
if(curr){
prev.push(curr);
}
return prev;
},[]).join("|");
el = el || "em";
@venil7
venil7 / console.timed_log.js
Created December 27, 2013 22:16
console.log, that prints number of milliseconds since last console.log invocation
console.timed_log = function() {
var args = Array.prototype.splice.call(arguments, 0);
var time = +new Date();
var diff = time - (this._time || time);
args.unshift(diff);
console.log.apply(console, args);
this._time = time;
};
var throttle2 = function(fn, threshhold, scope) {
var time, last = 0, handle,
args = arguments;
threshhold = threshhold || 250;
return function() {
var that = this;
time = +new Date();
if ((time - last) > threshhold) {
last = time;
// console.timed_log('ran');
@venil7
venil7 / gist:8117137
Created December 24, 2013 19:43
up/down
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>list</title>
<style>
.stoppable {
background-color: gray;
}
{
"caret_extra_width": 1,
"caret_style": "smooth",
"close_windows_when_empty": false,
"color_scheme": "Packages/Oceanic Next Color Scheme/Oceanic Next.tmTheme",
"copy_with_empty_selection": true,
"default_line_ending": "unix",
"detect_slow_plugins": false,
"drag_text": false,
"draw_minimap_border": true,