Skip to content

Instantly share code, notes, and snippets.

View jingege's full-sized avatar

Bill Zhang jingege

View GitHub Profile
@dustyfresh
dustyfresh / nginx-load-scripts-mitigation.conf
Last active March 14, 2023 06:07
nginx rule to mitigate DoS attack on WordPress load-scripts.php
# https://baraktawily.blogspot.fr/2018/02/how-to-dos-29-of-world-wide-websites.html
# https://wpvulndb.com/vulnerabilities/9021
location ~* ^/wp-admin/load-scripts\.php$ {
if ( $query_string ~* "^.{1024,}$" ) {
return 444;
}
}
@viko16
viko16 / insertScript.js
Created June 10, 2014 08:27
方便在chrome插件中插入js代码 #javascript
function insertScript(path) {
var script = document.createElement('script')
script.src = chrome.extension.getURL(path)
document.body.appendChild(script)
}
// insert patch sdk
insertScript('patch.js')
@definitelyMVP
definitelyMVP / CuratorAsyncGetDataExample.java
Created February 19, 2013 05:52
Curator async getData example
import com.netflix.curator.framework.CuratorFramework;
import com.netflix.curator.framework.CuratorFrameworkFactory;
import com.netflix.curator.framework.api.BackgroundCallback;
import com.netflix.curator.framework.api.CuratorEvent;
import com.netflix.curator.retry.ExponentialBackoffRetry;
/**
* @author yl
* @date 2013-02-19
*/
@definitelyMVP
definitelyMVP / PersistantWatcherExample.java
Last active July 1, 2016 10:39
curator node cache example
import com.netflix.curator.framework.CuratorFramework;
import com.netflix.curator.framework.CuratorFrameworkFactory;
import com.netflix.curator.framework.recipes.cache.ChildData;
import com.netflix.curator.framework.recipes.cache.NodeCache;
import com.netflix.curator.framework.recipes.cache.NodeCacheListener;
import com.netflix.curator.retry.ExponentialBackoffRetry;
/**
* @author yl
* @date 2013-02-19
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.charset.Charset;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.bootstrap.ServerBootstrap;
@bnyeggen
bnyeggen / clojure_hive_thrift.clj
Created December 13, 2011 15:28
Clojure to Hive via Thrift
(comment You will want just about everything in your hive/lib dir included in your Classpath)
(ns myproj.core
(:import [org.apache.hadoop.hive.service HiveClient]
[org.apache.thrift.transport TSocket]
[org.apache.thrift.protocol TBinaryProtocol]))
(defn send-hive
"Creates a new socket and Hive client connection, runs the query, pulls the result, and closes the connection.
Eventually modify to split and parse according to schema of result.
@bnyeggen
bnyeggen / clojure_hive_jdbc.clj
Created December 13, 2011 15:12
Clojure to Hive via JDBC
(comment Add [org.clojure/java.jdbc "0.1.1"] to project dependencies)
(ns myproject.core
(:use [clojure.java.jdbc :only [with-connection, with-query-results]]))
(let [db-host "MyHost"
db-port 10000
db-name "default"]
(def db {:classname "org.apache.hadoop.hive.jdbc.HiveDriver" ; must be in classpath
:subname (str "//" db-host ":" db-port "/" db-name)
@rponte
rponte / ClientFormLogin.java
Created October 28, 2011 01:08
sending http post (httpclient 4.x - httpcomponents) with parameters example
package org.apache.http.examples.client;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
@trashhalo
trashhalo / build.gradle
Created August 13, 2011 23:55
Gradle task converts markdown to pdf
import com.petebevin.markdown.MarkdownProcessor
import org.xhtmlrenderer.pdf.ITextRenderer
import org.ccil.cowan.tagsoup.Parser
import org.apache.xalan.xsltc.trax.SAX2DOM
import org.xml.sax.InputSource
buildscript{
repositories {
mavenCentral()
mavenRepo urls: "http://scala-tools.org/repo-releases"
@hdenk
hdenk / build.gradle
Created February 8, 2011 03:37
clojure webapp with http-authentication using ring/moustache, deployable as foo.war
// gradle-build that uses meikel brandmeyers clojure-plugin for gradle (clojuresque)
// see http://bitbucket.org/kotarak/clojuresque
// use a standard maven directory-layout -> /src/main/clojure, /src/main/webapp
apply plugin: 'clojure'
apply plugin: 'war'
apply plugin: 'project-report'
warnOnReflection = false
aotCompile = true // needed for gen-class in servlet.clj