Skip to content

Instantly share code, notes, and snippets.

View loverdos's full-sized avatar

Christos KK Loverdos loverdos

View GitHub Profile
import java.lang.System
import java.io.File
import java.util.regex.Pattern
val Path = System.getenv("PATH")
val PathSep = File.pathSeparator
val pathFolders = Path.split(PathSep).toList.map(new File(_)).filter { file =>
if(file.isDirectory) {
if(2 != args.length) {
System.err.println("Usage: change-path-element in-elem out-elem")
System.exit(1)
}
val In = args(0)
val Out = args(1)
//println("In = " + In)
//println("Out = " + Out)
(if(args.isEmpty) Array("build.xml") else args) foreach { file =>
try {
print(file + ": ")
println(scala.xml.XML.loadFile(file) \ "target" map (target => target \ "@name") filter (!_.isEmpty) mkString ", ")
} catch {
case e => println(e.getClass + ": " + e.getMessage)
}
}
$ curl -I http://www.gsis.gr/diagonismos_ELLAK.html
HTTP/1.0 404 Not Found
Date: Fri, 19 Mar 2010 17:34:11 GMT
Server: Apache
Last-Modified: Thu, 14 Apr 2005 10:53:27 GMT
ETag: "2ebe1-34cc-55dcf7c0"
Accept-Ranges: bytes
Content-Length: 13516
Content-Type: text/html; charset=ISO-8859-7
import java.util.zip._
import java.io._
class InMemZip(compressionLevel: Int) {
private val _outBytes = new ByteArrayOutputStream
private val _zipOutStream = {
val s = new ZipOutputStream(_outBytes)
s.setLevel(compressionLevel)
s
}
// expecting the https:// url on the command line
import java.net.URL
val url = new URL(args(0))
val con = url.openConnection()
con.connect()
val certs = con.asInstanceOf[javax.net.ssl.HttpsURLConnection].getServerCertificates
certs.zipWithIndex.foreach { case (cert, index) =>
# program may be a soft-link
PRG="$0"
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`/"$link"
@loverdos
loverdos / HttpStatus.java
Created October 26, 2010 12:40
Http status codes
public final class HttpStatus {
private HttpStatus() {
}
public static final int CONTINUE = 100;
public static final int SWITCHING_PROTOCOLS = 101;
public static final int OK = 200;
public static final int CREATED = 201;
public static final int ACCEPTED = 202;
public static final int NON_AUTHORITATIVE_INFORMATION = 203;
@loverdos
loverdos / gist:977003
Created May 17, 2011 18:05
IDEA JVM Settings
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-Xms512m
-Xmx512m
-XX:MaxPermSize=250m
-XX:ReservedCodeCacheSize=64m
-XX:+DoEscapeAnalysis
-XX:NewRatio=1
-XX:+DisableExplicitGC
-XX:+AggressiveOpts
@loverdos
loverdos / gist:1248378
Created September 28, 2011 16:16
The greatest CssSel
import net.liftweb.util.CssSel
/**
* A great invention that allows to always write our CSS transforms with an &
* at the end and have this one as the last case.
*
* https://gist.github.com/gists/1248378
*/
object EndOfCssSel {