Skip to content

Instantly share code, notes, and snippets.

View jesperronn's full-sized avatar

Jesper Rønn-Jensen jesperronn

View GitHub Profile
@jesperronn
jesperronn / Capfile
Created January 26, 2016 11:43 — forked from troelskn/Capfile
Sample cap setup
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
# Include tasks from other gems included in your Gemfile
#
# For documentation on these, see for example:
#
@jesperronn
jesperronn / js_toggle.coffee
Last active January 15, 2016 12:40
Generic checkbox toggle select all/none functionality
# Generic checkbox toggle select all/none functionality.
#
#
# Given the following checkbox:
# <input type="checkbox" class="js-toggle-all"
# data-target=".approved-count"
# data-count="#counter"
# data-total="#total">
#
# This checkbox kan toggle and count based on the selection of other checkboxes.
@jesperronn
jesperronn / strip_cpr_numbers.rb
Last active December 15, 2015 11:55
Danish CPR numbers: strip ssn dashes from numbers when saving, so that they are used consistently throughout the application
# Formatting and validation of Danish CPR number
# when saving we will throw away the dash "-" in the SSN and show it when retrieving
#
# Custom retrieval of formatted value: This is done by the method
# `formatted_cpr`. Use that in your views if you need it
#
# or in extreme cases you can override the getter method and call `formatted_cpr`
#
# Strategies for saving of unformatted value:
# 1. use either `base.after_validation` to hook into callbacks. This is a little annoying
MIN_COUNT = 2
# Naïve implementation, just return whatever number I need
def sum_up_a(existing)
return 2 if existing == 0
return 1 if existing == 1
return 0
end
sum_up_a(0) # => 2
@jesperronn
jesperronn / docx2md.md
Last active November 21, 2023 12:49 — forked from aembleton/docx2md.md
Convert a Word Document into MD

Converting a Word Document to Markdown in One Move

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

Installing Pandoc

On a mac you can use homebrew by running the command brew install pandoc.

The Solution

<div id="remote">
<input class="typeahead" type="text" placeholder="Oscar winners for Best Picture">
</div>
SimpleCov.coverage_dir('tmp/coverage')
# save to CircleCI's artifacts directory if we're on CircleCI
# see https://circleci.com/docs/code-coverage
if ENV['CIRCLE_ARTIFACTS']
dir = File.join(ENV['CIRCLE_ARTIFACTS'], 'coverage')
SimpleCov.coverage_dir(dir)
end
require 'simplecov-csv'
#!/usr/bin/env bash
BASEDIR=$(dirname $0)
. $BASEDIR/functions.sh
# step "Remounting / and /boot as read-write:"
# try mount -o remount,rw /
# try mount -o remount,rw /boot
# next
#
# usecases:
@jesperronn
jesperronn / svn_create.sh
Created April 15, 2015 20:39
SVN manipulate history
#!/usr/bin/env bash
# set -x
# script here will create new subversion repository (file based).
# then it will make 10 commits
# Then we will manipulate the commit dates of the ten commits
START_FOLDER=$(pwd)
REPO=repo02
WD=working2
HOOKFILE=$REPO/hooks/pre-revprop-change
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style>
#before, #after {display: none;}
</style>
<style id="jsbin-css">