Skip to content

Instantly share code, notes, and snippets.

View anderssonfilip's full-sized avatar

Filip Andersson anderssonfilip

View GitHub Profile
@anderssonfilip
anderssonfilip / keybase.md
Created September 13, 2019 02:25
keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object:

CREATE (p:Person { name: 'Alice' })
CREATE (p:Person { name: 'Bob' })
CREATE (c:City { name: 'London' })
CREATE (c:City { name: 'Portsmouth' })
CREATE (s:StreetName { name: 'High Street' })
MATCH (s:StreetName), (c:City) CREATE (s)-[:IS_IN]->(c)
MATCH (p:Person{name:'Alice'}), (c:City{name:'London'}) CREATE (p)-[:LIVES_IN]->(c)
MATCH (p:Person{name:'Bob'}), (c:City{name:'Portsmouth'}) CREATE (p)-[:LIVES_IN]->(c)
@anderssonfilip
anderssonfilip / Rotate
Created May 1, 2014 22:26
Javascript rotation in a plane
var rotate = function(x, y){
var rx = 0;
var ry = 0;
var quarter = end/(Math.PI/2)
console.log("rotation: " + end)
if(end === 0)
var ts: List[Long] = List.empty
def time[R](block: => R): R = {
val t0 = System.nanoTime()
val result = block
val t1 = System.nanoTime()
val t = t1 - t0
ts = ts ++ List(t)
result
}
@anderssonfilip
anderssonfilip / LiftedEmbedding
Last active August 29, 2015 13:57
Slick lifted Coffees
class Coffees(tag: Tag) extends Table[(String, Int, Double, Int, Int)]
(tag, "COFFEES") {
def name = column[String]("NAME", O.PrimaryKey)
def price = column[Double]("PRICE")
}
@anderssonfilip
anderssonfilip / DirectEmbedding
Last active August 29, 2015 13:57
Slick direct Coffees
@table(name="COFFEES")
case class Coffee(
@column(name="NAME")
name : String,
@column(name="PRICE")
price : Double
)
@anderssonfilip
anderssonfilip / gist:9528419
Last active August 29, 2015 13:57
Spray Client example
// Akka Actor system
import akka.actor.ActorSystem
// HTTP related imports
import spray.http.{ HttpRequest, HttpResponse }
import spray.client.pipelining.{ Get, sendReceive }
// Futures related imports
import scala.concurrent.Future
import scala.util.{ Success, Failure }
class PairOfShoes(var leftSize: Int, var rightSize: Int) {
def mix(newLeftSize: Int, newRightSize: Int) =
{
leftSize = newLeftSize
rightSize = newRightSize
}
override def hashCode(): Int = leftSize + 31 * rightSize
def canEqual(that: Any): Boolean = that match {
@anderssonfilip
anderssonfilip / gist:8955633
Last active August 29, 2015 13:56
Simple Python script to cap disk space of a folder
import os
cap = 1 # cap in Megabytes
from datetime import date, timedelta
from time import gmtime
cutoffDate = date.today()-timedelta(days=1) # does not delete files newer than this (exclusive of the date)
def GetFolderSize(start_path = '.'): #get disk space in Megabytes
return sum(os.path.getsize(f) for f in os.listdir('.') if os.path.isfile(f)) / (1024*1024)
@anderssonfilip
anderssonfilip / gist:8955589
Last active February 15, 2022 07:05
Simple Python script to archive older files in a folder by tagging
import os
import glob
from datetime import date, timedelta
import re
from time import gmtime, strftime
folder = '<Insert folder name here>'
files = ['FileA.txt', 'FileB.txt']
archivePeriod = 5 # archive period in days