Skip to content

Instantly share code, notes, and snippets.

View alex-ross's full-sized avatar

Alexander Ross alex-ross

View GitHub Profile
#!/usr/bin/env ruby
require 'gosu' # gem install gosu --no-document
include Gosu
$dimension, $splits = 200, 20
$size = $dimension.to_f / $splits.to_f
class Worm
attr_writer :dir
def initialize() reset end
@alex-ross
alex-ross / app.rb
Created May 10, 2014 20:27
Simple rack application. Start with `rackup`
class App
def self.call(env)
path = env["REQUEST_PATH"]
case path
when "/"
body = "<h1>Hello,</h1><p>world!</p>"
[200, {}, [body]]
else
body = "Couldn't find any page at #{path}"
[400, {}, [body]]
@alex-ross
alex-ross / integration_example.rb
Last active August 29, 2015 14:06
Integration example that allows multiple sessions at same time
require "test_helper"
class CompaniesTest < ActionDispatch::IntegrationTest
it "admin can signin and visit companies" do
admin = new_session_as :admin
admin.goes_to "/companies"
end
private
-- 1. Place in ~/Library/Scripts and enable the Applescript menu via the Applescript Editor
-- 2. Substitute "vpn.example.com" and "redacted" for your VPN server and password
-- 3. Open Security & Privacy System Preferences, go to Privacy, Accessibility
-- 4. Enable Applescript Editor and System UI Server
-- 5. Trigger script from the menu
-- 6. Enjoy being connected
tell application "Cisco AnyConnect Secure Mobility Client"
activate
end tell
@alex-ross
alex-ross / assets_helper.php
Last active October 13, 2015 15:48
Thin assets helper class for php. Made it just for fun but may come useful for realy small projects.
<?php
/**
* @author Alexander Ross <alex@aross.se>
* @license MIT
*/
class AssetsHelper
{
private $js_array = [];
private $css_array = [];
@alex-ross
alex-ross / Preferences.sublime-settings
Last active December 10, 2015 18:08
My sublime settings-file
{
"auto_find_in_selection": true,
"bold_folder_labels": true,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": false,
"fold_buttons": true,
"folder_exclude_patterns":
[
".svn",
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
<link href="https://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600,700,900' rel='stylesheet' type='text/css'>
<style>
.icon-file-alt {
angular.module('LoadingIndicator', [])
.config(['$httpProvider', function ($httpProvider) {
var startLoadingIndicator = function() {
angular.element('.loading').text('Loading ...');
};
$httpProvider.responseInterceptors.push('HttpLoadingInterceptor');
$httpProvider.defaults.transformRequest.push(function (data, headersGetter) {
// On request start
/**
* Redirect unauthorized users to given path
* whenever any response returns http code 401.
*/
angular.module('RedirectUnauthorized')
.config(['$httpProvider', function($httpProvider) {
// Where should we redirect unauthorized users?
var loginPath = '/signin';
@alex-ross
alex-ross / unit.js
Last active December 30, 2015 15:49
Example of unit.js file for karma in rails applications. This should allow tests to be written in both coffescript or javascript
/**
* Karma configuration
*
* Enables tests to be written in both javascript and coffeescript.
*
* Run your tests with: `karma start spec/karma/config/unit.js`
*
* Place your tests in similar paths: `spec/javascripts/<anydir>/<file>_spec.coffee`
* This file should be in: `spec/karma/config/unit.js`
*