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
jarretmoses / React Native Clear Cache
Last active Mar 30, 2020
Clearing the Cache of your React Native Project
View React Native Clear Cache
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache
kainam00 / rvm-amazon-linux.bash
Created Jul 31, 2015
Install RVM on Amazon Linux
View rvm-amazon-linux.bash
# Install prerequisites
yum install -y gcc openssl-devel libyaml-devel libffi-devel readline-devel zlib-devel gdbm-devel ncurses-devel ruby-devel gcc-c++ jq git
# Import key
curl -sSL | gpg2 --import -
# Install RVM
curl -sSL | bash -s stable --ruby
bwhiteley / gist:049e4bede49e71a6d2e2
Last active Mar 3, 2020
Initialize Swift subclass of UIView, designed in .xib
View gist:049e4bede49e71a6d2e2
// Create CustomView.xib, set File's Owner to CustomView.
// Link the top level view in the XIB to the contentView outlet.
class CustomView : UIView {
@IBOutlet private var contentView:UIView?
// other outlets
override init(frame: CGRect) { // for using CustomView in code
super.init(frame: frame)
Suave / gist:6127873
Created Aug 1, 2013
mysql: truncate all tables in one command line
View gist:6127873
mysql -Nse 'show tables' DATABASE_NAME | while read table; do mysql -e "truncate table $table" DATABASE_NAME; done
jonathanmoore / gist:2640302
Created May 8, 2012
Get the share counts from various APIs
View gist:2640302

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.


warden / backup.rake
Created Jan 10, 2011
Rake task for backing up MySQL database in Rails projects
View backup.rake
namespace :db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7"
task :backup => [:environment] do
datestamp ="%Y-%m-%d_%H-%M-%S")
base_path = Rails.root
base_path = File.join(base_path, ENV["DIR"] || "backups")
backup_base = File.join(base_path, 'db_backups')
backup_folder = File.join(backup_base, datestamp)
backup_file = File.join(backup_folder, "#{RAILS_ENV}_dump.sql")
db_config = ActiveRecord::Base.configurations[RAILS_ENV]
View capybara cheat sheet
=Clicking links and buttons=
click_link('Link Text')
click('Link Text') # Click either a link or a button
click('Button Value')
You can’t perform that action at this time.