Skip to content

Instantly share code, notes, and snippets.

@ygweric
ygweric / util.m
Last active November 16, 2015 03:24
数字转中文大写 obj-c
+ (NSString*)numberToChineseUppercase:(double)num{
int iLen,iNum,iAddZero=0;
NSMutableString *szChMoney = [[NSMutableString alloc] init];
NSArray *hzUnit = @[@"分",@"角",@"元",@"拾",@"佰",@"仟",@"万",@"拾",@"佰",@"仟",@"万",@"亿",@"拾",@"佰",@"仟",@"万",@"拾",@"佰",@"仟"];
NSArray *hzNum = @[@"零",@"壹",@"贰",@"叁",@"肆",@"伍",@"陆",@"柒",@"捌",@"玖"];
NSString *szNum = [NSString stringWithFormat:@"%18.0f",num*100];
szNum = [szNum stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
iLen =(int) szNum.length;
@stantonk
stantonk / doit
Created November 15, 2012 22:46
Install python 2.7.3 on CentOS 5.8
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
yum groupinstall "Development tools"
yum install zlib-devel
yum install bzip2-devel openssl-devel ncurses-devel
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar xf Python-2.7.3.tar.bz2
cd Python-2.7.3
@mike-zhang
mike-zhang / netfwd.go
Created October 8, 2012 15:33 — forked from wallrat/proxy.go
Simple GO TCP proxy
// can be run in go 1.0.3
// build : go build netfwd.go
package main
import (
"net"
"fmt"
"io"
"os"
)
@mgood
mgood / gist:3276107
Created August 6, 2012 16:19
Python expression evaluator
"""
An attempt to make a safe evaluator of a subset of Python expressions.
This is mostly a proof-of-concept for getting feedback, it has not been
thoroughly checked for safety, use at your own risk :)
It uses the Python ast module to parse the expression, but all evaluation is
done by walking the ast, it is not directly executed by the Python runtime.
Nosetests are provided below including coverage of supported and unsupported
@wallrat
wallrat / proxy.go
Created July 6, 2012 11:25
Simple GO TCP proxy
package main
import (
"net"
"fmt"
"io"
"os"
)
func main() {
if len(os.Args) != 3 {
fatal("usage: netfwd local remote")
@crazygit
crazygit / install_go_tools.sh
Last active July 2, 2021 03:16
免翻墙安装Go tools
#!/usr/bin/env bash
# 免翻墙安装Go tools
branch="release-branch.go1.4"
mkdir -p $GOPATH/src/golang.org/x
git clone -b $branch git@github.com:golang/tools.git $GOPATH/src/golang.org/x/tools
git clone git@github.com:golang/net.git $GOPATH/src/golang.org/x/net
cd $GOPATH
go install golang.org/x/tools/cmd/goimports
@cloverstd
cloverstd / cache.py
Last active October 27, 2021 05:35
tornado cache
# coding: utf-8
try:
import cPickle as pickle
except ImportError:
import pickle
try:
import hashlib
sha1 = hashlib.sha1
@justjavac
justjavac / img2txt.js
Last active December 9, 2021 06:46
img2txt:基于canvas的图片转字符画工具
var cv = document.getElementById('cv');
var c = cv.getContext('2d');
var txtDiv = document.getElementById('txt');
var fileBtn = document.getElementById("up-button");
var img = new Image();
img.src = 'a.jpg';
img.onload = init; // 图片加载完开始转换
fileBtn.onchange = getImg;
// 根据灰度生成相应字符
@floer32
floer32 / centos_python_env_setup
Last active May 2, 2022 03:47 — forked from stantonk/doit
CentOS 6: Install Python 2.7.4, pip, virtualenv, and virtualenvwrapper on CentOS (plus some bonus items at the end if you want). You should probably run with `sudo`.
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
# Install stuff #
#################
# Install development tools and some misc. necessary packages
yum -y groupinstall "Development tools"
yum -y install zlib-devel # gen'l reqs
@glombard
glombard / combine.py
Created November 24, 2014 00:22
Merging 4 images into one with Python and PIL/Pillow
# Combine multiple images into one.
#
# To install the Pillow module on Mac OS X:
#
# $ xcode-select --install
# $ brew install libtiff libjpeg webp little-cms2
# $ pip install Pillow
#
from __future__ import print_function