Skip to content

Instantly share code, notes, and snippets.

View carhartl's full-sized avatar

Klaus Hartl carhartl

View GitHub Profile

Keybase proof

I hereby claim:

  • I am carhartl on github.
  • I am carhartl (https://keybase.io/carhartl) on keybase.
  • I have a public key whose fingerprint is E232 B27A 7789 83C6 B383 C981 F4DA 8A9F 83F7 395E

To claim this, I am signing this object:

@carhartl
carhartl / cartodb-utils.py
Created March 24, 2016 14:57 — forked from andrewxhill/cartodb-utils.py
command-line python interface for manipulating data on CartoDB
import os
import urllib
import urllib2
import base64
import json
import sys
import argparse
try:
import requests
except ImportError:
@carhartl
carhartl / postgis.rb
Created January 12, 2016 13:59
Monkey-patching brew formulas for installing postgres 9.4 + postgis 2.1.7
class Postgis < Formula
desc "Adds support for geographic objects to PostgreSQL"
homepage "http://postgis.net"
url "http://download.osgeo.org/postgis/source/postgis-2.1.7.tar.gz"
sha256 "00ab79a3f609d7ea458f6fc358032ad059cb720baf88285243d6436a597a7ec2"
revision 1
def pour_bottle?
# Postgres extensions must live in the Postgres prefix, which precludes
# bottling: https://github.com/Homebrew/homebrew/issues/10247
@carhartl
carhartl / uniq_input.rb
Last active January 7, 2016 16:30
Remove redundant substrings from list
input = %w(Bochum Stu Stut Stuttt Stutt Stuttgart Heesestr. Berl Berlin)
input.sort!.reverse.uniq { |s| input.grep(/\A#{s}/).last } # => ["Stuttt", "Stuttgart", "Heesestr.", "Bochum", "Berlin"]
@carhartl
carhartl / album.rb
Last active August 29, 2015 14:20 — forked from rklemme/album.rb
require 'yaml'
Track = Struct.new :title, :duration
# An Album represents an audio medium which has title,
# interpret, a pause duration between tracks and a list
# of individual tracks.
class Album
attr_reader :title, :interpret, :pause
@carhartl
carhartl / update-git-remotes.sh
Last active June 23, 2022 15:13
Update git remotes within a workspace directory when you've renamed an organization
#!/bin/sh
#
# Assumes that the directory any repo was cloned to matches its name on GitHub,
# e.g. https://github.com/digitalservice4germany/java-application-template
# was cloned to a directory named "java-application-template".
#
# Run this in the (parent) directory where you want to update git remotes.
find "$PWD" -maxdepth 2 -type d | while read -r dir; do
cd "$dir" || exit
if [ -d .git ]; then
@carhartl
carhartl / .rubocop.yml
Last active August 29, 2015 14:19
Rubocop with Gemfile
AllCops:
Include:
- 'config.ru'
@carhartl
carhartl / gist:254f6ffa42b5e19d80bb
Last active August 29, 2015 14:18
rubocop-emoji.rb
# rubocop app.rb --require "./emoji_formatter" --format EmojiFormatter
require "rubocop"
# This formatter display green hearts for files with no offenses and
# letters for files with problems in the them. In the end it
# appends the regular report data in the clang style format.
class EmojiFormatter < RuboCop::Formatter::ProgressFormatter
def report_file_as_mark(offenses)
mark = if offenses.empty?
"\u{1f49a}"
diff --git a/ext/dl/extconf.rb b/ext/dl/extconf.rb
index 8317ac3..f1b3155 100644
--- a/ext/dl/extconf.rb
+++ b/ext/dl/extconf.rb
@@ -1,7 +1,9 @@
require 'mkmf'
if RbConfig::CONFIG['GCC'] == 'yes'
- $CFLAGS << " -fno-defer-pop -fno-omit-frame-pointer"
+ # $CFLAGS << " -fno-defer-pop -fno-omit-frame-pointer"
# blog post: http://blog.slashpoundbang.com/post/12938588984/remove-all-accents-and-diacritics-from-string-in-ruby
# coding: utf-8
string.tr(
"ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž",
"AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz")