Skip to content

Instantly share code, notes, and snippets.

View creamidea's full-sized avatar

NekoTrek creamidea

View GitHub Profile
@creamidea
creamidea / createTempfile.py
Created October 23, 2014 19:10
创建临时的文件,用于xlrd
import os
import tempfile
import shutil
from contextlib import contextmanager
@contextmanager
def tempinput(file_):
temp = tempfile.NamedTemporaryFile(delete=False)
shutil.copyfileobj(file_, temp)
temp.close()
#均衡负载
upstream google {
ip_hash;
server 216.239.32.39:443 max_fails=1 weight=2;
server 173.194.120.88:443 max_fails=1 weight=2;
server 74.125.21.98:443 max_fails=1;
server 74.125.21.40:443 max_fails=1;
server 74.125.21.47:443 max_fails=2;
# server 74.125.21.41:443 max_fails=3;
@creamidea
creamidea / deep_extend_javascript_objects_underscore_mixin.js
Created January 28, 2016 05:05 — forked from kurtmilam/deep_extend_javascript_objects_underscore_mixin.js
Deep Extend / Merge Javascript Objects - underscore.js Mixin
/* Copyright (C) 2012-2014 Kurt Milam - http://xioup.com | Source: https://gist.github.com/1868955
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TO
@creamidea
creamidea / struct.c
Created March 13, 2016 13:38
内存对齐
// http://www.cppblog.com/snailcong/archive/2009/03/16/76705.html
#include <iostream>
using namespace std;
struct st1 {
char a;
int b;
short c;
};
@creamidea
creamidea / gbk-iTerm.sh
Created March 16, 2016 04:59
调用iTerm,将编码改成gbk
#!/bin/bash
# 使用GBK Profile
echo -e "\033]50;SetProfile=GBK\a"
# 环境编码切换为GBK
export LANG=zh_CN.GBK
export LC_ALL=zh_CN.GBK
# 更改当前 iTerm2 tab title
echo -ne "\033]0;"$@"\007"
$@
echo -ne "\033]0;"${PWD/#$HOME/~}"\007"
@creamidea
creamidea / menu.lst
Created March 31, 2016 06:15 — forked from poppen/menu.lst
menu.lst of grub4dos for booting iso images from usb drive
# This is a sample menu.lst file. You should make some changes to it.
# The old install method of booting via the stage-files has been removed.
# Please install GRLDR boot strap code to MBR with the bootlace.com
# utility under DOS/Win9x or Linux.
color white/light-blue yellow/cyan light-gray/magenta white/light-red
title Acronis True Image Home
find --set-root /atih.iso
map /atih.iso (0xff) || map --mem /atih.iso (0xff)
# weixnpy_uwsgi.ini file
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /home/www/icslg/wx/weixnpy/
# Django's wsgi file
module = weixnpy.wsgi:application
env = DJANGO_SETTINGS_MODULE = weixnpy.settings
# the virtualenv (full path)
@creamidea
creamidea / switchproxy2surge.js
Last active February 17, 2019 03:12
简单的将switchproxy中的规则变成surge的规则,只支持 DOMAIN-HOST
// Step 1: open the switchproxy's option page
// Step 2: click the "auto switch" on the left bar
// Step 3: click the edit button
// Step 4: open the developer tools
// Step 5: input the code below
var source = $('textarea[ng-model="source.code"]')[0].value
var surgeRules = source.replace(/\*\.(.*?)\s+\+proxy/g,"DOMAIN-SUFFIX,$1,Proxy")
copy(surgeRules)
// Step 6: replace the original rules with surgeRules(Ctrl+V)
// Step 7: upload to the iCloud (Surge)
@creamidea
creamidea / cnpm.cmd
Last active September 5, 2016 16:30
@echo off
npm --registry=https://registry.npm.taobao.org --cache=%HOME%/AppData/Roaming/npm-cache/cnpm --disturl=https://npm.taobao.org/dist --userconfig=%HOME%/.cnpmrc %*
@echo off
"%~dp0emacsclientw.exe" -na "%~dp0runemacs.exe" "%1"