Skip to content

Instantly share code, notes, and snippets.

View raineorshine's full-sized avatar

Raine Revere raineorshine

  • New York, NY
View GitHub Profile
@raineorshine
raineorshine / transpiler-request-for-feedback.md
Created April 5, 2014 21:57
js-to-source-js transpiler Request for Feedback

I want to be able to edit existing JS files using pythonic whitespace like CoffeeScript, but output JS that matches the original coding conventions and is indistinguishable from hand-written code. I'd like to be able to convert Javascript to the other syntax for editing, then back to Javascript when saved. This would allow seamless use of this tool while making the code accessible to the entire vanilla JS community. I envision this integrated into editors like Sublime Text. Alternatively it could be a grunt task. A challenge will be editing a js file while preserving existing coding conventions and unedited portions as-is. I also have no experience with compilers, parsers, etc although I have an interest.

Unlike other transpilers, it is meant to be read in from vanilla js and output code that is indistinguishable from hand-written js. This would allow you to use the cleaner syntax while working on any vanilla js and it would work when contributing to existing vanilla js open source libraries.

Would this be

@raineorshine
raineorshine / parse-pipe-delimited.js
Created April 8, 2014 23:35
Rough example of parsing a pipe-delimited dataset.
var dataset = "...";
/*
FEATURE_ID|COL2|COL3
400|Ted|25
401|Bob|29
402|Sam|28
*/
// get an array of lines
var lines = dataset.split('\n');
@raineorshine
raineorshine / point-free-promises.js
Created April 20, 2014 13:37
Maybe some day I'll understand the code I wrote...?
// functional helpers
var before = function() {
var functions = Array.prototype.slice.call(arguments, 0);
return function() {
var that = this;
var args = Array.prototype.slice.call(arguments, 0);
var ccat = [].concat.bind([]);
return curry(tail, functions.map(
compose(
curry(invoke.apply, that),
@raineorshine
raineorshine / jquery-essentials.md
Created April 29, 2014 00:08
jQuery Essentials

.css

Sets or gets the css of an elements

// get
var currentColor = $('.container').css();

// set
$('.container').css({ color: 'red', fontSize: 24 });

.text

@raineorshine
raineorshine / mongo-getting-started.md
Last active August 29, 2015 14:01
Mongo - 19 Commands to Get Started

Example

$ mongod &
$ mongo
> use ark
> db.users.insert({ name: 'Noah' })
> db.animals.insert({ name: 'Elephant', type: 'pachyderm' })
> db.animals.insert({ name: 'Tiger', type: 'cat' })
> db.animals.find({ type: 'pachyderm' })
{ "_id" : ObjectId("5370d1b4050f0b6e16263f19"), "name" : "Elephant", "type" : "pachyderm" }
@raineorshine
raineorshine / osx-cheatsheet.txt
Created May 31, 2014 06:38
OS X Keyboard Shortcuts
# My favorite shortcuts from http://support.apple.com/kb/ht
# Finder
Control-A Move to beginning of line/paragraph
Command-Shift-A Open the Applications folder
Command-D Duplicate selected item
# All
Fn-Delete Forward Delete
Object.prototype.getName = function() {
var funcNameRegex = /function (.{1,})\(/;
var results = (funcNameRegex).exec((this).constructor.toString());
return (results && results.length > 1) ? results[1] : "";
};
@raineorshine
raineorshine / symlink.md
Created August 8, 2014 14:10
How to backup system files to DropBox or Google Drive using symlinks.
@raineorshine
raineorshine / point-free-thoughts.js
Created August 8, 2014 17:49
Dreaming about point-free style...
function(req, res) {
res.redirect(url)
}
second + instance + redirect
{arguments[1]}.redirect
/* global define:true module:true window: true */
if (typeof define === 'function' && define.amd) {
define(function() { return MYMODULE; });
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = MYMODULE;
} else if (typeof this !== 'undefined') {
this['RSVP'] = MYMODULE;
}