Skip to content

Instantly share code, notes, and snippets.

View kumekay's full-sized avatar

Sergei Silnov kumekay

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / JoystickKeyboard.ino
Created February 23, 2016 10:26
Arduino micro sketch: using joystick as keyboard with arrows and enter
/*
Written by Sergei Silnov @kumekay po@kumekay.com
Based on:
https://github.com/NicoHood/HID/wiki/Keyboard-API#boot-keyboard
*/
#include "HID-Project.h"
const int pinLed = LED_BUILTIN;
@kumekay
kumekay / autossh.conf
Last active February 8, 2016 14:30
Reverse SSH tunnel with autossh started with upstart for ubuntu. Allows to connect to computer hidden behind NAT over SSH. Good replacement for vpn in some cases
# File: /etc/init/autossh.conf
# Start ssh tunnel after network for specified user
description "Start autossh reverse tunnel"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [016]
respawn
respawn limit 5 60