Skip to content

Instantly share code, notes, and snippets.

View mostafa-asg's full-sized avatar
:octocat:
while(!(succeed = try()))

Mostafa Asgari mostafa-asg

:octocat:
while(!(succeed = try()))
View GitHub Profile
@mostafa-asg
mostafa-asg / gitignore for java
Last active August 7, 2017 05:01
.gitignore for java projects
# Eclipse
.classpath
.project
.settings/
# Intellij
.idea/
*.iml
*.iws
@mostafa-asg
mostafa-asg / HBase row count
Last active October 9, 2017 12:05
HBase row count
hbase org.apache.hadoop.hbase.mapreduce.RowCounter [TABLE_NAME]
@mostafa-asg
mostafa-asg / Set proxy on your linux terminal
Last active October 9, 2017 12:07
Set proxy on your linux terminal
export http_proxy="<YOUR PROXY>"
export https_proxy="<YOUR PROXY>"
@mostafa-asg
mostafa-asg / gist:dda81ad6e6eb324a4e1be204d402243a
Created January 6, 2018 08:45
bean’s namespace for Spring beans configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>
public class SpinLock {
private AtomicReference<Thread> owner = new AtomicReference<Thread>();
public void lock() {
Thread thread = Thread.currentThread();
while (!owner.compareAndSet(null, thread)) {
}
}
package main
type FuncIntInt func(int) int
func memorized(fn FuncIntInt) FuncIntInt {
cache := make(map[int]int)
return func(input int) int {
if val, found := cache[input]; found {
println("Read from cache")
class Dfa {
var states = Seq.empty[State]
var finalStates = Seq.empty[State]
var currentState : State = null
var input:String=""
val transition = new Transition
val transitionMap = transition.transitionMap
def states( block: => Seq[State] ): Dfa = {
import slick.jdbc.H2Profile.api._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Await
import scala.concurrent.duration.Duration
object Main {
case class User(username:String, password: String,id:Long=0)
class Users(tag: Tag) extends Table[User](tag , "users") {
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o main .
@mostafa-asg
mostafa-asg / GitCommitEmoji.md
Created February 11, 2019 10:12 — forked from parmentf/GitCommitEmoji.md
Git Commit message Emoji