Skip to content

Instantly share code, notes, and snippets.

@toshinarin
toshinarin / gist:5957489
Created July 9, 2013 13:50
Qiitaでexportしたファイルのビューア
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<style>
#entries-title {
@toshinarin
toshinarin / show_fps
Last active August 29, 2015 13:55
ブラウザのFPSを表示するブックマークレット
javascript:!function(){$(function(){var requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;var prev=0;var info=$('<div id="testest"></div>').css({position:"fixed",left:10,bottom:20,backgroundColor:"rgba(0, 0, 0, 0.8)",fontSize:12,color:"#ffffff",padding:5,zIndex:1e5}).appendTo("body");var count=0;function step(timestamp){if(++count==30){info.text((1e3/((timestamp-prev)/count)+"").substr(0,5));prev=timestamp;count=0}requestAnimationFrame(step)}requestAnimationFrame(step)})}();

http://www.zusaar.com/event/3667003

片岡さん(株式会社シロク CTO)

  • Blocksの循環参照
  • weakSelfパターンはアンチパターンだと思ってる
  • その場限りのBlocks
    • $.each(function(){}) てきなやつ
  • 一度きりのblocks
    • blocksへの参照をnilを代入して断ち切る
  • 最後にweakSelfパターン
@toshinarin
toshinarin / lightning-hex-clock.js
Last active August 29, 2015 14:02
Hex clockを高速化するブックマークレット http://www.jacopocolo.com/hexclock/
!function(diff){
var current = new Date().getTime();
$('#tweet').remove();
function refreshData2()
{
var d = new Date(current += diff);
var h = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();
if (h<=9) {h = '0'+h};
(function(fire) {
var cmd = [38,38,40,40,37,39,37,39,66,65], l = cmd.length, pos = 0;
$(document).on('keydown', function(event) {
var key = event.which;
if (cmd[pos] !== key) {
pos = 0;
} else if (++pos === l) {
fire();
pos = 0;
}
@toshinarin
toshinarin / change_screenshot_folder_on_mac.sh
Created July 14, 2014 03:19
Save screenshots to another folder on Mac
#!/bin/bash
TARGET_FOLDER="${HOME}/Pictures/screenshot"
FILE_PREFIX="s"
echo "setting..."
if [ ! -d ${TARGET_FOLDER} ]; then
mkdir -p ${TARGET_FOLDER}
echo "${TARGET_FOLDER} is made."
@toshinarin
toshinarin / NSMutableArray_copy_test.m
Last active August 29, 2015 14:04
NSMutableArray copy test
NSMutableArray *mary = [@[ @"a", @"b", @"c" ] mutableCopy];
NSArray *ary = [mary copy];
[mary removeLastObject];
NSString *str1 = [mary componentsJoinedByString:@", "];
NSString *str2 = [ary componentsJoinedByString:@", "];
NSLog(@"{str1: %@}, {str2: %@}", str1, str2); // {str1: a, b}, {str2: a, b, c}
@toshinarin
toshinarin / lgtm.coffee
Created August 22, 2014 07:31
hubot-script
# Description:
# Spice LGTM up with some images.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@toshinarin
toshinarin / continuous_tap_on_android.py
Last active August 29, 2015 14:12
Android monkeyrunnerで特定の箇所をタップし続ける
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
import signal
import sys
import random
shouldQuit = False
shouldSkip = False