Skip to content

Instantly share code, notes, and snippets.

View mjs's full-sized avatar
💭
curl -s http://104.196.37.21/|grep -Eo '^\S+'

Menno Finlay-Smits mjs

💭
curl -s http://104.196.37.21/|grep -Eo '^\S+'
View GitHub Profile
@mjs
mjs / timeout.go
Last active August 29, 2015 14:02 — forked from darkhelmet/timeout.go
func Download(out chan string, urls... string) {
for url := range(urls) {
go func() {
out <- HttpGet(url)
}()
}
}
func Process(in chan string) {
select {
@mjs
mjs / foo.go
Last active March 17, 2016 01:11
package foo
import "fmt"
func NewThing() *Thing {
return &Thing{
Name: "Thing",
other: make(other),
}
}
@mjs
mjs / demo.go
Created March 17, 2016 20:30
Demo of go-yaml issue under Go 1.6
package main
import (
"fmt"
// Swap these 2 for comparison. Under Go 1.6 the program works
// with json but not yaml.
"gopkg.in/yaml.v2"
// yaml "encoding/json"
)
# listen on 127.0.0.1 so that apt on the host machine can use the cache
http_port 127.0.0.1:8888
# listen on lxdbr0 addresses
http_port 10.0.8.1:8888
http_port [fdc1:e6b1:6aac:99f5::1]:8888
acl allowed_src_networks src "/etc/squid-deb-proxy/autogenerated/allowed-networks-src.acl"
acl blockedpkgs urlpath_regex "/etc/squid-deb-proxy/autogenerated/pkg-blacklist-regexp.acl"
#!/usr/bin/perl
$mirror = "nz.archive.ubuntu.com";
#$mirror = "us.archive.ubuntu.com";
# For Cape Town
#$mirror = "ubuntu.saix.net/ubuntu-archive";
$| = 1;
while (<>) {
@line = split;
@mjs
mjs / juju-db
Last active September 1, 2016 21:56
Helper to get a MongoDB shell on a Juju controller
#!/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
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)
package main
import (
"fmt"
"net/http"
"net/url"
"sync"
)
type ProxyConfig struct {
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...
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"