Skip to content

Instantly share code, notes, and snippets.

View kernelhcy's full-sized avatar
🚁
living~

Congyu Huang kernelhcy

🚁
living~
View GitHub Profile
@kernelhcy
kernelhcy / SSLBuffer.cpp
Created April 17, 2014 02:39 — forked from roxlu/SSLBuffer.cpp
libuv+libopenssl
#include "SSLBuffer.h"
SSLBuffer::SSLBuffer()
:ssl(NULL)
,read_bio(NULL)
,write_bio(NULL)
,write_to_socket_callback(NULL)
,write_to_socket_callback_data(NULL)
,read_decrypted_callback(NULL)
,read_decrypted_callback_data(NULL)
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@kernelhcy
kernelhcy / new_gist_file.vbs
Created November 7, 2014 15:45
获取Windows系统当前序列号
Dim s
s = InputBox("当前Windows系统序列号为:", "Windows序列号", GetWindowsSN)
WScript.Quit
'取得当前Windows序列号函数
Function GetWindowsSN()
Const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
#traverse all the directory and subdirectory
define walk
@kernelhcy
kernelhcy / keyboard.java
Created August 7, 2013 05:09
Android中软键盘的操作
//隐藏软键盘。
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
//进入activity不显示软键盘
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
或者在AndroidManifest.xml中设置android:windowSoftInputMode="adjustUnspecified|stateHidden"。
@kernelhcy
kernelhcy / capture_image.java
Created August 7, 2013 04:58
Android中调用相机拍照
Intent itb = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
itb.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(capturePicFile));
startActivityForResult(itb);
//设置MediaStore.EXTRA_OUTPUT可以获取原始大小的图片,否则,相机仅仅返回小图片。
@kernelhcy
kernelhcy / intent_usage.java
Created August 7, 2013 05:05
Android中Intent用法
//显示网页
Uri uri = Uri.parse("http://google.com");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//显示地图
Uri uri = Uri.parse("geo:38.899533,-77.036476");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
//其他 geo URI 範例
@kernelhcy
kernelhcy / get_image_from_local.java
Created August 7, 2013 05:05
Android获取本地图片
Intent itb = new Intent();
itb.setType("image/*");
itb.setAction(Intent.ACTION_GET_CONTENT);
itb.putExtra("crop", "true"); //选择后对图片进行剪裁
itb.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(capturePicFile));
startActivityForResult(itb, GET_IMAGE_FROM_LOCAL);
@kernelhcy
kernelhcy / crop_image.java
Created August 7, 2013 05:06
Android中剪裁图片
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(Uri.fromFile(capturePicFile), "image/*");
//如何选择
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
//输出大小
intent.putExtra("outputX", 96);
@kernelhcy
kernelhcy / parallel_job.sh
Created August 7, 2013 09:39
多任务并行执行脚本
#!/bin/bash
#
# 多个进行并行执行任务
#
SEND_THREAD_NUM=8
tmp_fifofile="/tmp/$$.fifo" # 脚本运行的当前进程ID号作为文件名
mkfifo "$tmp_fifofile" # 新建一个随机fifo管道文件
exec 6<>"$tmp_fifofile" # 定义文件描述符6指向这个fifo管道文件
rm $tmp_fifofile