Skip to content

Instantly share code, notes, and snippets.

View qianjigui's full-sized avatar
🎯
Focusing

WPC qianjigui

🎯
Focusing
View GitHub Profile
## Copy from http://codeseekah.com/2012/09/12/compiling-objective-c-without-a-gui/
CC=clang # or gcc
FRAMEWORKS:= -framework Foundation
LIBRARIES:= -lobjc
CFLAGS=-Wall -Werror -g -v
LDFLAGS=$(LIBRARIES) $(FRAMEWORKS)
SRC=src
@qianjigui
qianjigui / linux_fork_pipe_waitpid_error_demo.c
Created March 19, 2014 13:01
Child Process zombie OR pipe block error. 如果父进程没有主动回收子进程的return status且父进程没有退出, 子进程在exit后进行zombie状态;进程间建立了pipe,一方关闭将导致另一方无法通信且默认会block
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
int main()
{
@qianjigui
qianjigui / android_build_preinstall_apps.sh
Created April 20, 2014 04:12
Android System, Many devices will contain preinstall apps
#!/system/xbin/busybox sh
PREINSTALL_RECORD_FILE=/data/system.notfirstrun
if [ ! -e $PREINSTALL_RECORD_FILE ]; then
echo "do preinstall job"
for i in `/system/xbin/busybox find /system/etc/property/app/ -type f -name '*.apk'`;
do
/system/bin/sh /system/bin/pm install $i
done
/system/xbin/busybox touch $PREINSTALL_RECORD_FILE
echo "preinstall ok"
@qianjigui
qianjigui / shell_previous_status.sh
Created April 21, 2014 07:25
Shell get the previous command's return status. 0 = success
#!/bin/bash
echo 'Error' > /abc.txt
echo $? #1
echo 'Pass'
echo $? #0
echo 'Pass' && echo 'Error' > /adc.txt && echo 'After Error'
echo $? #1
@qianjigui
qianjigui / Ruby_LDAP_Use_Example.rb
Created June 12, 2014 04:08
Ruby_LDAP_Use_Example
class LdapRequest
HOST = 'mail.example.com'
PORT = 636
TREEBASE='DC=example.com,DC=com'
ATTRS=['mail', 'department', 'telephoneNumber', 'mobile']
def initialize(username, password)
@ldap = Net::LDAP.new :host => HOST,
:port => PORT,
:encryption => :simple_tls,
:auth => {
@qianjigui
qianjigui / Makefile_multithread_sync_file.mk
Created July 7, 2014 11:06
Makefile_multithread_sync_file.mk
CONFIG_LAST_TIME_FILE := $(srctree)/.compile.project.time
CONFIG_STAT_TIME:=$(if $(wildcard $(CONFIG_FILE)),$(shell stat -c %Y $(CONFIG_FILE)),)
TMP_CONFIG_LAST_TIME:=$(if $(wildcard $(CONFIG_LAST_TIME_FILE)),$(shell cat $(CONFIG_LAST_TIME_FILE)),)
# ......
ifneq ("$(CONFIG_STAT_TIME)","$(TMP_CONFIG_LAST_TIME)")
$(warning "merge config and defaut config:")
OUT_CONFIG := $(srctree)/.config
xxx_config := $(call config.generate-auto-rules)
@qianjigui
qianjigui / Rails_mysql_utf8_encoding.patch
Created August 22, 2014 03:28
Rails MYSQL UTF8 Connection
Subject: [PATCH] Fix DB linking encoding to utf8
---
Gemfile | 2 +-
Gemfile.lock | 4 ++--
config/application.rb | 2 ++
config/database.yml | 12 ++++++------
config/environment.rb | 2 ++
5 files changed, 13 insertions(+), 9 deletions(-)
@qianjigui
qianjigui / java_sdk_build.gradle
Created September 4, 2014 04:17
Java SDK Build gradle template: proguard, static-test
apply plugin: 'java'
//repositories {
// mavenCentral()
// maven {
// url 'https://repo.eclipse.org/content/groups/releases/'
// }
//}
@qianjigui
qianjigui / Go_concurrent_demo.go
Last active August 29, 2015 14:06
GO concurrent demo
package main
// similar to Matt Aimonetti's example, read his blog!
// http://matt.aimonetti.net/posts/2012/11/27/real-life-concurrency-in-go/
func concurrently(integers []int) []int {
// make a channel to talk to the goroutines
ch := make(chan int)
// prepare a slice with all the results
responses := []int{}
@qianjigui
qianjigui / Go_httpserver_demo.go
Created September 8, 2014 00:31
Go httpserver demo
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello, world")
}