Skip to content

Instantly share code, notes, and snippets.

View fadhlirahim's full-sized avatar
💭
Most happiest building code that make sense.

Fadhli Rahim fadhlirahim

💭
Most happiest building code that make sense.
View GitHub Profile
@fadhlirahim
fadhlirahim / envvars
Created February 12, 2016 04:49 — forked from jufemaiz/envvars
AWS EC2 Elastic Beanstalk Instance (Ruby Puma)
# /opt/elasticbeanstalk/containerfiles/envvars
# Default environment variables for Elastic Beanstalk
export EB_ROOT=/opt/elasticbeanstalk
export EB_CONFIG_FILE=$EB_ROOT/deploy/configuration/containerconfiguration
export EB_CONFIG_SOURCE_BUNDLE=$EB_ROOT/deploy/appsource/source_bundle
export EB_CONFIG_APP_BASE=/var/app
export EB_CONFIG_APP_SUPPORT=$EB_CONFIG_APP_BASE/containerfiles
export EB_CONFIG_APP_ONDECK=$EB_CONFIG_APP_BASE/ondeck
export EB_CONFIG_APP_CURRENT=$EB_CONFIG_APP_BASE/current
@fadhlirahim
fadhlirahim / 01_add_cors.config.yaml
Created February 4, 2016 14:36 — forked from vsviridov/01_add_cors.config.yaml
Add CORS to Nginx on AWS Elastic Beanstalk
container_commands:
01_fix_static_cors:
command: "/tmp/fix_static_cors.sh"
files:
"/tmp/fix_static_cors.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
@fadhlirahim
fadhlirahim / account.rb
Created January 27, 2016 00:59 — forked from smoil/account.rb
Ajax select/multi select in Rails using Select2
class Account < ActiveRecord::Base
def self.search(name = nil)
# search logic
end
end
@fadhlirahim
fadhlirahim / _flash_messages.html.erb
Created January 11, 2016 13:14 — forked from roberto/_flash_messages.html.erb
Rails flash messages using Twitter Bootstrap
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
@fadhlirahim
fadhlirahim / notes.md
Last active August 29, 2015 14:06 — forked from DavidWittman/notes.md

A Brief Introduction to Fabric

Fabric is a deployment management framework written in Python which makes remotely managing multiple servers incredibly easy. If you've ever had to issue a change to a group servers, this should look pretty familiar:

for s in $(cat servers.txt); do ssh $s service httpd graceful; done

Fabric improves on this process by providing a suite of functions to run commands on the servers, as well as a number of other features which just aren't possible in a simple for loop. While a working knowledge of Python is helpful when using Fabric, it certainly isn't necessary. This tutorial will cover the steps necessary to get started with the framework and introduce how it can be used to improve on administering groups of servers.

#controller
@start_date = Date.civil(params[:range][:"start_date(1i)"].to_i,params[:range][:"start_date(2i)"].to_i,params[:range][:"start_date(3i)"].to_i)
#view
<%= date_select('range', 'start_date', :order => [:month, :day, :year])%>
/**
* An extension that always calls success when a spy is called.
*
* @example
* spyOn(foo, 'bar').andCallSuccessWith("baz");
* var options = {
* success: jasmine.createSpy();
* }
* foo.bar(options);
* expect(options.success).toBeCalledWith("baz");
@fadhlirahim
fadhlirahim / theme.html
Created October 5, 2012 08:29 — forked from soemarko/theme.html
embed github gist to tumblr
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
# Add fixture-generation methods to ControllerExampleGroup. We load
# this file within our spec_helper.rb
# http://pivotallabs.com/users/jb/blog/articles/1152-javascripttests-bind-reality-
Spec::Rails::Example::ControllerExampleGroup.class_eval do
# Saves the markup to a fixture file using the given name
def save_fixture(markup, name)
fixture_path = File.join(RAILS_ROOT, '/tmp/js_dom_fixtures')
Dir.mkdir(fixture_path) unless File.exists?(fixture_path)
@fadhlirahim
fadhlirahim / cs-iife.coffee
Created July 7, 2012 03:17 — forked from ryanflorence/cs-iife.coffee
CoffeeScript Immediately Invoked Function Expressions
increment = do ->
x = 0
->
x++