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
(ns chan-test.core | |
(:gen-class) | |
(:require [clojure.core.async :as async] | |
[kuroshio.core :as k])) | |
(defn create-string [] | |
(apply str (take 10000 (repeat ".\r\n")))) | |
(defn println-err [& args] | |
(binding [*out* *err*] |
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
import urllib.request | |
address = 'http://apod.nasa.gov/apod/astropix.html' | |
file = urllib.request.urlopen(address) #read in the site and hunt for the image url | |
html = file.read() | |
data = html.decode('utf-8') | |
#print (data) | |
s = data.find("<a href=\"image")+14 #find the first instance of the image hyperlink |
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
(set 'cleanmode 1) | |
(defun toggle-cleanmode () | |
"toggles clean mode" | |
(interactive) | |
(cond ((not cleanmode) | |
(menu-bar-mode -1) | |
(tool-bar-mode -1) | |
(scroll-bar-mode -1) | |
(set 'cleanmode 1)) | |
((eq 1 cleanmode) |
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
(defun rust-save-compile-and-run-this () | |
(interactive) | |
(save-buffer) | |
(compile | |
(format "rustc %s && %s" | |
(buffer-file-name) | |
(file-name-sans-extension (buffer-file-name))))) | |
(defun rust-save-compile-and-run () | |
(interactive) |
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
(defn lazy-re [re pp] | |
(let [re-m (re-matcher re pp) | |
re-cm #(re-find re-m) | |
call-lzre | |
(fn step [] | |
(lazy-seq | |
(when-let [r (re-cm)] | |
(cons r | |
(step)))))] | |
(call-lzre))) |
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
(ns github | |
"pull in github source files and gist content | |
malformed api calls, invalid resource uri, and rate-limiting should return nil" | |
(:require [cheshire.core :as json] | |
[clojure.string :as string]) | |
(:import (org.apache.commons.codec.binary Base64 StringUtils))) | |
(defn get-gist [gist-uri] | |
(let [gist-id (last (string/split gist-uri #"/+")) ;;just need id for git api | |
gist-resp (try (slurp (str "https://api.github.com/gists/" gist-id)) |
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
import urllib.request | |
address = 'http://apod.nasa.gov/apod/astropix.html' | |
file = urllib.request.urlopen(address) #read in the site and hunt for the image url | |
html = file.read() | |
data = html.decode('utf-8') | |
#print (data) | |
s = data.find("<a href=\"image")+14 #find the first instance of the image hyperlink |
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::sync::atomic::{AtomicBool,Ordering}; | |
use std::sync::{Arc, RWLock}; | |
struct Latch { | |
latch:Arc<AtomicBool>, | |
} | |
impl Latch { | |
fn new () -> Latch { | |
Latch {latch:Arc::new(AtomicBool::new(false))} |
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
import boto.ec2 | |
import sys | |
def get_snaps (desc, vol,conn): | |
snapshots = conn.get_all_snapshots(owner='id...', | |
filters={'description':'*'+desc+'*'}) | |
return snapshots | |
def op_snaps (vols,max_snaps,conn): |
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(core)] | |
extern crate core; | |
use self::core::num::Int; | |
fn rng<T:PartialEq+Int, F:FnMut(T)> (d:T,dt:T,mut f:F) { | |
if d>dt { for n in (dt..d).rev() { f(n); } } | |
else { for n in (d..dt) { f(n); } } | |
} | |
fn main () { |