Skip to content

Instantly share code, notes, and snippets.

View isterin's full-sized avatar

Ilya Sterin isterin

View GitHub Profile
### Keybase proof
I hereby claim:
* I am isterin on github.
* I am isterin (https://keybase.io/isterin) on keybase.
* I have a public key ASBeeNpLPjr5HN39W8poOT69YgYgraigHy1SRqG32UZ_6go
To claim this, I am signing this object:
class ProxiedHttpRequest(val req:HttpRequest) {
lazy val proxyServer = InetAddress.getByName(“some.proxy.com”)
}
object ProxiedHttpRequest {
implicit def delegateToOriginalHttpRequest(
r: ProxiedHttpRequest):HttpRequest = r.req
}
object Application {
def proxyRequest(req:ProxiedHttpRequest) {
val where = req.proxyServer
object Application {
def proxyRequest(req:ProxiedHttpRequest) {
val where = req.proxyServer
/*
Here I need access to original request being wrapped to get the headers This is ugly and I’d prefer to access it as I would a regular HttpRequest req.headers()
*/
val headers = req.req.headers()
}
}
class ProxiedHttpRequest(val req:HttpRequest) {
lazy val proxyServer = InetAddress.getByName(“some.proxy.com”)
}
@isterin
isterin / Application.scala
Created July 9, 2017 03:21
Scala automatic wrapper/delegation with implicits
class ProxiedHttpRequest(val req:HttpRequest) {
lazy val proxyServer = InetAddress.getByName(“some.proxy.com”)
}
object ProxiedHttpRequest {
implicit def delegateToOriginalHttpRequest(
r: ProxiedHttpRequest):HttpRequest = r.req
}
object Application {
def proxyRequest(req:ProxiedHttpRequest) {
val where = req.proxyServer
<%= form_for @changeset, @action, fn f -> %>
<%= for {[id, name], ae} <- Enum.group_by(f.data.appentries, &([&1.sqmentry.sqmgroup.id, &1.sqmentry.sqmgroup.name])) do %>
<div>Group: <%= name %></div>
# Here I have to iterate the hierarchy
<%= inputs_for f, :appentries, fn e -> %>
<%= inputs_for e, :sqmentry, fn s -> %>
<%= inputs_for s, :sqmgroup, fn g -> %>
<div>
# input field goes here for (e, :status)
</div>
const playlist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
let N = process.argv[2] || 10;
function shuffle(a) {
const newA = a.slice(); // Copy array
for (let i = newA.length; i; i--) {
let j = Math.floor(Math.random() * i);
[newA[i - 1], newA[j]] = [newA[j], newA[i - 1]];
}
@isterin
isterin / one.scala
Last active July 6, 2016 04:09
Scala automatic wrapper/delegation with implicits
class ProxiedHttpRequest(val req:HttpRequest) {
lazy val proxyServer = InetAddress.getByName(“some.proxy.com”)
}
@isterin
isterin / find_grep
Last active January 12, 2016 23:48
Interfaces are eating the world
find . -name "*.txt" | xargs egrep -il "last\\s+report" | xargs egrep -il "From:\s+Tom"
@isterin
isterin / pattern.scala
Last active September 15, 2015 18:37
Scala pattern matching
import java.util
import java.util.{Map => JMap, List => JList}
import scala.reflect.runtime.universe._
object PatternMatching extends App {
val o: JMap[String, Any] = new util.HashMap[String, Any]()
val o2: JList[JMap[String, Any]] = new util.ArrayList[JMap[String, Any]]()