Skip to content

Instantly share code, notes, and snippets.

val xs = List.fill(100)("X")
var count = 0
xs.maxBy { x =>
{
count += 1
x.length()
}
} //> res0: String = X
@mhewedy
mhewedy / check.js
Created July 16, 2016 19:58
js six strange literals
function check(v) {
var out = {}
out.value = v
if (v) {
out.ifCheck = true
} else {
out.ifCheck = false
}
@mhewedy
mhewedy / subtitles.groovy
Last active September 13, 2016 11:58
subtitles, simply rename the movie and subtitles files by {number}.{ext}
// Groovy script to rename TV series media files and subtitles
// so that the subtitles picket automatically by the media player.
import groovy.io.FileType
import java.nio.file.Path
import java.nio.file.Paths
import java.util.regex.Pattern
def pattern = ~/[s|S](\d{2})?[e|E](\d{2})?.*\.(.*)?/
@mhewedy
mhewedy / abc.js
Created September 23, 2016 18:31
Get employee list from http://stackoverflow.com/company/team (I Like JS & JQUERY )
$('.teams li').map(function(){
var that = $(this);
var o = {};
['name', 'job-title', 'location'].forEach(function(e){
o[e] = that.find('.' + e).text();
});
console.log(o);
});
@mhewedy
mhewedy / Optional.java
Created October 12, 2016 11:47
java util Optional
public static void main(String[] args) {
System.out.println(getEmployeeNames(simulateWsResult1()));
System.out.println(getEmployeeNames(simulateWsResult2()));
System.out.println(getEmployeeNames(simulateWsResult3()));
System.out.println(getEmployeeNames(simulateWsResult4()));
}
static class Result {
@mhewedy
mhewedy / HibernateSelectMapApplication.java
Created November 11, 2016 00:08
using List<Map<String, Object>> as return type for hql queries
package test;
import java.util.List;
import java.util.Map;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@mhewedy
mhewedy / gmaps-drawing-tools-places.htm
Created March 25, 2017 11:04 — forked from anonymous/gmaps-drawing-tools-places.htm
gmaps-drawing-tools-places.htm
<!DOCTYPE html>
<!-- http://gmaps-samples-v3.googlecode.com/svn/trunk/drawing/drawing-tools.html -->
<!-- https://developers.google.com/maps/documentation/javascript/examples/places-searchbox -->
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<title>Drawing Tools (B)</title>
<!-- NOTE: two libraries to load are comma-separated; otherwise last mention of the query string arg overwrites the previous -->
<script type="text/javascript"
<?xml version="1.0" encoding="utf-8"?>
<MPD
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:mpeg:dash:schema:mpd:2011"
xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd"
xmlns:cenc="urn:mpeg:cenc:2013"
xmlns:mas="urn:marlin:mas:1-0:services:schemas:mpd"
xmlns:drm="http://example.net/052011/drm"
type="static"
mediaPresentationDuration="PT1H26M45.269334S"
@mhewedy
mhewedy / example.cs
Last active July 27, 2017 21:11
Multiple DAL
// The domain Object
public class Employee
{
string firstName;
string lastName;
}
// The Business Layer
@mhewedy
mhewedy / Test.java
Last active August 14, 2017 12:17
Using java 8 streams to build a rules validator/transformer
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Stream;
public class Test {
public static void main(String[] args) {
Request request = new Request(600, "Abbas");