Skip to content

Instantly share code, notes, and snippets.

View dieunb's full-sized avatar
🎯
Focusing

Dieu Nguyen dieunb

🎯
Focusing
View GitHub Profile
@dieunb
dieunb / rails auto refress view
Created May 21, 2014 16:13
rails auto refresh view after seconds
<% content_for :head do %>
<meta http-equiv="refresh" content="3">
<% end %>
- (void)getPhoneContacts:(void(^)(NSMutableArray* contacts))handler
{
NSMutableArray *contacts = [[NSMutableArray alloc] initWithCapacity:0];
CFErrorRef *error = nil;
ABAddressBookRef _addressBook = ABAddressBookCreateWithOptions(NULL, error);
ABAddressBookRequestAccessWithCompletion(_addressBook, ^(bool granted, CFErrorRef error) {
if (error || !granted) {
// handle error
NSLog(@"ERROR: %@", error);
@dieunb
dieunb / force gitignore
Created July 30, 2014 10:19
Force setup with gitignore
git rm -r --cached . (add params -f to force removing cache)
git add .
git commit -m ".gitignore is now working"
@dieunb
dieunb / gist:9c9b8a882436eb785442
Last active August 29, 2015 14:17
[Book Reviewing System]

[Book Reviewing System] Framgia has many technical books that all employees can read. To manage and use them effectively, the management and reviewing system is needed. ####User

  • can register for app
  • can signin, signout
  • can see the list of all books
  • can search books by title, category, rating, favorite, etc.
  • can rate and write a review for book (also can edit, delete it)
  • can comment to a review (also can edit, delete it)
  • can mark a book as reading
@dieunb
dieunb / rails remake data
Created June 1, 2015 04:04
Rails remake data
namespace :db do
desc "remake database data"
task remake: :environment do
if Rails.env.development? || Rails.env.staging?
["db:drop", "db:create", "db:migrate", "db:seed"].each do |action|
Rake::Task[action].invoke
end
else
puts 'Can rake db:remake in development & staging environments only'
end
@dieunb
dieunb / Capfile
Last active August 29, 2015 14:24
rails capistrano deploy script
# Load DSL and set up stages
require "capistrano/setup"
# Include default deployment tasks
require "capistrano/deploy"
require "capistrano/rvm"
require "capistrano/bundler"
require "capistrano/rails/assets"
require "capistrano/rails/migrations"
@dieunb
dieunb / sublime-user-setting
Created July 15, 2015 07:32
Sublime user setting
{
"ensure_newline_at_eof_on_save": true,
"font_size": 13,
"highlight_line": true,
"ignored_packages":
[
"Vintage"
],
"rulers":
[
@dieunb
dieunb / fetch pull request code
Last active August 1, 2017 08:12
Review pullrequest
Test pull request
Step 1: Add config to git config file at .git foler following below:
[remote "pullrequest"]
url = git@github.com:rcainc/homeup.git
fetch = +refs/pull/*/head:refs/remotes/pullrequest/pr/*
Step 2: git fetch pullrequest
Step 3: git checkout name_pullrequest -b name_new_local_branch
example: git checkout pullrequest/pr/57 -b pr57
Step 4: Using git blame file_path to check owner line of code.
@dieunb
dieunb / ElasticSearch.sh
Last active August 29, 2015 14:26 — forked from ricardo-rossi/ElasticSearch.sh
Installing ElasticSearch on Ubuntu 14.04
### USAGE
###
### ./ElasticSearch.sh 1.5.0 will install Elasticsearch 1.5.0
### ./ElasticSearch.sh 1.4.4 will install Elasticsearch 1.4.4
### ./ElasticSearch.sh will fail because no version was specified (exit code 1)
###
### CLI options Contributed by @janpieper
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch
### ElasticSearch version
@dieunb
dieunb / rvm generate gemset
Created August 8, 2015 06:56
rvm generate gemset
rvm --ruby-version --create ruby-version@name_of_project