Skip to content

Instantly share code, notes, and snippets.

Eduard Bondarenko edbond

  • Kiev, Ukraine
Block or report user

Report or block edbond

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@edbond
edbond / arrvsset.rb
Created Mar 29, 2018
Array include vs Set include
View arrvsset.rb
# frozen_string_literal: true
require 'set'
require 'benchmark/ips'
ARRAY = 100_000.times.map(&:itself)
SET = Set.new(ARRAY)
def array_include?
ARRAY.include?(50_000)
View rails41_jsonb.rb
Rails.application.config.after_initialize do
ActiveSupport.on_load(:active_record) do
oid = ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID
# https://github.com/rails/rails/blob/v4.2.3/activerecord/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb
oid::Jsonb = Class.new(oid::Json) do
def type
:jsonb
end
View spyke.rb
class JSONParser < Faraday::Response::Middleware
def parse(body)
json = MultiJson.load(body, symbolize_keys: true)
{
data: json[:result],
metadata: json[:extra],
errors: json[:errors]
}
@edbond
edbond / doc.md
Last active Sep 9, 2018
external JS with react-native, clojurescript and re-natal
View doc.md
View transit vs json vs edn
Ξ transit/transit-cljs → node target/transit.bench.js
100 iters, JSON.parse seattle data
"Elapsed time: 81.000000 msecs"
100 iters, transit read seattle data
"Elapsed time: 105.000000 msecs"
100 iters, JSON.stringify seattle data
"Elapsed time: 44.000000 msecs"
100 iters, transit write seattle data
"Elapsed time: 1204.000000 msecs"
100 iters, transit write seattle data no-cache
View screenshots.clj
(defn make-screenshots-xf []
(fn [xf]
(let [_ (debug "Starting new browser")
browser (new-driver {:browser :chrome})]
(debug "New browser Maximize")
(maximize browser)
(fn
([]
(debug "Init")
(xf))
@edbond
edbond / relax.clj
Created Oct 29, 2015
Download youtube mp3 from playlists on radiorelax.ua site
View relax.clj
(ns relaxfm.core
(:gen-class)
(:require [hickory.core :as hc]
[hickory.select :as hs]
[clj-http.client :as http]
[clojure.string :as s]
[clojure.java.shell :as sh]
[clj-time.core :as t]
[clj-time.format :as tf]
[clj-time.coerce :as tc]))
@edbond
edbond / comment.cljs
Created Aug 29, 2015
Render React component from Om
View comment.cljs
(ns nhchat.components.comment
(:require [om.core :as om]
[om-tools.core :refer-macros [defcomponent]]
[sablono.core :refer-macros (html)]))
(enable-console-print!)
(defcomponent wrapper [{:keys [comment]} owner]
(render [_]
(html [:div]))
@edbond
edbond / int_str.clj
Created Apr 17, 2015
int to "localized" string in ClojureScript
View int_str.clj
(def i 343224324234)
(defn int->str-1
[]
(let [s (str i) p (mod (count s) 3)]
(->>
(reduce-kv
(fn [acc i c]
(if (and (> i 0) (zero? (mod (- i p) 3)))
(conj acc \, c)
View kittens.clj
(ns kittens.core
(:require [environ.core :refer (env)]
[clj-http.client :as http]
[clojure.java.io :as io]
[clojure.core.async :as async :refer (go go-loop <!)]))
(def api-key (-> env :dev :flickr :api-key))
(def rest-api-url "https://api.flickr.com/services/rest/")
(def folder "photos")
You can’t perform that action at this time.