Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Actively recommending people not to use WordPress!

Michael Bøcker-Larsen mblarsen

💭
Actively recommending people not to use WordPress!
View GitHub Profile
@mblarsen
mblarsen / vbfix.sh
Created Aug 10, 2014
Fix for when vbox/vagrant/VBoxManage won't start due to NS_ERROR_FAILURE/host-only adapter
View vbfix.sh
#!/bin/bash
#
# There was an error while executing `VBoxManage`, a CLI used by Vagrant
# for controlling VirtualBox. The command and stderr is shown below.
#
# Command: ["hostonlyif", "create"]
#
# Stderr: 0%...
# Progress state: NS_ERROR_FAILURE
# VBoxManage: error: Failed to create the host-only adapter
@mblarsen
mblarsen / deploy.yaml
Last active Aug 2, 2021
Solution for `git clone` using Ansible for repos with private submodules with github deploy keys
View deploy.yaml
# Problem:
#
# If you use git submodules linking two private github repos, you'll need to create a separate deploy key for each.
# Multiple keys are not supported by Ansible, nor does ansible (when running git module) resort to your `.ssh/config` file.
# This means your ansible playbook will hang in this case.
#
# You can however use the ansible git module to checkout your repo in multiple steps, like this:
#
- hosts: webserver
vars:
View gist:e24c73aa8004bb0bccfc
#
# Removes duplicates from a directory based on checksum
# Run each line manually and check if it is the result you expect
#
# Based on: http://www.chriswrites.com/how-to-find-and-delete-duplicate-files-in-mac-os-x/#Terminal
# And: http://stackoverflow.com/a/1450288/204610
# Find duplicates and write to duplicates-report.txt
find . -type f -exec cksum {} \; | sort | tee /tmp/f.tmp | cut -f 1,2 -d ' ' | uniq -d | grep -hif /dev/stdin /tmp/f.tmp > duplicates-report.txt
View mailgun.modman
app/code/community/* app/code/community/
app/design/adminhtml/default/default/layout/* app/design/adminhtml/default/default/layout/
app/design/adminhtml/default/default/template/* app/design/adminhtml/default/default/template/
app/etc/modules/* app/etc/modules/
View gist:d5cc8449ba4664350916eca2b0f23cfa
#!/bin/bash
# typical htdoc file and directory permissions
# + -o is a way to combine multiple finds in one
sudo find . -type d -exec chmod 755 {} + -o -type f -exec chmod 644 {} \;
@mblarsen
mblarsen / cdr.sh
Last active Nov 28, 2016
A small shell command like `cd` that cd-s you back to project root.
View cdr.sh
#!/bin/bash
#
# A small script that works like `cd` except that
# it keeps cd-ing until it reachs the project root
# project is defined by default as the directory
# that contains a .git sub-directory.
#
# Change this behavior like this:
# CDR_ROOT_ID=composer.json
View systemjs.bundle.config.js
module.exports = {
baseURL: 'resources/assets/',
transpiler: 'plugin-babel',
defaultJSExtensions: true,
meta: {
'vendor/JsBarcode/*': { format: 'global', deps: ['jquery'] },
'vendor/knockout/build/output/knockout-latest.js': { format: 'global', deps: ['jquery'] },
'vendor/materialize-css/dist/js/materialize.js': { format: 'global', deps: ['jquery'] },
'vendor/moment/min/moment.min.js': { format: 'global', deps: ['jquery'] },
'vendor/**/*js': {
View knockout.subscribeChanged.js
/**
* Knockout.js extension that gives both new and old value to
* subscription functions.
*
* Credit: http://stackoverflow.com/a/18184016/204610
*
* Changed JBeagle's code to return a disposable subscription
* object so it conforms to subscribe()
*/
ko.subscribable.fn.subscribeChanged = function (callback) {
@mblarsen
mblarsen / bind-with-php.php
Last active Jul 24, 2016
Closure::bind (native JS-like bind in PHP)
View bind-with-php.php
<?php
class A {
public $param = 7;
}
class B {
private $param = 28;
}
@mblarsen
mblarsen / lists-problem-3.elm
Last active Jul 27, 2016
99 Elm problems — My solutions (solution only listed if different from others)
View lists-problem-3.elm
elementAt : List a -> Int -> Maybe a
elementAt xs n =
case List.drop (n - 1) xs of
[ ]
-> Nothing
y::ys
-> Just y