Skip to content

Instantly share code, notes, and snippets.

View keichan34's full-sized avatar
👋
Hello!

Keitaroh Kobayashi keichan34

👋
Hello!
View GitHub Profile

Keybase proof

I hereby claim:

  • I am keichan34 on github.
  • I am sleepy_keita (https://keybase.io/sleepy_keita) on keybase.
  • I have a public key ASASuKTnKfWXIiwyRu4jyTDn-i8LUj1qZLrKHeNPRBtlsAo

To claim this, I am signing this object:

@keichan34
keichan34 / hi.exs
Last active September 17, 2016 09:57
compile-time list
defmodule Hi do
keys = ~w(hello there)a
for {key, idx} <- Enum.with_index(keys) do
def index_of_key(unquote(key)) do
{:ok, unquote(idx)}
end
def key_at_index(unquote(idx)) do
{:ok, unquote(key)}
@keichan34
keichan34 / .babelrc
Last active September 11, 2016 13:25
Sample Phoenix + Brunch (Babel) + Mocha test setup for unit tests
{
"presets": ["es2015"]
}
@keichan34
keichan34 / config.fish
Last active May 26, 2016 14:27
I got tired of loading nvm every time in my fish shell, so this.
# Requires bass and nvm
# bass: https://github.com/edc/bass
# nvm: https://github.com/creationix/nvm
function nvm
set -g NVM_LOADED "1"
bass source ~/.nvm/nvm.sh ';' nvm $argv
end
function ensure_nvm_loaded
@keichan34
keichan34 / ses_credential_generator.exs
Created March 26, 2016 13:58
Amazon SES SMTP Credential Generator
#!/usr/bin/env elixir
Application.start(:crypto)
key = case System.argv do
[key | _] -> key
_ ->
IO.puts "Usage: ses_credential_generator.exs [AWS Secret Access Key]"
exit(:shutdown)
end
@keichan34
keichan34 / execute-cron-on-all-sites.php
Created January 29, 2014 01:21
A simple script, intended to be run in the context of a WordPress install -- `wp-cli`'s `eval-file` is the easiest way -- to ping the cron of all sites registered in the network.
<?php
$start_date = date_i18n('Y/m/d H:i:s');
$start_time = microtime(true);
echo "Start site-wide wp-cron at $start_date\n";
$sites = wp_get_sites();
foreach ($sites as $site) {
$url = "http://" . $site['domain'] . $site['path'];
@keichan34
keichan34 / php_stdclass_init.php
Created October 3, 2013 08:02
PHP stdClass initialization vs array-to-object typecast
<?php
$start = microtime(true);
for($i=0;$i<1000000;$i++) {
$a = new stdClass();
$a->hello = 'there';
}
$end = microtime(true);
@keichan34
keichan34 / wp_langs.rb
Created April 1, 2013 12:38
language codes for WordPress
langs = {
"azb" => "Azeri – آذری",
"af" => "Afrikaans",
"ar" => "Arabic – عربي",
"bn_BD" => "Bangla - Bengali",
"eu" => "Basque - Euskara",
"be_BY" => "Belarusian - Беларуская - Biełaruskaja",
"bs_BA" => "Bosnian - Bosanski",
"bg_BG" => "Bulgarian - Български",
"ca" => "Catalan - Català",
@keichan34
keichan34 / wp_install.sh
Last active December 15, 2015 14:38
A WordPress install script Adds version and language options
#!/bin/bash
language="default"
version="latest"
dl_url=""
while getopts l:v:u: opt; do
case $opt in
l)
language=$OPTARG
@keichan34
keichan34 / anchorlinks-fbcanvas.js
Created November 3, 2012 06:47
Enable #links in Facebook Canvas