Skip to content

Instantly share code, notes, and snippets.

View saiqulhaq's full-sized avatar
🏠
Working from home

Saiqul Haq saiqulhaq

🏠
Working from home
View GitHub Profile
@saiqulhaq
saiqulhaq / gist:b8573273e1c1d584cabd
Created December 20, 2014 16:22
rails icon_link_to helper
// Usage
// font awesome
// icon_link_to("Dashboard", internal_path, fa: :dashboard, class: "btn btn-primary")
// bootstrap
// icon_link_to("Dashboard", internal_path, bs: :home, class: "btn btn-primary")
def icon_link_to text, path, options = {}
list = block_given? ? yield : ""
btn_dropdown = options.delete(:dropdown) ? content_tag(:i, "", class: 'fa fa-angle-left pull-right') : ""
if icon = options.delete(:fa) // font-awesome
return link_to(content_tag(:i, "", class: 'fa fa-' + icon.to_s) + content_tag(:span, text) + btn_dropdown, path, options) + list
@saiqulhaq
saiqulhaq / rspec_model_testing_template.rb
Last active August 29, 2015 14:20 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
require 'active_record'
require 'bcrypt'
class User < ActiveRecord::Base
PASSWORD_SALT = '$2a$20$ESQ40HbYj00QFse2rbArOe'.freeze
PASSWORD_COST = 15.freeze
establish_connection adapter: 'sqlite3', database: ':memory:'
connection.create_table table_name, force: true do |t|
t.string :email
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<title>Belajar Git</title>
</head>
<body>
<a href="http://feedburner.google.com/fb/a/mailverify?uri=saiqulhaq&amp;loc=en_US">Subscribe to M. Saiqul Haq Site by Email</a>
</body>
</html>
class ApplicationController < ActionController::Base
...
# FORCE to implement content_for in controller
def view_context
super.tap do |view|
(@_content_for || {}).each do |name,content|
view.content_for name, content
end
end
end
source 'http://rubygems.org'
gem 'rails', '3.1.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '3.0.1'
<script src="your_path/holder.js"></script>
@saiqulhaq
saiqulhaq / message-bus.js
Last active April 20, 2016 04:09
Message Bus
/*jshint bitwise: false*/
// please take a look at line numbers 80-85, and 172-177
(function(global, document, undefined) {
'use strict';
longPoller = function(poll,data){
var gotData = false;
var aborted = false;
lastAjax = new Date();
@saiqulhaq
saiqulhaq / .vimrc
Created October 23, 2016 07:09
vimrc
set nocompatible " be iMproved
filetype off " required!
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
" required!
Plugin 'VundleVim/Vundle.vim'
@saiqulhaq
saiqulhaq / glorw.txt
Created October 30, 2016 11:12 — forked from stuartpb/glorw.txt
General list of reserved words
### General List of Reserved Words
### Stuart P. Bentley <stuart@testtrack4.com>, June 4, 2013
## This is a general list of words you may want to consider reserving,
## in a system where users can pick any name, in a context where the
## system may use names as well. One prominent example of a system
## where this is the case would be a site that serves pages for users,
## at their username, from the site root, like
## http://twitter.com/stuartpb . In this system, you would want to
## reserve some routes for pages that would commonly be expected to