Skip to content

Instantly share code, notes, and snippets.

View zhuqling's full-sized avatar

zhuqling zhuqling

  • @xinsailei
  • Guangzhou
View GitHub Profile
@zhuqling
zhuqling / elastic search define analysis and test
Last active August 29, 2015 14:07
elastic search指定分析器与分析器测试
# 中文全文检索,使用mmseg
## 创建索引
PUT http://localhost:9200/index
## 设置mapping
POST /index/fulltext/_mapping
{
"fulltext": {
"_all": {
@zhuqling
zhuqling / elastic_search_chinese_ik_analysis_mapping.md
Last active August 29, 2015 14:08
elastic search使用中文IK分词器

中文全文检索

安装

cp elasticsearch-analysis-ik-1.2.6.jar ./plugins/analysis-ik/ # 复制jar

cp . ./config/ik/ # 复制字库

nano ./config/elasticsearch.yml

@zhuqling
zhuqling / oracle_restrore_dmp_file.txt
Last active August 29, 2015 14:09
ORACLE restrore dmp file
# ORACLE restrore dmp file
## create tablespace
<pre>
create temporary tablespace STUDIO_temp tempfile '<DBPATH>/STUDIO_temp.dbf' size 500M;
create tablespace STUDIO datafile '<DBPATH>/STUDIO.dbf' size 500M;
create temporary tablespace FRAMEWORK_temp tempfile '<DBPATH>/FRAMEWORK_temp.dbf' size 500M;
@zhuqling
zhuqling / deckjs_syntax_highlight.markdown
Last active August 29, 2015 14:10
deck js 语法高亮

A SYNTAX HIGHLIGHTER EXTENSION FOR DECK.JS

from: http://niftybits.wordpress.com/2012/01/09/a-syntax-highlighter-extension-for-deck-js/

So for the past few hours, have been playing with Deck.js . I like the idea of a web based presentation format rather than a blob like powerpoint. At the same time, I’m a bit circumspect too – given the state of the tools. At least for my use, there’s really no burning need that powerpoint can’t solve (though I get the shivers everytime I have to do a presentation). All the web based/HTML5 seem raw at the moment on some much needed features (slide notes, slide prints, scaling issues etc).

Anyway, after a few minutes on Google and StackOverflow, decided to give Deck.js a spin. Deck.js is really nice and you should take a tour if you haven’t done so. So finally, after giving the online presentation and the introduction a try, downloaded the latest to give it a more thorough spin. As usual, one of the first things was embedding code snippets and I thought it would be nice to

// Additional code in node-http-proxy.js
var crypto = require('crypto');
var redis = require('redis');
var client = redis.createClient(config.opt.redis_port, 'cloudno.de');
client.auth(config.opt.redis_auth, function(result) {
util.log("Redis authenticated.");
})
/*
* FormData for XMLHttpRequest 2 - Polyfill for Web Worker
* (c) 2014 Rob Wu <rob@robwu.nl>
* License: MIT
* - append(name, value[, filename])
* - XMLHttpRequest.prototype.send(object FormData)
*
* Specification: http://www.w3.org/TR/XMLHttpRequest/#formdata
* http://www.w3.org/TR/XMLHttpRequest/#the-send-method
* The .append() implementation also accepts Uint8Array and ArrayBuffer objects
import os
import random
from scrapy.conf import settings
class RandomUserAgentMiddleware(object):
def process_request(self, request, spider):
ua = random.choice(settings.get('USER_AGENT_LIST'))
if ua:
request.headers.setdefault('User-Agent', ua)
class ProxyMiddleware(object):
@zhuqling
zhuqling / makeAnimatedGif.m
Last active August 29, 2015 14:28 — forked from mayoff/makeAnimatedGif.m
Example of creating an animated GIF on iOS, with no 3rd-party code required. This should also be easy to port to OS X.
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
static UIImage *frameImage(CGSize size, CGFloat radians) {
UIGraphicsBeginImageContextWithOptions(size, YES, 1); {
[[UIColor whiteColor] setFill];
UIRectFill(CGRectInfinite);
CGContextRef gc = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(gc, size.width / 2, size.height / 2);
@zhuqling
zhuqling / gist:ae8c43fb69605e2e55db
Last active August 29, 2015 14:28 — forked from akisute/gist:1141953
Create an animated gif file from images in iOS
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
- (void)exportAnimatedGif
{
UIImage *shacho = [UIImage imageNamed:@"shacho.png"];
UIImage *bucho = [UIImage imageNamed:@"bucho.jpeg"];
NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"animated.gif"];