Skip to content

Instantly share code, notes, and snippets.

View ijonas's full-sized avatar

Ijonas Kisselbach ijonas

View GitHub Profile
@ijonas
ijonas / gist:9719722
Last active August 29, 2015 13:57
Reading in a config file.
if configBytes, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", os.Getenv("HOME"), ".ddknife")); err == nil {
for _, row := range strings.Split(string(configBytes), "\n") {
if tuple := strings.Split(row, "="); len(tuple) == 2 {
configFileSettings[tuple[0]] = tuple[1]
}
}
}
@ijonas
ijonas / speedtest.go
Created April 9, 2014 05:47
Go / Node / Ruby Speed comparison
package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
r := rand.New(rand.NewSource(99))
@ijonas
ijonas / Vagrantfile
Created April 28, 2014 11:04
CBStack Configuration Files
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "opscode/ubuntu1404"
config.vm.network "forwarded_port", guest: 80, host: 8090
config.vm.network "forwarded_port", guest: 3306, host: 3306
config.vm.network "forwarded_port", guest: 9200, host: 9200
@ijonas
ijonas / gist:896e35cb6d0be921decb
Created July 30, 2014 16:17
Not using default scope
class Product < ActiveRecord::Base
validates :title, :description, :image_url, :presence=> true
validates :price, :numericality => {:greater_than_or_equal_to => 0.01}
validates :title, :uniqueness => true
validates :image_url, format: {
:with => %r{\.(gif|jpg|png)\Z}i,
:message => 'must be a url'
}
def ordered_by_title
@ijonas
ijonas / keybase.md
Created September 17, 2014 14:47
keybase.md

Keybase proof

I hereby claim:

  • I am ijonas on github.
  • I am ijonas (https://keybase.io/ijonas) on keybase.
  • I have a public key whose fingerprint is DE26 F284 D61B 9703 78D7 B94C E3AC 4853 1526 EB62

To claim this, I am signing this object:

@ijonas
ijonas / logrotateconf
Created December 1, 2014 09:57
Quick & dirty Ruby script to generate a whole bunch of logrotate conf files.
#! /usr/bin/env ruby
# license: MIT
# example usage: ./logrotateconf $PWD/newrelic_agent.log > newrelic_agent
conf = <<-eos
{
rotate 14
daily
missingok
create 640 ubuntu ubuntu
notifempty
@ijonas
ijonas / gist:41e3a155e94c64fc4630
Created April 1, 2015 09:05
ReactNative NavigatorIOS component doesn't pass 'navigator' object into props
var CBSupport = React.createClass({
_handleNextButtonPress: function() {
debugger
AlertIOS.alert("Be A Lert");
// this.props does not contain a 'navigator' property
this.props.navigator.push({
component: Login,
title: 'Login'
});
class AppServerConfig
attr_accessor :port, :admin_password
end
class Configuration
attr_accessor :tail_logs, :max_connections, :admin_password
def initialize
@app_server_config = AppServerConfig.new
end
require "resque"
require "resque/failure/multiple"
require "resque/failure/redis"
require 'exceptional'
# Configure Resque connection from config/resque.yml. This file should look
# something like:
# development: localhost:6379
# test: localhost:6379:15
# production: localhost:6379
<!-- Would you specify: -->
<script type="text/x-handlebars" data-template-name="user">
{{content.name}}
<a href="#" {{action "logout" target="App.currentUserController"}}>Logout</a>
</script>
<!-- or -->
<script type="text/x-handlebars" data-template-name="user">