Skip to content

Instantly share code, notes, and snippets.

View kumekay's full-sized avatar

Sergei Silnov kumekay

View GitHub Profile
@kumekay
kumekay / parser.ex
Last active March 29, 2016 19:11 — forked from cromwellryan/parser.ex
JSON Parser in Elixir
defmodule JSON do
import String
def parse( content ) do
case parse_content(content) do
{ value, "" } -> value
{ _, _ } -> raise "crap"
end
end
@kumekay
kumekay / snapshot.sh
Last active July 25, 2016 19:56
Web camera on Intel Edison with uploads to s3
photo_timestamp=$(date +%Y-%m-%d_%H%M)
fswebcam -r 1280x720 --jpeg 100 -D 3 -S 13 "${photo_timestamp}.jpg"
aws s3 cp "$photo_timestamp.jpg" "s3://$s3_bucket" && \
aws s3 cp "$photo_timestamp.jpg" "s3://$s3_bucket/latest.jpg" --acl public-read && \
rm "$photo_timestamp.jpg"
@kumekay
kumekay / video2images.sh
Created August 6, 2016 13:43
video2images.sh
INPUT_VIDEO=$1
VIDEO_LENGTH="$(ffprobe -i input.mp4 -show_format | grep duration | sed 's/[A-Za-z=]*//g')"
ffmpeg -i $INPUT_VIDEO -vf fps=40/$VIDEO_LENGTH out/frame%02d.jpg
@kumekay
kumekay / cnn.py
Last active August 6, 2016 15:20
'''Neural style transfer with Keras.
Before running this script, download the weights for the VGG16 model at:
https://drive.google.com/file/d/0Bz7KyqmuGsilT0J5dmRCM0ROVHc/view?usp=sharing
(source: https://gist.github.com/baraldilorenzo/07d7802847aaad0a35d3)
and make sure the variable `weights_path` in this script matches the location of the file.
Run the script with:
```
python neural_style_transfer.py path_to_your_base_image.jpg path_to_your_reference.jpg prefix_for_results
@kumekay
kumekay / apas_test_client.rb
Created December 20, 2016 01:51
Apas test client
require 'socket'
server = TCPSocket.open(ENV.fetch('APAS_TCP_SERVER', 'localhost'),
ENV.fetch('APAS_TCP_PORT', '4040'))
ready = server.gets(5)
puts ready
loop do
msg = rand > 0.1 ? "AT_pour_amb=#{100 + rand(200).to_i};" : 'AT_bottle_changed=1;'
server.print(msg)
puts msg
@kumekay
kumekay / domains.js
Created October 1, 2017 15:13
Extract all domains through browser console
let links = document.querySelectorAll( "a" );
let hosts = []
links.forEach ( (l) => { hosts.push(l.host.replace("www.", ""))})
const domains = new Set(hosts)
domains.join("\n")
@kumekay
kumekay / erlang.sh
Created October 18, 2017 16:17
Ubuntu 16.04 (including WSL) Erlang compilation rather minimal dependencies
#!/bin/bash
sudo apt update
sudo apt install -y build-essential autoconf libncurses5-dev libssh-dev
@kumekay
kumekay / rename_phoenix_project.sh
Last active November 7, 2021 06:13 — forked from nerdyworm/rename.sh
rename a phoenix 1.3 project
#!/bin/bash
set -e
CURRENT_NAME="CurrentName"
CURRENT_OTP="current_name"
NEW_NAME="NewName"
NEW_OTP="new_name"
@kumekay
kumekay / bme280.rb
Last active March 17, 2018 16:06
mruby + esp32 + thingspeak @ wroc_love.rb 2018
include ESP32
API_KEY = "****"
SSID = "****"
PASS = ""****"
i2c = I2C.new(I2C::PORT0, scl: 22, sda: 21).init(I2C::MASTER)
bme280 = SENSOR::BME280.new(i2c, 0x76)
bme280.init
@kumekay
kumekay / change_eb_ruby_version.sh
Last active March 19, 2019 21:41 — forked from januszm/change_eb_ruby_version.sh
Change Ruby minor version in AWS Elastic Beanstalk
# Currently (03.2019) it's not possible to change the Ruby 'minor' version (eg. 2.3 => 2.4) using the web console
# However, it's possible using the 'awscli' tool.
# List of available platforms: https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.ruby
brew install awscli # pip install awscli
aws elasticbeanstalk update-environment \
--solution-stack-name "64bit Amazon Linux 2018.03 v2.9.1 running Ruby 2.6 (Puma)" \
--environment-name "***-dev-web" --region "us-east-1" --profile "***-dev"