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:14986cecadee05e768e5
Created Mar 19, 2016 — forked from sulf/gist:1157909
Rails helper time_ago_in_words() and distance_of_time_in_words() translated into JavaScript
View gist:14986cecadee05e768e5
var distance_of_time_in_words, time_ago_in_words;
time_ago_in_words = function(from_time, include_seconds) {
if (include_seconds != null) {
} else {
include_seconds = false;
return App.distance_of_time_in_words(from_time,, include_seconds);
distance_of_time_in_words = function(from_time, to_time, include_seconds) {
View import
require 'csv'
csv_text ='...')
csv = CSV.parse(csv_text, :headers => true)
csv.each do |row|
Vic-L / js code
Created Aug 10, 2015
typeahead debugging
View js code
$('.typeahead').focus().typeahead('val', '').focus().typeahead('val', 'what ever value you want to test');
View assets path
View nil?
if (typeof(some_variable) != 'undefined' && some_variable != null)
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 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 {
View output_to_file"myfile.csv", "w") do |csv|
csv << BusinessService.column_names
BusinessService.all.each do |m|
csv << m.attributes.values
View bootstrap variables
$bootstrap-sass-asset-helper: false !default;
// Variables
// --------------------------------------------------
//== Colors
//## Gray and brand colors for use across Bootstrap.
View grant privileges
grant all privileges on mydb.* to myuser@'%' identified by 'mypasswd';
You can’t perform that action at this time.