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
| user www; | |
| worker_processes 1; | |
| events { | |
| worker_connections 1024; | |
| } | |
| http { | |
| include /usr/local/etc/nginx/mime.types; | |
| default_type application/octet-stream; |
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 bytes = input.as_bytes(); | |
| let mut raw = Vec::<u8>::with_capacity(input.len()); | |
| for (offset, codepoint) in input.char_indices() { | |
| let c = codepoint as u32; | |
| if (c > 0x40 && c < 0x5b) || (c > 0x60 && c < 0x7b) || | |
| (c > 0x29 && c < 0x3a) || c == 0x2b || c == 0x2f { | |
| raw.push(bytes[offset]); | |
| } else if codepoint.is_whitespace() || c == 0x3d { |
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 mut opts = HashMap::new(); | |
| opts.insert("screen_name", "someone"); | |
| let opts = opts; | |
| let json = twitter.get("users/show", &opts); | |
| println!("{}", json.pretty()); | |
| let obj = json.as_object().unwrap(); | |
| let sn = obj.get("screen_name").unwrap().as_string().unwrap(); |
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 mut key = String::new(); | |
| let mut sec = String::new(); | |
| let mut tok = String::new(); | |
| let mut tok_sec = String::new(); | |
| for (var, val) in env::vars() { | |
| match var.as_ref() { | |
| "TWITTER_KEY" => key = val, | |
| "TWITTER_SECRET" => sec = val, | |
| "TWITTER_TOKEN" => tok = val, |
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 works | |
| fn hash(data: &[u8], key: &[u8]) { | |
| let mut hmac = Hmac::new(Sha1::new(), key); | |
| hmac.input(data); | |
| let signature = &hmac.result().code().to_base64(B64_STD); | |
| println!("sig:\n{}", signature); | |
| } | |
| //this does not work (compiler error in next file) |
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
| mod twot { | |
| pub struct Config<'a> { | |
| key: &'a str, | |
| secret: &'a str, | |
| token: &'a str, | |
| token_secret: &'a str | |
| } | |
| impl<'a> Config<'a> { | |
| pub fn new(key: &'a str, sec: &'a str, tok: &'a str, tok_sec: &'a str) -> Config<'a> { |
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
| "use strict"; | |
| var Twit = require("twit"); | |
| var T = new Twit({ | |
| consumer_key: "", | |
| consumer_secret: "", | |
| access_token: "", | |
| access_token_secret: "" | |
| }); |
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
| var pl = function(file) { | |
| var img = new Image(); | |
| img.src = "img/"+file+".jpg"; | |
| return img; | |
| }; | |
| var imgs = { | |
| readers: pl("lov0"), | |
| circle: pl("lov1"), | |
| blanket: pl("lov2"), |
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
| window.vidloader = function() { | |
| var vid = document.createElement("video"); | |
| vid.src = "vid.ogv"; | |
| vid.preload = "auto"; | |
| return ""; | |
| }; |
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
| -module(alice). | |
| -export([decrypt_xor/1]). | |
| decrypt_xor(Text) -> | |
| Strings = lists:map(fun(N) -> | |
| {N, char_distro([X bxor N || X <- Text])} end, lists:seq(0,255)), | |
| [{Key,_}|_] = lists:reverse(lists:keysort(2, Strings)), | |
| [X bxor Key || X <- Text]. | |
| char_distro(Text) -> |
NewerOlder