Skip to content

Instantly share code, notes, and snippets.

View mkotsalainen's full-sized avatar

Matti Kotsalainen mkotsalainen

View GitHub Profile
var HelloMessage = React.createClass({
render: function() {
return <div>Hello {this.props.name}</div>;
}
});
React.render(<HelloMessage name="John" />, mountNode);
package main
import "fmt"
import "net/http"
import "io/ioutil"
import "io"
import "os"
import "strings"
import "code.google.com/p/go.net/html"
package main
import "fmt"
import "net/http"
import "io/ioutil"
import "io"
import "os"
import "strings"
import "code.google.com/p/go.net/html"
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"bytes"
"encoding/json"
"go/ast"
@mkotsalainen
mkotsalainen / turn_off_strict_host_checking.yml
Created June 18, 2013 12:30
Ansible action to turn off git strict host checking
- name: Turn off strict host checking so that git checkout works
lineinfile: dest=/etc/ssh/ssh_config regexp='StrictHostKeyChecking\s+no' line='StrictHostKeyChecking no'
@mkotsalainen
mkotsalainen / install_webserver.yml
Last active December 18, 2015 15:19
An example Ansible playbook stolen from http://www.ansibleworks.com/docs/playbooks.html for educational purposes
---
-
hosts: webservers
user: root
vars:
http_port: 80
max_clients: 200
tasks:
@mkotsalainen
mkotsalainen / locustfile.py
Last active December 17, 2015 03:08
A small Locust perf test
# coding: utf-8
import random
from locust import Locust, TaskSet, task
from pyquery import PyQuery
class WebsiteTasks(TaskSet):
# det här exekveras varje gång Locust skapar en användare
# vi läser in länkar till blogginlägg och nyheter från Creunas hemsida
# test comment
print 'ok'
@mkotsalainen
mkotsalainen / image_compressor.sh
Created November 10, 2012 15:11
A shell script that wraps compresses all png/jpegs images under a directory
#!/bin/bash
if [[ $# -ne 1 || ! -d $1 ]]; then
echo "Usage: image_compressor.sh [dir]"
exit 1
fi
# check requirements
for cmd in optipng jpegoptim setfattr
@mkotsalainen
mkotsalainen / list_colors.rb
Created September 30, 2012 20:41
Lists the colors in a css file
require 'set'
unless ARGV.length == 1
puts "usage: display_colors_in_css.rb [css_file]"
exit 1
end
css = IO.read(ARGV[0])
color_refs = css.scan /\#[0-9A-Fa-f]{3,6}/
color_set = Set.new( color_refs.map(&:upcase) )
puts color_set.to_a.sort