Skip to content

Instantly share code, notes, and snippets.

@masakielastic
masakielastic / 0_reuse_code.js
Created January 20, 2014 17:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Untitled Slide

Welcome to Glide.

Glide is the easiest way to create useful slide for all of your Gists.

  • input key <- to go backward.
  • input key -> to go forward.

Publishing

/Users/masakielastic/.phpbrew/build/php-5.6.0alpha3/ext/openssl/xp_ssl.c:88:12: warning:
'SSL_get_error' is deprecated: first deprecated in OS X 10.7
[-Wdeprecated-declarations]
int err = SSL_get_error(sslsock->ssl_handle, nr_bytes);
^
/usr/include/openssl/ssl.h:1501:5: note: 'SSL_get_error' declared here
int SSL_get_error(const SSL *s,int ret_code) DEPRECATED_IN_MAC_OS_X_...
^
/Users/masakielastic/.phpbrew/build/php-5.6.0alpha3/ext/openssl/xp_ssl.c:107:8: warning:
'ERR_peek_error' is deprecated: first deprecated in OS X 10.7
require 'formula'
# When trunk is 3.x, then 3.x is devel and 3.(x-1)
# is stable.
# https://code.google.com/p/v8/issues/detail?id=2545
# http://omahaproxy.appspot.com/
class V8 < Formula
homepage 'http://code.google.com/p/v8/'
url 'https://github.com/v8/v8/archive/3.25.zip'
{"cr":[13],"lf":[10],"control":[0,1,2,3,4,5,6,7,8,9,11,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,173,1536,1537,1538,1539,1540,1541,1564,1757,1807,6158,8203,8206,8207,8232,8233,8234,8235,8236,8237,8238,8288,8289,8290,8291,8292,8293,8294,8295,8296,8297,8298,8299,8300,8301,8302,8303,55296,55297,55298,55299,55300,55301,55302,55303,55304,55305,55306,55307,55308,55309,55310,55311,55312,55313,55314,55315,55316,55317,55318,55319,55320,55321,55322,55323,55324,55325,55326,55327,55328,55329,55330,55331,55332,55333,55334,55335,55336,55337,55338,55339,55340,55341,55342,55343,55344,55345,55346,55347,55348,55349,55350,55351,55352,55353,55354,55355,55356,55357,55358,55359,55360,55361,55362,55363,55364,55365,55366,55367,55368,55369,55370,55371,55372,55373,55374,55375,55376,55377,55378,55379,55380,55381,55382,55383,55384,55385,55386,55387,55388,55389,55390,55391,55392,55393,55394,55
@masakielastic
masakielastic / print_each_grapheme.php
Last active August 29, 2015 14:10
print_each_grapheme.php
<?php
define('ANY', 2);
define('CR', 4);
define('LF', 8);
define('CONTROL', 16);
define('EXTEND', 32);
define('REGIONAL_INDICATOR', 64);
define('SPACINGMARK', 128);
define('L', 256);
define('V', 512);
class String
def grapheme_length
length = self.length
grapheme_length = 0
pos = 0
while (pos < length) do
next_length = grapheme_next_length(pos)
pos += next_length
grapheme_length += 1
@masakielastic
masakielastic / print_each_grapheme.js
Last active April 19, 2023 18:39
print_each_grapheme.js
require('es6-shim');
function next_char_info(str, pos) {
var cp = str.codePointAt(pos);
var size = cp > 0xFFFF ? 2 : 1;
return {'cp': cp, 'size': size};
}
var ANY = 2;
@masakielastic
masakielastic / grapheme_length.js
Last active November 9, 2017 14:22
grapheme_length.js
require('es6-shim');
function in_char_class(cp, classes) {
// http://www.unicode.org/Public/UNIDATA/auxiliary/GraphemeBreakProperty.txt
var db = {
'cr': [0xD],
'lf': [0xA],
'control': [0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xB,0xC,0xE,0xF,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,0x7F,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xAD,0x600,0x601,0x602,0x603,0x604,0x605,0x61C,0x6DD,0x70F,0x180E,0x200B,0x200E,0x200F,0x2028,0x2029,0x202A,0x202B,0x202C,0x202D,0x202E,0x2060,0x2061,0x2062,0x2063,0x2064,0x2065,0x2066,0x2067,0x2068,0x2069,0x206A,0x206B,0x206C,0x206D,0x206E,0x206F,0xD800,0xD801,0xD802,0xD803,0xD804,0xD805,0xD806,0xD807,0xD808,0xD809,0xD80A,0xD80B,0xD80C,0xD80D,0xD80E,0xD80F,0xD810,0xD811,0xD812,0xD813,0xD814,0xD815,0xD816,0xD817,0xD818,0xD819,0xD81A,0xD81B,0xD81C,0xD81D,0xD81E,0xD81F,0xD820,0xD821,0xD822,0xD823,0xD8
package main
import (
"unicode/utf8"
)
func main() {
str := "葛\U000E0101飾区"
print_each_grapheme(str)
}