Skip to content

Instantly share code, notes, and snippets.

View glava's full-sized avatar
🥑

Goran Ojkić glava

🥑
  • Soundcloud
  • Berlin
View GitHub Profile
@glava
glava / RoundRobin
Created December 15, 2011 15:59
Round Robin - java
package test;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import junit.framework.TestCase;
class Robin {
private int i;
# terminal command for monitoring http requests
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
@glava
glava / Rakefile
Last active August 8, 2020 12:34
Stop, Start, Restart Rake tasks for Rails
desc 'Stop rails server'
task :stop do
 File.new("tmp/pids/server.pid").tap { |f| Process.kill 9, f.read.to_i }.delete
end
desc 'Starts rails server'
task :start do
Process.exec("rails s puma -d")
end
@glava
glava / custom_events.js
Created January 17, 2014 15:49
Custom events in JavaScript Mostly based on this excellent article http://www.nczonline.net/blog/2010/03/09/custom-events-in-javascript/
function EventTarget() {
this._listeners = {};
}
EventTarget.prototype = {
constructor: EventTarget,
addListener: function(type, listener){
if (typeof this._listeners[type] == "undefined"){
@glava
glava / gist:8562207
Created January 22, 2014 16:44
Adding trim to any string
Function.prototype.method = function (name, func) {
this.prototype[name] = func;
return this;
};
String.method('trim', function () {
return this.replace(/^\s+|\s+$/g, '');
});
@glava
glava / sbt-template.sh
Last active August 29, 2015 14:02
Creates a SBT project directory structure
#!/bin/bash
#------------------------------------------------------------------------------
# Name: sbt-template.sh
# Purpose: Create an SBT project directory structure
# Usage: project=foo ./sbt-template.sh
#------------------------------------------------------------------------------
set -e
if [ -d "${project}" ]; then
echo "ERROR: Directory with specified ${project} name exist."
@glava
glava / app.js
Last active August 2, 2016 02:41 — forked from mshwery/app.js
Knockout + custom components + browserify
var ko = require('knockout');
ko.components.register('simple-name', require('./simple-name.js'));
ko.applyBindings({ userName: ko.observable() });
@glava
glava / InsertInto.scala
Created December 18, 2015 13:26
Add save function to every jooq table
import org.jooq.impl.TableImpl
import org.jooq.Record
object InsertInto {
// This enables you to write inserts like this
// Tables.USER_TABLE.save(userRecord)
implicit class EnhancedTableImpl[T <: Record](val table: TableImpl[T]) extends AnyVal {
def save(record: T)(implicit context: DSLContext) = {
val fields = record.fields().toSeq
context
@glava
glava / argument parsing
Created January 15, 2016 13:28
argument parsing
#!/bin/bash
while getopts ":i:o:s:" opt; do
case $opt in
s)
ss=$OPTARG
;;
i)
input=$OPTARG
;;
// Fire up that repl!
// You can't mix apple and oranges
var orange: String = "nice sweet orange"
var apple: Int = 10
orange = apple // error: type mismatch
// You should keep info about the type all the time
var oranges: List[String] = List("sweet 1", "sweet 2")
var apple: Int = 10