Skip to content

Instantly share code, notes, and snippets.

View seanlilmateus's full-sized avatar

Mateus seanlilmateus

View GitHub Profile
#!/usr/bin/env ruby
require 'rubygems'
require 'osx/cocoa'
app = OSX::NSApplication.sharedApplication
window = OSX::NSWindow.alloc.initWithContentRect_styleMask_backing_defer(
[0,0,500,500],
OSX::NSTitledWindowMask + OSX::NSClosableWindowMask,
//
// NSObject+BlockObservation.h
// Version 1.0
//
// Andy Matuschak
// andy@andymatuschak.org
// Public domain because I love you. Let me know how you use it.
//
#import <Cocoa/Cocoa.h>
@dbgrandi
dbgrandi / netservices_macruby.rb
Created November 9, 2009 11:15 — forked from voodootikigod/netservices_macruby.rb
Using the NSNetServiceBrowser with macruby
delegate = Object.new
def delegate.netServiceBrowserWillSearch(browser)
puts "search commencing!"
end
def delegate.netServiceBrowser(browser, didFindService:service, moreComing:more)
# this never calls regardless of the services on the network.
puts "Found service #{service.name}."
end
@nolanw
nolanw / NSObject+ProcObservation.h
Created January 6, 2010 08:32
Slight alteration of Any Matuschak's BlockObservation for MacRuby.
//
// NSObject+ProcObservation.h
// Version 1.0
//
// Andy Matuschak
// andy@andymatuschak.org
// Public domain because I love you. Let me know how you use it.
//
// NTW 2009-Oct-21: Added selectors with an options argument.
// NTW 2009-Oct-30: Transplanted new observation key from MYUtilities's KVUtils.
@nagachika
nagachika / ao-render-gcd.rb
Created May 12, 2010 22:53
AO Bench script (Normal and GCD version)
# -*- encoding: utf-8 -*-
# AO render benchmark (GCD version for MacRuby 0.6)
# Original program (C) Syoyo Fujita in Javascript (and other languages)
# http://lucille.atso-net.jp/blog/?p=642
# http://lucille.atso-net.jp/blog/?p=711
# Ruby(yarv2llvm) version by Hideki Miura
# http://github.com/miura1729/yarv2llvm/blob/a888d8ce6855e70b630a8673d4cfe075a8e44f0e/sample/ao-render.rb
# Modified by Tomoyuki Chikanaga
#
@mort
mort / Creating Shazam in Java
Created July 8, 2010 09:18
Creating Shazam in Java
A backup of http://sites.google.com/site/redcodenl/creating-shazam-in-java-1 just in case
Why is this necessary? Read http://sites.google.com/site/redcodenl/patent-infringement
Please fork, tweet about, etc.
----
Creating Shazam in Java
A couple of days ago I encountered this article: How Shazam Works
This got me interested in how a program like Shazam works… And more importantly, how hard is it to program something similar in Java?
@Gautier
Gautier / CountDownTimer.java
Created December 12, 2010 00:58
Drop-in alternative for the Android CountDownTimer class, but which you can cancel from within onTick.
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@tpitale
tpitale / kermit.rb
Created January 6, 2011 16:08
Async MacRuby HTTP
module Kermit
class Request
def initialize(url, success, failure=nil)
@request = NSURLRequest.requestWithURL(NSURL.URLWithString(url))
@success = success
@failure = failure
# @parser = Yajl::Parser.new(:symbolize_keys => true)
end
def connection
@zwaldowski
zwaldowski / MASWindow.h
Created January 28, 2011 21:15
A Mac App Store-like NSWindow subclass.
//
// MASWindow.h
// A Mac App Store-like NSWindow subclass.
//
// Created by Zachary Waldowski on 1/8/11.
// Secured under the "do-whatever-the-hell-you-want-with-it" license. Erm, copyright 2011.
//
#import <Cocoa/Cocoa.h>
// Reads in a set of raw data files, and outputs smoothed files. (lots of libdispatch magic)
#define SIGMA (50)
#define CONST_A (1 / sqrt(2 * pi * (pow(SIGMA, 2))))
- (IBAction)smoothDataSets:(id)sender {
[openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger ret){
if(ret == NSOKButton){
// Generate a gaussian weight
int len = 6 * SIGMA + 1;
double weight[len];
for(int i = 0; i < len; i++){