Skip to content

Instantly share code, notes, and snippets.

View sbleon's full-sized avatar

Leon Miller-Out sbleon

View GitHub Profile
@sbleon
sbleon / mandelbash.rb
Created June 19, 2012 13:39
Explore Mandelbrot set in your terminal using only Ruby core features!
# Built on pseudo-code from http://en.wikipedia.org/wiki/Mandelbrot_set#Computer_drawings
COLORS = %w(1;32 0;32 0;36 1;36 1;37 0;37 1;30 0;30 0;34 1;34 0;35 1;35 0;31 1;31 0;33 1;33)
NUM_COLORS = COLORS.length
# Detect terminal resolution
term_size = `stty size`.split.map { |x| x.to_i }.reverse
X_MAX = term_size[0] - 1
Y_MAX = term_size[1] - 3 # Leave room for help text at bottom
def print_color_block(color)
@sbleon
sbleon / term
Last active May 7, 2019 14:41
Start working on a Rails project
#!/bin/sh
#
# Open a new Mac OS X terminal window or tab in the current or another
# directory and optionally run a command in the new window or tab.
#
# - Without any arguments, the new terminal window opens in
# the current directory, i.e. the executed command is "cd $PWD".
# - If the first argument is a directory, the new terminal will "cd" into
# that directory before executing the remaining arguments as command.
# - The optional "-t" flag executes the command in a new tab
<cfset oneRow = QueryNew('baz')>
<cfset QueryAddRow(oneRow)>
<cfquery name="broken" dbtype="query">
select <cfqueryparam value="1" cfsqltype="cf_sql_integer"> as num, 'a' as letter
from oneRow
union
select <cfqueryparam value="1" cfsqltype="cf_sql_integer"> as num, 'b' as letter
from oneRow
@sbleon
sbleon / gist:dbaf3ad41477010914ebcf0c9234b415
Created May 29, 2018 20:18
Example of broken cffeed Atom output
<cfscript>
theFeed = {
version='atom_1.0',
entry: [
{
content: {
type: 'text/plain',
value: 'Some text'
}
}
@sbleon
sbleon / CMakeLists.txt
Created October 5, 2014 02:25
Update CMakeLists.txt for picam_gpu
cmake_minimum_required(VERSION 2.8)
project( picam )
SET(COMPILE_DEFINITIONS -Werror)
find_package( OpenCV REQUIRED )
include_directories(/opt/vc/include)
include_directories(/opt/vc/include/interface/vcos)
include_directories(/opt/vc/include/interface/vcos/pthreads)
include_directories(/opt/vc/include/interface/vmcs_host/linux)
include_directories(/opt/vc/include/host_applications/linux/libs/bcm_host/include)
link_directories(/opt/vc/lib)
@sbleon
sbleon / gist:d84aa407930502439b27c31b3b8da93f
Created July 5, 2016 18:11 — forked from samhocevar/gist:00eec26d9e9988d080ac
Configure sshd on MSYS2 and run it as a Windows service
#!/bin/sh
#
# msys2-sshd-setup.sh — configure sshd on MSYS2 and run it as a Windows service
#
# Please report issues and/or improvements to Sam Hocevar <sam@hocevar.net>
#
# Prerequisites:
# — MSYS2 itself: http://sourceforge.net/projects/msys2/
# — admin tools: pacman -S openssh cygrunsrv mingw-w64-x86_64-editrights
#
@sbleon
sbleon / lussh
Created February 19, 2013 02:29
lussh - script to authorize your SSH key on a server
#!/bin/bash
# make sure to run this with /bin/bash, NOT /bin/sh
echo
echo This script will help you setup ssh public key authentication.
host=dummy
@sbleon
sbleon / open_hangout.scpt
Last active December 24, 2015 00:19
Open a Google Hangout in full-screen mode in Safari
(*
Open a specific Google Hangout in Safari's full-screen mode.
See blog post at http://singlebrook.com/blog/google-hangouts-for-remote-worker-telepresence for more,
including:
- instructions for creating persistent hangouts
- keeping machines in the hangout
leon@singlebrook.com
*)
@sbleon
sbleon / upload_to_cloud_files.rb
Created July 24, 2013 16:17
Upload a large file (> 5GB) to Rackspace Cloud Files
require 'rubygems'
require 'fog'
SEGMENT_LIMIT = 5368709119.0 # 5GB -1
BUFFER_SIZE = 1024 * 1024 # 1MB
CONTAINER = 'my-existing-container'
FILE_DIR = '/path/to/my/big/file'
FILE_NAME = 'huge_tarball.tgz'
RACKSPACE_USERNAME = 'my-rackspace-username'
RACKSPACE_API_KEY = 'my-rackspace-api-key'
# Place all this at the beginning of your spec_helper.rb to avoid sending
# incorrect coverage data to Code Climate.
require 'codeclimate-test-reporter'
SimpleCov.start 'rails' do
# We always want to run the HTML coverage formatter.
formatters = [ SimpleCov::Formatter::HTMLFormatter ]
# Code Climate records the first coverage data it is sent for any single
# commit, and then ignores future reports. If you're running a single spec,
# this will result in the reporting of erroneously low test coverage.