Skip to content

Instantly share code, notes, and snippets.

@kkrs
kkrs / AddNoCacheHeaders.scala
Created April 16, 2018 06:55 — forked from mrubin/AddNoCacheHeaders.scala
StaticAssetsController
package controllers.staticAssets
import play.api.http.HeaderNames
import play.api.mvc.{Action, Request, Result}
import scala.concurrent.Future
case class AddNoCacheHeaders[A](action: Action[A]) extends Action[A] with HeaderNames {
def apply(request: Request[A]): Future[Result] = {
import scala.concurrent.ExecutionContext.Implicits.global
@kkrs
kkrs / gist:275bf070c4deb4feec4e90cabbe7185d
Created March 24, 2018 19:02 — forked from also/gist:7729708
how does /usr/libexec/java_home work?
# /usr/libexec/java_home -X
$ sudo opensnoop -n java_home
UID PID COMM FD PATH
501 79809 java_home 3 /System/Library/PrivateFrameworks/JavaLaunching.framework/Versions/A/JavaLaunching
501 79809 java_home 3 /dev/dtracehelper
501 79809 java_home 4 /System/Library/CoreServices/SystemVersion.bundle//English.lproj
501 79809 java_home -1 /System/Library/CoreServices/SystemVersion.bundle//Base.lproj
501 79809 java_home 4 /System/Library/CoreServices/SystemVersion.bundle/English.lproj/SystemVersion.strings
501 79809 java_home -1 /System/Library/CoreServices/SystemVersion.bundle/English.lproj/SystemVersion.stringsdict
501 79809 java_home 3 /usr/share/icu/icudt51l.dat

Technical details for https://stackoverflow.com/a/44169445/6730571

Details of investigation:

On a base system, /usr/bin/java is a symlink that points to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java, which is an Apple wrapper tool that locates and executes the actual java.

(Do not touch anything in those 2 system directories. It should actually be impossible due to "System Integrity Protection" anyway.)

If you don't have Java installed, attempting to execute java will open a dialog that invites you to install it.

@kkrs
kkrs / ExercisePrimitives.scala
Created November 2, 2017 23:17 — forked from senorcarbone/ExercisePrimitives.scala
ID2203.1x Exercise Lib
package se.kth.edx.id2203.core
import java.net.{ InetAddress, InetSocketAddress }
import se.kth.edx.id2203.core.ExercisePrimitives.PerfectP2PLink._
import se.kth.edx.id2203.core.Ports._
import se.sics.kompics.{ Init, KompicsEvent }
import se.sics.kompics.network.{ Address, Network, Transport }
import se.sics.kompics.sl.{ ComponentDefinition, _ }
@kkrs
kkrs / GitHub-Forking.md
Created September 18, 2017 20:09 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@kkrs
kkrs / gist:6f67b9d57e7b0c4cbc022fd21fbe3273
Created July 27, 2017 21:53 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@kkrs
kkrs / EmbeddedKafkaCluster.java
Created February 16, 2017 22:41 — forked from vmarcinko/EmbeddedKafkaCluster.java
Embedded Zookeeper & Kafka cluster
import kafka.server.KafkaConfig;
import kafka.server.KafkaServer;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;