Skip to content

Instantly share code, notes, and snippets.

@xrl
xrl / rust-nightly-setup.sh
Last active August 29, 2015 14:26
Set up rustc/cargo toolchain on scaleway C1 ARMv7 server instance
apt-get update
apt-get upgrade -y
apt-get install -y aptitude vim git libssl-dev build-essential
mkdir ~/rust-temp-dir
cd ~/rust-temp-dir
# Rust 1.1.0
# export CARGO_URL="https://www.dropbox.com/sh/qfbt03ys2qkhsxs/AAACKdu99RNndY8AjA15pZlIa/1.1.0/cargo-2015-05-14-a483581-arm-unknown-linux-gnueabihf-65bc529734a332b57b4bcf3d7c32e7f6aa4d449f.tar.gz?dl=0"
# export RUST_URL="https://www.dropbox.com/sh/qfbt03ys2qkhsxs/AAANQ7TuyVUtA09TfFyR-s7aa/1.1.0/rust-2015-06-19-35ceea3-arm-unknown-linux-gnueabihf-1d459e0987537a1f2ecc1c5bd594d2e776f88927.tar.gz?dl=0"
require 'string'
function split(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
@xrl
xrl / heka_build.chef.rb
Last active August 29, 2015 14:22
How I build a heka deb with my custom plugin
user = "xavierlange"
heka_dir = "#{Chef::Config[:file_cache_path]}/heka"
%w(cmake mercurial fakeroot debhelper libgeoip-dev).each do |pkg|
package pkg
end
directory heka_dir do
owner user
group user
error: type `std::io::buffered::BufWriter<&mut [u8]>` does not implement any method in scope named `write_be_u32`
writer.write_be_u32::<BigEndian>(interval_ceiling).unwrap();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def lookup(type)
case type
when "string" then "string"
when "text" then "string"
when "boolean" then "boolean"
when "integer" then "number"
when "datetime" then "utc"
else raise "don't know corresponding type for ActiveRecord #{type}"
end
end
@xrl
xrl / gist:142708bc56453acc19b3
Created October 20, 2014 23:47
How to maintain a raring system
# You need to point apt at old-releases.ubuntu.com
sudo sed -i 's/us.archive.ubuntu.com/old-releases.archive.ubuntu.com/g' /etc/apt/sources.list
class LogLine(object):
def __init__(self,raw_line):
self.pid = pid(raw_line)
self.ip = ip(raw_line)
self.timestamp = timestamp(raw_line)
def pid(self,line):
pass
def ip(self,line):
/* Put your CSS here */
html, body {
margin: 20px;
}
class AdsSerializer < ActiveModel::Serializer
attributes :target_url,
:image_url,
:thumb_url
def image_url
image.url
end
def thumb_url
thumb.url
end
@xrl
xrl / Makefile
Created April 15, 2014 23:10
EOS5D Mark III PTP IO error while downloading file with gp_camera_file_get
main: main.c
cc main.c -o main -l gphoto2 -l gphoto2_port
clean:
rm -rf main