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.awt.Color; | |
import java.util.*; | |
public class ColorListSorter { | |
public static void quickSort(List<Color> list, int pivot, int end) { | |
if (pivot < end) { | |
int q = partition(list, pivot, end); | |
quickSort(list, pivot, q); | |
quickSort(list, q+1, end); | |
} |
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.awt.Color; | |
import java.util.*; | |
public class ColorListSorter { | |
public static void quickSort(List<Color> list, int pivot, int end) { | |
if (pivot < end) { | |
int q = partition(list, pivot, end); | |
quickSort(list, pivot, q); | |
quickSort(list, q+1, end); | |
} |
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
def englishChi2(bytes: Array[Byte]): Double = { | |
val englishLetterFrequency = Map( | |
'A' -> 0.08167, 'B' -> 0.01492, 'C' -> 0.02782, 'D' -> 0.04253, | |
'E' -> 0.12702, 'F' -> 0.02228, 'G' -> 0.02015, 'H' -> 0.06094, | |
'I' -> 0.06966, 'J' -> 0.00153, 'K' -> 0.00772, 'L' -> 0.04025, | |
'M' -> 0.02406, 'N' -> 0.06749, 'O' -> 0.07507, 'P' -> 0.01929, | |
'Q' -> 0.00095, 'R' -> 0.05987, 'S' -> 0.06327, 'T' -> 0.09056, | |
'U' -> 0.02758, 'V' -> 0.00978, 'W' -> 0.02360, 'X' -> 0.00150, | |
'Y' -> 0.01974, 'Z' -> 0.00074, ' ' -> 0.19181 | |
) |
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
#!/usr/bin/env ruby | |
# | |
# Script to encrypt the contents of an entire S3 bucket | |
# | |
# This works by copying each object in the bucket onto | |
# itself while modifying its server_side_encryption attribute | |
# | |
# | |
############################################################## |
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 turtle | |
def drawLine(x1, y1, x2, y2): | |
turtle.penup() | |
turtle.goto(x1, y1) | |
turtle.pendown() | |
turtle.goto(x2, y2) |
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
~ pbpaste | ruby -ne 'require "base64";enc=Base64.decode64($_.chars.each_slice(8).map(&:join).map{|byte|byte.to_i(2)}.map(&:chr).join);ascii=enc.split("").map{|chr|chr.ord};1.upto(26){|i| p ascii.map{|chr| (chr+i).chr}.join}' | |
"NEBJLLLNRBNLMFLEOBNESBEUMFRROLFBOOSBFLTFFFWIOMRLSNRRMFOEMERWRFTMMLBOJRMWFLELBMTOBFHFWBBMOSSJRMM" | |
"OFCKMMMOSCOMNGMFPCOFTCFVNGSSPMGCPPTCGMUGGGXJPNSMTOSSNGPFNFSXSGUNNMCPKSNXGMFMCNUPCGIGXCCNPTTKSNN" | |
"PGDLNNNPTDPNOHNGQDPGUDGWOHTTQNHDQQUDHNVHHHYKQOTNUPTTOHQGOGTYTHVOONDQLTOYHNGNDOVQDHJHYDDOQUULTOO" | |
"QHEMOOOQUEQOPIOHREQHVEHXPIUUROIERRVEIOWIIIZLRPUOVQUUPIRHPHUZUIWPPOERMUPZIOHOEPWREIKIZEEPRVVMUPP" | |
"RIFNPPPRVFRPQJPISFRIWFIYQJVVSPJFSSWFJPXJJJ[MSQVPWRVVQJSIQIV[VJXQQPFSNVQ[JPIPFQXSFJLJ[FFQSWWNVQQ" | |
"SJGOQQQSWGSQRKQJTGSJXGJZRKWWTQKGTTXGKQYKKK\\NTRWQXSWWRKTJRJW\\WKYRRQGTOWR\\KQJQGRYTGKMK\\GGRTXXOWRR" | |
"TKHPRRRTXHTRSLRKUHTKYHK[SLXXURLHUUYHLRZLLL]OUSXRYTXXSLUKSKX]XLZSSRHUPXS]LRKRHSZUHLNL]HHSUYYPXSS" | |
"ULIQSSSUYIUSTMSLVIULZIL\\TMYYVSMIVVZIMS[MMM^PVTYSZUYYTMVLTLY^YM[TTSIVQYT^MSLSIT[VIMOM^IITVZZQYTT" | |
"VMJRTTT |
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
#include <Adafruit_NeoPixel.h> | |
#ifdef __AVR__ | |
#include <avr/power.h> | |
#endif | |
#define PIN 6 | |
// Parameter 1 = number of pixels in strip | |
// Parameter 2 = Arduino pin number (most are valid) | |
// Parameter 3 = pixel type flags, add together as needed: |
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
#include <Adafruit_NeoPixel.h> | |
#ifdef __AVR__ | |
#include <avr/power.h> | |
#endif | |
#define PIN 6 | |
// Parameter 1 = number of pixels in strip | |
// Parameter 2 = Arduino pin number (most are valid) | |
// Parameter 3 = pixel type flags, add together as needed: |
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
def decodeSingleByteXOR(cipherText: String, char: Char): String = { | |
val cipherTextByteArray = decodeHex(cipherText) | |
new String(cipherTextByteArray.zip(Array.fill(cipherTextByteArray.length)(char)).map((t) => t._2 ^ t._1).map(_.toByte), "UTF-8") | |
} | |
def bruteForceSingleByteXOR(cipherText: String): Array[String] = { | |
(('A' to 'Z') ++ ('a' to 'z') ++ ('0' to '9')).toArray.map(decodeSingleByteXOR(cipherText,_)) | |
} | |
def decodeHex(hex: String): Array[Byte] = { |
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
/** | |
* Returns a text from html file content without user's tags and their bodies. | |
* | |
* @param is an input stream with html file content. | |
* @return The string only with text from file content. | |
*/ | |
public String getContentAsText(InputStream is) throws IOException, DocumentReadException | |
{ | |
if (is == null) | |
{ |