Skip to content

Instantly share code, notes, and snippets.

View satriahrh's full-sized avatar

Satria H R Harsono satriahrh

View GitHub Profile
{
"severity": "INFO",
"eventTime": "2021-08-20T17:41:51.763+0700",
"caller": "services/sync.go:141",
"message": "Debug agent",
"serviceContext": { "service": "grosir-pintar", "version": "1.0.0" },
"trace_id": "5c50cf049a384f1d",
"operation": "services_Agent_SyncAgentDataWithJDS_UpdateAgent",
"agent_id": 343,
"agent": {
func main() {
for event := range []string{"coin", "coin", "push", "touch"} {
err := fsm.Transition(event)
if err != nil {
fmt.Println(err)
}
fmt.Println(fsm.Current())
}
}
var fsm := FiniteStateMachine{
Initial: "on",
StateMap: StateMap{
"locked": Transition{
"coin": Action{
Destination: "unlocked",
},
"push": Action{
Destionation: "locked",
}
type IFiniteStateMachine interface {
Current() State
Transition(event Event) error
}
func (fsm *FiniteStateMachine) Current() State {
if fsm.current == "" {
return fsm.Initial
}
return fsm.current
type State string
type Event string
type Action struct {
Destination State
}
type Transition map[Event]Action
type StateMap map[State]Transition
@satriahrh
satriahrh / public_private_protected.rb
Created February 4, 2020 15:42
public vs private vs protected in Ruby
class A
def test
self.call_private("A") rescue p 'cannot call self.call_private("A")'
call_private("A")
call_protected("A")
self.call_protected("A")
end
protected

Git Cheat Sheet

Push Tag to Remote

Push a specific tag only, no forcing to push all tags. See more

git push origin <tag_name>

Ruby Cheat Sheet

How to generate a random date and time between two dates?

Time.at((date2.to_f - date1.to_f)*rand + date1.to_f)
D, [2019-04-22T17:25:04.844532 #28255] DEBUG -- : (0.8ms) SET NAMES utf8mb4 COLLATE utf8mb4_bin, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
D, [2019-04-22T17:25:04.855728 #28255] DEBUG -- : DebtCollector::CashFunding::Investor Load (0.9ms) SELECT `cash_funding_investors`.* FROM `cash_funding_investors` WHERE `cash_funding_investors`.`user_id` = 1 LIMIT 1
I, [2019-04-22T17:25:04.931137 #28255] INFO -- : [paperclip] Trying to link /tmp/8d777f385d3dfec8815d20f7496026dc20190422-28255-15d663q to /tmp/8d777f385d3dfec8815d20f7496026dc20190422-28255-sr49e6
I, [2019-04-22T17:25:04.945184 #28255] INFO -- : [paperclip] Trying to link /tmp/8d777f385d3dfec8815d20f7496026dc20190422-28255-1908wza to /tmp/8d777f385d3dfec8815d20f7496026dc20190422-28255-1imoczc
D, [2019-04-22T17:25:04.946448 #28255] DEBUG -- : (0.5ms) BEGIN
I, [2019-04-22T17:25:04.947528 #28255] INFO -- : [paperclip] Trying to

PNG++ Installation on Ubuntu 16.04

Full documentation --> https://www.nongnu.org/pngpp/doc/0.2.9/

Requirements

The libpng it self, in Ubuntu 16.04 you can follow sudo apt install libpng12-dev.

The Steps

  1. Grab the lattest file here aka 0.2.9
  2. Go to download directory.