Skip to content

Instantly share code, notes, and snippets.

View PetrGlad's full-sized avatar
🚶‍♂️
.

Petr Gladkikh PetrGlad

🚶‍♂️
.
  • 09:27 (UTC +04:00)
View GitHub Profile
;; In "pil +"
(be aaa (1 2))
(be aaa (2 3))
(be aaa (@X @Z) (@X @Y) (@Y @Z))
(? (aaa 1 4))
;; After last line process completely hangs taking 100% CPU.
;; I cannot even kill it except "kill -9"
;; A version of zipper that allows mixing maps and vectors
;; Note that it traverses map entries too
(require '[clojure.zip :as z])
(defn map-vec-zipper [m]
(z/zipper
(fn [x] (or (map? x) (sequential? x)))
seq
(fn [p xs]
(if (isa? (type p) clojure.lang.MapEntry)
(into [] xs)
(require '[manifold.deferred :as d])
(require '[manifold.stream :as s])
(require '[aleph.http :as http])
(require '[clojure.core.async :as a])
(require '[byte-streams :as bs])
(def oauth-token "asdfasdfsadfasdfasdfsadfsad")
(defn get-stream []
(http/request
@PetrGlad
PetrGlad / Read GPIO sensor.py
Last active November 22, 2016 23:27
RaspberryPi tips
import RPi.GPIO as GPIO
import time
import sys
pir = int(sys.argv[1])
GPIO.setmode(GPIO.BCM)
GPIO.setup(pir, GPIO.IN)
print("PIN", pir)
print
@PetrGlad
PetrGlad / luks-mount.sh
Created November 20, 2016 14:34
LUKS mount howto
# <requires root>
apt install cryptsetup
blkid | grep 'crypto_LUKS'
# encrypted device --> LUKS device mapper --> mapped device --> mount
# to mount
cryptsetup luksOpen /dev/sda1 my-decrypted-storage
mount -t auto /dev/mapper/my-decrypted-storage /media/storage
@PetrGlad
PetrGlad / ArrayAdd.java
Created November 1, 2016 21:39
Array add - interview task
package com.company;
import java.util.Arrays;
public class ArrayAdd {
public static int[] incArray(int[] digits, int base) {
assert base > 0;
final int[] result = new int[digits.length + 1];
int carry = 1; // Increment value
for (int i = digits.length - 1; i >= 0; i--) {
@PetrGlad
PetrGlad / profile.clj
Last active February 15, 2017 14:16
My Leiningen profile
{:user {:dependencies [[pjstadig/humane-test-output "0.8.1"]]
:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]
:plugins [[lein-auto "0.1.2"]
[jonase/eastwood "0.2.3"]
[lein-kibit "0.1.2"]
[lein-ancient "0.6.10"]
[lein-cloverage "1.0.9"]
[lein-environ "1.1.0"]
[lein-pprint "1.1.2"]
docker create -p 127.0.0.1:5000:5000 --name registry registry
docker start registry
@PetrGlad
PetrGlad / psql-password-env.sh
Created August 24, 2016 10:47
psql-password
export PGPASSWORD=a-postgres-password