Skip to content

Instantly share code, notes, and snippets.

View hiraq's full-sized avatar

Hiraq Citra M hiraq

  • RuangGuru
  • Indonesia
View GitHub Profile
package consumeapi
import (
"net/http"
)
const Endpoint string = "http://api.provider.com"
type ConsumeApi struct {
Endpoint string
import requests
class ConsumeAPI(object):
ENDPOINT = 'http://api.provider.com'
def get(self):
return requests.get(self.ENDPOINT)
package main
import (
"fmt"
)
type Callback func()
func JustPrintIt(msg string) {
fmt.Println(msg)
package main
import "fmt"
func Catch() {
if r := recover(); r != nil {
fmt.Println(fmt.Sprintf("Recovered from : %v", r))
}
}
package main
import "fmt"
func JustPrintIt(msg string) {
defer func() {
fmt.Println("Should be triggered after function called")
}()
fmt.Println(msg)
import unittest
import mock
from module.my_class_a import MyClassA
class TestMyClassA(unittest.TestCase):
def setUp(self):
self._fake_path = '/path/to/the/fake/yaml/file'
@mock.patch('module.my_class_a.yaml')
import unittest
import mock
from module.my_class_a import MyClassA
class TestMyClassA(unittest.TestCase):
def setUp(self):
self._fake_path = '/path/to/the/fake/yaml/file'
@mock.patch('module.my_class_a.yaml')
@hiraq
hiraq / my_class_a.py
Last active August 26, 2016 16:06
Just for example at medium publications only
import yaml
class MyClassA(object):
def to_test(self, path):
with open(path, 'r') as stream:
output = yaml.load(stream)
return output
@hiraq
hiraq / atom-keybindings-linux.txt
Last active June 11, 2016 16:25
Atom editor keybindings for linux
ctrl-k ctrl-w : close all files
ctrl-w q : close current file
ctrl-k ctrl-alt-w : close other files
alt-\ : fokus to sidebar / tree
@hiraq
hiraq / confirmit.js
Created September 23, 2015 06:14
simple jquery plugin for window confirm
'use strict';
(function($) {
$.fn.confirmit = function(msg, successFunc) {
if (window.confirm(msg)) {
successFunc();
}
return this;
};