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 doMightError() (err error) { | |
switch { | |
case !doFirst(&err): | |
case !doSecond(&err): | |
case !doThird(&err): | |
default: | |
moreStuff() | |
} | |
return |
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 doMightError() (err error) { | |
if err = doFirst(); err != nil { | |
return | |
} | |
if err = doSecond(); err != nil { | |
return | |
} | |
if err = doThird(); err != nil { |
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
use strict; | |
use warnings; | |
my @alpha = split('', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'); | |
my %frequencies = ( 'A' => 84, 'B' => 23, 'C' => 21, 'D' => 46, 'E' => 116, | |
'F' => 20, 'G' => 25, 'H' => 49, 'I' => 76, 'J' => 2, | |
'K' => 5, 'L' => 38, 'M' => 34, 'N' => 66, 'O' => 66, | |
'P' => 15, 'Q' => 2, 'R' => 64, 'S' => 73, 'T' => 81, | |
'U' => 19, 'V' => 11, 'W' => 21, 'X' => 2, 'Y' => 24, |
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
#include "stdint.h" | |
#include "stdio.h" | |
void main(int argc, void *argv[]) { | |
uint64_t i; | |
for (i = 0; i < 2^32; i++) { | |
uint32_t x = (uint32_t)i; | |
uint32_t l = (-x-1) & 0xffff; | |
uint32_t r = ~x & 0xffff; | |
if (l != r) { |
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
int b = 100; | |
int s = 640; | |
int w = b*(s/b); | |
int h = w; | |
void setup() { | |
background(0); | |
size(w, h); | |
int side = w/b - 1; | |
int 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
// Copyright (c) 2014 John Graham-Cumming | |
// | |
// Takes a CSV containing rows in the form | |
// | |
// ip,name | |
// | |
// Connects to 'ip' on port 443 using TLS presenting the SNI name 'name' and | |
// verifies the result. | |
package main |
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
$(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 |
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
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 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 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 |