Skip to content

Instantly share code, notes, and snippets.

@KidkArolis
KidkArolis / deploy.rb
Created April 1, 2014 12:48
cap deploy.rb
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'twitter'
set :repo_url, 'ssh://git@github.com/KidkArolis/twitter.git'
# Ask which branch to deploy
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
set :deploy_to, "/home/ubuntu/#{fetch(:application)}"
@KidkArolis
KidkArolis / index.js
Created April 16, 2014 14:19
requirebin sketch
// try requiring some modules from NPM and then hit Run
console.log(require('cat-picture'), 123);
require('jquery');
@KidkArolis
KidkArolis / es6 modules.md
Last active August 29, 2015 14:02
ES6 modules suggestion

Only allow using default export or named exports, but not both within the same module. That way we can:

// import the default export
import marked from "marked";
import moment from "moment";

// import all of the named exports
import async from "async";
import fs from "fs";
@KidkArolis
KidkArolis / README.md
Last active August 29, 2015 14:02
bower rave

To get this going

bower install
npm install -g serv
serv
open http://localhost:8000

It logs

@KidkArolis
KidkArolis / gist:65caaa958f66bd46dbe6
Last active August 29, 2015 14:04
Convert CJS to AMD using r.js
var requirejs = require("requirejs")
requirejs.tools.useLib("build", function (req) {
req(["commonJs"], function (cjs) {
// first arg is filename (not sure why that matters yet)
// second arg - the code
var converted = cjs.convert("foo", "module.exports = 42;");
console.log(converted);
});
@KidkArolis
KidkArolis / rjs-configurator.js
Last active August 29, 2015 14:05
rjs-configurator
var rjsConfig = require("rjs-configurator");
// default npm usecase
rjsConfig.npm("../my-app", function (err, config) {
// contains map, packages
console.log(config);
});
// advanced usage
rjsConfig.generate({
@KidkArolis
KidkArolis / index.js
Created August 31, 2014 12:15
requirebin sketch
// example using the raf module from npm. try changing some values!
var requestAnimationFrame = require("cherrytree");
var requestAnimationFrame = require("cherrytree/location/history_location");
@KidkArolis
KidkArolis / index.js
Last active August 29, 2015 14:05
requirebin sketch
// some things we'll use to render the views
var $ = require("jquery");
var insert = require("insert-stylesheet");
var insertCss = require("insert-css");
var lorem = require("lorem-ipsum");
// when using cherrytree you need to create the router, many routes
// and some location implementation. The HistoryLocation keeps router
// state in sync with browser's address bar.
var Router = require("cherrytree");
Verifying that +karolis is my Bitcoin username. You can send me #bitcoin here: https://onename.io/karolis
function upload(stream, idOrPath, tag) {
var queries = new Array(global.parallelQueries);
var tx = db.begin();
when.map(queries, insert).catch(rollback);
tx.commit();
function insert(query) {
FileVersion.insert({index: i}).execWithin(tx, query);
}