Skip to content

Instantly share code, notes, and snippets.

View patforna's full-sized avatar

Patric Fornasier patforna

View GitHub Profile
@patforna
patforna / import.rb
Last active December 15, 2015 11:29 — forked from ngauthier/import.rb
compute tags, include '{% include JB/setup %}' instead of h1, ignore comments
require 'rubygems'
require 'nokogiri'
require 'fileutils'
require 'date'
# usage: ruby import.rb my-blog.xml
# my-blog.xml is a file from Settings -> Basic -> Export in blogger.
data = File.read ARGV[0]
doc = Nokogiri::XML(data)
@patforna
patforna / gist:6903956
Created October 9, 2013 16:24
why does integration:test also execute unit tests? (line 18-22 and 24)
> test:test
unit: should include file:/Users/patric/Dropbox/tmp/sbt/src/test/scala/com/springer/core/functional/foo/FunctionalTest.scala => false
unit: should include file:/Users/patric/Dropbox/tmp/sbt/src/test/scala/com/springer/core/integration/foo/IntegrationTest.scala => false
unit: should include file:/Users/patric/Dropbox/tmp/sbt/src/test/scala/com/springer/core/shared/utils/Clock.scala => true
unit: should include file:/Users/patric/Dropbox/tmp/sbt/src/test/scala/com/springer/core/system/foo/SystemTest.scala => false
unit: should include file:/Users/patric/Dropbox/tmp/sbt/src/test/scala/com/springer/core/unit/foo/UnitTest.scala => true
[info] Compiling 2 Scala sources to /Users/patric/Dropbox/tmp/sbt/target/scala-2.10/test-classes...
[info] UnitTest:
[info] - should run a unit test
[info] Passed: : Total 1, Failed 0, Errors 0, Passed 1, Skipped 0
# switch between different jdk versions. usage: jdk 1.7
function jdk() {
if [ $# -ne 0 ]; then
if [ -n "${JAVA_HOME+x}" ]; then
removeFromPath $JAVA_HOME
fi
export JAVA_HOME="/opt/java/jdk-$@"
export PATH=$JAVA_HOME/bin:$PATH
fi
echo JAVA_HOME set to $JAVA_HOME
{
"spanDepths": {
"-3545230476842099781": 1,
"4547029349960013747": 2
},
"trace": {
"duration": 43000,
"endTimestamp": 1401378812420000,
"serviceCounts": {
"service-a": 1,
// service A
val tracer = ZipkinTracer.mk(host = "localhost", port = 9410, sampleRate = 1)
Trace.unwind {
Trace.pushTracerAndSetNextId(tracer)
Trace.recordRpcname("service-A", "GET")
Trace.record(Annotation.ServerRecv())
// client call to service B (see below)
function addToPath() {
export PATH=$1:$PATH
}
function removeFromPath() {
export PATH=$(echo $PATH | sed -E -e "s;:$1;;" -e "s;$1:?;;")
}
# switch between different jdk versions. usage: jdk 1.7
function jdk() {
E, [2014-08-14T17:34:04.328831 #87010] ERROR -- : Ridley::Errors::ClientError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
E, [2014-08-14T17:34:04.328945 #87010] ERROR -- : /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/responses.rb:29:in `value'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/calls.rb:92:in `value'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/proxies/sync_proxy.rb:33:in `method_missing'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/proxies/cell_proxy.rb:17:in `_send_'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/pool_manager.rb:41:in `_send_'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/pool_manager.rb:140:in `method_missing'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/celluloid-0.16.0.pre2/lib/celluloid/calls.rb:26:in `public
(ns cracking.p_02_05
(:require [clojure.test :refer :all]))
(defn different? [[a b]] (not (= a b)))
(defn first-elem [[a b]] a)
; This is a solution using "Floyd's cycle-finding algorithm"
(defn detect-loop [coll]
(let [tortoise (drop 1 coll)
#!/usr/bin/env bash
grep -rh '@mixin' web/public/css | cut -d' ' -f2 | egrep -o '^[a-z\-]+' > /tmp/mixins
for mixin in `cat /tmp/mixins`; do
echo --- $mixin
grep --exclude mixin.names -ri "@include $mixin" web/public/css | grep -v '//'
done
#
# starting point
#
class DeployCLI
def run
template, args = ...
TemplateRenderer.new.render(template, args)
end
end