Skip to content

Instantly share code, notes, and snippets.

View nawie's full-sized avatar

iwan hartanto nawie

View GitHub Profile
"""
setTimeout like javascript on python
====================================
https://codeburst.io/javascript-like-settimeout-functionality-in-python-18c4773fa1fd
"""
import threading
from functools import wraps

VIM Cheatsheet

based on : https://vim.rtorr.com/

Basic operation

- :saveas [file] = save file as
- :e! or :edit! = reopen file (or last closed file)
- :w = write (save) the file, but don't exit
/*
* module for encode,decode gammu text message
* original gammu message is encoded using 4 length zeropad and hex
*
*/
const zpad = (n) => ('0000'+n).slice(-4);
const zunpad = (n) => n.replace(/^0+/, '');
function toHex(s) {
@nawie
nawie / defineProperty.js
Created May 14, 2018 01:50 — forked from afuggini/defineProperty.js
Object.defineProperty polyfill
/*!
* https://github.com/es-shims/es5-shim
* @license es5-shim Copyright 2009-2015 by contributors, MIT License
* see https://github.com/es-shims/es5-shim/blob/master/LICENSE
*/
// vim: ts=4 sts=4 sw=4 expandtab
// Add semicolon to prevent IIFE from being passed as argument to concatenated code.
;
@nawie
nawie / caller_name.py
Last active May 2, 2018 04:35 — forked from techtonik/caller_name.py
Python - inspect - Get full caller name (package.module.function)
# Public Domain, i.e. feel free to copy/paste
# Considered a hack in Python 2
import inspect
def caller_name(skip=2):
"""Get a name of a caller in the format module.class.method
`skip` specifies how many levels of stack to skip while getting caller
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.