Skip to content

Instantly share code, notes, and snippets.

View kim4apple's full-sized avatar

kim4apple kim4apple

  • Shenzhen, China
View GitHub Profile
@kim4apple
kim4apple / getargv.c
Created February 18, 2019 09:59 — forked from nonowarn/getargv.c
/* Copied, Pasted and summarized from ps' source code.
You can use sysctl to get other process' argv.
*/
#include <sys/sysctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define pid_of(pproc) pproc->kp_proc.p_pid
@kim4apple
kim4apple / NSData+UTF8.m
Last active May 16, 2018 06:20
ignore the invalid utf-8
- (NSData *)cleanUTF8:(NSData *)data {
// this function is from
// https://stackoverflow.com/questions/3485190/nsstring-initwithdata-returns-null
//
//
iconv_t cd = iconv_open("UTF-8", "UTF-8"); // convert to UTF-8 from UTF-8
int one = 1;
iconvctl(cd, ICONV_SET_DISCARD_ILSEQ, &one); // discard invalid characters
size_t inbytesleft, outbytesleft;
inbytesleft = outbytesleft = data.length;
@kim4apple
kim4apple / README.md
Last active August 29, 2015 14:06 — forked from oodavid/README.md

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
git=/usr/local/git/bin/git
touch Info.plist
version=`$git describe --dirty`
version=`echo $version | sed 's/[a-zA-Z]*//'`
versionNum=`echo $version | sed 's/\-[0-9]*\-[a-zA-Z0-9]*//'`
echo "#define GIT_VERSION $version" > InfoPlist.h
echo "#define APP_VERSION $versionNum" >> InfoPlist.h
// this code will cause a UIView to shake--good for "login error"
CAKeyframeAnimation * anim = [ CAKeyframeAnimation animationWithKeyPath:@"transform" ] ;
anim.values = [ NSArray arrayWithObjects:
[ NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-5.0f, 0.0f, 0.0f) ],
[ NSValue valueWithCATransform3D:CATransform3DMakeTranslation(5.0f, 0.0f, 0.0f) ],
nil ] ;
anim.autoreverses = YES ;
anim.repeatCount = 2.0f ;
anim.duration = 0.07f ;