Skip to content

Instantly share code, notes, and snippets.

@pelish8
pelish8 / Watch.js
Created December 29, 2013 18:10
Watch the changes of object properties. Use with --harmony_proxies js flag.
(function () {
'use strict';
var tempFn = function (){};
var root = this;
var handler = function (obj, option) {
option = {
get: option.get || tempFn,
set: option.set || tempFn,
del: option.del || tempFn
@pelish8
pelish8 / nodejs.sh
Last active December 26, 2015 05:19
# install node.js
sudo apt-get update && sudo apt-get install -y python-software-properties python g++ make && sudo add-apt-repository ppa:chris-lea/node.js && sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 && echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list && sudo apt-get update && sudo apt-get -y install nodejs mongodb-10gen && sudo npm install -g node-inspector
@pelish8
pelish8 / Vagrantfile
Created May 2, 2013 15:12
Example of Vagrantfile for php.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"
@pelish8
pelish8 / VagrantAPX.sh
Last active December 16, 2015 10:49
Vagrant provision shell script for installing Apache 2, PHP5 and Xdebug.
#!/bin/sh
getIp()
{
ifconfig |grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3 }'
}
if hash php 2>/dev/null; then
sudo /etc/init.d/apache2 restart
getIp

This is all based on the [alpha release][1].

Properties

From the built-in help system:

For many settings TextMate will look for a .tm_properties file in the current folder and in any parent folders (up to the user’s home folder).

These are simple setting = value listings where the value is a format string in which other variables can be referenced.

This file has been truncated, but you can view the full file.
'use strict';
var COMPILED = !0, goog = goog || {};
goog.global = this;
goog.DEBUG = !1;
goog.LOCALE = "en";
goog.provide = function (a) {
if (!COMPILED) {
if (goog.isProvided_(a))
throw Error('Namespace "' + a + '" already declared.');
@pelish8
pelish8 / macros.mm
Created February 3, 2013 10:48
Macros for NSLog with method name and line number.
#ifdef DEBUG
# define ASLog(format, ...) NSLog((@"%s [Line %d] " format), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
# define ASCLog(condition, format, ...) if (condition) NSLog((@"%s [Line %d] " format), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
#define ASLog(...)
#define ASCLog(...)
#endif
@pelish8
pelish8 / Notification.mm
Created January 26, 2013 10:37
Notification example
@implementation MyObject
// Posts a MyNotification message whenever called
- (void)notify {
[[NSNotificationCenter defaultCenter] postNotificationName:@"MyNotification" object:self];
}
// Prints a message whenever a MyNotification is received
- (void)handleNotification:(NSNotification*)note {
NSLog(@"Got notified: %@", note);
@pelish8
pelish8 / incrementalBuild.sh
Created January 24, 2013 22:18
Incremental Xcode build number every time when the project is builds. Place script in Build Phases > Run Script.
TARGET="$PROJECT_DIR/$INFOPLIST_FILE"
echo $TARGET
if [ ! -f "$TARGET" ]; then
echo "missing file $TARGET"
exit 1;
fi
NEW_VERSION=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$TARGET"`
let NEW_VERSION+=1
/usr/libexec/PListBuddy -c "Set CFBundleVersion $NEW_VERSION" "$TARGET"
@pelish8
pelish8 / caretPosition.mm
Last active December 11, 2015 16:29
Get caret postion in textView.
caretPosition = [[[textView selectedRanges] objectAtIndex:0] rangeValue].location;