Skip to content

Instantly share code, notes, and snippets.

View RohitRox's full-sized avatar
🎯
Focusing

Rohit Joshi RohitRox

🎯
Focusing
View GitHub Profile
# Sorts an array based on a property of each object within the array
#
# Examples:
#
# [Em.Object.create(a: 1), Em.Object.create(a: 5), Em.Object.create(a: 3)].sortProperty('a')
# > [{a: 1}, {a: 3}, {a: 5}]
#
# As a computed property:
#
# AC = Em.ArrayController.extend
@RohitRox
RohitRox / public_read_bucket_policy.rb
Created June 20, 2014 05:21
Amazon public read bucket policy
# gem 'aws-sdk'
require 'aws-sdk'
AWS.config(:access_key_id => '', :secret_access_key => '')
policy = '{
"Id": "Policy1380877762691",
"Statement": [
{
@RohitRox
RohitRox / ubuntu_after_do
Created July 21, 2014 17:35
Ubuntu after do for web developers
sudo apt-get update
sudo apt-get install curl
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
@RohitRox
RohitRox / modulejs.js
Created January 21, 2015 18:29
One way to organize Javascript.
var module = new function() {
var define, definitions, require;
definitions = {};
define = function(moduleName, dependencies, fn) {
if (fn === undefined) {
fn = dependencies;
dependencies = [];
}
definitions[moduleName] = {
dependencies: dependencies,
@RohitRox
RohitRox / project.rb
Last active August 29, 2015 14:16
Ruby Refactoring with Meta and Modules
class Project < ActiveRecord::Base
STATUS_TRANSITIONS =
{
initial: :not_started,
not_started: { value: "On the board" },
recommendation_sent: { value: "Recs: Recommendations Sent", event: :recommend},
restarted: { event: :restart, to: :not_started }
}
@RohitRox
RohitRox / apply_syntax_config.json
Created April 24, 2015 20:10
Highlight :javascript and :css block in haml in Sublime Text
// Sublime 3, comes installed with Rails package. This also provide "Ruby Haml". If you press ctrl + alt + p and type haml you will probably see two Set Syntax: Ruby Haml.
// The best solution for me was also install ApplySyntax and in it's user settings add the following:
// Put your custom syntax rules here:
"syntaxes": [
{
// This rule could be incorporated into the next one, but I prefer to be
// more explicit rather than less
"name": "Haml/Syntaxes/Ruby Haml",
@RohitRox
RohitRox / application.rb
Created June 18, 2015 16:01
My Rails application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
# Load configs from config/application.yml
# config/application.yml
# default: &default
@RohitRox
RohitRox / cookie_utils.js
Created April 17, 2012 08:47
javascript cookie utils
@RohitRox
RohitRox / rails_snippets_application_helper.rb
Last active October 5, 2015 13:38
Setting layouts and helper to access control
#in helper/application_helper.rb
def authorize_resources
unless user_signed_in?
redirect_to new_user_session_path
end
end
#in application_controller
@RohitRox
RohitRox / ubuntu_hacks
Created May 28, 2012 04:33
My ubuntu hacks
#starting sublime, opening whole directory and in background
#in .zshrc
alias e="path-to-sublime-executable ./ &"
#setting terminal real transparent (after setting metacity for windows manager )
gconftool-2 /apps/metacity/general/compositing_manager --type bool --set true