Skip to content

Instantly share code, notes, and snippets.

View smashwilson's full-sized avatar
🤖
HAPPINESS IS MANDATORY

Ash Wilson smashwilson

🤖
HAPPINESS IS MANDATORY
  • GitHub Staff
  • 05:24 (UTC -04:00)
View GitHub Profile
@smashwilson
smashwilson / ocr.rb
Created April 12, 2014 14:26
Read images from a webcam. OCR any text and write it to stdout.
require 'hornetseye_v4l2'
require 'hornetseye_xorg'
require 'hornetseye_rmagick'
require 'tesseract'
include Hornetseye
camera = V4L2Input.new
image = X11Display.show { camera.read }
image.to_ubytergb.save_ubytergb 'snapshot.png'
@smashwilson
smashwilson / core-failures
Created August 17, 2014 23:22
Atom script/grunt test output on Linux Mint
>> [2038:0817/132045:ERROR:browser_main_loop.cc(163)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on.
>> ATTENTION: default value of option force_s3tc_enable overridden by environment.
>> [2069:0817/132046:INFO:renderer_main.cc(227)] Renderer process started
>> [2038:0817/132047:INFO:CONSOLE(92)] "Download the React DevTools for a better development experience: http://fb.me/react-devtools", source: /home/smash/code/atom/node_modules/react-atom-fork/lib/React.js (92)
>> ..[2038:0817/132048:INFO:CONSOLE(122)] "Failed to load package named 'package-with-broken-keymap'", source: /home/smash/code/atom/src/package.coffee (122)
>> .................................[2038:0817/132050:INFO:CONSOLE(301)] "Error compiling less stylesheet: /home/smash/.atom/packages/script/stylesheets/script.less
>> Line number: 8
>> 'ui-mixins.less' wasn't found", source: /home/smash/code/atom/src/theme-manager.coffee (301)
>>
// This is a proposal for an alternative approach to client interactions with Gophercloud.
import (
"time"
"github.com/rackspace/gophercloud"
"github.com/rackspace/gophercloud/rackspace"
)
// Provider adheres to a common gophercloud.Client interface.
@smashwilson
smashwilson / commands.sh
Last active November 7, 2019 23:35
Move a subdirectory from one git repository to a subdirectory of another, without losing commit history.
# Assumptions:
#
# * After the merge is complete, the directory should exist in the target repository and not exist in the source
# repository. In other words, this is a move, not a cross-reference: we never want to be able to push commits
# back to the source repository, or merge further changes from the source repository. If you want to do that
# instead, a subtree merge is what you're looking for.
#
# * The directory doesn't exist in the target repository yet.
#
# In this example, we're moving the "/openstack-swift/" directory from jclouds/jclouds-labs-openstack to
@smashwilson
smashwilson / pagination.rb
Created October 17, 2014 11:59
Pagination in Fog
require 'pp'
storage = Fog::Storage.new(
provider: :rackspace,
rackspace_username: ENV['RAX_USERNAME'],
rackspace_api_key: ENV['RAX_API_KEY'],
rackspace_region: :dfw
)
d = storage.directories.get('big-container')
@smashwilson
smashwilson / multipleopts.go
Created November 17, 2014 15:56
Using multiple OpenStack extensions that modify the server creation options in Gophercloud
import (
"github.com/rackspace/gophercloud/openstack/compute/v2/servers"
bfw "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
dc "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig"
)
// 1. Base CreateOpts
baseOpts := servers.CreateOpts{
Name: "servername",
@smashwilson
smashwilson / terrible_hackedup_ruby.rb
Created February 13, 2015 14:12
Automatically convert Perigee calls to client.Request calls.
#!/bin/env ruby
require 'find'
def convert(path)
content = File.read(path)
ncontent = []
line_no = 1
in_req = false
@smashwilson
smashwilson / example.yml
Created February 13, 2015 18:45
Sample playbook for Rackspace Cloud Monitoring modules.
---
- name: Rackspace Cloud Monitoring test playbook
hosts: all
connection: local
gather_facts: false
tasks:
- name: Entity
rax_mon_entity:
credentials: .credentials
// User code:
// "Extract" still has return type "os.GetHeader, err"
c, err := containers.Get(client, "foo").Extract()
if err != nil {
if gophercloud.HasErrorCode(err, gophercloud.ErrNotFound) {
// ...
}
@smashwilson
smashwilson / lb-update-condition.js
Created September 2, 2015 12:57
Updating the condition of an existing node on a Cloud Load Balancer
// Updating the condition of an existing load balancer node with pkgcloud.
var pkgcloud = require('pkgcloud');
var client = pkgcloud.loadbalancer.createClient({
provider: 'rackspace',
username: process.env.RACKSPACE_USERNAME,
apiKey: process.env.RACKSPACE_APIKEY,
region: process.env.RACKSPACE_REGION
});