Skip to content

Instantly share code, notes, and snippets.

kntyskw

Block or report user

Report or block kntyskw

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kntyskw
kntyskw / App.java
Created Jun 26, 2018
DLNA対応TVをSORACOM Inventoryに登録してWebコンソールから操作する ref: https://qiita.com/kntyskw/items/bae6ef159ebd6af5c6e4
View App.java
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
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://beam.soracom.io';
var mqttClient = mqtt.connect(mqttEndpoint, mqttOptions);
@kntyskw
kntyskw / install_registry_image.sh
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.
View install_registry_image.sh
#!/bin/sh
# 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/common.sh
# Load ElasticBeanstalk environment variables
touch /tmp/env.sh
@kntyskw
kntyskw / start_docker_registry_on_eb.sh
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.
View start_docker_registry_on_eb.sh
#!/bin/bash
. /opt/elasticbeanstalk/hooks/common.sh
# Load ElasticBeanstalk environment variables
touch /tmp/env.sh
chmod 600 /tmp/env.sh
jq .docker.env[] $EB_CONFIG_FILE | tr -d \" > /tmp/env.sh
@kntyskw
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 = AWS::EC2.new({:region => ENV['AWS_DEFAULT_REGION']})
@eips_to_assign = ARGV # [EIP1 EIP2 EIP3 EIP4 ...]
DEBUG=false
def self.main
@kntyskw
kntyskw / ec2_multicast.sh
Last active Aug 6, 2019
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 …
View ec2_multicast.sh
#!/bin/sh
[[ -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 ; }
IIF=$1
OIF=$2
shift
shift
SRC_MACADDR=`ip link show $OIF | awk '/ether/ {print $2}' | tr -d :`
View Assign me a VIP
#!/bin/sh
VIP=$1
IF=$2
# Determine the interface's MAC address
MAC=`ip link show $IF | awk '/ether/ {print $2}'`
# Determine ENI ID of the interface
ENI_ID=`curl http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC/interface-id`
View Get neighbour mac addresses
#!/bin/sh
IF=$1
# 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 http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MY_MAC_ADDR/subnet-id 2> /dev/null`
@kntyskw
kntyskw / gist:5394696
Created Apr 16, 2013
Add a routing table and iptables rule to route specified packets via LVS
View gist:5394696
#!/bin/sh
LVS_IP=172.31.24.1
TABLE=1
ip route flush table $TABLE
ip route show | grep -Ev ^default | while read ROUTE; do
ip route add table $TABLE $ROUTE
done
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.