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
package com.showyou.importer.twitter; | |
import java.io.IOException; | |
import java.io.InputStream; | |
/** | |
* Created by Phil Kulak | |
* Date: 1/1/12 | |
* | |
* Parses an InputStream from the Twitter site streams API. The stream needs to be length-delimited (?delimited=length) |
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
package main | |
import ( | |
"crypto/md5" | |
"fmt" | |
"io" | |
"runtime" | |
) | |
var chars = "abcdefghijklmnopqrstuvwxyz" |
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
package main | |
import ( | |
"bufio" | |
"log" | |
"os" | |
) | |
var concurrency = 100 |
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
// Takes an ArrayBuffer; returns an array of these objects: | |
// { | |
// seconds: *number of seconds into the video of this image*, | |
// bytes: *the bytes of this image, as an ArrayBuffer* | |
// } | |
var parseBif = function(buffer) { | |
var data = new Uint8Array(buffer); | |
// Make sure this really is a BIF. | |
var magicNumber = [0x89, 0x42, 0x49, 0x46, 0x0d, 0x0a, 0x1a, 0x0a]; |
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 ruby | |
require 'open-uri' | |
require 'time' | |
require 'json' | |
class Runner | |
def initialize | |
@base = "http://192.168.0.10/DCIM/100OLYMP" |
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 ruby | |
require 'unirest' | |
# Set these by going to etron.audiusa.com/web/aucwp/login once by hand and figuring them out | |
EMAIL = "[email protected]" | |
PASSWORD = "password" | |
ACCOUNT = 9999 | |
PIN = 9999 |
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
let opening = ['{', '[', '(']; | |
let closing = ['}', ']', ')']; | |
let all = opening.concat(closing) | |
function validate(s) { | |
if (s.length == 0) return true; | |
// ignore unknown chars at the head | |
while (all.indexOf(s.charAt(0)) == -1) { | |
s = s.slice(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
/** | |
* A very simple, non-blocking semaphore. | |
*/ | |
class Semaphore(capacity: Int) { | |
private val channel = Channel<Boolean>(capacity) | |
suspend fun acquire() { | |
channel.send(true) | |
} |
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 is mostly here for my reference. If someone on the internet finds this, I hope it's | |
# helpful, but don't trust it! I'm pretty new at this, which is why I have to keep exhaustive | |
# notes like this. The corollary then, is that if you're a pro at this, and notice something | |
# dumb I'm doing, please let me know. | |
# | |
# The idea here is to end up with an ecrypted BTRFS filesystem running Snapper in a way that | |
# makes rollbacks super easy. I tried to keep things simple, so the swap is a file, not a | |
# partition (that would have to be encryped separately). The subvolume layout is totally flat, | |
# to make rollbacks a simple matter of moving the volumes around. When this is all done, a | |
# simple ls of either .snapshots directory will show you your live filesystem right alongside |
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
fun main() { | |
val nonBlockingTime = measureTime { runBlocking { nonBlocking() } } | |
println(nonBlockingTime) | |
val pool = Executors.newFixedThreadPool(1000) | |
val blockingTime = measureTime { blocking(pool) } | |
println(blockingTime) | |
} | |
suspend fun nonBlocking(total: Int = 1000) = coroutineScope { |
OlderNewer