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 rbtree | |
import ( | |
"cmp" | |
"slices" | |
) | |
type color int8 | |
const ( |
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
#!/usr/bin/env swipl | |
:- use_module(library(clpfd)). | |
:- initialization(main, main). | |
main(_) :- | |
current_prolog_flag(max_tagged_integer, Max), | |
between(3, Max, N), | |
fermat(X, Y, Z, N), | |
format('X = ~d~n', 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
package main | |
// go port of https://eli.thegreenplace.net/2010/01/02/top-down-operator-precedence-parsing | |
import ( | |
"fmt" | |
"log" | |
"regexp" | |
"strconv" | |
) |
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
# app/views/partials/_links.json.jbuilder | |
json._links do | |
if object.is_a?(ActiveRecord::Relation) | |
json.self do | |
json.href url_for(object.klass) | |
end | |
else | |
json.self do | |
json.href url_for(object) |
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
[ | |
{ | |
"name" : "foo", | |
"value" : 100 | |
}, | |
{ | |
"name" : "bar", | |
"value" : 200 | |
} | |
] |
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
$ echo '<n' | ./bnf | |
>>> "<" | |
<<< "<" | |
>>> upper case char | |
^^^ upper case char | |
>>> lower case char | |
<<< lower case char | |
>>> upper case char | |
^^^ upper case char | |
>>> lower case char |
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 "golang.org/x/tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
pic := make([][]uint8, dy) | |
for i := 0; i < dy; i++ { | |
row := make([]uint8, dx) | |
for j := 0; j < dx; j++ { | |
row[j] = uint8(i ^ j) |
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
// http://qiita.com/GeneralD/items/5a05f176ac2321e7a51b | |
#define CASE(str) if ([__s__ isEqualToString:(str)]) | |
#define SWITCH(s) for (NSString *__s__ = (s); __s__; __s__ = nil) | |
#define DEFAULT | |
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType | |
{ | |
NSURL *url = request.URL; | |
if ([self isExternalUrl:url]) { |
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
$ wrk -t12 -c400 -d30s http://localhost:9000/ | |
Running 30s test @ http://localhost:9000/ | |
12 threads and 400 connections | |
Thread Stats Avg Stdev Max +/- Stdev | |
Latency 10.92ms 1.86ms 23.20ms 91.61% | |
Req/Sec 2.44k 745.81 3.65k 65.37% | |
655855 requests in 30.09s, 56.29MB read | |
Socket errors: connect 157, read 56, write 13, timeout 0 | |
Requests/sec: 21799.25 | |
Transfer/sec: 1.87MB |
NewerOlder