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 / Maven Assembly Plugin
Last active October 7, 2019 09:15
Apache Maven Assembly Plugin: Usage
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
@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 / kafka-console-consumer tip1
Last active November 2, 2023 12:56
Print key of records in kafka-console-consumer
use --property print.key=true
Example : ./kafka-console-consumer.sh --bootstrap-server <BROKERS_ADDRESS> --topic <YOUR_TOPIC> --property print.key=true
@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 / Css styles
Last active August 27, 2022 21:05
centering images in Hugo - Based on this article : (http://www.ebadf.net/2016/10/19/centering-images-in-hugo/)
img[src$='#center']
{
display: block;
margin: 0.7rem auto; /* you can replace the vertical '0.7rem' by
whatever floats your boat, but keep the
horizontal 'auto' for this to work */
/* whatever else styles you fancy here */
}
img[src$='#floatleft']
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o main .
@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")