Skip to content

Instantly share code, notes, and snippets.

View elfenlaid's full-sized avatar
🐧
Slow Distillation ⚗️💭

Egor Mihnevich elfenlaid

🐧
Slow Distillation ⚗️💭
View GitHub Profile
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
module Bencoding where
import Control.Applicative
import Crypto.Hash.SHA1
import Data.Attoparsec.ByteString.Char8 (Parser)
import qualified Data.Attoparsec.ByteString.Char8 as P
import Data.ByteString as B
import Data.ByteString.Char8 as BC
######################
# Options
######################
REVEAL_ARCHIVE_IN_FINDER=false
FRAMEWORK_NAME="${PROJECT_NAME}"
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"
@elfenlaid
elfenlaid / client.hs
Last active August 29, 2015 14:17 — forked from mpickering/client.hs
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
module Main
( main
) where
--------------------------------------------------------------------------------
import Control.Concurrent (forkIO)
import Control.Applicative ((<$>))
@elfenlaid
elfenlaid / Fuckup.m
Created May 30, 2014 15:42
Simple copypaste became the reason of interesting debug story :)
+ (UIImage *)generatedBackground {
static NSArray *colors = nil;
if (!colors) {
colors = @[
[UIColor colorWithRed:0.957 green:0.138 blue:0.287 alpha:1.000],
...
[UIColor colorWithRed:0.972 green:0.207 blue:0.225 alpha:1.000],
];
}
@elfenlaid
elfenlaid / OperationExample.m
Created May 15, 2014 11:32
Operation example
@interface MyAsyncOperation ()
@property (nonatomic) BOOL isExecuting;
@property (nonatomic) BOOL isFinished;
@end
@implementation MyAsyncOperation
- (void)start {
self.isFinished = NO;
self.isExecuting = YES;
@elfenlaid
elfenlaid / translate.clj
Created March 24, 2014 13:47
first useful script on clojure :)
(ns translate.core
(:use clojure-csv.core))
(defonce store (parse-csv (slurp "resources/trans.csv")))
(def lang-shortcuts { "Russian" "ru"
"French" "fr"
"Italian" "it"
"German" "de"
"Spanish" "es"
@elfenlaid
elfenlaid / user.el
Last active January 3, 2016 12:29
Move region up\down
;;; Move region
(defun selected-text ()
(let ((text (if (region-active-p)
(vector (buffer-substring-no-properties (region-beginning) (region-end))
(region-beginning) (region-end))
nil)))
(if (null text) (unit-at-cursor 'line) text)))
(defun move-line (start end n)
@elfenlaid
elfenlaid / cvs_parse.clj
Last active December 31, 2015 17:19
clojure file processing
(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)))))
(defn parse-cvs [seq]
@elfenlaid
elfenlaid / lazy_file.clj
Last active December 31, 2015 15:28
lazy file
(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))))
@elfenlaid
elfenlaid / hcache.clj
Last active December 29, 2015 20:59
trying to get some fun with clojure
(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})))