Skip to content

Instantly share code, notes, and snippets.

View mnylen's full-sized avatar

Mikko Nylén mnylen

  • Mikko Nylén Oy
  • Toijala
  • X @nylemi
View GitHub Profile
use std::io::BufferedReader;
use std::io;
fn main() {
let mut reader = BufferedReader::new(io::stdin());
println!("What is your name?");
let age_input: ~str = reader.read_line().unwrap();
let age_trimmed: &str = age_input.trim();
# using VirtualBox version $VBOX_VERSION
FROM boot2docker/boot2docker
RUN apt-get install p7zip-full
RUN mkdir -p /vboxguest && \
cd /vboxguest && \
curl -L -o vboxguest.iso http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso && \
7z x vboxguest.iso -ir'!VBoxLinuxAdditions.run' && \
sh VBoxLinuxAdditions.run --noexec --target . && \
c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
if git rev-parse --git-dir >/dev/null 2>&1
@mnylen
mnylen / checklist.md
Last active September 20, 2015 20:19
Checklist to get ElasticSearch cluster on AWS EC2 working

Checklist to get ElasticSearch cluster on AWS EC2 working

  • Install cloud-aws-plugin (https://github.com/elastic/elasticsearch-cloud-aws)

  • Give your EC2 instances IAM Instance Policy with permission to ec2:DescribeInstances. The plugin will automatically get correct access keys after this.

    • You should really do the above, but you can also just create a new IAM user and set up cloud.aws.access_key and cloud.aws.secret_key in elasticsearch.yml. But you really should create instance policy instead.
  • Set discovery.type: ec2 in elasticsearch.yml

@mnylen
mnylen / OS X Snow Leopard
Created January 5, 2011 13:21
How to get RVM + Subversion Ruby Bindings to work
$ rvm use 1.8.7-p302
$ wget http://subversion.tigris.org/downloads/subversion-1.6.15.tar.gz
$ tar -xzf subversion-1.6.15.tar.gz && cd subversion-1.6.15
$ ./configure --with-ruby-sitedir=~/.rvm/rubies/ruby-1.8.7-p302/lib/ruby --without-berkeley-db
$ make swig-rb && make install-swig-rb
To test things out:
$ irb
ruby-1.8.7-p302 > require 'svn/client'
=> true

deny

deny is a simple DSL for doing authorizations in Ruby on Rails controllers. It follows the principle of default deny: all requests are denied unless explicitly permitted.

Usage

First, include the Deny module to your ApplicationController. This sets up the controller to deny all requests made.

express = require 'express'
assetManager = require 'connect-assetmanager'
app = express.createServer
app.use assetManager
var pressedKeys = {};
var tick = function(msDuration) {
gamejs.event.get().forEach(function(e) {
if (e.type == gamejs.event.KEY_DOWN) {
pressedKeys[e.key] = true;
} else if (e.type == gamejs.event.KEY_UP) {
delete pressedKeys[e.key];
}
});
# config/initializers/suppress_action_view_field_errors.rb
# The default form builder appends <div class="field_with_errors"> (or something similar)
# to all fields and labels for model attributes that have validation errors. Doesn't work
# so well with Bootstrap.
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
"#{html_tag}".html_safe
end
val zip = new ZipStreamHelper(new ZipInputStream(...))
zip.rewindTo("hello.xml") { in =>
val parser = STaxParser()
val root = parser.fromInputStream(in)
}