Skip to content

Instantly share code, notes, and snippets.

View HendrikLouw's full-sized avatar

Hendrik F. Louw HendrikLouw

View GitHub Profile
@HendrikLouw
HendrikLouw / dom_table_to_csv.cljs
Created June 26, 2017 09:17
Export table to CSV with JS APIs and Clojuresript
; Extends Nodelist in order for us to just map through nodelists (array like js objects)
(extend-type js/NodeList
ISeqable
(-seq [array] (array-seq array 0)))
(defn download-csv [csv filename]
(let [csv-file (js/Blob. (clj->js [csv]) {:type "text/csv"})
download-link (.createElement js/document "a")]
(aset download-link "download" filename)
(aset download-link "href" (.createObjectURL (aget js/window "URL") csv-file))
<div class="container">
<button class="stick-to-bottom-button"></button>
</div>
<style>
.container {
position: relative;
}
.stick-to-bottom-button {
@HendrikLouw
HendrikLouw / find-replace
Created May 16, 2012 10:45
Find and replace with ack-grep
ack-grep --print0 -irl 'Online' | xargs -0 -L1 sed -i 's/Online/Healthy/g'
@HendrikLouw
HendrikLouw / white_space_remover
Created April 16, 2012 07:44
Cleanup whitespaces
# Remove trailing spaces from files
sed -i 's/[ \t]*$//g' app/**/*.rb
# Convert tabs to spaces
sed -i 's/[ ]/ /g' app/**/*.rb
@HendrikLouw
HendrikLouw / gist:2291204
Created April 3, 2012 11:38
Resque restart when a file is touched ( like passenger restart )
# Can't remember where I found this, backing it up here.
# Use bottom script like so
# on.condition(:restart_file_touched) do |c|
# c.interval = 5.seconds
# c.restart_file = File.join(rails_root, 'tmp', 'restart.txt')
# end
# restart.god
module God
@HendrikLouw
HendrikLouw / about.md
Last active June 12, 2018 09:29 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
# Template for apache config that uses expiry headers, gzip compression and etags
# Mainly aimed at Rails apps that run on passenger but I could use this everywhere else
<VirtualHost *:80>
ServerName servername.com
ServerAlias servername.com
DocumentRoot /var/rails/servername.com/public
SetOutputFilter DEFLATE
<Directory "/var/rails/servername.com/current/public">