Skip to content

Instantly share code, notes, and snippets.

@zeayes
zeayes / shell.sh
Last active December 30, 2015 05:29
some useful shell scripts
#!/bin/bash
# 对第三列求和
awk -F "," '{sum+=$3} END {print sum}' test.csv
# 对第三列匹配求和
awk -F "," ' $3 ~ /^CG/ {sum+=$5} END { print sum}' test.csv
# git clone
  • 下载
wget --no-check-certificate https://pypi.python.org/packages/source/s/supervisor/supervisor-3.0.tar.gz
  • 安装
tar xzf supervisor-3.0.tar.gz && cd supervisor-3.0
python setup.py install
package main
import (
"fmt"
"time"
"strconv"
"strings"
"io/ioutil"
"net/http"
"net/url"
# -*- coding: utf-8 -*-
MAX_TAX = 500
MAX_PRICE = 1000
class Item(object):
"""商品类"""
def __init__(self, price, tax_rate, category):
ffmpeg -loglevel debug -report -i recordUnity3D.mov -acodec libfaac -b:a 128k -vcodec libx264 -b:v 1200k -r 24 -flags +aic+mv4 -pix_fmt yuv420p -threads 0 -y output.mp4
ffmpeg started on 2014-09-13 at 23:11:04
Report written to "ffmpeg-20140913-231104.log"
ffmpeg version 2.3.2 Copyright (c) 2000-2014 the FFmpeg developers
built on Aug 14 2014 07:21:22 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.3.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 52. 92.100 / 52. 92.100
libavcodec 55. 69.100 / 55. 69.100
libavformat 55. 48.100 / 55. 48.100
libavdevice 55. 13.102 / 55. 13.102
@zeayes
zeayes / http_get.m
Created January 13, 2015 06:25
http get example for objective
#import <Foundation/Foundation.h>
int main(int argc, const char *argv[]) {
@autoreleasepool {
NSError *error;
NSURL *url = [NSURL URLWithString: @"http://127.0.0.1:6100/user/10167/profile/"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval: 10];
NSData *received = [NSURLConnection sendSynchronousRequest:request
@zeayes
zeayes / datetime.m
Created January 13, 2015 06:26
objective c datetime formatter example
#import <Foundation/Foundation.h>
int main(int argc, const char *argv[]) {
@autoreleasepool {
// formatter datetime
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_us"];
[formatter setLocale:locale];
[formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
@zeayes
zeayes / json.m
Created January 13, 2015 06:28
objective c json encoding example
#import <Foundation/Foundation.h>
int main(int argc, const char *argv[]) {
@autoreleasepool {
NSArray *people = @[
@{@"name": @"John", @"age": @23, @"gender": @YES},
@{@"name": @"Tom", @"age": @25, @"gender": @YES},
@{@"name": @"Lucy", @"age": @20, @"gender": @NO},
];
if ([NSJSONSerialization isValidJSONObject:people]) {
@zeayes
zeayes / sort.m
Created January 13, 2015 06:30
objective c example
#import <Foundation/Foundation.h>
@interface Person : NSObject
@property NSString *firstName;
@property NSString *lastName;
@property NSNumber *age;
@end
@zeayes
zeayes / bind.m
Created March 27, 2015 09:26
dynamic binding
#import <Foundation/Foundation.h>
@interface Square : NSObject
{
float area;
}
- (void)calculateAreaOfSide: (CGFloat)side;
- (void)printArea;
@end