This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
curl -s -w "%{time_namelookup} %{time_connect} %{time_starttransfer} %{time_total}\n" -o /dev/null http://www.google.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$result = json_decode(file_get_contents('php://stdin')); | |
$dir = realpath(dirname(__FILE__)); | |
// check if there is new tweet | |
if($result->statuses[0]->id != file_get_contents($dir.'/latest_tweet_id.dat')){ | |
// record latest tweet id | |
file_put_contents($dir.'/latest_tweet_id.dat', $result->statuses[0]->id); | |
// iterate search result | |
$mail_body = ""; | |
$date = new DateTime(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:14.04 | |
RUN rm /bin/sh && ln -s /bin/bash /bin/sh | |
RUN apt-get -y update | |
RUN apt-get -y dist-upgrade | |
RUN apt-get -y install python-software-properties software-properties-common git-core curl wget gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev | |
RUN add-apt-repository -y ppa:brightbox/ruby-ng | |
RUN apt-get -y update | |
RUN apt-get -y install ruby2.1 ruby2.1-dev | |
#ENV PATH "/root/.rbenv/shims:~/.rbenv/bin:$PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# usage: | |
# ls -R | grep FOLDER_NAME_TO_SEARCH | ./this_script.sh TARGET_FILE.html | |
# Verify if the # of passed parameter is only 1 | |
if [ $# -ne 1 ]; then | |
echo "you must specify 1 parameter to grab file to be copied" | |
exit 0; | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# usage: | |
# ControlCrontab.sh [check|register] | |
if [ `echo $USER` != "hogehoge" ]; then | |
echo "you must be hogehoge!!!!" | |
exit 0 | |
fi | |
if [ $# -eq 1 ] && [ $1 = "check" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: curl -s http://api.stackoverflow.com/1.1/tags | gunzip | ruby add_ltsv_log_stackoverflow.rb | |
# note: works even with ruby 1.8.x | |
require 'SimpleJson_jp.rb' # downloaded from http://ruby-webapi.googlecode.com/svn/trunk/misc/SimpleJson/SimpleJson_jp.rb | |
src = ARGF.read | |
parser = JsonParser.new | |
json = parser.parse(src) | |
print Time.now.strftime("date:%Y-%m-%d\t") | |
json['tags'].each do |item| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'optparse' | |
separator = "," | |
source = false | |
ARGV.clone.options do |opts| | |
opts.banner = "Usage: #{$0} [options]" | |
opts.on('-f', '--file=/path/to/file', String, 'Source file'){|v| | |
source = v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# usage: | |
# check_disk_usage.sh <SERVER-NAME> | |
function check_disk_usage(){ | |
local TOTAL=`snmpget -On -c public -v 1 "${1}" UCD-SNMP-MIB::dskTotal.1 | awk '{print $4}'` | |
local AVAIL=`snmpget -On -c public -v 1 "${1}" UCD-SNMP-MIB::dskAvail.1 | awk '{print $4}'` | |
local USED=`snmpget -On -c public -v 1 "${1}" UCD-SNMP-MIB::dskUsed.1 | awk '{print $4}'` | |
local PERCENT=`snmpget -On -c public -v 1 "${1}" UCD-SNMP-MIB::dskPercent.1 | awk '{print $4}'` | |
echo HDD of ${1} is ${PERCENT}% used - Total:${TOTAL}, Avail:${AVAIL}, Used:${USED} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# usage: cat accumulated_number_data.ltsv | ruby calc_delta.rb | |
class LtsvDataLine | |
attr_accessor :data | |
def initialize(line) | |
@data = Hash.new | |
line.split("\t").each{|packet| | |
@data[packet.split(":")[0]] = packet.split(":")[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
Benchmark.ips do |x| | |
command = "bundle version" | |
yomikomu = "export RUBYOPT='-ryomikomu' && export YOMIKOMU_AUTO_COMPILE='true'" | |
yomikomanai = "export RUBYOPT='' && export YOMIKOMU_AUTO_COMPILE='false'" | |
x.report("yomikomanai") { p `#{yomikomanai} && #{command}` } | |
x.report("yomikomu(fs)") { p `#{yomikomu} && export YOMIKOMU_STORAGE='fs' && #{command}` } | |
x.compare! | |
end |
OlderNewer