Skip to content

Instantly share code, notes, and snippets.

View joshteng's full-sized avatar

Joshua Teng joshteng

View GitHub Profile
@joshteng
joshteng / README.txt
Created July 13, 2013 04:50 — forked from i-scorpion/README.txt
Makes your twitter bootstrap tables' header 'sticky'
Here is a simple jQuery plugin to make a table header fixed on top when window is scrolled.
Using the code from twitter bootstrap documentation page, this code is customized for table header.
Create the table with following layout -
<table class="table-fixed-header">
<thead class="header">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
@joshteng
joshteng / rails_app_gems.rb
Last active June 10, 2018 18:52
My Crazy Gem List for Most Rails App
source 'https://rubygems.org'
ruby "2.0.0"
gem 'rails', '3.2.13'
# Gems used only for assets and not required
# in production environments by default.
group :production do
gem 'rack-google-analytics'
@joshteng
joshteng / .zshrc
Last active December 20, 2015 18:59
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Example aliases
@joshteng
joshteng / rails_3_vs_4_mass_assignment_protection.rb
Created August 16, 2013 04:26
Rails 4 way of protecting from mass assignment
###############
#In Rails 3, we protect attributes that should not be mass assignable by users of the website this way:
###############
#in the model file:
class Post < ActiveRecord::Base
attr_accessible :title, :content
end
#and your controller might look something like that
# Shoulda activemodel cheatsheet
# DB
should have_db_column(:title).of_type(:string).with_options(default: 'Untitled', null: false)
should have_db_index(:email).unique(:true)
# Associations
should belong_to :company
should have_one(:profile).dependent(:destroy)
should have_many(:posts).dependent(:nullify)
@joshteng
joshteng / is_anagram.rb
Created September 11, 2013 17:57
SUTD SEPT 2013
# The method should be symmetric, i.e.,
# is_anagram?(word1, word2) == is_anagram?(word2, word1) for any two words
is_anagram?('cinema', 'iceman') # => true
is_anagram?('iceman', 'cinema') # => true
# Pedantically, a word is always an anagram of itself.
# This is called being "reflexive," i.e., is_anagram?(word, word) == true for any word
is_anagram?('pants', 'pants') # => true
# is_anagram? should be case-insensitive
@joshteng
joshteng / anagrams_for.rb
Created September 11, 2013 18:07
Ruby Basics 2
# The dictionary is just an arbitrary collection of strings.
# It need not contain English words, e.g., 'etlsm'.
dictionary = ['acres', 'cares', 'Cesar', 'races', 'smelt', 'melts', 'etlsm']
# If the input word happens to be in the dictionary, it should be in the the returned array, too.
# The list should also be case-insensitive.
anagrams_for('acres', dictionary) # => ['acres', 'cares', 'Cesar', 'races']
anagrams_for('ACRES', dictionary) # => ['acres', 'cares', 'Cesar', 'races']
anagrams_for('Cesar', dictionary) # => ['acres', 'cares', 'Cesar', 'races']
#Table Delegate
def tableView(tableView, didSelectRowAtIndexPath: indexPath)
tableView.deselectRowAtIndexPath(indexPath, animated: true)
# @alert = UIAlertView.alloc.initWithTitle("test", message:"test", delegate:nil, cancelButtonTitle:"Cancel", otherButtonTitles:"Yes").show
@alert = UIAlertView.alloc.initWithTitle("Confirm Support Request", message:"A customer service representative will give you a call", delegate: self, cancelButtonTitle: "cancel", otherButtonTitles: "Yes")
@alert.show
end
call "sip:97158683@shims.starhub.net.sg'"
say "Tag, you’re it!"
message("hello", {network:"SMS", to: "97158683"});