Skip to content

Instantly share code, notes, and snippets.

View duykhoa's full-sized avatar

Kevin Tran duykhoa

View GitHub Profile
! not a real code
k-nav(user="#{user}"
k-sidebar(menu_items= [ { "Posts", "/admin/posts" }, ... ]
main
k-posts(active="[[PostsActive]]")
k-post-data(url= "/api/posts", user="#{user}", data="{{postList}}", page="[[page]]")
k-post-list(post-list="[[postList]]", page="{{page}}")
@duykhoa
duykhoa / gist:50e90c872d4757fef682
Created March 1, 2016 14:06 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.

@duykhoa
duykhoa / web-servers.md
Created February 28, 2016 07:51 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@duykhoa
duykhoa / osx-10.9-setup.md
Created January 29, 2016 09:29 — forked from kevinelliott/osx-10.9-setup.md
Clean Install – Mac OS X 10.9 Mavericks

Mac OS X 10.9 Mavericks

Custom recipe to get OS X 10.9 Mavericks running from scratch, setup applications and developer environment. I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install.

Install Software

The software selected is software that is "tried and true" --- software I need after any fresh install. I often install other software not listed here, but is handled in a case-by-case basis.

Install from App Store

@duykhoa
duykhoa / data.json
Last active December 20, 2015 08:56
data.json for blackhulk project (10533 lines - 2106 posts)
This file has been truncated, but you can view the full file.
[
{
"title": "Plan to throw one away[First]",
"content":
"This is a **software development story** from early in my career. The company in question went bust eighteen years ago, so it’s probably safe to tell the tale now.1 When I had interviewed for the job, the interviewer had explained that I was needed to work on their JavaScript engine. The company was a web development tools startup, and they had spotted that it would be a good idea to have JavaScript code running on the server as well as on the client, so that you could share your business logic and validation code between the client-side and server-side parts of your application. There are now lots of products in this space but twenty years ago was probably too soon for this to be a success. Anyway, the interviewer told me that the JavaScript engine was nearly done, but there were one or two features that were missing, and it was running a bit slowly, so I might have to do a bit of optimization. Sure, I said, that sounded like it would
@duykhoa
duykhoa / parallel_test.sh
Last active October 20, 2015 09:21
script to setup and run parallel test
function setupdb {
# Remove it, Just worked for me.
for I in {1..8}
do
echo " Setup db $I "
TEST_ENV_NUMBER=$I RAILS_ENV=crm_test rake db:drop
TEST_ENV_NUMBER=$I RAILS_ENV=crm_test rake db:create
TEST_ENV_NUMBER=$I RAILS_ENV=test rake crm:setup
TEST_ENV_NUMBER=$I RAILS_ENV=test rake crm:seed
done
@duykhoa
duykhoa / deploy.rb
Last active January 7, 2019 16:03
Mina deploy with Puma task, support `start, stop, restart` feature, use `pumactl`. Thanks this tutorial for saving my life: http://ruby-journal.com/how-to-setup-rails-app-with-puma-and-nginx/
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm' # for rvm support. (http://rvm.io)
set :domain, 'deploy@host'
set :repository, 'git...
set :branch, 'master'
set :shared_paths, ['config/database.yml', 'config/application.yml', 'log', 'tmp/sockets', 'tmp/pids']
@duykhoa
duykhoa / a.rb
Last active August 29, 2015 14:22
hash group
a = [{:id=>1, :phone=>2}, {:id=>1, :phone=>3}, {:id=>2, :phone=>2}]
a.group_by { |item| item[:id] }
{1=>[{:id=>1, :phone=>2}, {:id=>1, :phone=>3}], 2=>[{:id=>2, :phone=>2}]}
b = _[1]
[{:id=>1, :phone=>2}, {:id=>1, :phone=>3}]
b.map { |h| h[:phone] }
[2, 3]
@duykhoa
duykhoa / deploy.rb
Last active August 29, 2015 14:22 — forked from jbonney/deploy.rb
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
# Usually mina focuses on deploying to one host and the deploy options are therefore simple.
# In our case, there is a number of possible servers to deploy to, it is therefore necessary to
# specify the host that we are targeting.
server = ENV['server']
# Since the same host can have multiple applications running in parallel, it is necessary to
### 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