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
package main | |
import ( | |
"fmt" | |
) | |
type ( | |
person struct { | |
name string | |
age int |
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
create procedure `suicide`(arg int) | |
begin | |
if arg = 1 then | |
select id, "GIMMEPID" from information_schema.processlist | |
where info like "%GIMMEPID%" limit 1 into @pid, @_; | |
select "BYE!"; | |
kill @pid; | |
end if; | |
select 'FINISHED!'; |
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
type Counter struct { | |
Write uint | |
Read uint | |
stream chan uint | |
inLoop bool | |
} | |
func NewCounter(wi, ri uint) *Counter { | |
c := &Counter{Write: wi, Read: ri} | |
c.stream = make(chan uint) |
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
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
func main() { | |
chans := []chan int{ | |
make(chan int, 1), |
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
namespace :maintenance do | |
task :save_startup_script do | |
script = "#!/bin/bash\n" | |
crontab_task = "@reboot #{deploy_to}/shared/startup.sh > #{deploy_to}/shared/log/startup.log #minareboot" | |
isolate do | |
invoke 'unicorn:start' | |
invoke 'sidekiq:start' | |
script << commands.join(" && \\\n") | |
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 | |
$config_file = "default.json"; | |
$config = json_decode(file_get_contents($config_file)); | |
$host = $config["default_host"]; | |
$uri = $_SERVER["QUERY_STRING"]; | |
if ($config["ab_enabled"]) { | |
if (in_array($_COOKIE["ab"], $config["ab_hosts"])) { | |
$host = $_COOKIE["ab"]; |
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
DELIMITER $$ | |
CREATE FUNCTION angle_point(lat double, lon double, deg double, dist double) RETURNS POINT DETERMINISTIC | |
BEGIN | |
DECLARE dist2 double; | |
DECLARE rdeg double; | |
DECLARE rlat1 double; | |
DECLARE rlon1 double; | |
DECLARE rlat2 double; | |
DECLARE rlon2 double; |
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
def session_user | |
@session_user ||= if current_user.admin? && params[:user_id].present? | |
User.find(params[:user_id]) | |
else | |
current_user | |
end | |
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
%w[ logger yaml rack eventmachine ].each(&method(:require)) | |
log = Logger.new(STDOUT) | |
config = YAML.load_file('config.yml') | |
Thread.new{ EM.run } | |
templates = config['storage']['templates'].map{ |tpl| config['storage']['root'] + tpl } | |
cache = templates.map{ |tpl| Dir[tpl] }.inject(:+).keep_if{ |f| File.file?(f) } | |
cache = Hash[cache.map do |f| | |
l = config['storage']['root'].length |
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
[ | |
{ | |
"weight": "400", | |
"style": "italic", | |
"family": "ABeeZee" | |
}, | |
{ | |
"weight": "400", | |
"style": "normal", | |
"family": "ABeeZee" |