This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
anchorlinks-fbcanvas.js | |
Enables anchor links (<a href="#hello">Go to id="hello"</a>) in | |
Facebook Canvas (page tabs, canvas app, etc) | |
Requires: jQuery, Facebook JS SDK | |
*/ | |
jQuery(function($) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
language="default" | |
version="latest" | |
dl_url="" | |
while getopts l:v:u: opt; do | |
case $opt in | |
l) | |
language=$OPTARG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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à", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$start = microtime(true); | |
for($i=0;$i<1000000;$i++) { | |
$a = new stdClass(); | |
$a->hello = 'there'; | |
} | |
$end = microtime(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'benchmark' | |
Benchmark.bmbm do |x| | |
x.report("Push x2") do | |
ary = [] | |
100000.times do | |
ary << 'hi' | |
ary << 'hihi' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule SimpleHelloWorld do | |
import Plug.Conn, only: [resp: 3, halt: 1] | |
def init(_), do: nil | |
def call(%{request_path: request_path} = conn, _) when request_path == "/" do | |
conn | |
|> resp(200, "Hello, world!") | |
|> halt | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/Desktop > ruby --version | |
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14] | |
~/Desktop > ruby ./concat_benchmark.rb | |
Calculating ------------------------------------- | |
Interpolation 81.309k i/100ms | |
Array + join 65.714k i/100ms | |
String concatenation 62.816k i/100ms | |
String mutation 68.529k i/100ms | |
------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header("Content-Type: application/rss+xml"); | |
date_default_timezone_set("Asia/Tokyo"); | |
function formatTime($duration) //as hh:mm:ss | |
{ | |
$hours = floor($duration / 3600); | |
$minutes = floor( ($duration - ($hours * 3600)) / 60); | |
$seconds = $duration - ($hours * 3600) - ($minutes * 60); |
OlderNewer