Skip to content

Instantly share code, notes, and snippets.

View edbond's full-sized avatar
🗽
Working from home

Eduard Bondarenko edbond

🗽
Working from home
View GitHub Profile
(defn query-node-with-path
([[ s & _ :as source ]
{type :type children :children wf :word-fragment :as node}
acc]
(prn "source " source)
(prn "s " s)
(prn "type " type)
(prn "node " node)
(prn "acc " acc)))
@edbond
edbond / core.clj
Last active December 31, 2015 22:18
SGS instaparse
(ns sgs.core
(:require [instaparse.core :as p]
[clojure.pprint :refer (pprint)]))
;; http://stackoverflow.com/questions/20654883/whats-an-elegant-way-to-parse-this-data-format-in-clojure
(def sgs
(p/parser
"
<SGS> = (<COMMENT_ROW> | ROW)+
@edbond
edbond / output.rb
Created December 17, 2013 14:44
pack links limited by line width
["YIIzO", "turcUUfN", "EhSethGlS", "p_fhwdsts", "C", "HRoz", "_QXH", "EFDMpgc", "N", "DbKdomnTiu", "CVtLGKsP", "MAZx", "rlLuMB", "qipauyMRkp", "t", "RV", "uIldIkV", "lKaYnIeWs", "_FKzuYmBMo", "SVlI", "vXwgdmxF", "UI", "bC lZ", "D", "zVHGWTtBD", "WQcf", "JzEAJ", "BLItG", "fvPqgfonB", "Uz_", "G", "w", "k", "qkbIEgNrQ", "pY", "CX", "OGw_", "TRJds", "vXLGltC_q", "KNnvml", "Se ED"]
{:vlazit=>["YIIzO", "turcUUfN"], :ne_vlazit=>["EhSethGlS", "p_fhwdsts", "C", "HRoz", "_QXH", "EFDMpgc", "N", "DbKdomnTiu", "CVtLGKsP", "MAZx", "rlLuMB", "qipauyMRkp", "t", "RV", "uIldIkV", "lKaYnIeWs", "_FKzuYmBMo", "SVlI", "vXwgdmxF", "UI", "bC lZ", "D", "zVHGWTtBD", "WQcf", "JzEAJ", "BLItG", "fvPqgfonB", "Uz_", "G", "w", "k", "qkbIEgNrQ", "pY", "CX", "OGw_", "TRJds", "vXLGltC_q", "KNnvml", "Se ED"], :length=>215}
@edbond
edbond / core.clj
Created December 10, 2013 11:13
snakeyaml
(ns snakeyaml-example.core
(:require [clojure.string :refer (split)])
(:import [org.yaml.snakeyaml.constructor SafeConstructor
AbstractConstruct Construct]
[org.yaml.snakeyaml.nodes Tag Node ScalarNode NodeId]
[snakeyaml-example.core Dice ConstructDice DiceConstructor]))
(set! *warn-on-reflection* true)
(gen-class
@edbond
edbond / core.cljs
Created August 16, 2013 19:57
clojurescript macros error
(ns platezhki.core
(:require [goog.events :as ev]
[goog.dom :as dom])
(:use-macros [platezhki.macros :only (inside)]))
;; Electricity
(defn log [& args]
(.log js/console args))
(inside ".electro" (log "OK")
@edbond
edbond / validate_ip.rb
Last active December 19, 2015 15:08
Regexp vs Exceptions for IPAddr validation
require 'ipaddr'
def by_exception ip
begin
IPAddr.new(ip, Socket::AF_INET)
true
rescue ArgumentError
false
end
end
#!/bin/python
import numpy as np
import talib
open, high, low, close = [......] # same arrays
cdl = talib.CDL3INSIDE(np.array(open), np.array(high), np.array(low), np.array(close))
print cdl
require 'thread/pool'
class ChartExport
def self._threads_test
a = Queue.new
1000.times {
pool = Thread.pool(10)
100.times {
pool.process { a << 1 }
}
@edbond
edbond / redshift.conf
Created January 29, 2013 20:27
redShift config
; Global settings
[redshift]
temp-day=6500K
temp-night=4500K
transition=1
gamma=0.8:0.7:0.8
;gamma=1.000:1.000:1.000
;location-provider=geoclue
location-provider=manual
adjustment-method=vidmode
@edbond
edbond / heads.rb
Created August 7, 2012 14:07
Headers
require 'pp'
h = [1, 2, 3, 1, 2, 3, 2, 1, 3, 2, 1]
opened = []
r = h.inject("") do |a, x|
# close tags if needed
while opened.last != nil && opened.last >= x
a << "</h#{opened.pop}>"