Skip to content

Instantly share code, notes, and snippets.

View alyssais's full-sized avatar
🤒
Out sick

Alyssa Ross alyssais

🤒
Out sick
View GitHub Profile
@alyssais
alyssais / README.md
Last active October 3, 2024 14:01
Easy DICE SSH for University of Edinburgh School of Informatics students

Easy DICE SSH

This is my SSH config that makes connecting to DICE easier It goes through the gateway automatically and you don't have to specify your username every time.

To use, add this content to ~/.ssh/config, (or whatever the SSH config file is on Windows), and replace sXXXXXXX with your login.

Often I find myself writing this and it always seemed annoyingly repetetive:

layout = ->
  # ...
  
layout()
window.addEventListener "resize", layout
loop do
puts `stty size`.split(/\s/).last.to_i.times.map { rand(124).zero? ? ?* : " " }.join
sleep (1.0/20)
end
@alyssais
alyssais / primes.rb
Last active October 1, 2015 11:49
Calculate the prime summands of each even number greater than 4. (https://en.wikipedia.org/wiki/Goldbach%27s_conjecture)
require "prime"
def prime_summands(n)
Prime.each do |x|
Prime.each do |y|
return x, y if x + y == n
break if y > n - 4
end
break if x > n - 4
end
@alyssais
alyssais / rspec
Created August 16, 2015 12:50
Fix pry terminal corruption issues with rspec. The same file is executed by both Ruby and Bash. Isn't that cool‽
#!/bin/sh
<<SH_COMMENT
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')
@alyssais
alyssais / require_external_gem.rb
Last active August 29, 2015 14:27
A very hacky way to require gems from outside a bundler environment
require 'shellwords'
def require_external_gem(name)
return require name unless defined? Bundler
dir = Bundler.with_clean_env do
`echo #{name.shellescape} | ruby -e \
'puts Gem::Specification.find_by_name(STDIN.read.chomp).gem_dir'`.chomp
end

Keybase proof

I hereby claim:

  • I am penman on github.
  • I am penman (https://keybase.io/penman) on keybase.
  • I have a public key whose fingerprint is 4E88 5A31 6BE3 361F E95E C23A 716C 6648 9EA7 86B5

To claim this, I am signing this object:

@alyssais
alyssais / authentication_spec.rb
Last active August 29, 2015 14:13
Testing controller concerns in Rails
# This is an example spec that uses the ControllerConcernHelper module
require "rails_helper"
describe Authentication, type: :controller_concern do
controller do
include AbstractController::Callbacks
before_action :authenticate
def test_action
export ZSH=$HOME/.oh-my-zsh
ZSH_THEME="robbyrussell"
COMPLETION_WAITING_DOTS="true"
HIST_STAMPS="yyyy-mm-dd"
plugins=(git)
export PATH=$HOME/.rbenv/bin:$HOME/.pyenv/bin:$HOME/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin
export LANG=en_GB.UTF-8
export TERM="xterm-256color"
source $ZSH/oh-my-zsh.sh
eval "$(rbenv init -)"
@alyssais
alyssais / httppp.rb
Created October 8, 2014 21:18
HTTP Plays Pokémon!
require 'java'
require 'sinatra'
def keycode(key)
name = "VK_#{key.upcase}"
java.awt.event.KeyEvent.const_get(name)
end
robot = java.awt.Robot.new