This file contains 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 | |
set -e | |
function die { | |
echo >&2 $1 | |
exit 1 | |
} | |
command -v algo >/dev/null 2>&1 || die "Have you installed the Algorithmia CLI" |
This file contains 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 nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; |
This file contains 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
/* | |
Example usage: | |
Note: in all of these cases, the return value must be `Result<T, E>` where: | |
- `T` has a conversion to `AlgoOutput` (e.g. String, Vec<u8>, JsonValue, (), or anything Serializeable) | |
- `E` has a conversion to `Box<Error>` (e.g. String or any custom type that `impl Error`) | |
-------------Text----------------------- | |
algo_entrypoint! { text => hello } | |
fn hello(input: &str) -> Result<String, String> { | |
Ok(format!("Hello {}", input)) |
This file contains 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
#![feature(test)] | |
extern crate serde_json; | |
extern crate json; | |
extern crate test; | |
#[cfg(test)] | |
mod tests { | |
use json::{self, JsonValue}; | |
use serde_json::{self, Value}; | |
use test::Bencher; |
This file contains 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
extern crate libwkhtmltox_sys as libwkhtmltox; // https://github.com/anowell/libwkhtmltox-sys | |
use libwkhtmltox::*; | |
use std::ffi::{CString, CStr}; | |
use std::os::raw::{c_char, c_int, c_uchar}; | |
unsafe extern fn finished_callback(converter: *mut wkhtmltopdf_converter, val: c_int) { | |
println!("finished_callback: {}", val); | |
// Read the PDF output |
This file contains 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
# Bind prefix to tick, but let double-tick through | |
unbind ` | |
set -g prefix ` | |
bind-key ` send-key ` | |
# Ring the bell if any background window rang a bell | |
set -g bell-action any | |
# Default termtype. If the rcfile sets $TERM, that overrides this value. | |
set -g default-terminal screen-256color |
This file contains 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 to search for string in a set of files | |
# | |
# Add this function to ~/.bashrc | |
# Restart terminal or run: source ~/.bashrc | |
# Optionally set EDITOR in ~/.bash_profile (I use "EDITOR=subl") | |
# | |
# Examples: | |
# # Outputs filenames and matches of all found occurrences of "authenticate_user" in .rb files | |
# search *.rb "authenticate_user" | |
# |
This file contains 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 AnalogClock | |
attr_reader :hour, :min, :meridiem | |
def initialize(time) | |
return nil unless time.instance_of?(String) | |
# split on space and colon | |
split_time = time.split(/:| /) | |
return nil unless split_time.length == 3 |
This file contains 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
// Expected behavior: | |
// 'abc', 'cba' => true | |
// 'abca', 'cba' => true | |
// 'cba', 'abca' => true | |
// '', '' => true | |
// 'abcd', 'abc' => false | |
// 'abc', 'abcd' => false | |
bool hasSameCharacters(char* c1, char* c2) | |
{ |
This file contains 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
// Expected behavior: | |
// 'abc', 'cba' => true | |
// 'abca', 'cba' => true | |
// 'cba', 'abca' => true | |
// '', '' => true | |
// 'abcd', 'abc' => false | |
// 'abc', 'abcd' => false | |
bool hasSameCharacters(char* c1, char* c2) | |
{ |