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
(defn lazy-open [file] | |
(letfn [(helper [rdr] | |
(lazy-seq | |
(if-let [line (.readLine rdr)] | |
(cons line (helper rdr)) | |
(do (.close rdr) (println "closed") nil))))]) | |
(do (println "opening") | |
(helper (clojure.java.io/reader file)))) |
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
(ns hcache.core | |
(:require [clj-http.lite.client :as client] | |
[clojure.string :as string] | |
[clojure.core.async :as async :refer [>! <! >!! <!! go chan]]) | |
(:import (java.io File))) | |
(def h {"User-Agent" "Mozilla/5.0 (Windows NT 6.1;) Gecko/20100101 Firefox/13.0.1"}) | |
(defn page [url] | |
(:body (client/get url {:headers h}))) |
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 grequests | |
urls = [ | |
'http://www.heroku.com', | |
'http://python-tablib.org', | |
'http://httpbin.org', | |
'http://python-requests.org', | |
'http://kennethreitz.com' | |
] |
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
(defn board-step [board] | |
(let [live-cell \# | |
dead-cell \space | |
live-cell? (fn [cell] (= cell live-cell)) | |
transit-cell (fn [cell live-neib] | |
(if (live-cell? cell) | |
(cond | |
(< live-neib 2) dead-cell | |
(> live-neib 3) dead-cell | |
:else live-cell) |
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
(defn one-or-no-letter-diff? [a b] | |
(loop [xs (seq a) | |
ys (seq b)] | |
(cond | |
(= xs ys) true | |
(and (empty? xs) (= (count ys) 1)) true | |
(and (empty? ys) (= (count xs) 1)) true | |
(= (first xs) (first ys)) (recur (rest xs) (rest ys)) | |
:else (or (= (rest xs) ys) (= (rest ys) xs) (= (rest xs) (rest ys)))))) |
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
( | |
#((if (odd? %2) | |
(conj %1 %2) ; а почему тут кложура пытается чо та эвалюэйтить? я ж всего навсего пытаюсь лист вернуть | |
%1)) | |
'() | |
1) | |
; ClassCastException clojure.lang.PersistentList cannot be cast to clojure.lang.IFn | |
; ды, не самый удачный пример) я фкурси про всякие та filter и т.д., |
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
<?xml version="1.0"?> | |
<root> | |
<item> | |
<name>Shifts to Parentheses</name> | |
<appendix>Shifts, when pressed alone, type parentheses. When used with other keys they're normal shifts.</appendix> | |
<identifier>private.shifts_to_parens</identifier> | |
<!-- This is the basic mapping. --> | |
<autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::NONE, KeyCode::SHIFT_R, KeyCode::KEY_0, ModifierFlag::SHIFT_L</autogen> |
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
// Here a cave in which live all runtime dragons and wizards | |
#include <objc/runtime.h> | |
// We can swap instance methods, they start with '-' minus sign, you know | |
static void instance_methods_swap(id object, SEL firstSel, SEL secondSel) { | |
method_exchangeImplementations( | |
class_getInstanceMethod(object, firstSel), | |
class_getInstanceMethod(object, secondSel)); | |
} |
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
- (void)presentPicker | |
{ | |
[Flurry logEvent:@"Picker presented"]; | |
self.picker = | |
[[[MPMediaPickerController alloc] | |
initWithMediaTypes: MPMediaTypeAnyAudio] autorelease]; | |
[picker setDelegate:self]; | |
[picker setAllowsPickingMultipleItems:NO]; | |
picker.prompt = @"Choose sound to process"; |
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
@interface MediaPicker() | |
@property (nonatomic, retain) MPMediaPickerController *picker; | |
@end | |
@implementation PYSMediaPicker | |
@synthesize picker; | |
@synthesize delegate; | |