Skip to content

Instantly share code, notes, and snippets.

View craftzdog's full-sized avatar
๐Ÿ 
Working from home

Takuya Matsuyama craftzdog

๐Ÿ 
Working from home
View GitHub Profile
@craftzdog
craftzdog / create.js
Last active January 9, 2016 15:03
PouchDB sync issue
var PouchDB = require('pouchdb');
var local = new PouchDB('./db');
function createDB () {
var promise = Promise.resolve();
var docs = [];
for (var i=0; i<100; i++) {
docs.push({
@craftzdog
craftzdog / ExtensionLoader.js(169)
Created December 18, 2015 02:11
brackets/atomใฎใ‚จใ‚ฏใ‚นใƒ†ใƒณใ‚ทใƒงใƒณใฎไป•็ต„ใฟ ref: http://qiita.com/noradaiko/items/a35d2b8191765a4e84e5
// Read optional requirejs-config.json
var promise = _mergeConfig(extensionConfig).then(function (mergedConfig) {
// Create new RequireJS context and load extension entry point
var extensionRequire = brackets.libRequire.config(mergedConfig),
extensionRequireDeferred = new $.Deferred();
contexts[name] = extensionRequire;
extensionRequire([entryPoint], extensionRequireDeferred.resolve, extensionRequireDeferred.reject);
return extensionRequireDeferred.promise();
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys, numpy
categories = numpy.loadtxt(sys.argv[1], str, delimiter="\t")
scores = numpy.load(sys.argv[2])
top_k = 10
prediction = zip(scores[0].tolist(), categories)
prediction.sort(cmp=lambda x, y: cmp(x[0], y[0]), reverse=True)
for rank, (score, name) in enumerate(prediction[:top_k], start=1):
import caffe
import numpy as np
import sys
if len(sys.argv) != 3:
print "Usage: python convert_protomean.py proto.mean out.npy"
sys.exit()
blob = caffe.proto.caffe_pb2.BlobProto()
data = open( sys.argv[1] , 'rb' ).read()
@craftzdog
craftzdog / userContent.css
Created January 6, 2015 10:43
Stylesheet for plain text e-mail on Thunderbird
/* Save it to ~/Library/Thunderbird/Profiles/*.default/chrome/userContent.css */
span[_moz_quote=true] {
color: orange !important;
}
pre[_moz_quote=true] {
color: orange !important;
}
blockquote[type=cite] {
color: orange !important;
@craftzdog
craftzdog / phantomjs-shims.js
Created December 20, 2014 01:05
PhantomJS shims for supporting HTML5
module.exports = function() {
var Ap = Array.prototype;
var slice = Ap.slice;
var Fp = Function.prototype;
if (!Fp.bind) {
// PhantomJS doesn't support Function.prototype.bind natively, so
// polyfill it whenever this module is required.
Fp.bind = function(context) {
(function() {
var Ap = Array.prototype;
var slice = Ap.slice;
var Fp = Function.prototype;
if (!Fp.bind) {
// PhantomJS doesn't support Function.prototype.bind natively, so
// polyfill it whenever this module is required.
Fp.bind = function(context) {
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
@craftzdog
craftzdog / 0_reuse_code.js
Created January 27, 2014 15:55
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
@craftzdog
craftzdog / crash_reports_mknetworkkit
Last active December 18, 2015 22:29
I got some crash reports where MKNetworkKit caused exceptions on my app. I hope these reports help to improve MKNetworkKit. Of course, it might be a memory management issue of my app so I'm glad to hear any suggestion. Thanks.
SIGSEGV
_mh_execute_header
Crashed Thread
0
Foundation 0x34fc5b14 +[__NSOperationInternal _observeValueForKeyPath:ofObject:changeKind:oldValue:newValue:indexes:context:]
1
Foundation 0x34fd309b NSKeyValueNotifyObserver
2
Foundation 0x34fd2da5 NSKeyValueDidChange