Skip to content

Instantly share code, notes, and snippets.

@sudowork
sudowork / gist:3aea3b9184aa005adffa08b2c4b4077c
Last active May 31, 2021 03:16
Script that attempts to force M1 macs into RGB mode when used with monitors that are defaulting to YPbPr.
Moved to https://github.com/sudowork/fix_m1_rgb
import Ember from 'ember';
const {
computed,
get,
} = Ember;
export default Ember.Controller.extend({
todos: computed('model', 'model.todos.[]', function() {
return get(this, 'model.todos');
@sudowork
sudowork / .robomongorc.js
Last active July 14, 2016 18:08
Robomongo RC file to attach a toCSV function to the DBQuery prototype.
// Adapted from https://github.com/paralect/robomongo/issues/348#issuecomment-38069899
var toCSV = function(data, options){
var headers = [];
var records = [];
var line;
var response = '';
var i, l = data.length, rl=0, j, k;
var reReplaceTextDelim;
var processRecord = function(src, rec, prefix){
var key, val, idx;
@sudowork
sudowork / vpn_fix.sh
Last active April 26, 2016 01:32
Fixes firewall rules and corrects routes that may have been overwritten by a VPN client.
#!/usr/bin/env bash
# You must have sudo ability on your machine
machine=${1:-"default"}
if [[ ! $(docker-machine ls | grep ${machine}) ]]; then
echo "${machine} is not a docker-machine"
exit 1
fi
@sudowork
sudowork / docker_vpn_fix.sh
Last active January 29, 2016 20:56
Fixes firewall rules and corrects routes that may have been overwritten by a VPN client.
#!/usr/bin/env bash
# You must have sudo ability on your machine
machine=${1:-"default"}
if [[ ! $(docker-machine ls | grep ${machine}) ]]; then
echo "${machine} is not a docker-machine"
exit 1
fi
@sudowork
sudowork / private.xml
Last active January 7, 2017 22:22
Karabiner private.xml configuration
<?xml version="1.0"?>
<root>
<devicevendordef>
<vendorname>YUBICO</vendorname>
<vendorid>0x1050</vendorid>
</devicevendordef>
<deviceproductdef>
<productname>YUBIKEY_II</productname>
require('npm').load(function (err, npm) {
npm.commands.ls([], true, function (err, data, lite) {
// log the version of express
console.log(lite.dependencies.express.version);
})
});
@sudowork
sudowork / gist:7441905
Last active December 28, 2015 04:19 — forked from jdsiddon/gist:7441841
/* sites.js */
var
mongoose = require('mongoose')
, Schema = mongoose.Schema
, update = require('./updates')
;
//Define the site model
var siteSchema = new Schema({
client: String,
; use list comprehension to get a list of chess squares
user=> (for [x (range 1 9), y (range 1 9)] [x y])
([1 1] [1 2] [1 3] [1 4] [1 5] [1 6] [1 7] [1 8] [2 1] [2 2] [2 3] [2 4] [2 5] [2 6] [2 7] [2 8] [3 1] [3 2] [3 3] [3 4] [3 5] [3 6] [3 7] [3 8] [4 1] [4 2] [4 3] [4 4] [4 5] [4 6] [4 7] [4 8] [5 1] [5 2] [5 3] [5 4] [5 5] [5 6] [5 7] [5 8] [6 1] [6 2] [6 3] [6 4] [6 5] [6 6] [6 7] [6 8] [7 1] [7 2] [7 3] [7 4] [7 5] [7 6] [7 7] [7 8] [8 1] [8 2] [8 3] [8 4] [8 5] [8 6] [8 7] [8 8])
; apply a filter using the :when keyword
user=> (for [x (range 1 9), y (range 1 9), :when (= x y)] [x y])
([1 1] [2 2] [3 3] [4 4] [5 5] [6 6] [7 7] [8 8])
; NON-tail recursive version of size
; because the recursive call must be returned to the caller
(defn non-tail-size [v]
(if (empty? v)
0
(inc (non-tail-size (rest v)))))
user=> (non-tail-size [1 2 3])
3
user=> (non-tail-size (range 10000))
StackOverflowError clojure.core/range/fn--4269 (core.clj:2664)