Skip to content

Instantly share code, notes, and snippets.

View adriacidre's full-sized avatar

Adrià Cidre adriacidre

View GitHub Profile
@adriacidre
adriacidre / singletonTrait.php
Created May 2, 2013 19:21
PHP Singleton pattern using traits
<?php
trait Singleton
{
private static $_instance;
private function __construct(){}
public function __clone()
{
throw new Exception('This object cannot be cloned!');
@adriacidre
adriacidre / Init_d_template
Created July 9, 2013 12:32
Simple init.d script template
#!/bin/bash
# myapp daemon
# chkconfig: 345 20 80
# description: myapp daemon
# processname: myapp
DAEMON_PATH="/home/wes/Development/projects/myapp"
DAEMON=myapp
DAEMONOPTS="-my opts"

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@adriacidre
adriacidre / positive_non_four.rb
Last active August 29, 2015 13:55
Count the number of positive integers less than N that does not contains digit 4.
#
# Count the number of positive integers less
# than N that does not contains digit 4.
#
# Source: http://www.careercup.com/question?id=4752301805797376
class PositiveNonFour
def count_integers_non_four_less_than(max, strategy = :brute_force)
@filter = 4
@adriacidre
adriacidre / systemctl.md
Last active February 3, 2023 07:23
Systemctl Cheatsheet

Service Management

Starting and Stopping Services

Starting

sudo systemctl start application.service

or simply

sudo systemctl start application
nc, _ := nats.Connect(nats.DefaultURL)
body := []byte(`{"status":"verification_pending", "verification_done"}`)
msg, err := nc.Request("workflow.get.next", body, 10*time.Millisecond)
nc.Close();
{
"arcs": [
{
"from": "initialized",
"to": "verification_pending",
"when": "verify"
},
{
"from": "verification_pending",
"to": "to_transcode",

Keybase proof

I hereby claim:

  • I am adriacidre on github.
  • I am kumulo (https://keybase.io/kumulo) on keybase.
  • I have a public key ASBM169TXG0MNhX3RpK19w_OV_RrxIHIE7Rf3CCnfC-qbQo

To claim this, I am signing this object:

@adriacidre
adriacidre / cart-example.go
Last active June 4, 2020 08:43
Cart example
type Cart struct {
Account int `json:"account_number"`
Fruits []string `json:"fruits"`
}
cart := &Cart{
Account: 1,
Fruits: []string{"apple", "peach", "pear"}}
}