Skip to content

Instantly share code, notes, and snippets.

View itsbth's full-sized avatar

Bjørn Tore Håvie itsbth

View GitHub Profile
local largest = -1
local iterations = 0
local is_palindrome
is_palindrome = function(n)
n = tostring(n)
return n == n:reverse()
end
for x = 100, 999 do
for y = 999, x, -1 do
local _continue_0 = false
lfn28p3 = (fn) ->
l, ext = fn\match "(.+)%.([^.]+)"
fn = l if l
fn = fn\upper()
fn = fn\gsub "[,[%];=+]", "_"
fn = fn\gsub "[^%a%d_.]", ""
fn = fn\sub(1, 6) .. "~1" if fn\len() > 8
ext = ext\sub(1, 3) if ext\len() > 3
return fn .. "." .. ext
@itsbth
itsbth / -
Created January 10, 2015 22:32
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 15G 14G 528M 97% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 2.0G 4.0K 2.0G 1% /dev
tmpfs 396M 940K 395M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 2.0G 4.0K 2.0G 1% /run/shm
none 100M 8.0K 100M 1% /run/user
/dev/sdb 32G 17G 14G 55% /home
Documents 120G 80G 40G 67% /media/sf_Documents
@itsbth
itsbth / main.rs
Last active August 29, 2015 14:11
use std::io;
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied,Vacant};
use std::ascii::AsciiExt;
fn main() {
let mut words: HashMap<String, uint> = HashMap::new();
for line in io::stdin().lock().lines() {
for word in line.unwrap().words() {
let lc = word.to_string().to_ascii_lower();
@itsbth
itsbth / py
Created December 15, 2014 01:57
from sys import stdin
from collections import Counter
from re import findall
words = Counter(findall("(\\w+(?:'\\w+)?)", stdin.read()))
print(words)
(import [sys [stdin]]
[collections [Counter]]
[re [findall]])
(setv words (-> (findall "(\w+(?:'\w+)?)"
(.read stdin))
(Counter)))
(print words)
use std::io;
use std::collections::HashMap;
use std::ascii::AsciiExt;
fn main() {
let mut words: HashMap<String, uint> = HashMap::new();
for line in io::stdin().lock().lines() {
for word in line.ok().unwrap().words() {
let lc = word.to_string().to_ascii_lower();
if words.contains_key(lc.as_slice()) {
from bottle import route, run, template
@route('/')
def index():
return template(*['<h1>Hello, {{subject}}!</h1>'], **{'subject': 'World', })
run(*[], **{'host': '0.0.0.0', 'port': '8080', })
(import [bottle [route run template]])
(with-decorator (route "/")
(defn index []
(apply template ["<h1>Hello, {{subject}}!</h1>"] {"subject" "World"})))
(apply run [] {"host" "0.0.0.0" "port" "8080"})
namespace FSharpBot
open Robocode
type MyFSharpBot() =
inherit Robot()
override this.Run() =
this.Initialize()
this.MainLoop()