Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

WPC qianjigui

🎯
Focusing
Block or report user

Report or block qianjigui

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@qianjigui
qianjigui / ruby_chinese_to_unicode8_java_format.rb
Created May 7, 2015
ruby_chinese_to_unicode8_java_format
View ruby_chinese_to_unicode8_java_format.rb
#!/usr/bin/env ruby
#encoding: utf-8
#
'你好'.unpack('U*').each do |i|
print "\\u%s" % [i.to_s(16)]
end
puts ''
View Go_httpserver_demo.go
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello, world")
}
View Go_concurrent_demo.go
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 / java_sdk_build.gradle
Created Sep 4, 2014
Java SDK Build gradle template: proguard, static-test
View java_sdk_build.gradle
apply plugin: 'java'
//repositories {
// mavenCentral()
// maven {
// url 'https://repo.eclipse.org/content/groups/releases/'
// }
//}
View Rails_mysql_utf8_encoding.patch
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 / Makefile_multithread_sync_file.mk
Created Jul 7, 2014
Makefile_multithread_sync_file.mk
View 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)
View Ruby_LDAP_Use_Example.rb
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 / shell_previous_status.sh
Created Apr 21, 2014
Shell get the previous command's return status. 0 = success
View shell_previous_status.sh
#!/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 / android_build_preinstall_apps.sh
Created Apr 20, 2014
Android System, Many devices will contain preinstall apps
View android_build_preinstall_apps.sh
#!/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 / linux_fork_pipe_waitpid_error_demo.c
Created Mar 19, 2014
Child Process zombie OR pipe block error. 如果父进程没有主动回收子进程的return status且父进程没有退出, 子进程在exit后进行zombie状态;进程间建立了pipe,一方关闭将导致另一方无法通信且默认会block
View linux_fork_pipe_waitpid_error_demo.c
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
int main()
{
You can’t perform that action at this time.