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
with_exclusive_lock("my_operation") do | |
# Something that can only happen one at a time | |
end | |
def with_exclusive_lock(lock_name, &block) | |
lock_file_name = "/tmp/#{lock_name}.lock" | |
FileUtils.touch(lock_file_name) | |
lock_file = File.new(lock_file_name) | |
lock_file.flock(File::LOCK_EX) | |
yield |
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
Ubuntu: | |
root@willtesting:/var/log# openssl ciphers -v | grep TLS | |
ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=RSA Enc=AESGCM(256) Mac=AEAD | |
ECDHE-ECDSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH Au=ECDSA Enc=AESGCM(256) Mac=AEAD | |
ECDHE-RSA-AES256-SHA384 TLSv1.2 Kx=ECDH Au=RSA Enc=AES(256) Mac=SHA384 | |
ECDHE-ECDSA-AES256-SHA384 TLSv1.2 Kx=ECDH Au=ECDSA Enc=AES(256) Mac=SHA384 | |
DHE-DSS-AES256-GCM-SHA384 TLSv1.2 Kx=DH Au=DSS Enc=AESGCM(256) Mac=AEAD | |
DHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=DH Au=RSA Enc=AESGCM(256) Mac=AEAD | |
DHE-RSA-AES256-SHA256 TLSv1.2 Kx=DH Au=RSA Enc=AES(256) Mac=SHA256 |
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" | |
func main() { | |
fmt.Println("Hello world!") | |
} |
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
func (r *repo_handle) get_tar_file() (string, error) { | |
target_dir, tmpdir_err := ioutil.TempDir("", "captain_app_tar") | |
log.Println("Got temp directory for app tar", target_dir) | |
if tmpdir_err != nil { | |
return "", tmpdir_err | |
} | |
archive_path := target_dir + "/" + "app.tar" | |
log.Println("Going to create the tar archive at path", archive_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
[sc-chi] root@proxy-02:~# docker insert slsdhf app.tar /tmp/app.tar | |
[sc-chi] root@proxy-02:~# echo $? | |
0 |
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 'minitest/autorun' | |
class TestWords < Minitest::Test | |
def test_that_similar_words_are_found | |
assert_equal one_off_words("moor", ["door", "moot", "boot", "boots"]), ["door", "moot"] | |
end | |
def test_fake_failure | |
assert_equal one_off_words("moor", ["door", "moot", "boot", "boots"]), ["door", "moot", "fuckers"] | |
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
class Array | |
def xor(key) | |
a = dup | |
a.length.times { |n| a[n] ^= key[n % key.size] } | |
a | |
end | |
end | |
stra = "123abc" | |
strb = "123adc" |
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 ( | |
"github.com/wjessop/go-piglow" | |
"log" | |
) | |
func main() { | |
var p *piglow.Piglow | |
var err error |
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 'thread' | |
LAST_VAL = 8 | |
q = Queue.new | |
(0..LAST_VAL).to_a.shuffle.each {|i| q << i} | |
vals = [] | |
next_val = 0 | |
loop do | |
puts "popping the stack" |
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 API I thought up, This example will | |
# sleep for 16 seconds (4 * 4 seconds + 5 seconds) | |
begin | |
RollingTimeout.new(5) {|timer| | |
sleep(4) | |
timer.reset | |
sleep(4) | |
timer.reset | |
sleep(4) |