Skip to content

Instantly share code, notes, and snippets.

View imom0's full-sized avatar
💭
I may be slow to respond.

iMom0 imom0

💭
I may be slow to respond.
View GitHub Profile
@imom0
imom0 / multicall.go
Last active December 7, 2023 10:26 — forked from miguelmota/multicall.go
Golang MultiCall solidity contract call example
package main
import (
"context"
"encoding/hex"
"fmt"
"strings"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
@imom0
imom0 / aws_az_list.md
Created November 29, 2023 03:01 — forked from karstenmueller/aws_az_list.md
List of AWS availability zones for each AWS region

AWS Regions

Region Code Region Name Availability Zones
us-east-1* N. Virginia us-east-1a us-east-1b us-east-1c us-east-1d us-east-1e
us-east-2 Ohio us-east-2a us-east-2b us-east-2c
us-west-1* N. California us-west-1a us-west-1b us-west-1c
us-west-2 Oregon us-west-2a us-west-2b us-west-2c
eu-west-1 Ireland eu-west-1a eu-west-1b eu-west-1c
eu-central-1 Frankfurt eu-central-1a eu-central-1b
var FindProxyForURL = function(init, profiles) {
return function(url, host) {
"use strict";
var result = init, scheme = url.substr(0, url.indexOf(":"));
do {
result = profiles[result];
if (typeof result === "function") result = result(url, host, scheme);
} while (typeof result !== "string" || result.charCodeAt(0) === 43);
return result;
};
@imom0
imom0 / log.py
Created October 27, 2013 09:33
log
In [1]: %paste
import sys
import logging
PROGRESS = 1000
class MyLogger(logging.Logger):
PROGRESS = PROGRESS
LOG_FORMATTER = '%(asctime)s - %(levelname)-10s - %(funcName)s - %(message)s'
<!doctype html>
<meta charset="utf-8">
<style>
svg {
font: 10px sans-serif;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
@imom0
imom0 / comment.json
Last active December 10, 2015 12:08
request url: http://localhost:8000/myapp/comment/comment/?format=json&note=1&limit=3
{
"meta": {
"limit": 3,
"next": "/myapp/comment/comment/?note=1&offset=3&limit=3&format=json",
"offset": 0,
"previous": null,
"total_count": 4
},
"objects": [
{
@imom0
imom0 / count.py
Created November 19, 2012 04:21
Count tuple-key dict element appearence
# url http://stackoverflow.com/questions/13447226/count-how-many-times-a-part-of-a-key-appears-in-a-dictionary-python
from collections import Counter
from itertools import chain
a = { (1,2):3, (1,3):5, (2,1):6 }
# first
# nested iter, order is important
Counter(j for k in a for j in k)
@imom0
imom0 / filter.py
Created November 14, 2012 06:59
find wlans of China Union in Beijing.
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import json
point1 = 39.988948, 116.417802
point2 = 39.955797, 116.483548
results = []
with open('points.json') as f:
@imom0
imom0 / slugify.py
Created October 14, 2012 06:55
slugify
def slugify(value):
"""
Normalizes string, converts to lowercase, removes non-alpha characters,
and converts spaces to hyphens.
Took from django sources.
"""
value = Markup(value).striptags()
if type(value) == unicode:
import unicodedata
@imom0
imom0 / python_infrastructure.md
Created October 12, 2012 09:11 — forked from onlytiancai/python_infrastructure.md
python 基础设施讨论贴

python项目通用组件和基础服务

很多公司都大量使用了python,其中有一些开发规范,code guidline, 通用组件,基础框架是可以共用的。

每个公司都自己搞一套, 太浪费人力,我想开一帖和大家讨论一下这些python基础设施的搭建。

原则是我们尽量不重新发明轮子,但开源组件这么多,也要有个挑选的过程和组合使用的过程,在这里讨论一下。

另一方面,有些开源组件虽然强大,但我们不能完全的驾驭它,或只使用其中很少的一部分,我们就可以考虑用python实现一个简单的轮子,可控性更强,最好不要超过300行代码。