Skip to content

Instantly share code, notes, and snippets.

@yujiod
yujiod / keenio_collector.rb
Created March 9, 2014 01:18
Clone Keen IO data to Elasticsearch
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require "net/https"
require "uri"
require "json"
require "time"
KEENIO_PROJECT_ID = "XXXXXXXX"
KEENIO_READ_KEY = "YYYYYYYY"
@alexaltair
alexaltair / Today's Learning.md
Last active December 18, 2015 17:38
An exploration of infinite lists.

The first thing that really surprised me today was the flexibility of Ruby's shovel operator, <<. A student in the class had tried the following:

a = [0]
a << a

What do you think a is now? I was sure it would be [0, [0]]. But lo and behold, Ruby sparkles;

a = [0]
a &lt;&lt; a
@screamingmunch
screamingmunch / Wk1_Mon(Day1).md
Last active December 18, 2015 14:49
Terminal Commands, Shebang, #!/usr/bin/env ruby, chmod, cat, less

Day 1 of GA WDI program: we spent majority of the class in terminal(shell), getting comfortable with command line prompts. We also played with some Ruby in and Sublime Text. All in all, a good review of all the prep work on command line stuff. Ubuntu isn't as scary as when I first installed it yesterday.

tl;dr: Terminal Commands, Shebang #!/usr/bin/env ruby, chmod a+x demo.rb , Literals, cat, less.

file_name.md --> md stands for markdown file type

Linux:

Ctrl + to zoom in (in apple: Cmd +)

@jcasimir
jcasimir / render_and_redirect.markdown
Created September 11, 2011 21:29
Render and Redirect in Rails 3

Render and Redirect

The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render in a controller when we want to respond within the current request, and redirect_to when we want to spawn a new request.

Render

The render method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form' or render @post.comments, but here we'll focus on usage within the controller.

:action