Skip to content

Instantly share code, notes, and snippets.

View lzyzsd's full-sized avatar
:octocat:

Young for you lzyzsd

:octocat:
  • Open Source
  • singapore
View GitHub Profile

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt

Min Streams Interface Spec

This spec describes a minimal stream interface meant for protocol implementors. Modules written to the interfaces in this spec can be used by a wide variety of projects. The protocols will not need any extra dependencies themselves. It's just an interface to implement.

Simple Stream

A simple stream is just a function. It represents a pull-stream. It has the following signature:

// Implementing a stream.

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

/* Kosso : March 12th 2011
This the only way I managed to do this without the app crashing on resume.
Done slightly differently to the KS example, since they unregister the service and
do not use a setInterval timer.
*/
//############ in app.js :
// test for iOS 4+
@lzyzsd
lzyzsd / app.js
Created June 7, 2013 06:08 — forked from jonalter/app.js
var win = Titanium.UI.createWindow({
backgroundColor: 'blue'
});
var btn = Ti.UI.createButton({
title : 'Add Notification'
});
btn.addEventListener('click', function(e) {
var activity = Ti.Android.currentActivity();
//////////////////////push_notifications.js///////////////////////
var apns = function(){
var pref = require('preferences').preferences;
Titanium.Network.registerForPushNotifications({
types: [
Titanium.Network.NOTIFICATION_TYPE_BADGE,
Titanium.Network.NOTIFICATION_TYPE_ALERT
],
success:function(e)
# 0. Make sure you have Ruby 1.9.3 installed, and optionally RVM and PostgreSQL
# 0.2 If you are on the Mac, make sure you have a c compiler by installing XCode Command Line Tools or gcc4.2 with homebrew
# https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers
# 0.5 Make sure you have bundler version ~> 1.2 as Rails depends on it
gem install bundler
# 1. Get edge Rails source (master branch)
git clone https://github.com/rails/rails.git
save_button.addEventListener('click', ()->
if Ti.Filesystem.isExternalStoragePresent
save_image = Ti.Filesystem.getFile(path).read()
new_path = Titanium.Filesystem.externalStorageDirectory + Date.now().toString() + ".png"
f = Ti.Filesystem.getFile(new_path)
result = f.write(save_image)
unless result
return null
// this is your app.js
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// define our main window and open it. it will be an activity (navBarHidden: true), and will control our child window views
Titanium.UI.createWindow({
navBarHidden: true,
backgroundColor: '#fff',
url: 'mainwindow.js',
exitOnClose: true
@lzyzsd
lzyzsd / index.js
Created April 22, 2013 14:12 — forked from FokkeZB/index.js
function doClick(e) {
alert('Clicked!');
}
// Remove the event listener like this:
// $.myWidget.off("click", doClick);
$.index.open();