Skip to content

Instantly share code, notes, and snippets.

View bartolsthoorn's full-sized avatar

Bart Olsthoorn bartolsthoorn

View GitHub Profile
# Looping pixels!
Win = Gosu::Window.new(500, 500, false)
img = Gosu::Image.new(Win, filename)
# Show info of 1 pixel
p = img.get_pixel(100,100);
puts p.to_s
# loop and make grey
img.each{ |pixel|
def check_pixel(x, y)
set_checked(x, y)
@shape_pixels = @shape_pixels + 1
if (@shape_y_pixels[y] == nil)
@shape_y_pixels[y] = 0
end
if (@shape_x_pixels[x] == nil)
@shape_x_pixels[x] = 0
end
def resize(size)
ImageScience.with_image(@imagefilename) do |img|
img.thumbnail(size) do |resizedimg|
@tempimage = resizedimg
@width = resizedimg.width
@height = resizedimg.height
return true
end
end
end
def histogram(location)
if !@texplayinit
init_texplay
end
histogram_image = TexPlay.create_blank_image(@@Win, 101, 1022)
img = Gosu::Image.new(@@Win, @imagefilename)
@histopixels = Array.new
101.times{ |x|
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"7dsqpiKslrOcAL+OB1RRhwYpikMn1s9AtBvRWsh2kpA=",
"work"=>{"name"=>"dsfsdfd",
"categorization_attributes"=>{"1"=>"1",
"3"=>"1"},
@bartolsthoorn
bartolsthoorn / test.html
Created March 4, 2011 09:34
got it working!
<script>$.getScript("/javascripts/jquery.tweet.js", function(){
$("#activity").tweet({
avatar_size: 32,
count: 4,
query: "TEDxAms+OR+TEDxAmsterdam",
loading_text: "Searching Twitter..."
});
$('.scroll-pane').jScrollPane();
});
</script>
- (void)viewDidLoad
{
[super viewDidLoad];
[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
if (![[NSUserDefaults standardUserDefaults] objectForKey:kCurrentPage]) {
[[NSUserDefaults standardUserDefaults] setInteger:1 forKey:kCurrentPage];
currentPage = 1;
} else {
currentPage = [[NSUserDefaults standardUserDefaults] integerForKey:kCurrentPage];
@bartolsthoorn
bartolsthoorn / facebook.php
Created July 1, 2011 14:50
Retrieving Facebook Wall Posts.
<?php
// FACEBOOK WALL RSS FETCHER
// For ID, request: https://graph.facebook.com/xxyourpagexx
$wall = stealthget("http://www.facebook.com/feeds/page.php?format=atom10&id=96302003265", "http://facebook.com");
?>
<pre>
Wall Characters: <?=strlen($wall)?>
@bartolsthoorn
bartolsthoorn / AppViewController.m
Created July 8, 2011 09:21
The webview does not fill the entire height in landscape mode. (300,800). Odd.
- (void)viewDidLoad
{
[self setupPages];
[super viewDidLoad];
}
- (void)setupPages
{
UIWebView *wview;
wview = [[UIWebView alloc] initWithFrame:CGRectMake(16, 16, 300, 800)];
wview.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
@bartolsthoorn
bartolsthoorn / AppViewController.m
Created July 8, 2011 11:18
Is it possible to change the url of one webview later in another function by using the specified tag?
for( int i = 0; i < 4; i++ ) {
UIWebView *wview;
int wx;
if (i < 2) {
wx = 12;
} else {
wx = 512;
}
wview = [[UIWebView alloc] initWithFrame:CGRectMake(wx, 16, 500, 716)];