Skip to content

Instantly share code, notes, and snippets.

@comilab
comilab / bookmarklet_checkbox.js
Last active March 11, 2017 08:00
ページ上にチェックボックスを生成するBookmarklet
javascript: (function(){var t,a,b,c;t=prompt('表示するテキスト');if(t===null)return false;a=document.createElement('div');a.draggable=true;a.style='background-color:rgba(255,255,255,0.5);border:1px solid rgba(0,0,0,0.5);position:fixed;top:0;left:0;overflow:auto;resize:both;';b=document.getElementsByTagName('body')[0];c=document.createElement('label');c.innerHTML='<input type="checkbox">'+t;c.style='display:block;padding:.5em';a.ondragend=function(e){a.style.top=Math.max(0,e.clientY-32)+'px';a.style.left=Math.max(0,e.clientX)+'px';};a.ondrag=b.ondrop=function(e){e.preventDefault();return false;};a.appendChild(c);b.appendChild(a);})();
@comilab
comilab / .gitlab-ci.yml
Created September 13, 2016 20:19
GitLab.com + GitLab-CI + Shared runners + gulp + rsyncで自動デプロイ
image: node:latest
cache:
paths:
- node_modules/
before_script:
- apt-get update -y
- apt-get install rsync openssh-client -y
- npm install
@comilab
comilab / bookmarklet_mi.js
Created February 28, 2014 10:04
iPhoneでホーム画面にブックマークを追加した時のアイコンを「み」にするBookmarklet(未テスト)
javascript:(function(){var d=document,a=d.createElement("link");a.rel="apple-touch-icon";a.href="http://upload.wikimedia.org/wikipedia/commons/6/60/Japanese_Hiragana_kyokashotai_MI.png";d.getElementsByTagName('head').item(0).appendChild(a)})();
@comilab
comilab / DateTimeImmutable.php
Created September 9, 2013 15:09
PHP5.5で追加されたDateTimeImmutableをPHP5.4以下で使う
<?php
class DateTimeImmutable extends DateTime
{
protected static $immutable = true;
public function add($interval)
{
return $this->call('add', func_get_args());
}
@comilab
comilab / getRandomName.js
Last active December 22, 2015 14:18
名前に使えそうな、音読できるランダム文字列を生成する
var getRandomName = function() {
// ゥは使わない気がするので一旦外す
var chars = 'アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヲンヴガギグゲゴザジズゼゾダヂヅデドバビブベボパピプペポァィェォッャュョー'.split(''),
prefixes1 = 'ウクグツフブプヴ'.split(''),
prefixes2 = 'ツフブプヴ'.split(''),
prefixes3 = 'キシチニヒミリギジヂビピ'.split(''),
length = Math.max(Math.floor(Math.random() * 9), 2),
name = '';
while (name.length < length) {
@comilab
comilab / CanvasFont.html
Last active January 7, 2017 13:53
canvas要素を使って文字を綺麗に描画してみる
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<style type="text/css">
body {
font-size: 22px;
}
@comilab
comilab / TwitterModoki.html
Last active December 21, 2015 15:29
AngularJSでTwitterもどきを作る
<!DOCTYPE html>
<html lang="ja">
<head>
<title>Twitterもどき</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
</head>
<body ng-app ng-init="tweets = []; t='';">
<form name="tweetForm">
<textarea required="required" name="t" ng-model="t" ng-maxlength="140"></textarea>
<span>{{t.length}} / 140</span>