Skip to content

Instantly share code, notes, and snippets.

@kiennt
kiennt / gcloud
Last active March 26, 2018 01:47
backup
#!/usr/bin/env bash
create_backup_account() {
PROJECT_NAME=$1
SERVICE_ACCOUNT_NAME=$2
SERVICE_ACCOUNT=${SERVICE_ACCOUNT_NAME}@${PROJECT_NAME}.iam.gserviceaccount.com
gcloud iam service-accounts \
create ${SERVICE_ACCOUNT_NAME} \
--display-name "Backup service"
@kiennt
kiennt / spec_vi.md
Last active November 22, 2022 02:17
Stripe API spec

Các yêu cầu chung của API

0. Vì sao cần viết tài liệu này

Tài liệu này viết ra nhằm mục đích giúp cho

  • Xác định các định dạng cơ bản của các API
  • Lưu trữ lại các luồng dữ liệu của phần thanh toán
  • Mô tả chi tiết từng API cho hệ thống Backend phần thanh toán
@kiennt
kiennt / data.json
Created September 12, 2017 10:10 — forked from Kattoor/data.json
Get Facebook access token with only backend node.js
{
"email": "jasper_catthoor@hotmail.com",
"pass": "",
"client_id": "",
"client_secret": "",
"redirect_uri": "http://localhost:3000"
}
@kiennt
kiennt / app.ex
Created February 12, 2017 04:27
split_case_benchmark
defmodule App do
def split_case(value) do
# implementation in here
end
def run do
for _ <- 1..1_000_000 do
split_case("HelloWorld")
end
end
@kiennt
kiennt / model_user.ex
Created December 20, 2016 03:54
Absinthe authorization example
defimpl Kipatest.Can, for: Kipatest.User do
use Kipatest.Web, :model
def can?(%User{} = subject, :owner, %User{} = user) do
user.id == subject.id
end
end
defmodule Kipatest.AccessToken do
use Kipatest.Web, :model
@type t :: %{__struct__: atom}
@primary_key {:id, Ecto.UUID, autogenerate: true}
schema "access_tokens" do
field :is_valid, :boolean, default: true
field :refresh_token, Ecto.UUID, autogenerate: true
field :expired_at, Timex.Ecto.DateTime
$ curl -H 'SOAPAction: ""' 'http://103.23.146.174:8080/WS_Epurse_Interface_proc_L/services/EpurseV2Interface?wsdl' -d '
→ <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://Interface.epurseV2.vnptepay.vn">
→ <soapenv:Header/>
→ <soapenv:Body>\
→ <int:procService soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\
→ <JsonReq_str xsi:type="xsd:string">test\
→ </JsonReq_str>\
→ </int:procService>\
→ </soapenv:Body>\
→ </soapenv:Envelope>'
defmodule FobiWithGuard do
def fibo(0), do: 1
def fibo(1), do: 1
def fibo(n) when n > 1, do: fibo(n - 1) + fibo(n - 2)
end
<<a, b::size(3), rest::bitstring>> = <<1, 2, 3, 4, 5>>
# a => 1
# b => 0
# rest => <16, 24, 32, 5::size(5)>>