Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀

Sergei Silnov kumekay

🦀
View GitHub Profile
@kumekay
kumekay / erlang.sh
Created Oct 18, 2017
Ubuntu 16.04 (including WSL) Erlang compilation rather minimal dependencies
View erlang.sh
#!/bin/bash
sudo apt update
sudo apt install -y build-essential autoconf libncurses5-dev libssh-dev
@kumekay
kumekay / domains.js
Created Oct 1, 2017
Extract all domains through browser console
View domains.js
let links = document.querySelectorAll( "a" );
let hosts = []
links.forEach ( (l) => { hosts.push(l.host.replace("www.", ""))})
const domains = new Set(hosts)
domains.join("\n")
View apas_test_client.rb
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
View cnn.py
'''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
View 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 Jul 25, 2016
Web camera on Intel Edison with uploads to s3
View snapshot.sh
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 Mar 29, 2016 — forked from cromwellryan/parser.ex
JSON Parser in Elixir
View parser.ex
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 Feb 23, 2016
Arduino micro sketch: using joystick as keyboard with arrows and enter
View JoystickKeyboard.ino
/*
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 Feb 8, 2016
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
View autossh.conf
# 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
@kumekay
kumekay / pushme.py
Last active Feb 7, 2016
Pushbullet snippet for python
View pushme.py
# coding: utf-8
# ## Pushbullet routine
# usage:
#
# import sys
# sys.path.insert(0, '../tools')
# from tools.pushme import pushme
# pushme('anna', 'title', 'body')
# pushme('anna','accuracy', str(0.25))