Skip to content

Instantly share code, notes, and snippets.

View jasper-lyons's full-sized avatar
💭
Full time educator, part time developer

Jasper Lyons jasper-lyons

💭
Full time educator, part time developer
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script type="application/javascript">
var html = {
createElement: function (tagName, options) {
var element = document.createElement(tagName);
for (var attribute in options) {
@jasper-lyons
jasper-lyons / Loading vboxdrv in Ubuntu 16.04.md
Last active August 13, 2016 14:12
Gist containing all of the information I used to solve this issue and the extra things I had to do between.

First is googled the error message "vboxdrv not loaded" and ubuntu 16.04

This lead me to this ask ubuntu answer.

I read this a few times and began to understand that the issue is, vortial box's kernel modules are not signed which means that Ubuntu running secure boot will fail to load those modules. Since I have never signed modules before I figured I would read this enough times to understand. Unfortunately this answer in and of it's self was not informative enough for me to be comfortable with fixing this problem, I must know more.

I decided to take a look at this gist, linked to in the above answer. Again, this was insufficient for me to fully grok what was heppening but I did realise that:

  1. I needed to already have a directory with "keys" in
@jasper-lyons
jasper-lyons / Zipping lists in a text file in vim
Created August 19, 2016 12:03
Zipping lists in a text file
Given:
(1, 2, 3, 4, 5), (a, b, c, d ,e ,f)
run:
V:!ruby -e "puts ARGF.read.scan(/\(([^()]*)\)/).map {|m| m[0].split(',') }.inject {|a,b| a.zip(b) }.map {|m| \"(\#{m.join(', ')})\"}.join(', ')"
and get:
@jasper-lyons
jasper-lyons / undefined_base_name.rb
Last active February 24, 2017 21:59
ROM "undefined method 'base_name' for #<..." issue
require 'rom'
require 'rom-repository'
require 'byebug'
config = ROM::Configuration.new(:memory)
class Accounts < ROM::Relation[:memory]
register_as :accounts
end
@jasper-lyons
jasper-lyons / post-receive
Created October 19, 2017 19:02
Deploy rails app via git push
#! /bin/bash
while read oldrev newrev ref
do
# if we're on master branch
if [[ $ref =~ .*/master$ ]]; then
echo "Master ref received. Deploying master branch to production..."
git --work-tree=/srv/ageofai --git-dir=/home/git/ageofai checkout -f
source ~/.bash_profile
cd /srv/ageofai
if bundle install ; then
def reverse_captcha(captcha)
(captcha + captcha[0]). # "21752...7422"
split(''). # ['2', '1', '7', ... '4', '2']
each_cons(2). # [ ['2', '1'], ['1', '7'], ... ['4', '2'], ['2', '2'] ]
map { |a, b| a == b ? a.to_i : 0 }. # [0,0,0,0,0,...0,0,2]
reduce(&:+) # sum
end
function sheetChecksum (sheet)
local sum = 0
for _, row in ipairs(sheet) do
local largest, smallest = 0, math.huge
for _, cell in ipairs(row) do
if cell > largest then largest = cell end
if cell < smallest then smallest = cell end
end
# got a huge ammount of help from https://stackoverflow.com/questions/11550153/determine-position-of-number-in-a-grid-of-numbers-centered-around-0-and-increasi
def sequence(i):
n = 2 * i - 1
return n * n
def layer(i):
return math.floor((math.sqrt(i) + 1) / 2)
def length(i):
function onlyUniqueWords(string) {
return string.split(' ').reduce(function (arr, word) {
if (!arr) return arr;
if (arr.indexOf(word) > -1) return false;
return arr.concat(word);
}, []);
}
var passPhrases = `pphsv ojtou brvhsj cer ntfhlra udeh ccgtyzc zoyzmh jum lugbnk
...
#! /usr/bin/env guile -s !#
; guile needs the bash script comment closed
; saves an anonymous lambda later
(define inc (lambda (x) (+ x 1)))
; guiles list-set! function updates a list inplace but I want it to be immutable
; so I can use the old value from the list
(define (update-list lst index func)
(update-list-rec lst index func 0))