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 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 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
| /** | |
| * 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) | |
| { |
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 praw | |
| r = praw.Reddit('Homophone Triplet Game by /u/NotFlameRetardant') | |
| r.login('HomophoneTripletBot', PASSWORD, disable_warning=True) | |
| submission = r.get_submission(submission_id='3j1lso') | |
| flat_comments = praw.helpers.flatten_tree(submission.comments) | |
| already_done = set() | |
| count = 0 | |
| wordset = [['there', 'their', 'they\'re'], ['two', 'too', 'to'], ['buy', 'by', 'bye'], ['write', 'right', 'rite']] |
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 praw | |
| r = praw.Reddit('Homophone Triplet Game by /u/NotFlameRetardant') | |
| r.login('HomophoneTripletBot', PASSWORD, disable_warning=True) | |
| submission = r.get_submission(submission_id='3j1lso') | |
| flat_comments = praw.helpers.flatten_tree(submission.comments) | |
| already_done = set() | |
| count = 0 | |
| wordset = [['there', 'their', 'they\'re'], ['two', 'too', 'to'], ['buy', 'by', 'bye'], ['write', 'right', 'rite']] |
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
| object Matasano { | |
| def hexToBytes(hex: String): Array[Byte] = { | |
| hex.replaceAll("[^0-9A-Fa-f]", "").sliding(2,2).toArray.map(Integer.parseInt(_, 16).toByte) | |
| } | |
| def bytesToHex(bytes: Array[Byte]): String = { | |
| bytes.map("%02x" format _).mkString | |
| } | |
| def encode64(b: Array[Byte]): String = { |
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
| @$container.on 'submit', (e) => | |
| e.preventDefault() | |
| formData = new FormData(@$container.get(0)) | |
| formData.append("user[settings_file]", @file) | |
| $.ajax({ | |
| url: @$container.attr('action'), | |
| type: @$container.attr('method'), | |
| contentType: false, | |
| processData: false, | |
| data: formData, |
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
| /* If your shitbox doesn't have getopt, step into the nineties already. */ | |
| /* optarg, optind = next-argv-component [i.e. flag arg]; optopt = last-char */ | |
| while ((x = getopt (argc, argv, "ae:g:G:hi:lno:p:rs:tuvw:z")) != EOF) { | |
| /* Debug (("in go: x now %c, optarg %x optind %d", x, optarg, optind)) */ | |
| switch (x) { | |
| case 'a': | |
| bail ("all-A-records NIY"); | |
| o_alla++; break; | |
| #ifdef GAPING_SECURITY_HOLE | |
| case 'e': /* prog to exec */ |
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
| // An attempt at implementing the polygon labeling algo at: | |
| // http://mapcontext.com/autocarto/proceedings/auto-carto-8/pdf/an-algorithm-for-locating-candidate-labeling-boxes-within-a-polygon.pdf | |
| // I'm so sorry if you ever have to try and fix this code. Godspeed | |
| function findOptimalLabelLocation(section_point_array, name) { | |
| var xy_objs = _.map(section_point_array, function(xy) { return {x: xy[0], y: xy[1]} }); | |
| var simplified = simplify(xy_objs, 1); | |
| var edges = []; | |
| for (var i = 0; i < simplified.length-1; i++) { | |
| var current_point = simplified[i]; | |
| var next_point = (i == simplified.length-1) ? simplified[0] : simplified[i+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
| require 'koala' | |
| graph = Koala::Facebook::API.new("APIKEY") | |
| one_year_ago = Time.now - (52*7*24*60*60) | |
| feed = graph.get_object("355625917946909/feed?fields=from,likes.limit(10000000),link,comments.limit(10000000)&limit=10000000&since=#{one_year_ago.to_i}") | |
| most_liked = feed.select{|post| !post["likes"].nil? }.sort {|a,b| b["likes"]["data"].size <=> a["likes"]["data"].size} | |
| most_liked[0..15].each do |post| | |
| puts '%-40s' % "#{post["from"]["name"]}:" + "www.facebook.com/groups/#{post["id"].gsub(/_/,"/")} " + "Likes: #{post["likes"]["data"].length}" | |
| end |
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
| $( function() { | |
| var width, height, canvas, ctx, points, target, animateHeader = true; | |
| // Main | |
| initHeader(); | |
| initAnimation(); | |
| addListeners(); | |
| function initHeader() { |