Skip to content

Instantly share code, notes, and snippets.

View Endeios's full-sized avatar
🦁

Bruno Veronesi Endeios

🦁
View GitHub Profile
@Endeios
Endeios / GroovySSEParser.groovy
Last active August 29, 2015 14:03
My Groovy server sent events parser
import java.util.regex.Pattern
import java.util.regex.Matcher
def url = new URL('http://localhost:8080/my-events/eventStream');
//url = new URL('https://www.gnu.org/licenses/gpl-3.0.txt');
def data = """event:lol
data:Tue Jul 08 10:27:37 CEST 2014
"""
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@Endeios
Endeios / MyMDEditor
Created April 22, 2014 12:48
Simple MD editor
#!/usr/bin/env groovy
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@Endeios
Endeios / colorz.sh
Created March 12, 2014 13:59
the always useful shell color text codes, from https://gitorious.org/demure/dotfiles/source/
RCol='\e[0m' # Text Reset
# Regular Bold Underline High Intensity BoldHigh Intens Background High Intensity Backgrounds
Bla='\e[0;30m'; BBla='\e[1;30m'; UBla='\e[4;30m'; IBla='\e[0;90m'; BIBla='\e[1;90m'; On_Bla='\e[40m'; On_IBla='\e[0;100m';
Red='\e[0;31m'; BRed='\e[1;31m'; URed='\e[4;31m'; IRed='\e[0;91m'; BIRed='\e[1;91m'; On_Red='\e[41m'; On_IRed='\e[0;101m';
Gre='\e[0;32m'; BGre='\e[1;32m'; UGre='\e[4;32m'; IGre='\e[0;92m'; BIGre='\e[1;92m'; On_Gre='\e[42m'; On_IGre='\e[0;102m';
Yel='\e[0;33m'; BYel='\e[1;33m'; UYel='\e[4;33m'; IYel='\e[0;93m'; BIYel='\e[1;93m'; On_Yel='\e[43m'; On_IYel='\e[0;103m';
Blu='\e[0;34m'; BBlu='\e[1;34m'; UBlu='\e[4;34m'; IBlu='\e[0;94m'; BIBlu='\e[1;94m'; On_Blu='\e[44m'; On_IBlu='\e[0;104m';
Pur='\e[0;35m'; BPur='\e[1;35m'; UPur='\e[4;35m'; IPur='\e[0;95m'; BIPur='\e[1;95m'; On_Pur='\e[45m'; On_IPur='\e[0;105m';
C
package state
trait RNG {
def nextInt: (Int, RNG)
def positiveInt(rng: RNG): (Int, RNG)
def double(rng: RNG): (Double, RNG)
def intDouble(rng: RNG): ((Int, Double), RNG)
def doubleInt(rng: RNG): ((Double, Int), RNG)
def double3(rng: RNG): ((Double, Double, Double), RNG)
def ints(count: Int)(rng: RNG): (List[Int], RNG)
@Endeios
Endeios / Zerver
Created February 18, 2014 13:25
Scala Server
package propBased
import java.net.ServerSocket
import java.io.BufferedReader
import java.net.Socket
import java.io.InputStreamReader
import java.io.Writer
import java.io.Reader
import java.io.PrintWriter
@Endeios
Endeios / Option.scala
Last active January 3, 2016 21:19
Chap 4
package chap4
sealed trait Option[+A] {
def map[B](f: A => B): Option[B] = this match {
case None => None
case Some(a) => Some(f(a))
}
def flatMap[B](f: A => Option[B]): Option[B] = this match {
case None => None
@Endeios
Endeios / blueprint.xml
Last active January 1, 2016 14:29
Blueprint (a.k.a Dark PINT) file, with schema location, for editors that support autocompletion and pom with ready to copy/paste maven plugin to maker bundles with aQute bnd tools. in the pom is crucial the <extensions>true</extensions>, in order to activate the bundle packaging extension
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd ">
<!-- An empty blueprint descriptor -->
</blueprint>
@Endeios
Endeios / client
Created November 25, 2013 16:41
some functions in python for a simple multithreaded client,server
import socket
import futures
import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.DEBUG)
def loltest(ronfz):