Skip to content

Instantly share code, notes, and snippets.

View bassemZohdy's full-sized avatar

Bassem Reda Zohdy bassemZohdy

View GitHub Profile
FROM centos:6
LABEL maintainer="bzohdy"
RUN yum -y update && yum -y install ksh
ADD https://downloads.sourceforge.net/project/gull/seagull/1.8.2/seagull-1.8.2-Linux_RHEL6U1_X86_64.tar.gz /tmp/
WORKDIR /tmp
RUN tar xvf seagull-1.8.2-Linux_RHEL6U1_X86_64.tar.gz
WORKDIR /tmp/packages
RUN rpm -ivh seagull-core-1.8.2-linux-2.6-intel.rpm && \
rpm -ivh seagull-diameter-protocol-1.8.2-linux-2.6-intel.rpm
WORKDIR /opt/seagull
FROM alpine
LABEL maintainer="bassem.zohdy@gmail.com"
ARG JAVA_VERSION=8
ENV LANG C.UTF-8
ENV JAVA_HOME /usr/lib/jvm/default-jvm
ENV PATH $PATH:/usr/lib/jvm/default-jvm/jre/bin:/usr/lib/jvm/default-jvm/bin
RUN apk update --no-cache && apk add --no-cache bash openjdk$JAVA_VERSION
ADD https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-cli/2.0.0.BUILD-SNAPSHOT/spring-boot-cli-2.0.0.BUILD-20171013.160946-30-bin.tar.gz /opt/spring/
WORKDIR /opt/spring/
RUN tar xvf spring-boot-cli-2.0.0.BUILD-20171013.160946-30-bin.tar.gz
#!/usr/bin/env bash
set -e
#set -x
arrayContains(){
ARRAY=($1);
ITEM=$2;
if echo "${ARRAY[*]}" | grep -E -q " $ITEM |^$ITEM | $ITEM\$" ;
then
echo true;
else
#!/bin/bash
set -e
set -x
MAP_FILE='./map'
DELIMITER=","
add (){
KEY=$1
VALUE=$2
echo Key=$KEY Value=$VALUE
#/bin/bash
# if sudo not required
# find . -name *.sh 2>>/dev/null| xargs chmod +x
find . -name *.sh 2>>/dev/null| xargs sudo chmod +x
# to verify
# find . -name *.sh -ls 2>>/dev/null
# OR
# find . -name *.sh 2>>/dev/null| xargs ls -l
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.IntStream;
public class StreamSample {
@bassemZohdy
bassemZohdy / ScriptValidator.java
Created September 13, 2016 17:36
ScriptValidator validate java object with javascript
import java.util.function.Predicate;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class ScriptValidator implements Predicate<Object> {
private final ScriptEngine engine;
private final String functionName;
import static java.lang.Thread.currentThread;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Optional;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.function.Function;
public class BytesConvertUtils {
public static final Function<Integer, byte[]> intToBytes = l -> {
int count = Integer.BYTES;
return new byte[] { (byte) ((l >> 8 * --count) & 0xFF),
(byte) ((l >> 8 * --count) & 0xFF),
(byte) ((l >> 8 * --count) & 0xFF),
(byte) ((l >> 8 * --count) & 0xFF) };
};
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
public class StringToCharSequences implements Function<String, CharSequence[]> {
final private char delimiter;
public StringToCharSequences(char delimiter) {
this.delimiter = delimiter;