Skip to content

Instantly share code, notes, and snippets.

View sosoyososo's full-sized avatar

Karsa.Wang sosoyososo

View GitHub Profile
@sosoyososo
sosoyososo / Find_Unused_Pic_In_iOS_Project.sh
Last active March 10, 2016 03:22
找出iOS代码工程里没有用到的图片
#! /bin/bash
#clear file content
echo '' > /tmp/png.txt
echo '' > /tmp/str.txt
#find all png image
for file in `find ./ -iname "*.png"`; do
result=`echo ${file} | grep -o "\.xcassets.*"`
if [[ ${result} == "" ]]
@sosoyososo
sosoyososo / gist:0555c9ffeb8e7479218a
Created May 11, 2015 11:34
shap view with a image
@interface UIView(ImageMask)
- (void)setMaskImage:(UIImage *)maskImage;
@end
@implementation UIView(ImageMask)
- (void)setMaskImage:(UIImage *)maskImage {
objc_setAssociatedObject(self, @selector(setMaskImage:), maskImage, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
UIImageView *view = [[UIImageView alloc]initWithImage:maskImage];
view.frame = self.bounds;
self.layer.mask = view.layer;
@sosoyososo
sosoyososo / gist:55d6ecbb9d602d4db558
Last active March 10, 2016 03:25
在esou.com使用任意小说的任意一章的url作为参数,获取这本小说的所有文本内容,并按照章节保存为txt (貌似已经因为esou网站的更新不管用了)
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
)
@sosoyososo
sosoyososo / gist:6620803
Last active December 23, 2015 10:19
python:回文数字判断第二波
i = 1281854581821
def getReverse(base, num):
if num < 10:
return base*10 + num
return getReverse(base*10+num%10, num/10)
def getReverse1(num):
i = 0
while num:
i = i*10 + num%10
@sosoyososo
sosoyososo / gist:6620318
Created September 19, 2013 07:55
python:回文数字判断
i = 1281854581821
def getMax(num):
if num < 10:
return num
return getMax(num/10)
def isLastEqualFirst (num) :
if num < 10 :
return YES
@sosoyososo
sosoyososo / gist:6619980
Last active December 23, 2015 10:09
python:对graph新的copy方法
class Node():
index = 0
neighbors = []
def __init__ (self, arg) :
self.index = arg
def description(self):
out = []
out.append (self.index)
for item in self.neighbors:
@sosoyososo
sosoyososo / gist:6611926
Created September 18, 2013 16:43
python:生成一个graph中的节点,并建立各个节点之间的关系,实现对graph的遍历,对graph的copy#def Graph struct
class Node():
index = 0
neighbors = []
def __init__(self, arg):
self.index = arg
def description(self):
out = []
out.append (self.index)
for item in self.neighbors:
out.append(item.index)
@sosoyososo
sosoyososo / gist:6610758
Created September 18, 2013 15:21
python : 遍历一个目录下所有.h/.m/.mm 文件,并整理出来类的继承关系
#1.遍历某个路径的子目录
#2.按行读取头文件和源文件
#3.找到对应关系行
#4.判断是否在注释范围内
#5.分析并存储关系
import os, os.path, re, sys
_g_relations = {}
_g_graphRelations = {}
@sosoyososo
sosoyososo / gist:6610716
Created September 18, 2013 15:18
python:递归输出一个数组的全排列
def pickOne (array1, array2) :
length = len (array2)
if length == 0 :
return
for i in range (0, length) :
tempArray1 = array1[:]
tempArray2 = array2[:]
moveArrayItem (tempArray1, tempArray2, i)
print (tempArray1)
pickOne (tempArray1, tempArray2)
@sosoyososo
sosoyososo / gist:6152825
Last active December 20, 2015 15:18
随着触点移动画图
- (CGFloat)strokeWidth {
if (_strokeWidth < 0.0001) {
_strokeWidth = 5.f;
}
return _strokeWidth;
}
- (UIColor *)strokeColor {
if (!_strokeColor) {
_strokeColor = [UIColor redColor];