Skip to content

Instantly share code, notes, and snippets.

View gcandal's full-sized avatar
🧨
Dynamiting

Gabriel Candal gcandal

🧨
Dynamiting
View GitHub Profile

Keybase proof

I hereby claim: * I am gcandal on github. * I am gcandal (https://keybase.io/gcandal) on keybase. * I have a public key ASAAmSI_qg61cFJjDpkzvscaunjz319TB2y9tnmbXTIBuwo To claim this, I am signing this object:

{   "body": {     "key": {       "eldest_kid": "01200099223faa0eb57052630e9933bec71aba78f3df5f53076cbdb6799b5d3201bb0a",       "host": "keybase.io",       "kid": "01200099223faa0eb57052630e9933bec71aba78f3df5f53076cbdb6799b5d3201bb0a",       "uid": "d30bb8d0b3d2b70994cebf001a7afa19",       "username": "gcandal"     },     "merkle_root": {       "ctime": 1568379286,       "hash": "b1c31506388eb536a9b26698c4749ad92277cc83634fb7443d1c6689c0e9a91b8641ab7473ca7abe78a4c957c3cb8f5d25d1a9b3922a3646b64cf8eebcf7817d",       "hash_meta": "5fa728990c9b9afea643eb0e1272a6b5ab3c3c04af750c40e0b8e3a5a3438c2f",       "seqno": 7151538     },     "service": {       "entropy": "pdZQKtuZaGlIlxKeCMEVhgWB",       "name": "github",       "username": "gcandal"     },     "type": "web_service_bi
class AccountingLedger {
AccountingLedger(AccountingLedgerStorage storage) {
this.storage = Objects.requireNonNull(storage);
}
void save(final Record record) {
Objects.requireNonNull(record);
validate(record);
storage.save(record);
@gcandal
gcandal / abs2.java
Last active September 28, 2018 13:22
class AccountingLedger {
AccountingLedger(AccountingLedgerStorageType storageToUse) {
this.storageToUse = Objects.requireNonNull(storageToUse);
}
void save(final Record record) {
Objects.requireNonNull(record);
validate(record);
persistToDisk(record);
@gcandal
gcandal / abs1.java
Last active September 28, 2018 12:59
class AccountingLedger {
void save(final Record record) {
Objects.requireNonNull(record);
validate(record);
persistToDisk(record);
}
...
private void persistToDisk(final Record record) {
template<> string to_string(const float & attr_value) {
sprintf(buf, "%g\0", sValue);
(... some business logic ...)
return buf;
}
template<class T> string to_string(T attr_value) {
static stringstream ss;
template<class T> string to_string(T attr_value) {
static stringstream ss;
ss.str("");
ss << T;
string str = ss.str();
(... some business logic ...)
return res;
template<class T> string to_string(T attr_value) {
stringstream ss;
ss << T;
string str = ss.str();
(... some business logic ...)
return res;
}
for (int index = 0; index < something; i++) {
int element = stuff[index];
}
int element;
for (int index = 0; index < something; i++) {
element = stuff[index];
}
@gcandal
gcandal / dijkstra.py
Created February 19, 2015 10:41
Dijkstra's shortest path
'''
Gabriel C. 2015
Dijkstra's algorithm for shortest path,
on an adjacency list, not using a min-heap
'''
def pick_minimum(graph, visited, distances):
minimum = (0, 0, -1)