Skip to content

Instantly share code, notes, and snippets.

View iqiancheng's full-sized avatar
🌴
On vacation

千橙 iqiancheng

🌴
On vacation
View GitHub Profile
@iqiancheng
iqiancheng / SwitchyOmega_Conditions_Auto_Swich_List.pac
Last active August 29, 2015 14:25
SwitchyOmega Conditions Auto Swich List
var FindProxyForURL = function(init, profiles) {
return function(url, host) {
"use strict";
var result = init, scheme = url.substr(0, url.indexOf(":"));
do {
result = profiles[result];
if (typeof result === "function") result = result(url, host, scheme);
} while (typeof result !== "string" || result.charCodeAt(0) === 43);
return result;
};
@mycoin
mycoin / pager.js
Last active August 29, 2016 00:09
简单的分页组件
/**
* 分页组件
*
* @function
* @param {element} el 目标DOM节点
* @param {number} page 当前页
* @param {number} total 总页数
* @param {function} change 点击翻页回调函数
*
* @returns {string} 格式化后的字符串
@TheCrafter
TheCrafter / TST.java
Created September 18, 2017 07:44
Java: Simple Ternary Search Tree
import java.util.ArrayList;
import java.util.List;
/**
* Ternary search trie basic implementation. This piece of code was modified by Dimitris Vlachakis
* on 18/9/2017. You can find more info about the original work and its authors (Robert Sedgewick
* and Kevin Wayne) <a href="http://algs4.cs.princeton.edu/52trie/TST.java.html">here</a>.
*/
public class TST<Value> {
private int size; // size
@dggc
dggc / mapping creation
Created September 11, 2013 13:15
Code to create the mappings in Java
client.admin().indices().prepareCreate(source.toString().toLowerCase()).execute().actionGet();
XContentBuilder xbMapping = XContentFactory.jsonBuilder().startObject().startObject("documents");
xbMapping.startObject(ELASTIC_TTL).field("enabled", true).field("default", (30*60*1000)+"ms").endObject();
xbMapping.startObject("properties");
xbMapping.startObject("content").field("type", "string").endObject();
xbMapping.startObject("insertedDate").field("type", "long").endObject();
xbMapping.endObject();
xbMapping.endObject().endObject();
client.admin().indices().preparePutMapping("documents").setType("documents").setSource(xbMapping).execute().actionGet();
{
"indices": {
"memory": {
"index_buffer_size": "30%"
}
},
"index":{
"number_of_replicas":0,
"number_of_shards":10,
"translog": {
@Topher-the-Geek
Topher-the-Geek / PingPongChannelInitializer.java
Created September 27, 2013 14:43
Ping Pong in Netty 4.0.
package example;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.util.CharsetUtil;
@chaohuangtianjie994
chaohuangtianjie994 / geektime.user.js
Created May 24, 2019 08:59 — forked from Rand01ph/geektime.user.js
让极客时间的内容可以复制
// ==UserScript==
// @name geektime copy
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 让极客时间的内容可以复制!
// @author Rand01ph
// @match https://time.geekbang.org/column/*
// @grant none
// @require http://cdn.staticfile.org/jquery/2.1.1/jquery.min.js
// ==/UserScript==
#!/usr/bin/env python
# coding:utf-8
"""
A 'Crawler' for http://msdn.itellyou.cn/
"""
import re
import urllib
import urllib2
@lightsing
lightsing / casAutoLogin.user.js
Created March 7, 2017 05:11
CAS Auto Login Script
// ==UserScript==
// @name CAS Auto Login
// @namespace lab.lightsing.me
// @version 0.1
// @description CAS Auto Login
// @author lightsing
// @match https://cas.sustc.edu.cn/*
// ==/UserScript==
(function() {
@nathan130200
nathan130200 / YoutubeSkipAd.user.js
Last active August 25, 2020 08:17
Automatic skip-ad and hide ad elements in youtube without use AD-Block, this script don't remove AD-Elements, just hide from page.
// ==UserScript==
// @name YoutubeSkipAd
// @version 1.6.3
// @description Automatic skip-ad and hide in youtube.
// @author FRNathan13
// @include /(http|https):\/\/www.youtube.com\/(.*)
// @grant none
// ==/UserScript==
(function() {