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 [request] | |
(try (handler request) | |
(catch Exception e | |
(let [data (ex-data e)] | |
(case (:type data) | |
:coercion-error (do (warn e) (invalid-request (:data data))) | |
(do (error e) internal-server-error)))))) |
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
(defnk $GET | |
{:responses {200 schemas/SomeSchema} | |
[[:request | |
[:query-params limit :- s/Int] | |
:as req] | |
[:resources flow :- FlowResource]] | |
(...) |
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
SELECT * FROM users ORDER BY :order ASC |
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
(defnk $GET | |
"Get the Authenticated user" | |
{:responses {200 s/Any} | |
:auth-level #{:user}} | |
[[:resources user]] | |
{:status 200 | |
:body {:foo "bar"}}) |
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 Main where | |
import System.Environment (getArgs) | |
import qualified Data.ByteString.Lazy as L | |
import Data.Word | |
addBytes :: [Word8] -> Word8 | |
addBytes [] = 0 | |
addBytes (x:xs) = x + addBytes xs |
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 Main where | |
import System.Environment (getArgs) | |
import qualified Data.ByteString.Lazy as L | |
import Data.Word | |
{- | |
- Test to see how fast we can process an 1GB binary file. | |
- From the blog post: http://jvns.ca/blog/2014/05/12/computers-are-fast/ | |
- |
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
-- name: fetch-students-for-user | |
-- Returns all the students for this user | |
SELECT * | |
FROM users | |
WHERE id IN | |
(SELECT user_id FROM students WHERE flow_id IN | |
(SELECT id FROM flows WHERE owner_id = :user_id)) |
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::os; | |
fn unique_chars(s: &str) -> bool { | |
let v: Vec<char> = s.chars().collect(); | |
let mut y = v.clone(); | |
y.dedup(); | |
v.len() == y.len() | |
} |
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
#[crate_id="cherr"] | |
use std::os; | |
use std::io::fs; | |
fn main() { | |
// get the filename | |
let args = os::args(); | |
let filename: &str = args.get(1).as_slice(); |
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
extern crate crypto = "rust-crypto"; | |
use std::os; | |
struct Keys { | |
AccessKey: String, | |
SecretKey: String, | |
} | |
pub fn env_keys() -> Option<Keys> { |