Skip to content

Instantly share code, notes, and snippets.

//
// PSPDFThreadSafeMutableDictionary.m
//
// Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
//
// 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
@ofshellohicy
ofshellohicy / gist:8310932
Created January 8, 2014 02:46
解析URL query params
static NSString *stringByDecodingURLString(NSString *urlString)
{
NSString *string = [urlString stringByReplacingOccurrencesOfString:@"+"
withString:@" "];
if (string == nil) {
return nil;
}
return CFBridgingRelease(CFURLCreateStringByReplacingPercentEscapes(kCFAllocatorDefault,
(__bridge CFStringRef)string,
@ofshellohicy
ofshellohicy / requests.py
Created August 13, 2012 04:45 — forked from Chairo/requests.py
requests mutil-threading
# -*- coding:utf-8 -*-
import requests
from time import sleep
from threading import Thread
UPDATE_INTERVAL = 0.01
class URLThread(Thread):
def __init__(self, url, timeout=10, allow_redirects=True):
super(URLThread, self).__init__()
@ofshellohicy
ofshellohicy / backup.sh
Created August 13, 2012 04:43 — forked from Chairo/backup.sh
自动备份脚本
#!/bin/bash
#Funciont: Backup website and mysql database
#Author: licess
#Website: http://lnmp.org
#IMPORTANT!!!Please Setting the following Values!
bak_dir=/home/backup
if [ -d $bak_dir ]; then
echo 'begin'
@ofshellohicy
ofshellohicy / gist:3021727
Created June 30, 2012 01:50 — forked from felinx/gist:3021514
Handling exif info(orientation) losing after thumbnail a image with PIL
def _thumbnail_image(self, body, size):
try:
im = Image.open(StringIO(body))
# rotate image according rotation meta of this image
# for orientation in ExifTags.TAGS.keys():
# if ExifTags.TAGS[orientation] == 'Orientation' : break
orientation = 274 # get 274 through upper loop
try:
exif = im._getexif()