Skip to content

Instantly share code, notes, and snippets.

View duykhoa's full-sized avatar

Kevin Tran duykhoa

View GitHub Profile
{
"basics": {
"name": "Thomas Edison",
"label": "Inventor and Businessman",
"picture": "https://example.com/photo.jpg",
"email": "[email protected]",
"phone": "(123) 456-7890",
"website": "https://thomasedison.com",
"summary": "Prolific inventor and businessman known for developing many devices that greatly influenced life around the world, including the phonograph, the motion picture camera, and the electric light bulb.",
"location": {
@duykhoa
duykhoa / a.rb
Created January 18, 2018 09:24
test
class ImportParticipant
def initialize(source:, :target)
@source = source
@target = target
end
attr_reader :source, :target
def call
data = @source.read_and_parse
@duykhoa
duykhoa / pianokata
Last active October 12, 2017 10:16
Piano kata
require 'minitest/autorun'
class PianoKeyTest < Minitest::Test
KEYS_COUNT = 88
BLACK_KEY_SEQ = [0, 2, 5, 7, 9]
BLACK_SEQ_START_POS = 5
BLACK = "black"
WHITE = "white"
@duykhoa
duykhoa / as.f
Created March 30, 2017 05:42
email collection
f
@duykhoa
duykhoa / coverage_patch.sh
Last active March 17, 2017 05:16
COVERAGE PATCH
if [ -n "$ZSH_VERSION" ]; then
echo 'zsh env'
echo 'export COVERAGE=true' >> ~/.zshrc
elif [ -n "$BASH_VERSION" ]; then
echo 'bash env'
echo 'export COVERAGE=true' >> ~/.bashrc
else
echo 'You need to run `COVERAGE=true rspec` each time'
fi
@duykhoa
duykhoa / install-comodo-ssl-cert-for-nginx.rst
Created February 18, 2017 05:39 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@duykhoa
duykhoa / rack_notes.md
Created August 29, 2016 06:59
rack notes

Rack is a common interface to interact with different ruby server

to understand the concept of http server, we just need to search for some ruby code that implement a tcp server without any library.

here is a potato for you

  server = TCPServer.new('localhost', 12345)
@duykhoa
duykhoa / blogapplicationserver.rb
Created August 27, 2016 14:23
Simple webrick server: a blog application and post repository
require 'webrick'
class BlogApplication < WEBrick::HTTPServlet::AbstractServlet
class PostRepository
Post = Struct.new(:title, :content)
def self.get
[
Post.new("post1", "content1"),
Post.new("post2", "content2")
@duykhoa
duykhoa / web-server.rb
Created August 27, 2016 10:30 — forked from Integralist/web-server.rb
Create basic Web Server in Ruby (using WEBrick)
#!/usr/bin/env ruby
require "webrick"
=begin
WEBrick is a Ruby library that makes it easy to build an HTTP server with Ruby.
It comes with most installations of Ruby by default (it’s part of the standard library),
so you can usually create a basic web/HTTP server with only several lines of code.
The following code creates a generic WEBrick server on the local machine on port 1234,
@duykhoa
duykhoa / server.rb
Created July 12, 2016 15:03
Simple server in ruby
# Code from https://www.practicingruby.com/articles/implementing-an-http-file-server
require 'socket'
server = TCPServer.new('localhost', 2345)
loop do
socket = server.accept
request = socket.gets
response = <<-HTML
<html>