Anup Dhakal
Sagar Chamling
In this guide, LEPP stands for Linux, Nginx (pronounced as Engine-X) , Postgres and PHP (PHP Hypertext Preprocessor).
#!/bin/bash | |
parse_time() { | |
IFS=' ' read -ra PART <<< "$1" | |
seconds=0 | |
for i in "${PART[@]}"; do | |
number=$(expr match $i '\([0-9]\+\)') | |
unit=$(expr match $i '[0-9]*\([a-z]\+\)') | |
case $unit in | |
h) |
$ uname -r
#!/bin/bash | |
aria2c -j5 -i list.txt -c --save-session out.txt | |
has_error=`wc -l < out.txt` | |
while [ $has_error -gt 0 ] | |
do | |
echo "still has $has_error errors, rerun aria2 to download ..." | |
aria2c -j5 -i list.txt -c --save-session out.txt | |
has_error=`wc -l < out.txt` | |
sleep 10 |
//[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17] => [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17]] | |
function grouped(arr, limit){ | |
return arr.map((data, index) => { | |
return index % limit === 0 ? arr.slice(index, index + limit) : null; | |
}).filter((item) => { return item; }) | |
} | |
//range crete [0,1,2,3,4...number] | |
function range(number){ | |
return Array.from(new Array(number), (x,i) => i) |
# Based on: | |
# http://www.zackarychapple.guru/chrome/2016/08/24/chrome-headless.html | |
# https://www.chromium.org/developers/how-tos/get-the-code | |
# https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md | |
apt-get update | |
apt-get install -y curl git htop man unzip vim wget python | |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git | |
export PATH=$PATH:`pwd`/depot_tools | |
mkdir Chromium && cd Chromium |
# E.g. TaskClass = CaseClass('name', 'owner', 'pid') | |
# task1 = TaskClass(name = "hello", owner = "brian", pid = 15) | |
# task2 = TaskClass(name = "world", owner = "brian", pid = 13) | |
# tasks = [task1, task2] | |
# | |
# filter(lambda task: task.where(owner = "brian"), tasks) => [task1, task2] | |
# filter(lambda task: task.where(owner = "brian", pid = 13), tasks) => [task2] | |
# | |
# matcher = TaskClass(pid = 13) | |
# filter(lambda task: task.match(matcher), tasks) => [task2] |
import akka.actor._ | |
import akka.stream.scaladsl.Flow | |
import org.apache.spark.streaming.dstream.ReceiverInputDStream | |
import org.apache.spark.streaming.receiver.ActorHelper | |
import akka.actor.{ ExtensionKey, Extension, ExtendedActorSystem } | |
import scala.reflect.ClassTag | |
object AkkaStreamSparkIntegration { |
package tech.webstar.utils | |
import scala.collection.mutable | |
/** | |
* @author sasajib | |
*/ | |
trait BoundedQueue[A] extends mutable.Queue[A] { | |
def maxSize: Int | |
override def +=(a: A): this.type = { |
import scala.collection.mutable | |
/** | |
* Bounded priority queue trait that is intended to be mixed into instances of | |
* scala.collection.mutable.PriorityQueue. By default PriorityQueue instances in | |
* Scala are unbounded. This trait modifies the original PriorityQueue's | |
* enqueue methods such that we only retain the top K elements. | |
* The top K elements are defined by an implicit Ordering[A]. | |
* @author Ryan LeCompte ([email protected]) | |
*/ |