This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SocketServer | |
class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler): | |
def handle(self): | |
self.request.sendall(""" | |
<?xml version="1.0" encoding="utf-8"?> | |
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> | |
<cross-domain-policy><site-control permitted-cross-domain-policies="all"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import 'java.security.MessageDigest | |
'java.math.BigInteger) | |
(defn md5 [s] | |
(let [algorithm (MessageDigest/getInstance "MD5") | |
size (* 2 (.getDigestLength algorithm)) | |
raw (.digest algorithm (.getBytes s)) | |
sig (.toString (BigInteger. 1 raw) 16) | |
padding (apply str (repeat (- size (count sig)) "0"))] | |
(str padding sig))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 4clojure.com - 85. Power Set | |
; http://www.4clojure.com/problem/85 | |
(fn [s] | |
(set (for [i (range 0 (apply * (repeat (count s) 2)))] | |
(set (for [index-base (range 0 (count s)) | |
:let [index (apply * (repeat index-base 2))] | |
:when (pos? (bit-and i index))] | |
(nth (seq s) index-base)))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns uv.raw | |
(:require [clojure-hadoop.gen :as gen] | |
[clojure-hadoop.imports :as imp]) | |
(:import [org.apache.hadoop.util Tool] | |
[com.hadoop.mapreduce LzoTextInputFormat])) | |
(imp/import-conf) | |
(imp/import-fs) | |
(imp/import-io) | |
(imp/import-mapreduce) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import json | |
import urllib2 | |
import smtplib | |
from email.mime.image import MIMEImage | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
data = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Root logger option | |
log4j.rootLogger=INFO, stdout | |
# Direct log messages to stdout | |
log4j.appender.stdout=org.apache.log4j.ConsoleAppender | |
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout | |
log4j.appender.stdout.layout.ConversionPattern=%d %-5p %c{1} - %m%n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- project / build / plugins/ plugin --> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-shade-plugin</artifactId> | |
<version>2.1</version> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<goals> | |
<goal>shade</goal> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SocketServer | |
import random | |
import time | |
words = ('cat', 'dog', 'monkey', 'horse', 'rabbit') | |
class MyTCPHandler(SocketServer.BaseRequestHandler): | |
def handle(self): | |
while True: | |
self.request.sendall(' '.join(random.sample(words, 3)) + '\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.json4s._ | |
object JsonUtils { | |
implicit class AugmentJValue(val jvalue: JValue) { | |
implicit val formats = DefaultFormats | |
def getString(key: String): String = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Linux | |
Host github.com | |
ProxyCommand socat STDIO PROXY:192.168.1.101:%h:%p,proxyport=8118 | |
# Mac | |
Host github.com | |
ProxyCommand nc -X 5 -x 127.0.0.1:1086 %h %p | |
ServerAliveInterval 10 |
OlderNewer