Skip to content

Instantly share code, notes, and snippets.

View sergio1990's full-sized avatar
🇺🇦

Serhii Herniak sergio1990

🇺🇦
View GitHub Profile
@sergio1990
sergio1990 / led-blink-ble-simplest-sketch.ino
Created February 3, 2018 13:24
Control LED via the Bluetooth channel using Arduino+HM-10 BLE board
@sergio1990
sergio1990 / config-ble.ino
Created February 1, 2018 20:54
Arduino UNO sketch to configure HM-10 BLE board
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
int i = 0;
void setup() {
mySerial.begin(9600);
Serial.begin(9600);
}
@sergio1990
sergio1990 / ItemOption.java
Created August 18, 2017 09:27
Custom editor for CMS Cockpit of the Hybris Platform
package com.mycompany.cms2components.data;
public class ItemOption {
private Integer id;
private String title;
private String description;
private String thumbUrl;
public ItemOption()
{
@sergio1990
sergio1990 / tmux_article.sh
Created August 1, 2017 09:17
Example, how to script tmux to recreate a session with predefined windows and panes
#!/bin/bash
PROJECT_NAME="article"
# Check if a session with a such name already exists
tmux has-session -t $PROJECT_NAME
# If session does not exists
if [ $? != 0 ]
then
@sergio1990
sergio1990 / .vimrc
Created July 31, 2017 13:54
Disable arrow keys in Vim
" Disable Arrow keys in Escape mode
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
" Disable Arrow keys in Insert mode
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
@sergio1990
sergio1990 / example_script.sh
Created March 15, 2017 14:47
Example of Docker as a Function
function install_mix_dependencies() {
echo "Starting installing MIX dependencies..."
docker run \
--rm --memory="512M" \
-w="/app" \
-v $PWD:/app \
-e MIX_ENV=prod \
--entrypoint=/app/docker/mix_deps_install.sh \
elixir:1.3.2
}
defmodule DynamicProcesses.Examples do
alias DynamicProcesses.{SomeSupervisor, SomeWorker}
import Supervisor.Spec
def add_single_supervisor(id \\ "1") do
{:ok, supervisor_spec} = build_supervisor_spec(SomeSupervisor, [], id)
Supervisor.start_child(DynamicProcesses.Supervisor, supervisor_spec)
end
defmodule DynamicProcesses do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
]
opts = [strategy: :one_for_one, name: DynamicProcesses.Supervisor]
module WithDefaultScopeExtension
def with_default_scope(scope_options, &block)
normalized_scope_options = Array(scope_options)
scope(*normalized_scope_options) do
instance_exec(&block)
end
end
end
ActionDispatch::Routing::Mapper.send :include, WithDefaultScopeExtension
@sergio1990
sergio1990 / config.ru
Created October 9, 2016 12:50
Map your entire Rails application inside given URL prefix
require ::File.expand_path('../config/environment', __FILE__)
map 'YOUR_PREFIX_HERE' do
run Rails.application
end