Skip to content

Instantly share code, notes, and snippets.

👋
Hello!

Keitaroh Kobayashi keichan34

👋
Hello!
Block or report user

Report or block keichan34

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View array_benchmark.rb
#!/usr/bin/env ruby
require 'benchmark'
Benchmark.bmbm do |x|
x.report("Push x2") do
ary = []
100000.times do
ary << 'hi'
ary << 'hihi'
@keichan34
keichan34 / execute-cron-on-all-sites.php
Created Jan 29, 2014
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.
View execute-cron-on-all-sites.php
<?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 Oct 3, 2013
PHP stdClass initialization vs array-to-object typecast
View php_stdclass_init.php
<?php
$start = microtime(true);
for($i=0;$i<1000000;$i++) {
$a = new stdClass();
$a->hello = 'there';
}
$end = microtime(true);
@keichan34
keichan34 / active_record_marshalable.rb
Created Sep 5, 2013
Get Marshal.dump and Marshal.load to load cached association objects ( Whatever.includes(:example_models) ), as well.
View active_record_marshalable.rb
module ActiveRecordMarshalable
def marshal_dump
[attributes, self.association_cache, instance_variable_get(:@new_record)]
end
def marshal_load data
send :initialize, data[0]
instance_variable_set :@association_cache, data[1]
instance_variable_set :@new_record, data[2]
end
@keichan34
keichan34 / wp_langs.rb
Created Apr 1, 2013
language codes for WordPress
View wp_langs.rb
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 Dec 15, 2015
A WordPress install script Adds version and language options
View wp_install.sh
#!/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 Nov 3, 2012
Enable #links in Facebook Canvas
View anchorlinks-fbcanvas.js
You can’t perform that action at this time.