Skip to content

Instantly share code, notes, and snippets.

@dbernheisel
dbernheisel / bump-version.sh
Last active January 15, 2024 03:16
Bash script to bump the version
#!/bin/bash
# Works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# this script will display the current version, automatically
# suggest a "minor" version update, and ask for input to use
# the suggestion, or use a newly entered value.
mov2gif(){
ffmpeg -i "$1" -vf scale=800:-1 -pix_fmt rgb24 -r 10 -f image2pipe -vcodec ppm - |\
convert -delay 10 -layers Optimize -loop 0 - "$2"
}
(ns erdos-c.core
[:require [yokogiri.core :refer :all]])
(def client (make-client :javascript false))
(defn page [uri]
(get-page client (str "http://en.wikipedia.org" uri)))
(defn link-snippets [uri]
(xpath (page uri) "//a"))
@robfe
robfe / Typescript.md
Last active December 16, 2015 20:29

TypeScript (0.8)

  • A superset of the JavaScript language.
  • Code in TypeScript, compile to JavaScript, deploy JavaScript. (Similar workflow to CoffeeScript)

Advantages

  • Very similar to JavaScript.
  • Type safety - when you need it. TypeScript is a gradually typed language.
  • Less boilerplate.
  • Programmer's intent is clearer in the code.
@szarnekow
szarnekow / CarElement.xtend
Last active December 15, 2015 06:09
Illustration of the visitor pattern with Active Annotations.
@Visitable
abstract class CarElement {
// placeholder
def void accept(CarElementVisitor visitor)
}
@Data
class Wheel extends CarElement {
String name;
}
class Engine extends CarElement {}
@knutwannheden
knutwannheden / GenerateMyDsl.xtend
Last active December 11, 2015 23:28 — forked from anonymous/GenerateMyDsl.xtend
MWE2 workflow using pure Xtend.
package org.xtext.example.mydsl
import org.eclipse.emf.mwe.utils.DirectoryCleaner
import org.eclipse.emf.mwe.utils.StandaloneSetup
import org.eclipse.xtext.generator.Generator
import org.eclipse.xtext.generator.LanguageConfig
import org.eclipse.xtext.generator.builder.BuilderIntegrationFragment
import org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment
import org.eclipse.xtext.generator.exporting.QualifiedNamesFragment
import org.eclipse.xtext.generator.formatting.FormatterFragment
@ikoblik
ikoblik / scc.clj
Last active December 10, 2015 17:08
Strongly connected components implementation in Clojure.
(ns koblik.scc)
(defn dfs
"Depth first search. Short form of the method passes through all the
nodes of the graph even if it's disconnected .
(nodes-fn graph) expected to return list of all the nodes in the graph.
(child-fn graph node) expected to return list of all the nodes linked
to the given node.
Returns hash-map where nodes are associated with a pair :idx, :leader.
:idx stores finishing index of the node traversal (post-order counter)
:leader first finishing index of the current DFS."
@xuwei-k
xuwei-k / Hello.xtend
Created September 13, 2012 16:53
sbtend sample
class Hello{
def static void main(String[] args) {
println("Hello World")
}
}
@cgrand
cgrand / restrict-map.clj
Created May 29, 2012 10:15
Restricting nested maps to keys of interest
;; I could have used a closed dispatch (aka cond) but you may find this version more enjoyable
;; the spec format is the one provided by BG
(defprotocol Selector
(-select [s m]))
(defn select [m selectors-coll]
(reduce conj {} (map #(-select % m) selectors-coll)))
(extend-protocol Selector
@jabbrwcky
jabbrwcky / InsecureHttpClient.java
Created February 6, 2012 13:15
A sample how to configure Apache HTTPClient (4.+) to accept SSL connections *without* certificate and hostname validation
package net.hausherr.sample;
import org.apache.http.client.CookieStore;
import org.apache.http.conn.routing.HttpRoute;
import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;