Skip to content

Instantly share code, notes, and snippets.

View XueshiQiao's full-sized avatar
🕶️
WebRTC

xueshi XueshiQiao

🕶️
WebRTC
View GitHub Profile
@XueshiQiao
XueshiQiao / gist:5918651
Last active December 12, 2016 10:01
Disable warning "PerformSelector may cause a leak because its selector is unknown"
//disable warning:"PerformSelector may cause a leak because its selector is unknown"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.delegate performSelector:self.selector];
#pragma clang diagnostic pop
@XueshiQiao
XueshiQiao / gource.sh
Last active November 10, 2019 15:56 — forked from cgoldberg/gource.sh
Generate a MP4 Video for your Git project commits using Gource!
# 1.install gource using HomeBrew
$ brew install gource
# 2.install avconv
git clone git://git.libav.org/libav.git
cd libav
# it will take 3-5 minutes to complie, be patient.
./configure --disable-yasm
make && make install
@XueshiQiao
XueshiQiao / UIImage From URL – Simplified (Using Blocks)
Last active December 19, 2015 06:09
UIImage From URL – Simplified (Using Blocks)
void UIImageFromURL( NSURL * URL, void (^imageBlock)(UIImage * image), void (^errorBlock)(void) )
{
    dispatch_async( dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^(void)
    {
        NSData * data = [[[NSData alloc] initWithContentsOfURL:URL] autorelease];
        UIImage * image = [[[UIImage alloc] initWithData:data] autorelease];
        dispatch_async( dispatch_get_main_queue(), ^(void){
            if( image != nil )
            {
                imageBlock( image );
@XueshiQiao
XueshiQiao / AlertViewUsingBlock
Created June 29, 2013 06:46
AlertView without delegate but block!
//
// TWAlertView.h
// TWAlertView
//
//
#import <UIKit/UIKit.h>
typedef void (^TWAlertBlock)(void);
typedef void (^UIAlertConfig)(UIAlertView *);
- (UIImage *)compressImage:(UIImage *)image{
float actualHeight = image.size.height;
float actualWidth = image.size.width;
float maxHeight = 600.0;
float maxWidth = 800.0;
float imgRatio = actualWidth/actualHeight;
float maxRatio = maxWidth/maxHeight;
float compressionQuality = 0.5;//50 percent compression
if (actualHeight > maxHeight || actualWidth > maxWidth) {
@XueshiQiao
XueshiQiao / gist:5780008
Created June 14, 2013 07:06
iOS高效、优雅遍历Dictionary
[dictionary enumerateKeysAndObjectsUsingBlock:^(id key, id val, BOOL
*stop) {
//NSLog(@"%@, %@", key, val);
}];
@XueshiQiao
XueshiQiao / gist:5779128
Last active December 18, 2015 11:59
按提交次数显示一个Git repo提交人
git log | grep "Author" | cut -d" " -f3 | sort | uniq -c | sort -r
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=690800,CODECS="avc1.66.30,mp4a.40.2",RESOLUTION=576x360
0600/0600.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1460800,CODECS="avc1.66.30,mp4a.40.2",RESOLUTION=576x360
1500/1500.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=290400,CODECS="avc1.66.30,mp4a.40.2",RESOLUTION=416x260
0200/0200.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=580800,CODECS="avc1.66.30,mp4a.40.2",RESOLUTION=448x280
0400/0400.m3u8
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import json
import getopt
import urllib2
import commands
import string
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import json
import getopt
import urllib2
import commands
import string