Skip to content

Instantly share code, notes, and snippets.

@Bost
Bost / d3.chart.analog.js
Last active August 29, 2015 14:01 — forked from marufbd/d3.chart.analog.js
d3js - Data-Driven Documents
(function () {
d3.analog= function() {
var height = 200, gap=10,
xValue = function(d) { return d[0]; },
xScale = null,
color = d3.scale.category10();
function chart(selection) {
selection.each(function(d) {
var g = d3.select(this);
@Bost
Bost / conduit.clj
Last active August 29, 2015 14:20 — forked from attentive/conduit.clj
clojure; enlive - dynamic deftemplate
(ns gist.conduit
(:require [net.cgrand.enlive-html :as html]
[net.cgrand.tagsoup :as tagsoup]))
; The implementations of conduit and defconduit are modified versions of
; the macros template and deftemplate from the guts of Enlive.
; They're named 'conduit' because the selectors and transformations serve as a
; channel between the scaffold of HTML and some data provided as an argument.
@Bost
Bost / network.el
Created May 3, 2015 22:01
network-interface-list
(defun test-internet ()
(remove-if (lambda (el)
(string-match-p "lo.*" (car el)))
(network-interface-list)))
(test-internet)
(defun tzz-has-network ()
(remove-if (lambda (i)
(or (string-match-p "\\(vboxnet\\|docker\\).*" i)
@Bost
Bost / loop-recur.clj
Last active November 23, 2015 11:49
clojure loop recur
(loop [r 0
break false]
(if-not break
(if (< r 5)
(do
(println "Expensive calculation of r:" r)
(recur (inc r) false))
(do
(println "Breaking the loop at:" r)
(recur r true)))))
@Bost
Bost / HelloWorld.java
Created April 11, 2013 11:51 — forked from kano4/HelloWorld.java
java - HelloWorld
public class HelloWorld {
public static void main (String[] args) {
System.out.println("Hello, World!");
}
}
@Bost
Bost / clojure: about-datatypes.clj
Last active December 16, 2015 07:39
clojure - collections
(defn persistent-hash-map [k v]
"Create PeristentHashMap - performs faster for larger maps"
(hash-map k v))
(type (persistent-hash-map :a 1))
(defn persisten-array-map [k v]
"Create PeristentArrayMap - only suitable for very small maps"
{k v})
(type (persisten-array-map :a 1))
@Bost
Bost / cobol-mode.el
Created September 28, 2016 12:46 — forked from Edward-H/cobol-mode.el
An Emacs mode for COBOL code. It features syntax highlighting for most modern dialects, indentation, support for free- and fixed-format code and code skeletons.
;;; cobol-mode.el --- Mode for editing COBOL code -*- lexical-binding: t; -*-
;; Copyright (C) 2013-2015 Edward Hart
;; Author: Edward Hart <edward.dan.hart@gmail.com>
;; Maintainer: Edward Hart
;; Version: 0
;; Created: 9 November 2013
;; Keywords: languages
@Bost
Bost / list-ppa
Last active July 26, 2017 16:35 — forked from jnakatsui/list-ppa
list ppa on *nix system
#!/usr/bin/env bash
# get all the PPAs installed on a system ready to share for reininstall
for APT in `find /etc/apt/ -name \*.list`; do
# list found files - helps in case of: '... public key is not available: NO_PUBKEY'
echo $APT
grep -o "^deb http://ppa.launchpad.net/[a-z0-9\-]\+/[a-z0-9\-]\+" $APT | while read ENTRY ; do
USER=`echo $ENTRY | cut -d/ -f4`
PPA=`echo $ENTRY | cut -d/ -f5`
echo sudo apt-add-repository ppa:$USER/$PPA
@Bost
Bost / for-loop.sh
Last active July 31, 2017 14:45
bash: for-loop
#!/usr/bin/env bash
# Debugging
# set -x
# Stop on error
set -e
# Exit if variables are not set (recommended)
set –u
tstp() {
@Bost
Bost / logging.sh
Last active July 31, 2017 14:46
bash: logging a la log4j
#!/usr/bin/env bash
# Debugging
# set -x
# Stop on error
set -e
# Exit if variables are not set (recommended)
set –u
logfile=file.log