Skip to content

Instantly share code, notes, and snippets.

@brain64bit
brain64bit / gist:e60d6791acfd14d585ec
Created February 3, 2016 03:21 — forked from remy/gist:350433
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@brain64bit
brain64bit / links.textile
Created October 15, 2015 07:40 — forked from lucashungaro/links.textile
Links de referência utilizados em minha palestra
@brain64bit
brain64bit / iterm2.md
Created September 28, 2015 17:50
iterm2 cheatsheet

Tabs and Windows

Function Shortcut
Previous Tab + Left Arrow
Next Tab + Right Arrow
Go to Tab + Number
Go to Window + Option + Number
Go to Split Pane by Direction + Option + Arrow
Go to Split Pane by Order of Use + ] , + [
@brain64bit
brain64bit / readme.md
Last active September 19, 2015 08:39 — forked from jobsamuel/readme.md
Run NodeJS as a Service on Ubuntu 14.04 LTS

Run NodeJS as a Service on Ubuntu 14.04 LTS

With Node you can write very fast JavaScript programs serverside. It's pretty easy to install Node, code your program, and run it. But > how do you make it run nicely in the background like a true server?

  • Go to /etc/init/
  • $ sudo vim yourapp.conf
  • Paste script.conf
  • $ sudo start yourapp
  • And when you wanna kill the process $ sudo stop yourapp
@brain64bit
brain64bit / learn.lua
Last active August 29, 2015 14:19 — forked from tylerneylon/learn.lua
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
source :rubygems
# We are not loading Active Record, nor Active Resources etc.
# We can do this in any app by simply replacing the rails gem
# by the parts we want to use.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
gem "tzinfo"
# Let's use thin
@brain64bit
brain64bit / introrx.md
Last active August 29, 2015 14:15 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@brain64bit
brain64bit / gist:7cfcd25bf99b99159b02
Last active August 29, 2015 14:15 — forked from cpjolicoeur/gist:3590737
PostgreSQL mighty function

I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.

Problem Description

Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.

A traditional approach for this on a Rails project is to use something like the acts_as_list gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position SQL query.

This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri

@brain64bit
brain64bit / gist:48569ff0c6c146b0c8ef
Created December 4, 2014 07:02 — forked from dhh/gist:1014971
Rails Concerns Example
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@brain64bit
brain64bit / Ansibel
Last active August 29, 2015 14:07 — forked from yudapc/Ansibel
$ sudo apt-get install python-pip
$ sudo pip install boto
$ sudo pip install https://github.com/KMK-ONLINE/ansible/zipball/elasticache_redis_vpc
create new file with name "hostfile" :
[yudaserver]
128.199.146.166
create new file with name "nginx.yml" :
- name: DEPLOYMENT