This file contains hidden or 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" | |
"runtime" | |
"time" | |
) | |
func waitAround(die chan bool) { | |
<- die |
This file contains hidden or 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 worker(die chan bool) { | |
for { | |
select { | |
// ... do stuff cases | |
case <- die: | |
return | |
} | |
} | |
} |
This file contains hidden or 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
local t = {} | |
local c = 1 | |
for i=1,5000000 do | |
t[c] = i | |
c = c + 1 | |
end |
This file contains hidden or 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
local profiler = require 'lulip' | |
local p = profiler:new() | |
p:dont('some-module') | |
p:maxrows(25) | |
p:start() | |
-- execute code here | |
p:stop() | |
p:dump(output_file_name) |
This file contains hidden or 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
local ffi = require("ffi") | |
ffi.cdef[[ | |
typedef long time_t; | |
typedef struct timeval { | |
time_t tv_sec; | |
time_t tv_usec; | |
} timeval; |
This file contains hidden or 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
% perl rsa.pl rsa65537.key | |
Exponent 65537 | |
Plaintext [2374623765656] | |
Ciphertext [54189570645149678794693940654778175623133064659696656007570945283886977179371080120152561977021117382440218161492193509392092366273501288958199326710633675404929026067821522578649296730459190572345487456189328545191187492476957378888329005173000564263384860107839239781974940823115540499210407765338815164272] | |
% perl rsa.pl rsa1.key | |
Exponent 1 | |
Plaintext [2374623765656] | |
Ciphertext [2374623765656] |
This file contains hidden or 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
# quic-cleanup.pl | |
# | |
# When running the Google experimental quic_server it expects to find | |
# sites to serve in /tmp/quic-data. Under that there will be a | |
# directory per site. | |
# | |
# For example this was used to mirror the CloudFlare web site for | |
# QUIC testing. | |
# | |
# mkd |
This file contains hidden or 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
// loc_parser: functions to parse the textual part of a LOC record | |
// stored in our DNS. The key function here is parseLOCString which | |
// should be passed a dns.LOC and a string containing the latitude, | |
// longitude etc. | |
// | |
// This is an implementation of RFC 1876. Read it for background as | |
// the format in a dns.LOC is slightly unusual. | |
// | |
// Copyright (c) 2014 CloudFlare, Inc. |
This file contains hidden or 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
all: | parallel ; @echo $(JOB_COUNT) | |
parallel: .parallel ; @$(eval JOB_COUNT := $(shell sort -n $< | tail -n 1)) | |
.parallel: FORCE ; @$(MAKE) --no-print-directory par 2>/dev/null >$@ || true | |
FORCE: | |
to_n = $(words $2) $(if $(filter-out $1,$(words x $2)),$(call to_n,$1,x $2)) | |
PAR_COUNT := | |
par: $(addprefix par-,$(call to_n,32)) |
This file contains hidden or 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
$(call to_n,4) = $(words ) $(if $(filter-out 4,$(words x )),$(call to_n,4,x )) # $1 == 4, $2 is blank | |
= 0 $(if $(filter-out 4,1),$(call to_n,4,x )) # $(filter-out 4,1) is 1 | |
= 0 $(if 1,$(call to_n,4,x )) # So the $(call) will happen | |
= 0 $(call to_n,4,x ) | |
= 0 $(words x ) $(if $(filter-out 4,$(words x x )),$(call to_n,4,x x )) | |
= 0 1 $(if $(filter-out 4,2)),$(call to_n,4,x x )) # $(filter-out 4,2) is 2 | |
= 0 1 $(if 2,$(call to_n,4,x x)) # So the $(call) will happen | |
= 0 1 $(call to_n,4,x x) | |
= 0 1 $(words x x ) $(if $(filter-out 4,$(words x x x)),$(call to_n,4,x x x )) | |
= 0 1 2 $(if $(filter-out 4,3),$(call to_n,4,x x x )) # $(filter-out 4,3) is 3 |