Skip to content

Instantly share code, notes, and snippets.

Avatar

Jesper Rønn-Jensen jesperronn

View GitHub Profile
@jesperronn
jesperronn / strip_cpr_numbers.rb
Last active Dec 15, 2015
Danish CPR numbers: strip ssn dashes from numbers when saving, so that they are used consistently throughout the application
View strip_cpr_numbers.rb
# 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
View fill_up_to.rb
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 Oct 5, 2020 — forked from aembleton/docx2md.md
Convert a Word Document into MD
View docx2md.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

View remote.html
<div id="remote">
<input class="typeahead" type="text" placeholder="Oscar winners for Best Picture">
</div>
View .simplecov
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'
View check.sh
#!/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 Apr 15, 2015
SVN manipulate history
View svn_create.sh
#!/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
View index.html
<!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">
@jesperronn
jesperronn / git filter-branch
Created Jan 21, 2015
git filter-branch author EMAIL
View git filter-branch
NEW_MAIL="jesp....@gmail.com"
git filter-branch --env-filter '
> if [[ "$GIT_AUTHOR_EMAIL" = "EMAIL" || "$GIT_AUTHOR_EMAIL" = "$NEW_MAIL" ]]
> then
> if [[ "$GIT_AUTHOR_NAME" = "Ben Alman" ]]
> then
> GIT_AUTHOR_NAME="Jesper Rønn-Jensen"
> GIT_COMMITTER_NAME="Jesper Rønn-Jensen"
> export GIT_AUTHOR_NAME
> export GIT_COMMITTER_NAME
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to make opened Markdown files always be soft wrapped:
#
# path = require 'path'
#
You can’t perform that action at this time.