Skip to content

Instantly share code, notes, and snippets.

View biniama's full-sized avatar

Biniam biniama

View GitHub Profile
@biniama
biniama / Query and Output 1
Last active September 16, 2017 10:00
GraphDatabase - Titan with AWS DynamoDB
#A simple Gremlin query that finds restaurants based on a type of cuisine is shown below:
gremlin> g.V.has('genreId', 'Pizzeria').in.restaurant_name
==>La Fontana Pizza Restaurante and Cafe
==>Dominos Pizza
==>Little Cesarz
==>pizza clasica
==>Restaurante Tiberius
@biniama
biniama / Consumer.java
Last active December 7, 2023 13:46
Producer-Consumer Design Pattern in Java
package com.demo.pc;
import java.util.concurrent.BlockingQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Consumer implements Runnable {
private final BlockingQueue<Integer> sharedQueue;
@biniama
biniama / ex1.java
Last active August 20, 2018 22:55
Java Exam from MUM
1. Write a function that accepts an array of non-negative integers and returns the second largest integer in the array. Return -1 if there is no second largest.
The signature of the function is
int f(int[ ] a)
Examples:
if the input array is return
{1, 2, 3, 4} 3
{{4, 1, 2, 3}} 3
{1, 1, 2, 2} 1
{1, 1} -1
@biniama
biniama / ListItemCounter.groovy
Created August 22, 2016 09:39
How to count elements of List of List (count number of p's in List<Car>)
class Car {
String model
List<Integer> p = new ArrayList<>()
}
List<Car> cars = new ArrayList<Car>()
Car car1 = new Car()
car1.model = "BMW"
car1.p[0] = 1
@biniama
biniama / git-delete-merged-branches.sh
Created May 9, 2016 09:37
Delete all remote branches that have already been merged into master
git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
cut -d"/" -f2- |
xargs git push origin --delete
#Source: https://gist.github.com/schacon/942899
@biniama
biniama / DataSource.groovy
Last active January 27, 2026 09:02
Multiple datasource in Grails Services with SQL
dataSource {
pooled = true
jmxExport = true
driverClassName = "com.mysql.jdbc.Driver"
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
// cache.region.factory_class = 'org.hibernate.cache.SingletonEhCacheRegionFactory' // Hibernate 3
@biniama
biniama / groovy-sql.groovy
Created March 31, 2016 11:45
Comparing results of RXJava JDBC with normal groovy query
@GrabConfig(systemClassLoader=true)
@Grab('mysql:mysql-connector-java:5.1.25')
@Grab('log4j:log4j:1.2.17')
import groovy.sql.Sql
import groovy.sql.GroovyRowResult
import groovy.time.TimeCategory
def start = new Date()
@biniama
biniama / rxjava-jdbc.groovy
Created March 31, 2016 11:45
rxjava-jdbc example
@GrabConfig(systemClassLoader=true)
@Grab('mysql:mysql-connector-java:5.1.25')
@Grab('log4j:log4j:1.2.17')
@Grab('com.github.davidmoten:rxjava-jdbc:0.7')
import groovy.sql.Sql
import groovy.sql.GroovyRowResult
import groovy.time.TimeCategory
import com.github.davidmoten.rx.jdbc.Database
@GrabConfig(systemClassLoader=true)
@Grab('mysql:mysql-connector-java:5.1.25')
@Grab('log4j:log4j:1.2.17')
import groovy.sql.Sql
import groovy.sql.GroovyRowResult
import groovy.time.TimeCategory
def start = new Date()
@biniama
biniama / Config.groovy
Created December 16, 2015 16:58
Grails emailing using templates
/**
* Grails Mail Plugin Configurations
*/
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "email@gmail.com"
password = "password123"
props = ["mail.smtp.auth":"true",