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 singleton | |
import ( | |
"sync" | |
) | |
type singleton struct { | |
mu sync.Mutex | |
counter 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
var Or func(channels ...<-chan interface{}) <-chan interface{} | |
func init() { | |
Or = func(channels ...<-chan interface{}) <-chan interface{} { | |
switch len(channels) { | |
case 0: | |
return nil | |
case 1: | |
return channels[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
func main() { | |
res := make(chan interface{}) | |
defer close(res) | |
go wrap(res, func() (interface{}, error) { | |
return os.Open("./main.go") | |
}) | |
r := <-res | |
if msg, err := r.(error); err { | |
panic(msg) | |
} |
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 wrap | |
import ( | |
"reflect" | |
) | |
type ErrorWrapper struct { | |
err error | |
prevReturns []reflect.Value | |
} |
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
##TCP FLAGS## | |
Unskilled Attackers Pester Real Security Folks | |
============================================== | |
TCPDUMP FLAGS | |
Unskilled = URG = (Not Displayed in Flag Field, Displayed elsewhere) | |
Attackers = ACK = (Not Displayed in Flag Field, Displayed elsewhere) | |
Pester = PSH = [P] (Push Data) | |
Real = RST = [R] (Reset Connection) | |
Security = SYN = [S] (Start Connection) |
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
# part of https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt | |
rp_filter - INTEGER | |
0 - No source validation. | |
1 - Strict mode as defined in RFC3704 Strict Reverse Path | |
Each incoming packet is tested against the FIB and if the interface | |
is not the best reverse path the packet check will fail. | |
By default failed packets are discarded. | |
2 - Loose mode as defined in RFC3704 Loose Reverse Path | |
Each incoming packet's source address is also tested against the FIB | |
and if the source address is not reachable via any interface |
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 <iostream> | |
#include <sstream> | |
#include <string> | |
struct Int; | |
struct String; | |
struct Visitor { | |
void print_t(int i); | |
void print_t(std::string str); |
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
(defun stalin-sort (list) | |
(let ((cur (car list)) | |
(rest (cdr list))) | |
(cond | |
;; [] leads [] | |
((null rest) list) | |
;; e.g [3, 2, 4] => cur: 3, rest [2, 4], since 3 > 2 = car([2, 4]) | |
;; keep run the sort by current filter | |
((> cur (car rest)) | |
(stalin-sort (cons cur (cdr rest)))) |
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
let | |
pkgs = import <stable> {}; | |
inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa CoreFoundation CoreServices; | |
in # ignore |
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
module Lexer | |
( Token(..) | |
, TokenPos | |
, tokenize | |
) where | |
import Text.ParserCombinators.Parsec hiding (token, tokens) | |
import Control.Applicative ((<*), (*>), (<$>), (<*>)) | |
data Token = Ide String |
OlderNewer