Skip to content

Instantly share code, notes, and snippets.

View learning's full-sized avatar
🏠
Working from home

Learning learning

🏠
Working from home
View GitHub Profile
@learning
learning / test_imcontext.c
Created October 31, 2016 02:51
Test GtkIMContext in gtk+2.0
#include <stdio.h>
#include <gtk/gtk.h>
static gboolean focus_callback(GtkWidget *gtk_window,
GdkEvent *event,
GtkIMContext *im_context) {
gtk_widget_grab_focus(gtk_window);
gtk_im_context_focus_in(im_context);
gtk_im_context_reset(im_context);
return TRUE;
@learning
learning / circle.html
Last active March 4, 2016 10:19
circle.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>圆</title>
<style>
canvas {
display: block;
margin: 100px auto 0 auto;
box-shadow: 0 0 10px #000;
// Generated by gfwlist2pac in precise mode
// https://github.com/clowwindy/gfwlist2pac
var proxy = "SOCKS5 127.0.0.1:1080; SOCKS 127.0.0.1:1080; DIRECT;";
var rules = [
"||altrec.com",
"||darpa.mil",
"||fastpic.ru",
"||fxnetworks.com",
<iframe src="http://camzed.com/new/index.php/pages/online-users-widget?remote=1" width="240" height="680" frameborder="0" scrolling="no"></iframe>
@learning
learning / gist:3713111
Created September 13, 2012 09:15
你的文件
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
SHFoo *foo = [SHFoo alloc];
[foo say: @"Yes" whosay: @"Here is Shawn huang."];
Boolean b = true;
BOOL b2 = YES;
b = !b2;
NSLog(@"Bool: %d %d", b, b2);
}
@learning
learning / 京N开头
Created June 19, 2012 13:15
车牌号
yy440/zh440
yy000/zh000
yy432/zh432
yy228/zh228
y4y40
y40y0
yy800/zh800
@learning
learning / gist:2934519
Created June 15, 2012 03:30
Deff's Device
// Duff's Device
var iterations = Math.floor(items.length / 8),
startAt = items.length % 8,
i = 0;
do{
switch(startAt){
case 0: process(items[i++]);
case 7: process(items[i++]);
case 6: process(items[i++]);
@learning
learning / gist:2934517
Created June 15, 2012 03:30
Cancel bubble
elem.onclick = function(e){
e = e || window.event; // IE's event is window.event
var target = e.target || e.srcElement; // IE's target is srcElement
if(target.nodeName !== 'A'){
return;
}
if(typeof e.preventDefault === 'function'){
e.preventDefault();
@learning
learning / gist:2934515
Created June 15, 2012 03:29
memfactorial
function memfactorial(n){
if(!memfactorial.cache){
memfactorial.cache = {
'0': 1,
'1': 1
};
}
if(!memfactorial.cache.hasOwnProperty(n)){
@learning
learning / gist:2934513
Created June 15, 2012 03:29
timedProcessArray
function timedProcessArray(items, process, callback){
var todo = items.concat(); // Array clone
setTimeout(function(){
var start = +new Date();
do{
process(todo.shift());
}while(todo.length > 0 && (+new Date() - start < 50));