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
import os | |
import fcntl | |
from contextlib import contextmanager | |
@contextmanager | |
def file_lock(lock_file): | |
if os.path.exists(lock_file): | |
raise RuntimeError("Lockfile exists: %s" % lock_file) | |
else: |
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
function bal(){ | |
$serversNew = array(); | |
$servers = array("host1", "host2", "host3", "host4"); | |
$query = "give me all the"; | |
$numServers = count($servers); | |
while($numServers > 0) { | |
$key = hexdec(substr(md5($numServers . '+' . $query),0,4))%($numServers); |
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
class apps::tomcat7::tomcat7flow inherits apps::tomcat7::serverconf { | |
$ip_address = '127.0.0.1' | |
File['/var/lib/tomcat7/conf/server.xml']{ | |
ensure => 'present', | |
content => template('apps/flowservice/server7.erb'), | |
notify => Service['tomcat7'], | |
} | |
} |
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
<configuration> | |
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
<!-- encoders are assigned the type | |
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | |
<encoder> | |
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | |
</encoder> | |
</appender> | |
<root level="info"> |
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
[{"code":"ZNZ","city":"ZANZIBAR","country":"TANZANIA","lat":"-6.13","lon":"39.31"},{"code":"TYO","city":"TOKYO","country":"JAPAN","lat":"35.68","lon":"139.76"},{"code":"AKL","city":"AUCKLAND","country":"NEW ZEALAND","lat":"-36.85","lon":"174.78"},{"code":"BKK","city":"BANGKOK","country":"THAILAND","lat":"13.75","lon":"100.48"},{"code":"DEL","city":"DELHI","country":"INDIA","lat":"29.01","lon":"77.38"}, {"code":"SIN","city":"SINGAPORE","country":"SINGAPOR","lat":"1.36","lon":"103.75"},{"code":"BSB","city":"BRASILIA","country":"BRAZIL","lat":"-15.67","lon":"-47.43"},{"code":"RIO","city":"RIO DE JANEIRO","country":"BRAZIL","lat":"-22.90","lon":"-43.24"},{"code":"YTO","city":"TORONTO","country":"CANADA","lat":"43.64","lon":"-79.40"},{"code":"IPC","city":"EASTER ISLAND","country":"CHILE","lat":"-27.11","lon":"-109.36"},{"code":"SEA","city":"SEATTLE","country":"USA","lat":"47.61","lon":"-122.33"}]; |
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
<!-- the env variables are controlled by Chef and passed in via -D on the java command-line --> | |
<!-- This is using the appender here: https://github.com/t0xa/gelfj --> | |
<appender name="graylog2" class="org.graylog2.log.GelfAppender"> | |
<param name="graylogHost" value="${graylog.server}"/> | |
<param name="originHost" value="${graylog.origin}"/> | |
<param name="extractStacktrace" value="true"/> | |
<param name="addExtendedInformation" value="true"/> | |
<!-- The _web part is because a given app has multiple components --> | |
<!-- This app might have a _web as well as an _batch component --> | |
<param name="facility" value="${graylog.facility}_web"/> |
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
function encode64($input, $count) | |
{ | |
$output = ''; | |
$i = 0; | |
do { | |
$value = ord($input[$i++]); | |
$output .= $this->itoa64[$value & 0x3f]; // % 64 | |
if ($i < $count) | |
$value |= ord($input[$i]) << 8; // ord * 2^8 | |
$output .= $this->itoa64[($value >> 6) & 0x3f]; // (ord div 64) % 64 |
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
require 'rubygems' | |
require 'ruby-prof' | |
RubyProf.measure_mode = RubyProf::ALLOCATIONS | |
RubyProf.start | |
1_000_000.times{ Array.new(10) } | |
result = RubyProf.stop | |
# Print a flat profile to text | |
printer = RubyProf::FlatPrinter.new(result) | |
printer.print(STDOUT) |
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
1.9.2p320 :006 > x | |
=> ["𠜎"] | |
1.9.2p320 :007 > x.to_json | |
=> "[\"\\u070e\"]" | |
1.9.2p320 :008 > JSON.dump x | |
=> "[\"𠜎\"]" |
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
Enclosing class/module 'mDigest' for class MD5 not known | |
Enclosing class/module 'mDigest' for class RMD160 not known | |
Enclosing class/module 'mDigest' for class SHA1 not known | |
Enclosing class/module "cASN1ObjectId" for alias short_name sn not known | |
Enclosing class/module "cASN1ObjectId" for alias long_name ln not known |