Skip to content

Instantly share code, notes, and snippets.

View taro-m's full-sized avatar
🐱
meow

MURAOKA Taro taro-m

🐱
meow
  • Muraoka Design Laboratory
  • Tokyo, Japan
View GitHub Profile
@taro-m
taro-m / default.scss
Last active August 29, 2015 14:24
理想のフレームワーク
.main {
@include row;
}
.nav {
@include col-xs-3;
}
.body {
@include col-xs-9;
}
var domain = require('domain')
var d = domain.create();
d.on('error', function(er) {
console.error('caught', er);
});
d.run(function() {
console.log('HERE:1');
@taro-m
taro-m / hstore-graceful-migration.rb
Created April 23, 2015 03:14
Can we do like this?
def load_hstore_coloumn
begin
load_hstore_as_rails4
rescue
load_hstore_as_rails3
end
end
def save_hstore_column
save_hstore_as_rails4
foo.bar(foo, {
success: () ->
baz()
do_success()
error: () ->
do_error()
})
@taro-m
taro-m / multiple-addevent.html
Created June 20, 2014 06:25
multiple onload is not work. addeventlistener is work.
<!DOCTYPE HTML>
<meta charset="UTF-8">
<h1>Install multiple onload</h1>
<script>
window.addEventListener('load', function() {
alert('first onload');
console.log('first onload');
});
</script>
@taro-m
taro-m / scrollable-table.html
Created March 4, 2014 03:44
Just an idea. It'll take not-little time to implement.
<div>
<!-- A: header table (not scrorablle) -->
<table>
<tr><th>ID</th></tr>
<tr><th>Name</th></tr>
<tr><th>Created at</th></tr>
<tr><th>Modified at</th></tr>
</table>
<!-- B: data table (scrorablle x and y axis -->
@taro-m
taro-m / hyphen-in-regex.mkd
Created January 18, 2014 04:03
Put `-` in regexp's char class

Conclusion

When writing a regex patter like [a-zA-Z0-9_-] which have - in char class, it is better that put - at top. [-a-zA-Z0-9_]

Why?

If - is put at last and after a character: [_-], As a parser of regexp pattern, when met - after _ (a literal character), it can't be determined as a range operator or a literal character soon.

addDefaultHandlers: (options) ->
return _.extend({
# common handler
error: (jqXHR, textStatus, errorThrown) =>
console.log('NG', arguments)
success: (data, textStatus, jqXHR) =>
console.log('OK', arguments)
}, options)
main: () ->
def new_feature(id, values)
data = get_data(id)
if data.hasGoodValue?
data.updateByValues(values)
data.save()
else
showError()
end
end