Skip to content

Instantly share code, notes, and snippets.

@liu7yong
liu7yong / docker_svn-server.md
Created July 6, 2021 07:20 — forked from dpmex4527/docker_svn-server.md
Set up SVN server on docker
@liu7yong
liu7yong / config-git-proxy.txt
Created May 2, 2020 09:06 — forked from bynil/config-git-proxy.txt
Use git over socks5 proxy
Port: 1080
1. Create a file /YOUR PATH/gitproxy.sh with content:
#!/bin/sh
nc -X 5 -x 127.0.0.1:1080 "$@"
2. Edit your ~/.gitconfig
# For git://
@liu7yong
liu7yong / gitproxy-socat
Created April 25, 2020 06:55 — forked from sit/gitproxy-socat
A simple wrapper around socat to use as a git proxy command
#!/bin/sh
# Use socat to proxy git through an HTTP CONNECT firewall.
# Useful if you are trying to clone git:// from inside a company.
# Requires that the proxy allows CONNECT to port 9418.
#
# Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run
# chmod +x gitproxy
# git config --global core.gitproxy gitproxy
#
# More details at http://tinyurl.com/8xvpny
@liu7yong
liu7yong / WifiConnection.java
Last active November 7, 2021 14:45
How to connect to a specific wifi network in Android programmatically?
WifiConfiguration wifiConfig = new WifiConfiguration();
wifiConfig.SSID = String.format("\"%s\"", ssid);
wifiConfig.preSharedKey = String.format("\"%s\"", key);
WifiManager wifiManager = (WifiManager)getSystemService(WIFI_SERVICE);
//remember id
int netId = wifiManager.addNetwork(wifiConfig);
wifiManager.disconnect();
wifiManager.enableNetwork(netId, true);
wifiManager.reconnect();
@liu7yong
liu7yong / canvas.html
Last active August 29, 2015 14:13
html5 canvas test
<!DOCTYPE HTML>
<html>
<body>
<p>Original Image: </p>
<img id="demo_img" src="demo_small.png" alt="Original Image"/>
<p>Canvas:</p>
<canvas id="myCanvas" style="border:1px solid #000000;">your browser does not support the canvas tag </canvas>
<script type="text/javascript">
/*
* Copyright (C) 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@liu7yong
liu7yong / unpack_atlas.py
Created February 15, 2014 16:07
unpack png from atlas images (such as flappy bird)
#/usr/local/bin/python
import os, sys, math
from PIL import Image
def config_to_dict(atlas_entry):
d = {}
list = atlas_entry.split(" ")
d["frameName"] = list[0]
d["width"] = int(list[1])
d["height"] = int(list[2])
@liu7yong
liu7yong / gif.cpp
Created September 17, 2013 03:45
animate each image as a frame (like gif) in cocos2d-x
CCSprite *pSkill = (CCSprite *) getChildByTag(TAG_MENU)->getChildByTag(tag);
CCSprite *pHighLight = CCSprite::createWithSpriteFrameName("point1.png");
this->addChild(pHighLight, Z_ORDER_TITLE, TAG_SKILL_HIGHLIGHT);
pHighLight->setPosition(pSkill->getPosition());
CCArray *walkAnimFrames = CCArray::create();
for (int i = 1; i<= 4; i++)
{
walkAnimFrames->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(CCString::createWithFormat("point%d.png", i)->getCString()));
}
@liu7yong
liu7yong / resize.py
Last active December 23, 2015 03:49
batch resize images.
import os
import sys
from PIL import Image
def resize(folder, fileName, factor):
filePath = os.path.join(folder, fileName)
im = Image.open(filePath)
w, h = im.size
newIm = im.resize((int(w*factor), int(h*factor)), Image.ANTIALIAS)
# i am saving a copy, you can overrider orginal, or save to other folder
@liu7yong
liu7yong / unpack_plist.py
Last active April 3, 2019 02:00 — forked from wonkwh/unpack_plist.py
extract image from plist,png file created by texturepacker
#/usr/local/bin/python
import os,sys
from xml.etree import ElementTree
from PIL import Image
def tree_to_dict(tree):
d = {}
for index, item in enumerate(tree):
if item.tag == 'key':
if tree[index+1].tag == 'string':