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
text = 'abdfbcbedbabcfefbdddedbbfababc' | |
def build_huffman_tree(text): | |
f = {} | |
for char in text: | |
if char in f: | |
f[char] = f[char] + 1 | |
else: | |
f[char] = 1 |
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
object Main { | |
def perms(a: List[Int]): List[List[Int]] = { | |
if (a.size <= 1) List(a) | |
else { | |
for { | |
p <- perms(a.tail) | |
i <- (0 to p.size).toList | |
} yield p.take(i) ::: List(a.head) ::: p.drop(i) | |
} |
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
# make sure that you have libjpeg and PIL installed | |
import re | |
import os, sys | |
import Image | |
size = 60, 60 # max_width, max_height | |
files = [f for f in os.listdir('.') if re.match(r'view[\d]{3}_large', f)] |
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
<html> | |
<head> | |
<style type="text/css"> | |
.wide-container { | |
width: 200px; | |
height: 20px; | |
border: 1px solid red; | |
text-align: center; | |
vertical-align: middle; | |
display: table-cell; |
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
SSLContext ctx = SSLContext.getInstance("TLS"); | |
X509TrustManager tm = new X509TrustManager() { | |
public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException { | |
} | |
public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException { | |
} | |
public X509Certificate[] getAcceptedIssuers() { |
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 lombok.extern.slf4j.Slf4j; | |
import org.apache.http.conn.ClientConnectionManager; | |
import org.apache.http.conn.scheme.Scheme; | |
import org.apache.http.conn.scheme.SchemeRegistry; | |
import org.apache.http.conn.ssl.SSLSocketFactory; | |
import org.apache.http.impl.client.AbstractHttpClient; | |
import org.apache.http.impl.client.DefaultHttpClient; | |
import org.apache.http.impl.conn.PoolingClientConnectionManager; | |
import javax.net.ssl.SSLContext; |
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
package org.example; | |
public class Main { | |
private static long power(long x, long y) { | |
if (y == 0) { | |
return 1; | |
} else if (y == 1) { | |
return x; | |
} |
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
var jsdom = require('jsdom'); | |
jsdom.env({ | |
url: 'http://www.youtube.com/watch?v=c_b1j6trfa8', | |
scripts: ["http://code.jquery.com/jquery.js"], | |
done: function(error, window) { | |
var $ = window.$; | |
$('meta').each(function(){ | |
var name = $(this).attr('property'); |
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
SSLContextBuilder sslbuilder = new SSLContextBuilder(); | |
sslbuilder.loadTrustMaterial(null, | |
new TrustStrategy() { | |
@Override | |
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException { | |
return true; | |
} |
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
var fs = require('fs'); | |
var http = require('http'); | |
var urls = fs.readFileSync('files.txt', {encoding: 'utf8'}).split('\n'); | |
next(); | |
function next() { | |
if (urls.length > 0) { | |
download(urls.pop(), next); |
OlderNewer