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 perf_test | |
/* | |
Results on my machine: | |
BenchmarkSprintf-4 5000000 337 ns/op | |
BenchmarkBuffer-4 5000000 283 ns/op | |
BenchmarkManualAppend-4 20000000 91.0 ns/op | |
BenchmarkLineBuilder-4 10000000 182 ns/op |
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" | |
"github.com/pkg/errors" | |
) | |
func A() error { | |
// New errors created with pkg/errors.New() will include a full |
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
const ITERS: usize = 20; | |
fn print_fib(n: usize) { | |
let mut x = (1, 1); | |
for i in 0..n { | |
println!("{}: {}", i, x.0); | |
x = (x.1, x.0 + x.1) | |
} | |
} |
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" | |
"github.com/juju/juju/api" | |
"github.com/juju/juju/juju" | |
"github.com/juju/juju/jujuclient" | |
"github.com/juju/juju/state/multiwatcher" | |
) |
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
#!/usr/bin/python3.5 | |
import asyncio | |
import logging | |
from juju import loop | |
from juju.model import Model, ModelObserver | |
class ModelWatcher(ModelObserver): |
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" | |
"github.com/juju/juju/api" | |
"github.com/juju/juju/api/controller" | |
"github.com/juju/juju/juju" | |
"github.com/juju/juju/jujuclient" | |
"github.com/kr/pretty" |
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
imap = imapclient.IMAPClient(server) | |
imap.login(username, getpass()) | |
imap.select_folder('INBOX') | |
messages = imap.search(['NOT', 'DELETED']) | |
for message_id, data in imap.fetch(messages, ['RFC822']).iteritems(): | |
body = data['RFC822'] | |
# do stuff with message_id and body... | |
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" | |
"net/http" | |
"net/url" | |
"sync" | |
) | |
type ProxyConfig struct { |
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
import time | |
from logging import getLogger | |
from logging.handlers import SysLogHandler | |
logger = getLogger() | |
logger.addHandler(SysLogHandler("/dev/log")) | |
while True: | |
print time.asctime() | |
logger.error("x" * 200) |
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
#!/bin/bash | |
model=${1:-controller} | |
machine=${2:-0} | |
read -d '' -r cmds <<'EOF' | |
password=`sudo grep oldpassword /var/lib/juju/agents/machine-*/agent.conf | cut -d' ' -f2` | |
/usr/lib/juju/mongo*/bin/mongo 127.0.0.1:37017/juju --authenticationDatabase admin --ssl --sslAllowInvalidCertificates --username "admin" --password "$password" | |
EOF |