Skip to content

Instantly share code, notes, and snippets.

View jorgenpt's full-sized avatar

Jørgen Tjernø jorgenpt

View GitHub Profile
@jorgenpt
jorgenpt / create_magick_image.rb
Created January 18, 2012 01:54
Ruby function to convert 565 & 555 format data into a Magick::Image
require 'rmagick'
def create_magick_image(input, width, height, bpp)
mode = 'RGB'
case bpp
when 15
data = input.unpack('v*').collect do |rgb|
rgb = rgb & 0x7fff
red = (rgb >> 10) / 31.0
green = ((rgb >> 5) & 31) / 31.0
@jorgenpt
jorgenpt / color_scaling.rb
Created January 19, 2012 19:33
Things you shouldn't use Ruby for, #63
# Returns the framebuffer as an array of floats ranging from 0 to 1, ordered
# like [A, R, G, B, A, R, G, B, ..]
def to_a
red_mask = mask(@header.red_length)
green_mask = mask(@header.green_length)
blue_mask = mask(@header.blue_length)
alpha_mask = mask(@header.alpha_length)
red_max = (1 << @header.red_length) - 1.0
green_max = (1 << @header.green_length) - 1.0
a = 1
def a; 2; end
puts a # => 1
puts a() # => 2
b = 5
def b(foo); foo * foo; end
puts b # => 5
module Jenkins::Model
class CLICommand
def self.short_description(short_description = nil)
@short_description = short_description if short_description
@short_description
end
def short_description
@@short_description
end
@jorgenpt
jorgenpt / assert_ndk_version.sh
Last active February 21, 2023 06:05
Shell script to check for Android NDK version.
#!/bin/bash
# Bash script to assert that the current version of the NDK is at least the
# specified version. Prints 'true' to standard out if it's the right version,
# 'false' if it's not.
#
# Typically used like this, in your jni/Android.mk:
#
# ifneq ($(shell $(LOCAL_PATH)/assert_ndk_version.sh "r5c"),true)
# $(error NDK version r5c or greater required)
UIImageView *nextView = [[UIImageView alloc] initWithImage:[self imageAtIndex:imageIndex]];
[nextView setUserInteractionEnabled:YES];
[nextView setGestureRecognizers:[currentImage gestureRecognizers]];
[currentImage setGestureRecognizers:nil];
[[self view] addSubview:nextView];
[[self view] sendSubviewToBack:nextView];
[nextView release];
bool MouseLocationInWorld(out Vector3 location)
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast (ray, out hit, 100))
{
location = hit.point;
return true;
}
checking for FRIBIDI... configure: error: Package requirements (fribidi >= 0.19.0) were not met:
No package 'fribidi' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables FRIBIDI_CFLAGS
and FRIBIDI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
@jorgenpt
jorgenpt / stream.sh
Created April 21, 2012 06:59
Commands to stream desktop to justin.tv on OS X
#!/bin/sh -xe
API_KEY="YOUR_API_KEY_GOES_HERE"
FPS="10"
VLC_PATH="/Applications/VLC.app/Contents/MacOS/VLC"
# I don't know how this'll behave on multimon, so you might want to hard-code.
# INRES='1440x900'
INRES=$(osascript -e 'tell application "Finder" to get bounds of window of desktop'|sed 's/, /x/g'|cut -f3- -dx)
OUTRES='1280x800'
# You can change this to record microphone or something else, from man soxformat (under coreaudio):