Skip to content

Instantly share code, notes, and snippets.

View kommen's full-sized avatar

Dieter Komendera kommen

View GitHub Profile
(ns cljftp
(:require [clojure.java.io :as io])
(:import [java.net URL]))
;; See also https://www.ietf.org/rfc/rfc1738.txt
;; a public FTP test server https://dlptest.com/ftp-test/
(def ftp-url "ftp://dlpuser:[email protected]/")
(def file-name "test.txt")
@kommen
kommen / hiccup.cljs
Created September 20, 2020 14:12
poor/hiccup.cljs
;; "forked" from @plexus' https://github.com/plexus/hoc-schedule/blob/25f8cf59e57a1d2177fb99b79f1f6fad2c9fc942/src/poor/hiccup.cljs
(ns poor.hiccup
(:require [goog.dom :as gdom]
[clojure.string :as str]))
(defn split-tag [tag]
(let [tag (name tag)
parts (str/split tag #"\.")]
[(first parts)
#!/bin/bash
abs_bin_dir="$(cd "$(dirname "$0")" && pwd)"
FILE="${abs_bin_dir}/zprint-filter-0.4.4"
# check if zprint server port is reachable
ncat -z 127.0.0.1 7877
if [ $? == 0 ]; then
ncat 127.0.0.1 7877 <&0
@kommen
kommen / mp3_info.ex
Created May 8, 2016 18:28
Compute MP3 variable bitrate file duration with Elixir
defmodule Mp3Info do
def duration(data) do
compute_duration(data, 0, 0)
end
defp compute_duration(data, offset, duration) when byte_size(data) > offset do
case decode_header_at_offset(offset, data) do
{:ok, length, {samplerate, samples}} ->
compute_duration(data, offset + length, duration + (samples / samplerate))

Keybase proof

I hereby claim:

  • I am kommen on github.
  • I am kommen (https://keybase.io/kommen) on keybase.
  • I have a public key whose fingerprint is 2870 6088 7CB6 77E4 A7CD 145A 5DE6 A38A C816 E624

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am kommen on github.
  • I am kommen (https://keybase.io/kommen) on keybase.
  • I have a public key whose fingerprint is 139A F26F 5378 3EC5 1750 3093 08C6 65E7 CF8B 1940

To claim this, I am signing this object:

@kommen
kommen / gist:5743831
Created June 9, 2013 14:56
Queue presentViewController and dismissViewControllerAnimated with dispatch semaphores.
- (void) queueViewControllerTransition:(BOOL)show {
static dispatch_queue_t presentAndDismissViewControllerQueue;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
presentAndDismissViewControllerQueue = dispatch_queue_create("presentAndDismissViewControllerQueue", DISPATCH_QUEUE_SERIAL);
});
dispatch_async(presentAndDismissViewControllerQueue, ^{
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
dispatch_async(dispatch_get_main_queue(), ^{
@kommen
kommen / postgres-bloat.sql
Created March 1, 2013 15:32
How much space is wasted by your Postgres database due to table and index bloat.
-- Based on http://pgsql.tapoueh.org/site/html/news/20080131.bloat.html
-- see that linked version for detailed table and index listings on where that bloat is
SELECT pg_size_pretty(SUM(bs*(relpages-otta))::bigint) AS wastedsize,
pg_size_pretty(SUM(CASE WHEN ipages < iotta THEN 0 ELSE bs*(ipages-iotta) END)::bigint) AS wastedisize
FROM (
SELECT
schemaname, tablename, cc.reltuples, cc.relpages, bs,
CEIL((cc.reltuples*((datahdr+ma-
(CASE WHEN datahdr%ma=0 THEN ma ELSE datahdr%ma END))+nullhdr2+4))/(bs-20::float)) AS otta,
COALESCE(c2.relname,'?') AS iname, COALESCE(c2.reltuples,0) AS ituples, COALESCE(c2.relpages,0) AS ipages,
@kommen
kommen / gist:4214658
Created December 5, 2012 10:51
Ruby 2.0.0 vs. Ruby 1.9.3 Date
$ ruby -v
ruby 2.0.0dev (2012-12-01 trunk 38126) [x86_64-darwin12.2.0]
$ irb
irb(main):001:0> Date
=> Date
irb(main):002:0> Date.today
NoMethodError: undefined method `today' for Date:Class
from (irb):2
from /Users/kommen/.rbenv/versions/2.0.0-preview2/bin/irb:12:in `<main>'
irb(main):003:0> require 'date'
@kommen
kommen / deploy.rb
Created July 17, 2012 16:03
Cap task to only precompile rails 3.1 assets if asset files have changed
set :branch, "origin/#{ENV['BRANCH'] || "master"}"
namespace :assets do
desc "Precompile rails 3.1 assets"
task :precompile, :except => { :no_release => true } do
asset_paths = "app/assets lib/assets vendor/assets"
if !ENV['FORCE_PRECOMPILE'].nil? || capture("cd #{current_path}; git diff-tree --name-only -r #{deployed_revision} HEAD #{asset_paths} | wc -l").strip.to_i > 0
deploy.precompile_assets
else
logger.info "Skipping asset pre-compilation because there were no asset changes"