Edit: This list is now maintained in the rust-anthology repo.
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
fn main() { | |
give(); | |
} | |
fn give(){ | |
let mut vec = Vec::new(); | |
vec.push(1); | |
vec.push(2); | |
take(vec); | |
vec.push(3); |
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
#[allow(dead_code)] | |
fn encrypt(plaintext: &str, key: usize){ | |
let plaintext = &plaintext.to_uppercase(); | |
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
let mut cipher = String::from(""); | |
for each_char in plaintext.chars(){ | |
match alphabet.find(each_char) { | |
Some(index) => { | |
let char_index = (index + key) % 26; | |
let char_place = alphabet.chars().nth(char_index).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
use std::time::Duration; | |
use std::sync::Arc; | |
use std::sync::atomic::{AtomicBool, Ordering}; | |
use std::thread; | |
fn main() { | |
// Play with this flag | |
let fatal_flag = true; | |
let do_stop = 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
#[warn(unused_variables)] | |
#[warn(unused_must_use)] | |
use std::thread; | |
fn main(){ | |
let mut c = vec![]; | |
for i in 0..10{ | |
c.push(thread::spawn(move || { | |
println!("thread number {}", i); |
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 React from 'react' | |
import { Link } from 'react-router' | |
import getRouteHandlerBaseUrl from 'js/helpers/get-route-handler-base-url' | |
class Something extends React.Component { | |
componentWillMount() { | |
this._baseUrl = getRouteHandlerBaseUrl(this.props) | |
} |
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::sync::{Arc, Mutex, Condvar}; | |
use std::thread; | |
struct Producer { | |
cvar: Arc<(Mutex<bool>, Condvar)> | |
} | |
impl Producer { | |
pub fn new(cvar: Arc<(Mutex<bool>, Condvar)>) -> Producer { | |
Producer { |
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 find(key, dictionary): | |
for k, v in dictionary.iteritems(): | |
if k == key: | |
yield v | |
elif isinstance(v, dict): | |
for result in find(key, v): | |
yield result | |
elif isinstance(v, list): | |
for d in v: | |
for result in find(key, d): |
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 sys, ldap | |
# DN = [email protected], secret = password, un = username | |
DN, secret, un = sys.argv[1:4] | |
server = "ldap://server.com" | |
port = 389 | |
base = "dc=example,dc=com" | |
scope = ldap.SCOPE_SUBTREE |
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 | |
echo "Generating an SSL private key to sign your certificate..." | |
openssl genrsa -des3 -out myssl.key 1024 | |
echo "Generating a Certificate Signing Request..." | |
openssl req -new -key myssl.key -out myssl.csr | |
echo "Removing passphrase from key (for nginx)..." | |
cp myssl.key myssl.key.org | |
openssl rsa -in myssl.key.org -out myssl.key |
OlderNewer