Skip to content

Instantly share code, notes, and snippets.

@teamon
teamon / oofp.scala
Last active December 11, 2015 02:59
// OO Style
class A {
def f = lotOfStuff1(a)
def a = lotOfStuff2(b)
def b = lotOfStuff3(c)
def c(x: X) = { ... }
}
class A2 extends A {
override def c(x: X) = { something different here }

Plain - works fine

int a = 1;

Table - does not compile

+------------+

/*
* SSO - Lab 6.1
* Tymon Tobolski 181037
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
@teamon
teamon / acts_as_api.rb
Created November 1, 2012 13:44
DRY acts_as_api + custom rails responders integration
# config/initilizers/acts_as_api.rb
ActsAsApi::Config.include_root_in_json_collections = false
 stress λ pwd 18:35:34
/Users/teamon/bin/gatling-charts-highcharts-1.3.0/user-files/simulations/org/scalajars/stress
 stress λ cat ProjectSearchSimulation.scala 18:35:38
package org.scalajars.stress
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import com.excilys.ebi.gatling.jdbc.Predef._
import com.excilys.ebi.gatling.http.Headers.Names._
import akka.util.duration._
import bootstrap._
@teamon
teamon / .zshrc
Created October 22, 2012 13:09
Nicer ip
 ~ λ cat .zshrc | grep "function ip" --after 5
function ip {
echo "External: $(curl --silent checkip.dyndns.org | awk '{print $6}' | cut -f 1 -d "<")"
echo "Ethernet: $(ifconfig en0 | grep netmask | awk '{print $2}')"
echo "Airport: $(ifconfig en1 | grep netmask | awk '{print $2}')"
echo "VPN: $(ifconfig ppp0 | grep inet | awk '{print $2}')"
}
@teamon
teamon / clock.rb
Created October 20, 2012 21:18
clockwork + sidekiq integration
require 'clockwork'
require 'sidekiq'
# load all jobs from app/jobs directory
# no need to load rails env, we only care about classes
# (#perform method is not invoked in this process)
Dir["app/jobs/*"].each {|f| load f }
module Clockwork
every(1.day, 'midnight.job', :at => '00:00'){
@teamon
teamon / README
Created October 20, 2012 18:31
Custom form models
http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/
O rly? Duplikacja atrybutów, duplikacja walidacji, pozdro z walidacja typu uniqueness of albo cokolwiek innego co hituje bazy per model.
package recurly.api
import java.util.Date
import play.api.libs.ws._
import play.api.libs.concurrent._
import play.api.Logger
import com.ning.http.client.Realm.AuthScheme
class Api(val apiKey: String, val privateKey: String) {
val base = "https://api.recurly.com/v2"
package recurly.api
import java.util.Date
case class Account(
accountCode: String,
username: String,
email: String,
firstName: String,
lastName: String,