Skip to content

Instantly share code, notes, and snippets.

View sabril's full-sized avatar

Muhammad Syaiful Sabril sabril

View GitHub Profile
@sabril
sabril / print_job.rb
Created December 15, 2010 01:01
this is for print job
format.pdf {
table_of_content_pages = Hash.new
for specification in @job.specifications
specification_sections = SpecificationSection.specification_id_eq(specification.id)
for specification_section in specification_sections
pdf = Prawn::Document.new(:page_size => "LETTER", :top_margin => 0.5.in, :left_margin => 1.3.in, :bottom_margin => 0.in, :right_margin => 0.8.in )
if report_article_number(specification_section.specification.division.short_number) != "00"
pdf.bounding_box([0, 700], :width => 460, :height => 610 ) do
pdf.text "SECTION #{specification_section.section.report_print_number}", :align => :center, :size => 9, :style => :bold
pdf.move_down(5)
@sabril
sabril / after_code.haml
Created February 18, 2011 02:26
the old uploaded file in production mode is in myspecdata container so they are not linked with user container. See line 22, @container.object.exists?
.holder
- @job.job_folders.with_type("folder").each do |job_folder|
- @job_folder = job_folder
.main{ :id => "folder_#{@job_folder.id}"}
.icon
%a{"href" => "javascript:toggle_div(#{@job_folder.id});"}
= image_tag('plus.jpg', :size => "14x14", :id => "img_#{@job_folder.id}")
.icon= current_user.has_role?(:contact) ? image_tag("#{@job_folder.folder_type}.png", :size => "16x16", :alt => "file_folder_#{@job_folder.id}") : link_to_remote_redbox(image_tag("#{@job_folder.folder_type}.png", :size => "16x16", :alt => "file_folder_#{@job_folder.id}"), :url => new_multiple_files_url(:job_folder_id => @job_folder))
.main_name{ "style" => "width: 470px"}= @job_folder.folder_type == "folder" && !current_user.has_role?(:contact) ? in_place_editor_field(:job_folder, 'name', {}, :save_text => "Save") : @job_folder.name
.main_number  
@sabril
sabril / model.coffee
Created January 23, 2012 10:33 — forked from thelinuxlich/model.coffee
Sample Knockout.js model written in Coffeescript
# Modelo base
class @Model
constructor: (defaults,urls) ->
@__defaults = if typeof defaults is "object" then defaults else {}
@__urls = if typeof urls is "object" then defaults else {}
@set(@__defaults)
get: (attr) ->
ko.unwrapObservable @[attr]
development:
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: lifecoachdrive_development
# Provides the hosts the default session can connect to. Must be an array
# of host:port pairs. (required)
@sabril
sabril / Gemfile
Last active February 27, 2017 08:45
source 'https://rubygems.org'
ruby '2.0.0'
# we are living on the edge, but to stay save.. keep this updated to the latest stable
gem 'rails', '4.0.2'
# i like an elephant more than a dolphin :)
gem "pg"
# mongodb is good for prototyping either it's RDBMS or not
gem 'mongoid', github: "mongoid/mongoid"
@sabril
sabril / omniauth.rb
Created December 10, 2013 15:50
tinggal buat routes untuk callbacknya
# gem "omniauth"
# gem "omniauth-instagram"
# gem "instagram"
Rails.application.config.middleware.use OmniAuth::Builder do
provider :instagram, ENV['INSTAGRAM_KEY'], ENV['INSTAGRAM_KEY']
end
Instagram.configure do |config|
config.client_id = ENV['INSTAGRAM_KEY']
@sabril
sabril / aws_setup.md
Last active December 31, 2015 21:59 — forked from rudylee/digitalocean.md

Deploy Rails app to digitalocean/amazon EC2 with nginx, unicorn, capistrano, sidekiq & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh -i config/onvard.pem root@54.200.188.117

Add ssh fingerprint and enter password provided in email

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="assets/ico/favicon.png">
<title>Life Coach Drive</title>

Deploy Rails app to digitalocean/amazon EC2 with nginx, unicorn, capistrano & postgres

ubuntu 12.10 x32

ssh to root in terminal with your server ip

ssh root@123.123.123.123

or for ec2 you will need your public key

# derived from http://h2np.net/tips/wiki/index.php?RubyOpenSSLDigitalSignatureSample
require 'openssl'
require 'base64'
include OpenSSL
group_name = 'secp160k1'
message = 'test payload aa'
puts "=== Generate Key ==="