Skip to content

Instantly share code, notes, and snippets.

Hidenari Nozaki ghiden

View GitHub Profile
@ghiden
ghiden / open-firefox-page-in-safari.lua
Created Jul 21, 2018
Because github pages cannot open a bookmarklet from firefox, I can't bookmark pages to pinboard. So I've created this Hammerspoon script to open a firefox page on safari.
View open-firefox-page-in-safari.lua
getUrl = [[
tell application "System Events"
tell application "Firefox" to activate
delay .5
tell application "System Events"
keystroke "l" using command down
keystroke "c" using command down
end tell
delay .5
set u to the clipboard
@ghiden
ghiden / reflect.js
Last active Feb 9, 2017
A utility function to wait all promises to settle
View reflect.js
/*
Promise.all(arr.map(reflect)).then(function(results){
var success = results.filter(x => x.status === "resolved");
});
*/
module.exports = function reflect(promise){
return promise.then(v => ({v:v, status: "resolved"}), e => ({e:e, status: "rejected"}))
}
View keybase.md

Keybase proof

I hereby claim:

  • I am ghiden on github.
  • I am hidenari (https://keybase.io/hidenari) on keybase.
  • I have a public key whose fingerprint is 8A2E 98CD BB28 C287 B43E 8104 2C1A 5D84 CC80 8F5D

To claim this, I am signing this object:

@ghiden
ghiden / config.toml
Last active Mar 1, 2016
Load TOML config and pick environment from a environmental variable in Go
View config.toml
[dev]
url = "http://dev.example.com"
username = "dev.account"
password = "devdev"
[test]
url = "http://test.example.com"
username = "test.account"
password = "testtest"
@ghiden
ghiden / test-delay.js
Created Jun 25, 2015
Q delay behavior
View test-delay.js
var Q = require('q');
function test() {
var d = Q.defer();
setTimeout(function() {
d.reject(new Error('failed'));
}, 500);
return d.promise;
@ghiden
ghiden / delay-test.js
Created Jun 25, 2015
Bluebird delay behaviors
View delay-test.js
var Promise = require('bluebird');
function test1() {
return new Promise(function(resolve) {
setTimeout(function() {
console.log('resolve');
resolve(100);
}, 500);
});
}
View calculate-email-distributions.rb
#!/usr/bin/env ruby
if ARGV.length != 3
puts 'Need 3 arguments'
puts ' calculate-email-distribution INITIAL_SIZE STEP AMOUNT'
puts 'e.g.'
puts ' calculate-email-distribution 100 20 65000'
exit 0
end
@ghiden
ghiden / bluebird-csv.js
Created Jun 15, 2015
To promisify csv-parse using Bluebird
View bluebird-csv.js
"use strict";
var fs= require('fs');
var Promise = require('bluebird');
var parse= Promise.promisify(require('csv-parse'));
var file = fs.readFileSync('test.csv', 'utf8');
var headerKeys;
var options ={
trim: true,
View Venn.js-Experiment.markdown
View zsh-theme
function ruby_version() {
echo 'ruby('`rbenv version | sed -e 's/ .*//'`')'
}
function node_version() {
echo 'node('`nvm version`')'
}
PROMPT='%{$fg[yellow]%}$(ruby_version):$(node_version) %{$fg_bold[red]%}➜ %{$fg_bold[green]%}%~ %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}
$ '
You can’t perform that action at this time.