Skip to content

Instantly share code, notes, and snippets.

@rparree
rparree / cleanVisioSVG.sh
Last active May 8, 2020 21:11
Script i made to clean SVG export from Visio (2007). Testing the cleaned SVGs in Chrome, Firefox and Inkscape.
#! /bin/sh
#set px for font size with metric
perl -pi -e 's/font-size:(\d+);/font-size:$1px;/g' "$1"
#replace em metrics with px (this is a bit brittle, as the ems are relative to the container text)
#First the @dy=".." (multiply by 8)
perl -pi -e 's/dy=\"(\d+(\.\d+)?)em\"/"dy=\"".sprintf("%.1f",$1*8)."px\""/ge' "$1"
#Then all the others (multiply by 12, which is the default font size set bu visio export)
perl -pi -e 's/(\d+(\.\d+)?)em/sprintf("%.1f",$1*12)."px"/ge' "$1"
@rparree
rparree / newSbt.sh
Last active December 28, 2015 21:09 — forked from maciej/init-scala.sh
#!/bin/bash
# https://gist.github.com/rparree/7562785
PROJECT_NAME="$1"
SCALA_VERSION="2.10.2"
mkdir $PROJECT_NAME
cd $PROJECT_NAME
@rparree
rparree / Depedencies.scala
Created February 6, 2015 11:02
SBT example scalajs and generated resources
import sbt._
// import scala.scalajs.sbtplugin.ScalaJSPlugin._
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
object Dependencies {
val akkaVersion = "2.3.5"
val sprayVersion = "1.3.2"
val sprayJsonVersion = "1.3.1"
val `spray-can` = "io.spray" %% "spray-can" % sprayVersion
rparree@hp-8570w:jbadmin-setup> vagrant vbguest --auto-reboot --no-provision
GuestAdditions versions on your host (4.3.24) and guest (4.3.22) do not match.
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mir01.syntis.net
* extras: mirror-fr1.bbln.org
* updates: mir01.syntis.net
Package kernel-devel-3.10.0-123.20.1.el7.x86_64 already installed and latest version
Package gcc-4.8.2-16.2.el7_0.x86_64 already installed and latest version
Package 1:make-3.82-21.el7.x86_64 already installed and latest version
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.*;
import java.io.IOException;
char[] buffer = new char[1024];
String chunk = null;
while ((read = reader.read(buffer)) != -1) {
String s = String.valueOf(buffer, 0, read);
/* process the string: Look for "-", keep the part after it
for the next iteration. Add part before it to previous
chunk
*/
}
@rparree
rparree / scala-bnf.html
Last active January 13, 2017 06:49
Clickable Scala syntax BNF
<!--
Source: https://www.scala-lang.org/files/archive/spec/2.13/13-syntax-summary.html
Just some nifty regex search/replace
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
@rparree
rparree / MyStringBuilder.scala
Created January 26, 2017 09:28
Stackable Trait (start)
abstract class MyStringBuilder {
def get(): String
def append(s: String)
}
class BasicStringBuilder extends MyStringBuilder {
private var value : String = ""
def get(): String = value
def append(s: String) = value = value + s
}
case class PersonalInfo(email: String, twitter: Option[String])
case class Student(username: String, personalInfo: Option[PersonalInfo])