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
require 'nokogiri' | |
input = $stdin.readlines.join | |
page = Nokogiri::HTML(input) | |
page.css('.example').each do |elem| | |
elem.inner_html = '<i>Environment diagram omitted.</i>' | |
end | |
page.css('img').remove |
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
Flying sex snakes. | |
Michelle Obama's arms. | |
German dungeon porn. | |
White people. | |
Getting so angry that you pop a boner. | |
Tasteful sideboob. | |
Praying the gay away. | |
Two midgets shitting into a bucket. | |
MechaHitler. | |
Being a motherfucking sorcerer. |
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
-- Execute this as: | |
-- | |
-- ghc -O2 hog.hs && ./hog | |
-- | |
-- Which takes about 1 minute to execute. | |
import Data.List (any) | |
import Control.Monad (replicateM) | |
rolls :: Int -> Int -> [[Int]] |
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 copy | |
import random | |
people = [0, 1, 2, 3, 4, 5, 6, 7] | |
tries = 1000000 | |
count = 0 | |
for _ in range(tries): | |
shuffled_people = copy.copy(people) | |
random.shuffle(shuffled_people) |
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
people = (0...8).to_a | |
tries = 10_000_000 | |
count = 0 | |
tries.times do | |
if people.shuffle.each_with_index.all? { |person, index| person != index } | |
count += 1 | |
end | |
end | |
p count.to_f / tries |
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 javax.swing; | |
import java.util.Scanner; | |
import java.awt.Component; | |
/** | |
* This is a fake JOptionPane class. It overrides the two most commonly-used | |
* JOptionPane-based functions for IO (#showInputDialog and #showMessageDialog) | |
* and has them simply use System.in and System.out. | |
* |
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
require 'benchmark' | |
require 'extension_cord' | |
def average_reduce(arr) | |
arr.reduce(:+).to_f / arr.size | |
end | |
def average_upto(arr) | |
sum = 0 |
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
require 'docker' | |
require 'shellwords' | |
image = Docker::Image.all.first | |
s = IO.read('tmp.rb').shellescape | |
cmd = [ "/bin/bash", "-c", "echo #{s} > roobee.rb; ruby roobee.rb" ] | |
puts "Response from Docker: " |
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.pdb.query.simple.distance; | |
import java.io.File; | |
import java.io.IOException; | |
import java.sql.Connection; | |
import java.sql.SQLException; | |
import java.util.List; | |
import org.apache.commons.io.FileUtils; | |
import org.biojava.bio.structure.Element; |
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
for dir in */ | |
do | |
find ./$dir -type f | wc -l | |
done |