Skip to content

Instantly share code, notes, and snippets.

View mblarsen's full-sized 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 August 10, 2014 11:59
Fix for when vbox/vagrant/VBoxManage won't start due to NS_ERROR_FAILURE/host-only adapter
#!/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 July 24, 2022 13:27
Solution for `git clone` using Ansible for repos with private submodules with github deploy keys
# 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:
@mblarsen
mblarsen / gist:e24c73aa8004bb0bccfc
Created May 11, 2015 04:04
Removing duplicate files
#
# 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
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/
#!/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 November 28, 2016 04:22
A small shell command like `cd` that cd-s you back to project root.
#!/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
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': {
/**
* 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 July 24, 2016 03:23
Closure::bind (native JS-like bind in PHP)
<?php
class A {
public $param = 7;
}
class B {
private $param = 28;
}
@mblarsen
mblarsen / lists-problem-3.elm
Last active July 27, 2016 03:15
99 Elm problems — My solutions (solution only listed if different from others)
elementAt : List a -> Int -> Maybe a
elementAt xs n =
case List.drop (n - 1) xs of
[ ]
-> Nothing
y::ys
-> Just y