Skip to content

Instantly share code, notes, and snippets.

View qcam's full-sized avatar

Cẩm Huỳnh qcam

View GitHub Profile
@qcam
qcam / time-extension-msgpack.rb
Created May 20, 2019 09:03
MessagePack Time extension unpacker in Ruby
require "msgpack"
class DateTimeExtension
def self.unpack(data)
case data.size
when 4
seconds = data.unpack("N")[0]
Time.at(seconds).utc
when 8
defmodule GCounter.Node do
use GenServer
def start_link(node_name) do
GenServer.start_link(__MODULE__, node_name, [name: node_name])
end
@impl true
def init(node_name) do
init_counter = %{node_name => 0}
[
{
"source": "quan-cam.com",
"url": "https://quan-cam.com/rss",
"category": "personal"
},
{
"source": "medium.com/@hqc",
"url": "https://medium.com/feed/@hqc",
"category": "personal"
@qcam
qcam / rfc822.ex
Last active January 4, 2024 10:37
nimble_parsec example with RFC822 datetime parser (https://www.ietf.org/rfc/rfc822.txt)
defmodule RFC822 do
import NimbleParsec
day =
choice([
string("Mon"),
string("Tue"),
string("Wed"),
string("Thu"),
string("Fri"),
{"data":{"build-a-blog-in-elixir-with-nabo-and-phoenix":[{"content":"# g","created_at":"2019-01-14T08:18:53.347875Z","user":{"avatar_url":"https://avatars2.githubusercontent.com/u/26930297?v=4","name":"Kalipts","provider":"github","provider_user_url":"https://github.com/Kalipts"}}],"chet-server-lam-gi-day":[{"content":"s","created_at":"2019-06-24T13:33:26.312600Z","user":{"avatar_url":"https://avatars2.githubusercontent.com/u/35627119?v=4","name":"Juniorsz","provider":"github","provider_user_url":"https://github.com/Juniorsz"}}],"chuyen-an-cap":[{"content":"Vậy nếu vi phạm Creative Commons License thì sẽ bị 'xử lý' như thế nào vậy anh?","created_at":"2018-04-22T14:40:23.413143Z","user":{"avatar_url":"https://avatars3.githubusercontent.com/u/15165794?v=4","name":"j1nz","provider":"github","provider_user_url":"https://github.com/j1nz"}},{"content":"[@j1nz](https://github.com/j1nz) Mình cũng chả muốn \"xử lý\" làm gì cả ☹️. Mình là developer, mình không phải luật sư. Mình chúc họ cắn rứt lương tâm vậy.","created
@qcam
qcam / sample.xml
Last active March 20, 2018 06:42
Benchmarking XML parser in Erlang/Elixir
<?xml version="1.0" encoding="UTF-8"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>Two of our famous Belgian Waffles with plenty of real maple syrup</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>

Keybase proof

I hereby claim:

  • I am qcam on github.
  • I am qcam (https://keybase.io/qcam) on keybase.
  • I have a public key whose fingerprint is 7EAD EE10 DB51 9180 986A 30B4 1BE7 CEA2 28E5 28A9

To claim this, I am signing this object:

@qcam
qcam / hub
Last active January 25, 2017 16:01
Sample config file for hub
# Place your file in ~/.config/hub
github.com:
- user: huynhquancam
oauth_token: XXX # personal token can be obtained from your Github > Settings > Security > Personal Token
@qcam
qcam / hardcore-funcprog.md
Last active October 16, 2016 03:58
My note for Functional Programming Principles in Scala course on Coursera - https://www.coursera.org/learn/progfun1/

Functional Programming

Week 1

Programming Paradigms

Main programming paradigms include:

Imperative Programming
@qcam
qcam / hardcore-grpc.md
Last active August 30, 2016 00:57
[HARDCORE] gRPC

What's gRPC?

In gRPC a client application can directly call methods on a server application on a different machine as if it was a local object, making it easier for you to create distributed applications and services. As in many RPC systems, gRPC is based around the idea of defining a service, specifying the methods that can be called remotely with their parameters and return types. On the server side, the server implements this interface and runs a gRPC server to handle client calls. On the client side, the client has a stub (referred to as just a client in some languages) that provides the same methods as the server.

gRPC clients and servers can communicate no matter what programming languages they're written in. For instance, you can easily create gRPC servers in C++ and clients in Ruby/Python.

Transport and Semantics

gRPC uses (Protocol Buffers, aka. Protobuf)(https://github.com/google/protobuf), for data serialization.