Skip to content

Instantly share code, notes, and snippets.

arekt / gist:5275479
Created Mar 30, 2013
Example how to use content_for
View gist:5275479
+ def ble # concatenates everything and you can render whole part in partial by calling yield :ble, or content_for :ble
+ content_for :ble, content_tag(:p, "Here form starts:")
+ content_for :ble, content_tag(:p, "Here form starts:")
+ content_for :ble, content_tag(:p, "Here form starts:")
+ content_for :ble, content_tag(:p, "Here form starts:")
+ render "shared/bootstrap/ble"
+ end
+ def ble2 # you can render everything on the end of helper as well
+ content_for :ble, content_tag(:p, "Here form starts: asdfasdf")
View juggernaut_channels.rb
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do
View application_controller.rb
class ApplicationController < ActionController::Base
# Creates an accessor which is exposed to the view
def self.view_accessor(*names)
attr_accessor *names
helper_method *names
View permissions.html.haml
- roles = []
- roles << {"Can manage users" => {:scope =>["reza", "waitline"]}}
- roles << {"Can change settings" => {:scope =>["pssurvey"]}}
- roles << {"Can use" => {:scope =>["account"]}}
= ko_context system: {users: {"Arek" => roles, "田中" => roles }}, settings: [1,2,3] do
/ko foreach: window.s = new System(context.model.system).users
class Assignment
constructor: (o) ->
$.map o, (v,k) =>
@name = k
@app = v
class System
constructor: (o) ->
@users = $.map o.users, (v,k) =>
new User(k,v)
arekt / gist:8855962
Created Feb 7, 2014
Chaining ember promises in coffeescript
View gist:8855962
addProblem: (disease) ->"medicalRecord",2)
.then (mr) =>
.then (problems) =>
o = @store.createRecord("problem", {disease: disease, medicalRecord: mr})
.then (p) -> ->
console.log "Problem was saved correctly!"
View s3_query_url.rb
#Based off camwest's gist at
#Using to_s instead of extending String
require 'openssl'
require 'cgi'
class S3QueryURL
def initialize(bucket, path, options = {})
@access_key_id = options[:access_key_id]
arekt / log_select.rb
Created Jun 1, 2018
Helper script to read logs from s3 bucket.
View log_select.rb
#!/usr/bin/env ruby
require "aws-sigv4"
require "aws-sdk-core"
require "active_support/all"
require "aws-eventstream"
require "excon"
View appsync_subscribe.rb
require "json"
require "websocket-eventmachine-client"
require "securerandom"
require 'date'
require "base64"
REAL_TIME_HOST = API_HOST.gsub("appsync-api","appsync-realtime-api")
View Embedding python
## based on:
arek@qyobo:~/workspace/embeding_python$ gcc -I/usr/include/python2.7 -I/usr/include/x86_64-linux-gnu/python2.7 main.c -lpython2.7 -o run-python
arek@qyobo:~/workspace/embeding_python$ cat main.c
#include "Python.h"
main(int argc, char *argv[])