Skip to content

Instantly share code, notes, and snippets.

View usametov's full-sized avatar

Ulan Sametov usametov

  • Asta Nova Enterprise Solutions
View GitHub Profile
@usametov
usametov / audio2midi.md
Created November 2, 2020 05:40 — forked from natowi/audio2midi.md
list of audio to midi packages
@usametov
usametov / home-server.md
Created October 26, 2020 15:15 — forked from nileshtrivedi/home-server.md
Home Server setup: Raspberry PI on Internet via reverse SSH tunnel

Raspberry Pi on Internet via reverse SSH tunnel

HackerNews discussed this with many alternative solutions: https://news.ycombinator.com/item?id=24893615

I already have my own domain name: mydomain.com. I wanted to be able to run some webapps on my Raspberry Pi 4B running perpetually at home in headless mode (just needs 5W power and wireless internet). I wanted to be able to access these apps from public Internet. Dynamic DNS wasn't an option because my ISP blocks all incoming traffic. ngrok would work but the free plan is too restrictive.

I bought a cheap 2GB RAM, 20GB disk VM + a 25GB volume on Hetzner for about 4 EUR/month. Hetzner gave me a static IP for it. I haven't purchased a floating IP yet.

(defn rows->maps [csv]
(let [headers (map keyword (first csv))
rows (rest csv)]
(map #(zipmap headers %) rows)))
(ns clojure-elasticsearch.core
(:require [clojurewerkz.elastisch.rest :as esr]
[clojurewerkz.elastisch.rest.index :as idx]
[clojurewerkz.elastisch.rest.document :as doc]
[clojurewerkz.elastisch.query :as q]))
(def index-name "test")
(def type "articles")
(def query "third")
@usametov
usametov / ecverify.sol
Created September 8, 2020 22:51 — forked from axic/ecverify.sol
Ethereum ECVerify
//
// The new assembly support in Solidity makes writing helpers easy.
// Many have complained how complex it is to use `ecrecover`, especially in conjunction
// with the `eth_sign` RPC call. Here is a helper, which makes that a matter of a single call.
//
// Sample input parameters:
// (with v=0)
// "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad",
// "0xaca7da997ad177f040240cdccf6905b71ab16b74434388c3a72f34fd25d6439346b2bac274ff29b48b3ea6e2d04c1336eaceafda3c53ab483fc3ff12fac3ebf200",
// "0x0e5cb767cce09a7f3ca594df118aa519be5e2b5a"
"""
Bars indexed by total volume, with each set # of shares traded creating a distinct bar.
We can transform minute bars into an approximation for volume bars, but ideally we would use tick bars
to maintain information for all parameters across bars.
Let's set a target bar volume equal to the maximum minutely volume in our dataset
(otherwise we'd have to split minute bars, which we can't).
Then, we construct our bars in such a way as to minimize the distance from this target:
Combine minute bars while maintaining the time of the first and final minutes,
adding volume of bars together, and keeping track of the high and low over the interval.

Looking up documentation

The REPL can also be used for looking up API documentation, using the clojure.repl lib. Evaluate the following expression at the REPL:

user=> (require '[clojure.repl :refer :all])

This expression makes all the names defined in the clojure.repl namespace available in the REPL. doc

to evaluate the whole buffer use <localleader>eb
to evaluate the inner form use <localleader>ee
to open the log buffer horizontally (<localleader>ls),
vertically (<localleader>lv) or
in a tab (<localleader>lt)
All visible log windows (including the HUD) can be closed with <localleader>lq
# pip install python-twitter
# pip install nltk
# python -m nltk.downloader vader_lexicon
# pip install matplotlib
# pip install seaborn
import twitter
import os
import datetime
import nltk
# https://stackoverflow.com/questions/1143671/how-to-sort-objects-by-multiple-keys-in-python/29849371
people = [
{ 'name': 'John', "age": 64 },
{ 'name': 'Janet', "age": 34 },
{ 'name': 'Ed', "age": 24 },
{ 'name': 'Sara', "age": 64 },
{ 'name': 'John', "age": 32 },
{ 'name': 'Jane', "age": 34 },
{ 'name': 'John', "age": 99 },