Skip to content

Instantly share code, notes, and snippets.

View faisal00813's full-sized avatar

Mohammad Abdul Sami faisal00813

  • Locuples | iindyverse
  • Hyderabad
View GitHub Profile
@faisal00813
faisal00813 / deadboltHandler.scala
Created August 4, 2016 12:27
Deadbolt handler with JWT in scala
package api_security
import java.util
import be.objectify.deadbolt.core.models.{Permission, Role, Subject}
import be.objectify.deadbolt.scala.cache.HandlerCache
import io.igl.jwt._
import play.api.inject.{Binding, Module}
import play.api.libs.json.{JsBoolean, JsString, JsValue}
import play.api.{Configuration, Environment, Logger}
#Productivity
alias ls="ls --color=auto"
alias ll="ls --color -al"
alias grep='grep --color=auto'
mcd() { mkdir -p "$1"; cd "$1";}
cl() { cd "$1"; ls;}
backup() { cp "$1"{,.bak};}
md5check() { md5sum "$1" | grep "$2";}
alias makescript="fc -rnl | head -1 >"
@faisal00813
faisal00813 / Graph.scala
Created September 13, 2016 13:45
Graph implementation in Scala
package graph
/**
* Created by sami on 13/9/16.
*/
case class Edge[E, N](source: Graph[E, N], target: Graph[E, N], value: E)
class Graph[E, N](var value: N = null.asInstanceOf[N]) {
import scala.collection.immutable.Queue
#Sound Switcher
sudo apt-add-repository ppa:yktooo/ppa
sudo apt update && sudo apt install indicator-sound-switcher
#change Sudo timeout
#https://itsfoss.com/change-sudo-password-timeout-ubuntu/
#command notify
#https://itsfoss.com/notification-terminal-command-completion-ubuntu/
@faisal00813
faisal00813 / String Substitution.scala
Last active November 7, 2016 10:33
Substitues the variable with the value provided
/**code taken from http://stackoverflow.com/a/4051500/845019
* substitutes the string with #{variableName} format
*/
implicit def RichFormatter(string: String) = new {
def richFormat(replacement: Map[String, Any]) =
(string /: replacement) { (res, entry) => res.replaceAll("#\\{%s\\}".format(entry._1), entry._2.toString) }
}
@faisal00813
faisal00813 / updateDateTimeFrom_ID
Last active February 7, 2017 14:13
Query for updating the timesatamp in document extracted from _Id field
db['your-collection'].find().forEach(function (doc){
d = doc._id.getTimestamp();
doc.visitedOn = d;
db['your-collection'].update({"_id":doc._id},doc,{upsert:true});
print(d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds()) })
@faisal00813
faisal00813 / README.md
Created March 16, 2017 07:53
AllDiseasesAndConditions(CDC US)

README is empty

import thunk from 'redux-thunk';
import expect from 'expect';
describe('actions test', () => {
beforeAll(() => {
// do something here which you want to be executed before first test runs
}
it('editor.newPatient() should create a new patient', (done) => {
source `which virtualenvwrapper.sh`
cd ~
rm Node*
workon latest-sovrin-master
nohup start_sovrin_node Node1 9701 9702 > Node1.log &
sleep 5
nohup start_sovrin_node Node2 9703 9704 > Node2.log &
sleep 5
nohup start_sovrin_node Node3 9705 9706 > Node3.log &
sleep 5
@faisal00813
faisal00813 / akkahttp_routes.scala
Last active November 21, 2017 06:55
Akka-http request handler for application/octet-stream
pathPrefix("user") {
path("msgPackTest") {
post {
extractRequest {
req =>
println(req.headers)
req.entity match {
case strict: HttpEntity.Strict =>
val resp = req.entity.dataBytes.runFold(ByteString.empty) { case (acc, b) => acc ++ b }
.map(x=> processMsgPackMsg(x.compact.toArray[Byte]))