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 RuneCount(buffer []byte) int { | |
index, count := 0, 0 | |
for index < len(buffer) { | |
if buffer[index] < RuneSelf { | |
index++ | |
} else { | |
_, size := DecodeRune(buffer[index:]) | |
index += size | |
} | |
count++ |
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 RuneCount(b []byte) int { | |
i, n := 0, 0 | |
for i < len(b) { | |
if b[i] < RuneSelf { | |
i++ | |
} else { | |
_, size := DecodeRune(b[i:]) | |
i += size | |
} | |
n++ |
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 com.example.store.user; | |
/** | |
* Implements a user for our store. | |
*/ | |
public class User { | |
private String name; | |
public User(String name) { | |
this.name = name; | |
} |
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 ../umbrella.mk |
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
<?php | |
use PhpAmqpLib\Connection\AMQPConnection; | |
use PhpAmqpLib\Message\AMQPMessage; | |
use PhpAmqpLib\Wire\AMQPTable; | |
include(__DIR__ . '/config.php'); | |
$conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); | |
$ch = $conn->channel(); |
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(shiftand). | |
%% shiftand:match("announce", "annual_announce"). | |
-export([match/2]). | |
match(Pattern, Text) -> | |
PatLen = length(Pattern), | |
BitMaskTable = init_table(Pattern), | |
MatchMask = 1 bsl (PatLen - 1), |
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
<?php | |
include(__DIR__ . '/config.php'); | |
use PhpAmqpLib\Connection\AMQPConnection; | |
use PhpAmqpLib\Message\AMQPMessage; | |
$conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST); | |
$ch = $conn->channel(); |
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
%% run this on the CLI: | |
%% start erlang: erl +K true | |
c(memory). | |
%% file size is arbitrary but too big will make the VM crawl with what follows | |
{ok, Bin} = file:read_file("my_at_least_3MB_file.something"). | |
L = binary_to_list(Bin). | |
Pid = memory:start(). | |
%% keep N low, a value of 100 makes my VM unresponsive in my 16GB of RAM Retina Mac. |
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
%% compile and run fold_example:test(). | |
%% Records used here were taken from RabbitMQ's source code. | |
-module(fold_example). | |
-compile(export_all). | |
-record('P_basic', | |
{content_type, | |
content_encoding, | |
headers, |
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
REASON FIVE: You’ve found a bug in Cairngorm. | |
If you find a bug in Cairngorm, there’s a really good chance it’s too | |
early for you to be using it in mission critical projects. I state | |
this with confidence, because many years ago I was a C developer who | |
kept finding bugs in Kernighan and Ritchie’s C compiler. Every day, | |
I’d find something wrong with the compiler – in fact, come to think of | |
it, I think I was responsible for finding some real clangers in the | |
Pascal compiler on SunOS as well, back in the day. |
NewerOlder