Skip to content

Instantly share code, notes, and snippets.

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

jackey

🏠
Working from home
  • A programer
  • Changde, Hunan, China
View GitHub Profile
@jackey
jackey / gist:761060ae9dc17834159088fda1c95935
Last active December 22, 2016 13:40
Golang struct to interface{}
// declare two types
type PagerData struct {
Objects []interface{}
Total int
}
type User struct {
Name string
}
@jackey
jackey / test.c
Created March 18, 2016 04:49
php extension development
zval *names;
MAKE_STD_ZVAL(names);
array_init(names);
/**
* assign names to return_value
*/
@jackey
jackey / mj.go
Last active January 19, 2016 03:47
Golang Query MySQL database
func (mj *Mj) LoadWithPager(offset, limit int) []MeijuTable {
dsn := mj.GetDSN()
fmt.Println(dsn)
db, err := sql.Open(dsn)
fmt.Println(err)
if err != nil {
mj.Panic(err)
}
defer db.Close()
@jackey
jackey / ipshow.c
Last active August 29, 2015 14:27
get hostname addresses
//
// ipshow.c
// IPSHOW
//
// Created by Jackey Chen on 8/18/15.
// Copyright (c) 2015 Jackey Chen. All rights reserved.
//
#include <stdio.h>
#include <string.h>
@jackey
jackey / chat.go
Last active August 29, 2015 14:17
package main
import (
"bufio"
"net"
)
type Client struct {
incoming chan string
outgoing chan string
@jackey
jackey / httpsqs
Created October 14, 2014 02:35
httpsqs 启动脚本
# chkconfig: 3 66 40
# description: httpsqs
# processname: httpsqs
# config:
# Source function library
. /etc/rc.d/init.d/functions
RETVAL=0
prog="httpsqs"
@jackey
jackey / gist:34392fcd8d1a08285dd5
Created September 1, 2014 02:42
Baidu API 翻译PHP代码
<?php
function language($value,$from="auto",$to="auto")
{
$value_code=urlencode($value);
#首先对要翻译的文字进行 urlencode 处理
$appid="ZuVRDtLTr1PXxz7g028BUPYL";
#您注册的API Key
$languageurl = "http://openapi.baidu.com/public/2.0/bmt/translate?client_id=" . $appid ."&q=" .$value_code. "&from=".$from."&to=".$to;
#生成翻译API的URL GET地址
$text=json_decode(language_text($languageurl));
@jackey
jackey / gist:11311194
Created April 26, 2014 03:44
post data to drupal
[field_shen_image] => Array
(
[und] => Array
(
[1] => Array
(
[width] => 500
[_weight] => 1
[display] => 1
[fid] => 486
@jackey
jackey / medias.json
Created December 27, 2013 14:34
instagram medias search result in hashtag
stdClass Object
(
[pagination] => stdClass Object
(
[next_max_tag_id] => 1387972498648
[deprecation_warning] => next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead
[next_max_id] => 1387972498648
[next_min_id] => 1387972509152
[min_tag_id] => 1387972509152
[next_url] => https://api.instagram.com/v1/tags/snow/media/recent?count=0&client_id=6c474f0f5dbd49af824803a47de955ee&max_tag_id=1387972498648
# Something in lines of http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail
# Make sure you have IMAP enabled in your gmail settings.
# Right now it won't download same file name twice even if their contents are different.
import email
import getpass, imaplib
import os
import sys
detach_dir = '.'