This file contains hidden or 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.io.IOException; | |
import java.net.URLClassLoader; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
import java.nio.file.Path; | |
/** | |
* Example demonstrating a ClassLoader leak. | |
* | |
* <p>To see it in action, copy this file to a temp directory somewhere, |
This file contains hidden or 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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
This file contains hidden or 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
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
Read 4K randomly from SSD* 150,000 ns 0.15 ms |
This file contains hidden or 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
#! /usr/bin/env python | |
# -*- coding - utf-8 -*- | |
"""This program converts a rational number | |
into its decimal representation. | |
A rational number is a number of the form p/q | |
where p and q are integers and q is not zero. | |
The decimal representation of a rational number | |
is either terminating or non-terminating but |
This file contains hidden or 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
# This function solves the problem no. 40 of project-euler | |
# The link to the problem: http://projecteuler.net/problem=40 | |
# We find a correspondence in the two below sequences s1 and s2: | |
# s1 = 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 0, 1, 1, 1, 2, 1, 3, ... | |
# s2 = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ... | |
# the function nth_digit(n) finds the nth term of s1 | |
# termcount is the term of s2 in which nth term of s1 lies at position numdigit | |
# from the left | |
import math |
This file contains hidden or 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
def countw(listd, total): | |
arr = [[None for x in range(total + 1)] for y in range(len(listd))] | |
for i in range(total + 1): | |
arr[0][i] = 1 | |
for i in range(len(listd)): | |
arr[i][0] = 1 | |
for i in range(1, len(listd)): | |
for j in range(1, total + 1): |
This file contains hidden or 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
/* | |
* | |
* @desc: This program reads in two words(strings) s, t from stdin | |
* and find the minimum edit distance and the corresponding | |
* edit sequence to transform the string s into the string | |
* t. The allowable operations are insert, delete and | |
* substitute. The problem is solved using dynamic programming. | |
* | |
* @algo: Let d[i][j] denote the minimum edit distance between the first | |
* i chars of s and first j chars of t, i.e. between s[0..i] and |