Skip to content

Instantly share code, notes, and snippets.

kntyskw /
Created Jun 26, 2018
DLNA対応TVをSORACOM Inventoryに登録してWebコンソールから操作する ref:
import org.fourthline.cling.UpnpService;
import org.fourthline.cling.UpnpServiceImpl;
import org.fourthline.cling.model.message.header.STAllHeader;
import org.yasukawa.inventory.upnp.InventoryUpnpRegistryListener;
import org.yasukawa.inventory.upnp.UpnpController;
public class App {
public static void main(String[] args) throws Exception {
View file0.txt
$ npm install node-upnp-ssdp upnp-device-client
kntyskw / gist:40d144e47ed0067e125b
Created Dec 13, 2015
UPnP-MQTT Gateway connecting via SORACOM Beam to AWS IoT
View gist:40d144e47ed0067e125b
var ssdp = require('node-upnp-ssdp');
var UPnPDeviceClient = require('upnp-device-client');
var mqtt = require('mqtt');
var clientId = 'kenta-upnp-gateway';
var mqttOptions = { clientId: clientId };
var mqttEndpoint = 'mqtt://';
var mqttClient = mqtt.connect(mqttEndpoint, mqttOptions);
kntyskw /
Last active Aug 29, 2015
Downloads docker registry container image archive from the bucket specified by environment variable DOCKER_REGISTRY_BUCKET and import it to docker.
# Check if the registry image is already installed
IS_INSTALLED=`docker images | grep -E 'registry\s*latest' | wc -l`
if [ $IS_INSTALLED == 0 ]; then
. /opt/elasticbeanstalk/hooks/
# Load ElasticBeanstalk environment variables
touch /tmp/
kntyskw /
Last active Jan 3, 2016
Starts private docker repository backed by S3 on ElasticBeanstalk environment. It is supposed to launch before the application container is launched so that the application container image can be pulled from the local private repository.
. /opt/elasticbeanstalk/hooks/
# Load ElasticBeanstalk environment variables
touch /tmp/
chmod 600 /tmp/
jq .docker.env[] $EB_CONFIG_FILE | tr -d \" > /tmp/
kntyskw / assign_EIPs.rb
Last active Dec 20, 2015
Assign EIPs given from the standard input to ENIs assigned to the instance
View assign_EIPs.rb
#!/bin/env ruby
require 'rubygems'
require 'aws-sdk'
@ec2 ={:region => ENV['AWS_DEFAULT_REGION']})
@eips_to_assign = ARGV # [EIP1 EIP2 EIP3 EIP4 ...]
def self.main
kntyskw /
Last active Jan 29, 2020
Script to enable IP multicast without using Ethernet broadcast. It uses tc mirred and pedit actions to copy and edit an IP multicast packet to send over multiple Ethernet unicast frames. It requires two network interfaces to work. One is the interface to grab original multicast packets from and the other is to send out modified packets. This is …
[[ -n "$1" && -n "$2" ]] || { echo "Usage: $0 <interface to grab multicast packets from> <interface to send modified packets to> [target MAC address 1] [target MAC address 2] ..."; exit 0 ; }
SRC_MACADDR=`ip link show $OIF | awk '/ether/ {print $2}' | tr -d :`
View Assign me a VIP
# Determine the interface's MAC address
MAC=`ip link show $IF | awk '/ether/ {print $2}'`
# Determine ENI ID of the interface
View Get neighbour mac addresses
# Gets MAC address of the interface
MY_MAC_ADDR=`ip link show $IF | awk '/ether/ {print $2}'`
# Get the ID of the subnet that the interface is connected to
MY_SUBNET_ID=`curl$MY_MAC_ADDR/subnet-id 2> /dev/null`
kntyskw / gist:5394696
Created Apr 16, 2013
Add a routing table and iptables rule to route specified packets via LVS
View gist:5394696
ip route flush table $TABLE
ip route show | grep -Ev ^default | while read ROUTE; do
ip route add table $TABLE $ROUTE
ip route add table $TABLE default via $LVS_IP
ip rule del from all fwmark 1
You can’t perform that action at this time.