Skip to content

Instantly share code, notes, and snippets.

Digital nomad | RubyOnRails | AWS

Victor Leong Vic-L

Digital nomad | RubyOnRails | AWS
Block or report user

Report or block Vic-L

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Vic-L / gist:d7bae9cd3fd6b468ac04
Last active Aug 29, 2015
kill already running rails server
View gist:d7bae9cd3fd6b468ac04
lsof -wni tcp:3000
kill -9 <PID>
View gist:b84fbf839bb897643e7e
# in ApplicationHelper.rb
def flash_class(level)
case level
when :notice then "alert alert-info"
when :success then "alert alert-success"
when :error then "alert alert-error"
when :alert then "alert alert-block"
else "alert #{level}
Vic-L / gitignore
Last active Aug 29, 2015
rails new app essential setup
View gitignore
# Ignore bundler config.
# Ignore the default SQLite database.
# Ignore all logfiles and tempfiles.
Vic-L / command line
Last active Aug 29, 2015
create .ruby-version and .ruby-gemset for project
View command line
rvm --create --ruby-version 2.2.1@victor
View grant privileges
grant all privileges on mydb.* to myuser@'%' identified by 'mypasswd';
View bootstrap variables
$bootstrap-sass-asset-helper: false !default;
// Variables
// --------------------------------------------------
//== Colors
//## Gray and brand colors for use across Bootstrap.
View output_to_file"myfile.csv", "w") do |csv|
csv << BusinessService.column_names
BusinessService.all.each do |m|
csv << m.attributes.values
View check space
func deviceRemainingFreeSpaceInBytes() -> Int64? {
let documentDirectoryPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
let systemAttributes = NSFileManager.defaultManager().attributesOfFileSystemForPath(documentDirectoryPath.last as String, error: nil)
let freeSize = (systemAttributes?[NSFileSystemFreeSize] as? NSNumber)?.longLongValue
return freeSize
if let bytes = deviceRemainingFreeSpaceInBytes() {
println("free space: \(bytes)")
} else {
Vic-L / to_csv
Created Jun 18, 2015
rails console
View to_csv
require 'csv'
file = "#{Rails.root}/data.csv"
schools = School.where(state_code: 'CO').order('name ASC') file, 'w' ) do |writer|
schools.each do |s|
writer << [, s.zipcode,]
View nil?
if (typeof(some_variable) != 'undefined' && some_variable != null)
You can’t perform that action at this time.