Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Sam Bessalah samklr

🎯
Focusing
Block or report user

Report or block samklr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@samklr
samklr / install-proto.sh
Created Apr 20, 2015
Install Protobuf debian ...
View install-proto.sh
#! /bin/bash
wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz
tar xzf protobuf-2.6.1.tar.gz
cd protobuf-2.6.1
sudo apt-get update
sudo apt-get install build-essential
sudo ./configure
sudo make
sudo make check
sudo make install
@samklr
samklr / OffsetMngHbase.scala
Last active Aug 24, 2019
Offset Management on HBase
View OffsetMngHbase.scala
/*
Save offsets for each batch into HBase
*/
def saveOffsets(TOPIC_NAME:String,GROUP_ID:String,offsetRanges:Array[OffsetRange],
hbaseTableName:String,batchTime: org.apache.spark.streaming.Time) ={
val hbaseConf = HBaseConfiguration.create()
hbaseConf.addResource("src/main/resources/hbase-site.xml")
val conn = ConnectionFactory.createConnection(hbaseConf)
val table = conn.getTable(TableName.valueOf(hbaseTableName))
val rowKey = TOPIC_NAME + ":" + GROUP_ID + ":" +String.valueOf(batchTime.milliseconds)
View kafka-productivity-hacks.md

I've been working with Kafka for over 7 years. I inevitably find myself doing the same set of activities while I'm developing or working with someone else's system. Here's a set of Kafka productivity hacks for doing a few things way faster than you're probably doing them now. 🔥

Get the tools

View airpal.sh
apt-get install \
build-essential \
git \
gradle \
mysql-server
git clone https://github.com/airbnb/airpal.git
cd airpal
./gradlew clean shadowJar
mysql \
@samklr
samklr / AccumulatorListener.scala
Created Aug 2, 2016
Spark Accumulator Metrics
View AccumulatorListener.scala
import scala.collection.mutable.Map
import org.apache.spark.{Accumulator, AccumulatorParam, SparkContext}
import org.apache.spark.scheduler.{SparkListenerStageCompleted, SparkListener}
import org.apache.spark.SparkContext._
/**
* just print out the values for all accumulators from the stage.
* you will only get updates from *named* accumulators, though
@samklr
samklr / HealthStatus.scala
Created May 23, 2019 — forked from m-wrona/HealthStatus.scala
[Akka] Service health-check
View HealthStatus.scala
import akka.actor.{ ActorSystem, Props }
import akka.io.IO
import com.typesafe.config.Config
import com.typesafe.scalalogging.LazyLogging
import spray.can.Http
sealed class HealthStatusService(actorNames: List[String], webConfig: Config)(implicit system: ActorSystem) extends LazyLogging {
private[status] val healthCheckPath: String = webConfig.getString("status-path")
private[status] val timeoutDuration: Int = webConfig.getInt("timeout")
@samklr
samklr / REAME.md
Created May 20, 2019 — forked from davideicardi/REAME.md
Scala AES-CTR encryption, MAC, HMAC, ... with Bouncy Castle example
View REAME.md

Scala AES-CTR encryption Bouncy Castle example

Add the following library:

libraryDependencies += "org.bouncycastle" % "bcprov-jdk16" % "1.46"

AESCTR.scala

@samklr
samklr / output
Created May 16, 2019 — forked from MorganGeek/output
Install transmission on WD My Cloud
View output
FMCloud:~# wget https://gist.githubusercontent.com/MorganGeek/43ecb0ef1ac65322cd9237c16e77a5bb/raw/c8be05b2305c5b03b0e6ea1f2f27628625145371/wdmycloud-install-transmission.sh
--2017-06-17 07:54:43-- https://gist.githubusercontent.com/MorganGeek/43ecb0ef1ac65322cd9237c16e77a5bb/raw/c8be05b2305c5b03b0e6ea1f2f27628625145371/wdmycloud-install-transmission.sh
Resolving gist.githubusercontent.com (gist.githubusercontent.com)... 151.101.36.133
Connecting to gist.githubusercontent.com (gist.githubusercontent.com)|151.101.36.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1136 (1.1K) [text/plain]
Saving to: `wdmycloud-install-transmission.sh'
100%[===================================================================================================================>] 1,136 --.-K/s in 0.001s
View gist:f4c36236f5ce323a6edb31021763b495

Cryptographic Best Practices

Putting cryptographic primitives together is a lot like putting a jigsaw puzzle together, where all the pieces are cut exactly the same way, but there is only one correct solution. Thankfully, there are some projects out there that are working hard to make sure developers are getting it right.

The following advice comes from years of research from leading security researchers, developers, and cryptographers. This Gist was [forked from Thomas Ptacek's Gist][1] to be more readable. Additions have been added from

You can’t perform that action at this time.