Skip to content

Instantly share code, notes, and snippets.

Avatar
🕘
JST +09:00

Yoshiaki Sugimoto ysugimoto

🕘
JST +09:00
View GitHub Profile
@ysugimoto
ysugimoto / ellipsis.js
Last active Aug 29, 2015
複数行をellipsisする君
View ellipsis.js
(function(global) {
'use strict';
function Ellipsis(element, trail) {
this.element = element;
this.exactHeight = element.offsetHeight;
this.text = element.textContent;
this.textSize = this.text.length;
this.trail = trail || '...';
}
View GetZoneInfo.php
<?php
class GetZoneInfo {
const ORIGIN_SIGNATURE = '$ORIGIN';
const IN_SIGNATURE = 'IN';
const A_RECORD = "A";
const CNAME_RECORD = "CNAME";
protected $fqdnList = [];
View Releasenote-Go-1.4.md

Go 1.4 RC1が出たのでまとめ

原文: http://tip.golang.org/doc/go1.4

Introduction to Go 1.4 より

  • ガベージコレクタを改善したよ
  • go コマンドにいくつかツールが追加されたよ
  • Android, NaCl, AMD64上のPlan9サポートが追加されたよ。互換性も維持するよ
@ysugimoto
ysugimoto / iOS6sample.html
Created Oct 29, 2012
iOS6's handleEvent not works by Function's property
View iOS6sample.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>index</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0" />
<script>
document.addEventListener('DOMContentLoaded', function() {
@ysugimoto
ysugimoto / ws.js
Created Dec 17, 2012
WebSocket broadcast messaging from external protocol <Depends node-websocket-server>
View ws.js
var WebSocket = require('websocket').server,
Net = require('net'),
http = require('http'),
Dgram = require('dgram'),
unixPath = '/tmp/wsbroadcaster.sock',
unixSocket,
udpSocket,
wsServer,
httpServer;
@ysugimoto
ysugimoto / gamepad.js
Created Feb 16, 2013
gamepad API sample ( for webkit only )
View gamepad.js
(function() {
var pointerMatrix = [
[1,3,5,7,9,11,13,15,17,19,21,23],
[49,51,53,55,57,59,61,63,65,67,69,71],
[97,99,101,103,105,107,109,111,113,115,117],
[145,147,149,151,153,155,157,159,161,163,165],
[193,195,197,199,201,203,205,207,209,211,213],
[241,243,245,247,249,251,253,255,257,259,261]
];
var rubMap = {
@ysugimoto
ysugimoto / lazy.js
Last active Dec 14, 2015
Deferred pattern implements
View lazy.js
(function(module) {
"use strict";
// Scope stacks
var LAZY_ID = 0,
PARALLELS = [];
// exports
module.Lazy = Lazy;
@ysugimoto
ysugimoto / checkdatediff.rb
Created Jan 8, 2014
現在時刻のずれチェックするやつ
View checkdatediff.rb
#!/usr/bin/env ruby
require 'date'
require 'json'
require 'net/http'
response = Net::HTTP.get URI('http://ntp-a1.nict.go.jp/cgi-bin/json')
json = JSON.parse(response)
diff = json['st'] - Time.now.to_i
@ysugimoto
ysugimoto / check_user.sh
Created Jul 1, 2013
Linuxユーザ名が存在するかどうかチェックするやつ(これでいいのかな)
View check_user.sh
grep '^[ユーザ名]:' /etc/passwd
@ysugimoto
ysugimoto / filewatch.sh
Created Oct 9, 2012
inotifywait file watching handler
View filewatch.sh
#!/bin/sh
# kill already process
PROC=`pgrep -f inotifywait`
if [ -n "${PROC}" ]; then
echo $PROC | xargs kill
fi
/usr/bin/inotifywait -e create,modify -mrq /home/my.file | while read line; do
path=`echo $line | /bin/awk '{print $1$3}'`