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 std::io::prelude::*; | |
use std::net::TcpStream; | |
use std::io::BufReader; | |
use std::env; | |
fn get_tld_server(tld: &str) -> Option<String> { | |
let mut stream = TcpStream::connect("whois.iana.org:43").unwrap(); | |
stream.write_all(format!("{}\n", tld).as_bytes()).unwrap(); //Send the tld | |
let reader = BufReader::new(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
class Fixnum | |
# Constant variable with 'unique' roman numerals, plus some special cases (e.g. "IV, IX, XC, CM...") | |
ROMANS = { 1000 => "M", | |
900 => "CM", | |
500 => "D", | |
400 => "CD", | |
100 => "C", | |
90 => "XC", | |
50 => "L", |
Prerequisites : the letsencrypt CLI tool
This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.
You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge
.
Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.
I redirect all HTTP requests on HTTPS, so my nginx config looks like :
server {
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 color = "blue" | |
let num = 42 | |
localized("Colorless green ideas sleep furiously.") | |
localized("Colorless \(color) ideas sleep furiously.") | |
localized("\(num.formatted("%05d")) colorless green ideas sleep furiously.") |
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 std::io::prelude::*; | |
use std::net::{TcpListener, TcpStream}; | |
use std::io::BufReader; | |
use std::thread; | |
use std::fs::File; | |
fn get_definitions(word: String) -> Vec<String>{ | |
let mut dict = File::open("dict.txt").unwrap(); | |
let mut reader = BufReader::new(dict); | |
let mut matches: Vec<String> = Vec::new(); |
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
protocol OptionalType { | |
typealias T | |
var optional: T? { get } | |
} | |
extension Optional : OptionalType { | |
var optional: T? { return self } | |
} | |
extension SequenceType where Generator.Element: OptionalType { |
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
#!/bin/bash | |
# THIS IS A GIANT HACK | |
# if you think this would be a good idea if it weren't so terrible, go read https://github.com/rust-lang/rfcs/pull/1133 | |
set -e | |
# Parse args | |
for i in "$@" | |
do |
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 std::rc::Rc; | |
trait HKT<U> { | |
type C; // Current type | |
type T; // Type with C swapped with U | |
} | |
macro_rules! derive_hkt { | |
($t:ident) => { | |
impl<T, U> HKT<U> for $t<T> { |