Skip to content

Instantly share code, notes, and snippets.

@dbaba
dbaba / gist:b6318772c6d67d3eba24
Created December 11, 2014 06:07
Fetching TXT records with dnsjava
final Lookup lookup = new Lookup("my-txt.example.com", Type.TXT);
lookup.setResolver(new SimpleResolver());
lookup.setCache(null);
final Record[] records = lookup.run();
if (lookup.getResult() == Lookup.SUCCESSFUL) {
final StringBuilder builder = new StringBuilder();
for (Record record : records) {
final TXTRecord txt = (TXTRecord) record;
builder.delete(0, builder.length());
for (@SuppressWarnings("unchecked")
@dbaba
dbaba / test
Last active August 29, 2015 14:08
self.client = [[MQTTClient alloc]initWithClientId: @"iosapp" cleanSession:YES];
self.client.username = @"sohta2@github";
self.client.password = <パスワード>;
NSLog(@"publishToBroker!!!");
NSLog(@"%@", gMQTTHost);
[self.client connectToHost:gMQTTHost completionHandler:^(NSUInteger code) {
NSLog(@"%lu", (unsigned long)code);
if(code == ConnectionAccepted) {
NSLog(@"connect accepted!");
@dbaba
dbaba / Run File or Spec
Created September 25, 2014 08:57
javascript-node.tmbundle fix. Make sure 'Output' is 'Show in New Window' and 'Format' is 'HTML' in Bundle Editor.
#!/usr/bin/env ruby18 -wKU
require "#{ENV["TM_SUPPORT_PATH"]}/lib/escape"
require "#{ENV['TM_SUPPORT_PATH']}/lib/tm/save_current_document"
require "#{ENV["TM_SUPPORT_PATH"]}/lib/tm/executor"
TextMate.save_if_untitled('node')
TextMate::Executor.run(e_sh("node"), ENV['TM_FILEPATH'], :version_args => '-v', :version_regex => /(\w+ [\d.]+).*/)
@dbaba
dbaba / b2d_synctime.sh
Created September 7, 2014 06:32
To sync system clock on Boot2docker instance. Run this from the guest OS.
#!/bin/sh
ID_FILE_PATH=~/.ssh/id_boot2docker
B2D_PORT=2022
NTP_SERVER=time.asia.apple.com
CMD="sudo ntpclient -s -h ${NTP_SERVER}"
ssh -i ${ID_FILE_PATH} -p ${B2D_PORT} -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" docker@localhost "${CMD}"
input {
stdin {
type => "stdin-type"
}
file {
type => "syslog"
path => [ "/var/log/*.log", "/var/log/messages", "/var/log/syslog" ]
start_position => "beginning"
}
@dbaba
dbaba / logstash.conf
Created July 7, 2014 13:02
LogStash configuration file for Storm
input {
stdin {
type => "stdin-type"
}
file {
type => "syslog"
path => [ "/var/log/*.log", "/var/log/messages", "/var/log/syslog" ]
start_position => "beginning"
}
@dbaba
dbaba / gist:0678d88855fbe130e73b
Created July 3, 2014 02:41
SCP to a Boot2docker instance
scp -i ~/.ssh/id_boot2docker -P 2022 file-to-upload docker@localhost:~
#!/bin/sh
# a resolution to the eclipse hanging issue
# http://stackoverflow.com/questions/8972034/eclipse-hangs-on-loading-workbench
# modify here as you like.
ECLIPSE_WS=$HOME/Documents/workspace
rm -f $ECLIPSE_WS/.metadata/.lock
rm -f $ECLIPSE_WS/.metadata/.plugins/org.eclipse.core.resources/.snap
@dbaba
dbaba / sound.sh
Created April 18, 2014 06:19
Notification sound shell for command line users
#!/bin/bash
# Example:
# $ scons && ~/sound.sh
# $ mvn clean deploy && ~/sound.sh Basso
VOL=6
SND=$1
if [ -z $SND ]; then
@dbaba
dbaba / route53.rb
Created August 4, 2013 02:34
A lightweight client for Amazon Route53 with Amazon OpsWorks + Chef11, where the latest Fog + Nokogiri don't work because of forcedly installed Ruby 1.8.7 (Enterprise). Put this file in `libraries` folder and you can create/delete resource recordsets. Some of source codes are imported from Fog (https://github.com/fog/fog). Change and use this as…
require 'time'
require 'base64'
require 'net/http'
require 'net/https'
require 'openssl'
require 'uri'
module Route53
class Client