Skip to content

Instantly share code, notes, and snippets.

View alaz's full-sized avatar

Alexander Azarov alaz

View GitHub Profile
us.rdx2.lgtvsdp.com
us.info.lgsmartad.com
us.ibs.lgappstv.com
us.lgtvsdp.com
ad.lgappstv.com
smartshare.lgtvsdp.com
ibis.lgappstv.com
# added after fork
# from https://www.reddit.com/r/pihole/comments/6qmpv6/blacklists_for_lg_webos_tvs/ and others
def radixSort(arr: Seq[Int]): Seq[Int] = {
def fn(state: Seq[Int], d: Int): Seq[Int] = {
val ten_power_d = Iterator.fill(d)(10).product
val buckets = state.groupBy(_ / ten_power_d % 10).toMap
buckets.keys.toSeq.sorted.foldLeft(Seq.empty[Int]) { case (acc, i) =>
acc ++ buckets(i)
}
}
val digits = Iterator.iterate(arr) {
@alaz
alaz / readfile.js.es6
Last active January 7, 2017 16:00 — forked from depeele/gist:66656a73bf53773ae852f6613ae05876
HackerRank Javascript stdin using an ES6 generator and larger buffer
'use strict';
function* readLine(stream) {
const EOL = require('os').EOL;
const Fs = require('fs');
const buf = new Buffer(1024);
stream.resume();
stream.setEncoding('ascii');
@alaz
alaz / blocking.scala
Last active April 4, 2016 09:39 — forked from jessitron/gist:8777503
The magic of blocking { ... } in Scala's global ExecutionContext: it leads to the creation of more threads, so the CPUs don't get bored
val des = scala.concurrent.ExecutionContext.global
import scala.concurrent._
import duration._
def ct = Thread.currentThread.getName
val n = Runtime.getRuntime.availableProcessors
def hogThread(sec:Int) = future {
@alaz
alaz / 200x150.html
Created September 4, 2012 07:36
Osinka banner 200x150
<a href="http://www.osinka.ru/?utm_source=people&utm_medium=button&utm_content=osinka_banner_200x150_1&utm_campaign=110125"
title="Осинка.ру - все о моде, шитье и рукоделии"><img
src="http://www.osinka.ru/info/banners/osinka_banner_200x150_1.png"
width="200"
height="150"
border="0"></a>
@alaz
alaz / Comments.scala
Created January 20, 2012 13:06
Subset: "Blog post - comments" example
package com.osinka.subset.examples
/**
* Data model from this MongoDB doc page:
* http://www.mongodb.org/display/DOCS/Updating#Updating-The%24positionaloperator
*/
// Use :paste mode
import com.mongodb._
import com.osinka.subset._
@alaz
alaz / 01_init.scala
Created January 20, 2012 13:02
REPLable Subset play
import scala.io._
import collection.JavaConversions._
import com.mongodb._
import com.osinka.subset._
import SmartValues._
// we want to store it in MongoDB. ok..
val mongo = new Mongo("192.168.0.164")
val db = mongo getDB "test"
val coll = db getCollection "timeline"
@alaz
alaz / LiftResourceBundleControl.scala
Created November 23, 2011 15:11
ResourceBundle.Control implementation based on Liftweb resources XML format
package com.osinka.i18n
import java.util.{Locale,ResourceBundle}
import collection.JavaConversions._
import net.liftweb.common.Box._
import net.liftweb.util.{BundleBuilder,PCDataXmlParser}
/**
* ResourceBundle.Control implementation for Liftweb resources
*
trait PostStart { actor: Actor =>
def postStart: Unit
override def preStart {
super.preStart
actor.become {
case "PostStart" => try { postStart } finally { actor.unbecome }
}
actor.self ! "PostStart"
}
import reflect.{Manifest, ClassManifest}
import org.scalatest.matchers.{Matcher,MatchResult}
trait CustomMatchers {
/**
* Based on http://daily-scala.blogspot.com/2010/01/overcoming-type-erasure-in-matching-1.html
*/
class ConformMatcher[A](implicit m: Manifest[A]) extends Matcher[AnyRef] {
override def apply(obj: AnyRef) = {
def deepConformance[B,C](desired: Manifest[B], actual: Manifest[C]): Boolean = {