Skip to content

Instantly share code, notes, and snippets.

@rubiojr
rubiojr / mr_status_bar_app.rb
Created November 30, 2009 11:47
MacRuby StatusBar Application
#
# Initialize the stuff
#
# We build the status bar item menu
def setupMenu
menu = NSMenu.new
menu.initWithTitle 'FooApp'
mi = NSMenuItem.new
mi.title = 'Hellow from MacRuby!'
mi.action = 'sayHello:'
@martijnwalraven
martijnwalraven / gist:700216
Created November 15, 2010 09:46
Script to generate BridgeSupport file for a framework from Xcode
mkdir -p ${TARGET_BUILD_DIR}/${WRAPPER_NAME}/Resources/BridgeSupport
gen_bridge_metadata --64-bit -f ${TARGET_BUILD_DIR}/${WRAPPER_NAME} -o ${TARGET_BUILD_DIR}/${WRAPPER_NAME}/Resources/BridgeSupport/${TARGET_NAME}.bridgesupport
@corbinbs
corbinbs / alert_demo.py
Created July 15, 2011 02:19
Example Python Alert Dialogs using PyObjC (alternative to EasyDialogs?)
import objc
from AppKit import *
from Foundation import *
class Alert(object):
def __init__(self, messageText):
super(Alert, self).__init__()
self.messageText = messageText
self.informativeText = ""
##Some points to mention...
##
##The model knows nothing about the view or the controller.
##The view knows nothing about the controller or the model.
##The controller understands both the model and the view.
##
##The model uses observables, essentially when important data is changed,
##any interested listener gets notified through a callback mechanism.
##
##The following opens up two windows, one that reports how much money you
@divanvisagie
divanvisagie / objc.js
Created June 15, 2013 17:28
A snippet with different usage examples in NodObjC. Not all of this works but the concepts are mainly correct
var $ = require( 'NodObjC' );
// First you import the "Foundation" framework
$.import( 'Foundation' );
$.import( 'Cocoa' );
// Setup the recommended NSAutoreleasePool instance
var pool = $.NSAutoreleasePool( 'alloc' )( 'init' );
// NSStrings and JavaScript Strings are distinct objects, you must create an
@Daniel15
Daniel15 / 1_README.md
Last active May 6, 2024 06:40
Complete Google Drive File Picker example

Google Drive File Picker Example

This is an example of how to use the Google Drive file picker and Google Drive API to retrieve files from Google Drive using pure JavaScript. At the time of writing (14th July 2013), Google have good examples for using these two APIs separately, but no documentation on using them together.

Note that this is just sample code, designed to be concise to demonstrate the API. In a production environment, you should include more error handling.

See a demo at http://stuff.dan.cx/js/filepicker/google/

@dinge
dinge / gist:6983008
Created October 14, 2013 22:05
calling applescript from ruby
def osascript(script)
system 'osascript', *script.split(/\n/).map { |line| ['-e', line] }.flatten
end
osascript <<-END
tell application "Finder"
display dialog "Hello"
end tell
END
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@austinhyde
austinhyde / js-observables-binding.md
Last active August 16, 2023 18:19
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);

@fallroot
fallroot / open-notification-center-with-jxa.js
Created February 12, 2015 19:00
Open OSX Notification Center with JXA
Application('System Events')
.processes['SystemUIServer']
.menuBars
.menuBarItems
.whose({
name: 'Notification Center'
})
.menuBarItems()
.reduce(function(a, b) {
return a.concat(b);