Skip to content

Instantly share code, notes, and snippets.

@mapix
mapix / trick for default funcmap.go
Created August 7, 2019 16:04
trick for default funcmap
package main
import (
"os"
"text/template"
"strings"
)
func main() {
fmap := template.FuncMap{
"split": strings.Split,
# -*- coding: utf-8 -*-
import re
import os.path
import glob
import argparse
parser = argparse.ArgumentParser(description='split css')
parser.add_argument('css', help='css file')
parser.add_argument('index', help='index file')
#-*- coding: utf-8 -*-
# env PYTHONIOENCODING=utf8
# env LANG=en_US.UTF-8
# env LC_CTYPE=en_US.UTF-8
# env LC_ALL=en_US.UTF-8
# apt install locales
# locale-gen en_US.UTF-8
package main
import (
"fmt"
"reflect"
"runtime"
)
func Decorator(decoPtr, fn interface{}) (err error) {
var decoratedFunc, targetFunc reflect.Value
@mapix
mapix / sublime_text_2_useful_shortcuts.md
Created November 17, 2017 13:31 — forked from bdargan/sublime_text_2_useful_shortcuts.md
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods
@mapix
mapix / requests_debug.py
Created May 16, 2017 15:20
Enable python requests logging debug info
def enable_requests_debug():
from random import choice
from requests.packages.urllib3 import HTTPResponse
from requests.packages.urllib3.packages.six.moves import http_client
if getattr(HTTPResponse, 'has_enable_requests_debug', False):
return
RESET_COLOR = '\033[0m'
COLORS = ['\033[95m', '\033[94m', '\033[92m', '\033[93m', '\033[91m', '\033[1m']
package main
import (
"fmt"
"os"
)
func foo() error {
var err error
return err
@mapix
mapix / demo.txt
Created December 7, 2016 02:21 — forked from mgedmin/demo.txt
Fixing Mako tracebacks (version 2)
$ virtualenv /tmp/sandbox
...
$ /tmp/sandbox/bin/pip install mako
...
$ /tmp/sandbox/bin/python mako_tb.py
= Default traceback =
@mapix
mapix / comm.py
Created November 2, 2016 09:06 — forked from drocco007/comm.py
Python generator rate limiter using token bucket
from time import time, sleep
_128k = 128 * 1024
_256k = 256 * 1024
_512k = 512 * 1024
_1024k = 1024 * 1024
class TokenBucket(object):
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
// shuffle local