Skip to content

Instantly share code, notes, and snippets.

View Neurogami's full-sized avatar

Neurogami Neurogami

View GitHub Profile
@Neurogami
Neurogami / what-version-is-this-xrns.rb
Last active March 30, 2017 16:01
Ruby script to extract Renoise version info from xrns file
#!/usr/bin/env ruby
require 'fileutils'
=begin
An xrns file is just a zip file with a special file extension.
That archive holds a number of files. One of these is Song.xml.
This XML has a root element with an attribute named 'doc_version'
@Neurogami
Neurogami / simple-demo.xml
Created November 25, 2016 21:31
TWO project file
<?xml version="1.0" encoding="UTF-8"?>
<Mediator-Model Version="1" User="" TWO_Version="0.9.2">
<Model V="5" ID="TWO">
<Composite V="1" ID="Locations">
<OSC_Location V="2" ID="demo_location_0" Description="Demo sketch 0" Root_OSC_Address=""
Outgoing_IP="127.0.0.1" Outgoing_Port="7000" Incoming_Port="1000"/>
<OSC_Location V="2" ID="demo_location_1" Description="Location of the secnd demo sketch"
Root_OSC_Address="" Outgoing_IP="127.0.0.1" Outgoing_Port="7001"
Incoming_Port="1001"/>
/*!
@file bleuart_datamode.ino
@author hathach, ktown (Adafruit Industries)
This demo will show you how to initialize the module in COMMAND mode then
send data in DATA mode, uses the MODE pin
Altered to work with a Teensy 3.1 using Serial2
The Bluefruit CTS pin is connected to Teensy pin 8.

Scenario: Wanting to add a virtualhost file to Apache2, which was installed using apt while in bash

Assumption: /etc/apache2 in bash maps to %HOME%\AppData\Local\lxss\rootfs\etc\apache2

  1. Opened a Windows-linux bash shell
  2. Installed apache2 (sudo apt-get install ...)
  3. Wanted to add a virtual host file that had been used on another dev machine
  4. Decided that editing files with vi in the bash terminal was too annoying :)
  5. Found the matching "sites-available" folder via Win10 File Explorer.
  6. Copied an existing virtualhost file itno that folder
def random_string_using_char_set len, chars
(0...len).map { chars[rand(chars.size)] }.join
end
safe_chars = (('A'..'Z').to_a + ('a'..'z').to_a + ('3'..'9').to_a ) - %w{5 S Z l o O}
some_string = random_string_using_char_set 50, safe_chars
p some_string
@Neurogami
Neurogami / glitch.rb
Created August 12, 2013 04:56
Simple script to rin perfectly good image files.
#!/usr/bin/env ruby
=begin
Simple script to smack your glitch up.
Call this program with the name of an image file, and two numbers
The first number is used to determine when to mess with a byte in the
image file. If you pass in, say 2000, then even 2000th byte gets tweaked.
Data Center Dallas 1
Single Processor Quad Core Xeon 3220 - 2.40GHz (Kentsfield) - 2 x 4MB cache
Ubuntu Linux 12.04 LTS Precise Pangolin (64 bit)
4 GB DDR2 667
Non-RAID Disk Controller
500GB SATA II
5000 GB Bandwidth
100 Mbps Public & Private Networks Uplink Port Speeds
Private Network Port 100 Mbps private uplink
@Neurogami
Neurogami / main.controller-loop.js
Created March 5, 2013 22:50
Demo code for Leap game
controller.loop(function(frame) {
if (frame.cursorPosition) {
var position = region.mapToXY(frame.cursorPosition, canvas.width, canvas.height)
if (1 == frame.fingers.length ) {
var position = region.mapToXY(frame.cursorPosition, canvas.width, canvas.height)
Handlers['walkto']( [position[0], position[1]] );
}
if (2 == frame.fingers.length ) {
var v1 = new Vector.create(frame.fingers[0].tipPosition);
@Neurogami
Neurogami / main.prepareLeap.js
Created March 5, 2013 21:31
Sample code from v2 of Leap Web game
function prepareLeap(){
canvas = document.getElementById("gameCanvas");
context = canvas.getContext("2d");
controller = new Leap.Controller();
var leftX = parseInt($('#leftX').val());
var rightX = parseInt($('#rightX').val());
var bottomY = parseInt($('#bottomY').val());
var topY = parseInt($('#topY').val());
@Neurogami
Neurogami / main.04.js
Created February 27, 2013 23:54
Leap game code
grow: function (scaleFactorArray) {
var timeNow = new Date().getTime() / 1000;
var tDelta = timeNow - this.lastGrowMessage;
this.walkingTo = false;
this.growing = true;
this.bitmapAnim.scaleX = scaleFactorArray[0];
this.bitmapAnim.scaleY = scaleFactorArray[0];
if (tDelta < this.minGrowCallsTime ) { return }