Skip to content

Instantly share code, notes, and snippets.

View tilfin's full-sized avatar

Toshimitsu Takahashi tilfin

View GitHub Profile
@tilfin
tilfin / createHTMLNotification.js
Last active April 7, 2022 03:25
It is to easily pass data to notification html at createHTMLNotification for Chrome Extension. The way is to store data as JSON string in location.hash.
var data = { image: "image.jpg", text: "text..." };
var popup = webkitNotifications.createHTMLNotification(
'notification.html#' + encodeURIComponent(JSON.stringify(data)) );
@tilfin
tilfin / gist:5004848
Created February 21, 2013 13:50
Daemon program control script example (bash)
#!/bin/bash
prgfile=<Program Script filepath>
pidfile=<PID filepath>
start() {
if [ -f $pidfile ]; then
pid=`cat $pidfile`
kill -0 $pid >& /dev/null
if [ $? -eq 0 ]; then
@tilfin
tilfin / UIColorSelector.html
Created February 28, 2013 07:45
UIColor Selector HTML page
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=0.8, user-scalable=yes" />
<title>UIColorSelector</title>
<style type="text/css">
<!--
body, input { font-size:12pt }
input[type="range"] { width:256px; }
th, td {
@tilfin
tilfin / gist:5915842
Created July 3, 2013 06:28
daily-rotate S3 buckets such as for backup
#!/bin/bash
S3Buckets=("us-west1" "us-east1" "singapore")
MaxAge=7
epochsec=`date +"%s"`
epochday=$((epochsec / 86400))
dayidx=$((epochday % MaxAge))
bknum=${#S3Buckets[@]}
@tilfin
tilfin / mongodb
Last active December 19, 2015 09:39
init script for mongodb
#!/bin/sh
### BEGIN INIT INFO
# Provides: mongod
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start mongod at boot time
# Description: Enable service provided by mongod.
@tilfin
tilfin / app-only rate_limit_status
Created November 16, 2013 09:45
GET application/rate_limit_status when application-only authentication.
{
"rate_limit_context" = {
application = XXXXXXXXXXXXXXXXXXX;
};
resources = {
search = {
"/search/tweets" = {
limit = 450;
remaining = 450;
reset = 1384594997;
@tilfin
tilfin / gist:7800610
Created December 5, 2013 05:36
Xcode test sample for asynchronous request
- (void)testAsnchronouseRequest
{
[[MyAPIClient sharedClient] post:url params:@{ @"name": @"Taro", @"age": @"30" }, completion:^(NSDictionary *json, NSError *error)
{
NSDictionary *query = json[@"query"];
NSDictionary *body = json[@"body"];
XCTAssertNotNil(query[@"json"]);
XCTAssertEqualObjects(body[@"name"], @"Taro");
XCTAssertEqualObjects(body[@"age"], @"30");
@tilfin
tilfin / gist:8910706
Last active August 29, 2015 13:56
2217 requests logs that received an attack analyzed by detect-http-attack
66.35.64.34 2217 -
2014-02-10T11:49:12+09:00 200 /?_SERVER[DOCUMENT_ROOT]=http://www.google.com/humans.txt? -
2014-02-10T11:49:12+09:00 404 /0_admin/modules/Wochenkarte/frontend/index.php?x_admindir=http://www.google.com/humans.txt? -
2014-02-10T11:49:13+09:00 404 /123flashchat.php?e107path=http://www.google.com/humans.txt? -
2014-02-10T11:49:13+09:00 404 /2007/administrator/components/com_joomlaflashfun/admin.joomlaflashfun.php?mosConfig_live_site=http://www.google.com/humans.txt? -
2014-02-10T11:49:14+09:00 404 /22_ultimate/templates/header.php?mainpath=http://www.google.com/humans.txt? -
2014-02-10T11:49:14+09:00 404 /=http://www.google.com/humans.txt? -
2014-02-10T11:49:15+09:00 200 /?_CONFIG[files][functions_page]=http://www.google.com/humans.txt? -
2014-02-10T11:49:15+09:00 200 /?npage=-1&content_dir=http://www.google.com/humans.txt?%00&cmd=ls -
2014-02-10T11:49:16+09:00 200 /?npage=1&content_dir=http://www.google.com/humans.txt?%00&cmd=ls -
@tilfin
tilfin / munin_alert_hipchat.rb
Created March 17, 2014 03:31
Sending Munin Alert to hipchat
#!/usr/bin/env ruby
#
# Sending Munin Alert to hipchat
#
require 'hipchat-api'
#
# Settings
@tilfin
tilfin / ExportMSAccess.vb
Created March 20, 2014 12:30
Exports MS Access database objects to raw text files
Public Function ExportDatabaseSources(exportDir As String) As Boolean
On Error GoTo ErrHandler:
Dim db, td, d, c
Dim strRootPath As String
Set db = Application.CurrentDb
strRootPath = exportDir & "\"
If Len(Dir(strRootPath, vbDirectory)) = 0 Then