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
use std::fmt::{ Debug, Display, Formatter, Result }; | |
use std::string::ToString; | |
#[derive(Debug)] | |
struct Slice<'a, T: 'a> { | |
data: &'a [T] | |
} | |
impl <'a, T: ToString> Display for Slice<'a, T> { | |
fn fmt(&self, f: &mut Formatter) -> Result { |
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
(require 'evil) | |
(setq evil-move-defun-alist | |
'((ruby-mode . (ruby-beginning-of-defun . ruby-end-of-defun)) | |
(c-mode . (c-beginning-of-defun . c-end-of-defun)) | |
(js2-mode . (js2-beginning-of-defun . js2-end-of-defun)))) | |
(defun evil-move-defun (count &optional begin-defun end-defun) | |
"Move by defun" | |
(let ((count (or count 1)) |
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
{-# LANGUAGE FlexibleContexts #-} | |
import Data.Conduit | |
import qualified Data.Conduit.List as CL | |
import Network.HTTP.Conduit | |
import Control.Concurrent.Async (mapConcurrently) | |
import Control.Concurrent.MVar | |
import Control.Monad.IO.Class (liftIO) | |
import Control.Monad.Trans.Control (MonadBaseControl) |
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
;; (defproject parallel-download "1.0.0-SNAPSHOT" | |
;; :description "FIXME: write description" | |
;; :dependencies [[org.clojure/clojure "1.3.0"] | |
;; [clj-http "0.2.7"] | |
;; [enlive "1.0.0-SNAPSHOT"]] | |
;; :dev-dependencies [[swank-clojure "1.3.4"]] | |
;; :main parallel-download.core) | |
(ns parallel-download.core | |
(:use [clojure.string :only (join split)] |
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
;; hyone's solution to Longest Increasing Sub-Seq | |
;; https://4clojure.com/problem/53 | |
(fn longest-inc-seq [coll] | |
(reduce #(let [len-a (count %1) | |
len-b (count %2)] | |
(if (and (> len-b 1) (> len-b len-a)) %2 %1)) | |
[] | |
(reductions | |
(fn [xs y] |
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
[package] | |
name = "http_request1" | |
version = "0.1.0" | |
[dependencies] | |
hyper = "*" |
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
[package] | |
name = "http_request2" | |
version = "0.1.0" | |
[dependencies] | |
futures = "*" | |
hyper = "0.11.0" | |
tokio-core = "*" |
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
use std::error::Error as StdError; | |
use std::env; | |
use std::fmt; | |
use std::fs::File; | |
use std::io::Error as ioError; | |
use std::io::prelude::*; | |
use std::path::Path; | |
macro_rules! eprintln { |
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
struct Sheep<'a> { naked: bool, name: &'a str } | |
trait Animal<'a> { | |
fn new(name: &'a str) -> Self; | |
fn name(&self) -> &str; | |
fn noise(&self) -> &str; | |
fn talk(&self) { | |
println!("{} says {}", self.name(), self.noise()); |
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
# iex -S mix | |
iex(1)> import Ecto.Query | |
nil | |
iex(2)> import Ecto.Adapters.SQL | |
nil | |
iex(3)> user_id = 2 | |
2 | |
iex(4)> q = from u in SampleApp.User, join: fu in assoc(u, :relationships), where: u.id == ^user_id, select: fu.id |
NewerOlder