Skip to content

Instantly share code, notes, and snippets.

View hezi's full-sized avatar

Jorge (Hezi) Cohen hezi

View GitHub Profile
@hezi
hezi / gist:2699753
Created May 15, 2012 07:29
Open in finder the directory of an app running in simulator
# Usage: add to your .bashrc / .zshrc / whatever
# run like this - appdir <appname>
appdir() {
ps ax | grep $1.app | grep -v grep | awk '{print "\""$5" "$6" "$7"\""} ' | sed "s/$1\.app\/$1//g" | xargs open
}
@hezi
hezi / prefixer.py
Created May 20, 2012 10:24 — forked from drewmccormack/prefixer.py
Change the prefix of a Cocoa project
#!/usr/bin/env python
#---------
# Script to change the prefix of a framework
#---------
import os
import re
import string
@hezi
hezi / gist:2866995
Created June 4, 2012 07:40
Log all messages in Objective-C
#import <objc/runtime.h>
(void)instrumentObjcMessageSends(YES); //to start
(void)instrumentObjcMessageSends(NO); //to stop
// print result: tail -100f /tmp/msgSends-XXXX
// Source: http://bonto.ch/blog/2012/05/30/log-all-messages-in-objective-c/
@hezi
hezi / HZClassUsingEnum.h
Created July 12, 2012 14:06
Objective-C Enum-TO-NSString and Vice versa.
// Declare enums like so:
#define IMAGE_STATUS(XX) \
XX(kDOImageStatusOK, = 0) \
XX(kDOImageStatusCached, )\
XX(kDOImageStatusRetry, )
DECLARE_ENUM(DOImageStatus, IMAGE_STATUS)
@hezi
hezi / GIPSuperWebViewInit.js
Created December 9, 2012 11:09
partial GIPSuperWebViewInit.js
. . .
navigator.googleInternal = {
iframe_: undefined,
isInitialized: false,
init: function() {
if (this.isInitialized) {
return;
}
this.iframe_ = document.createElement('iframe');
@hezi
hezi / app.js
Created January 14, 2013 13:39 — forked from pixelhandler/app.js
var application_root = __dirname,
express = require("express"),
path = require("path"),
mongoose = require('mongoose');
var app = express.createServer();
// database
mongoose.connect('mongodb://localhost/ecomm_database');
@hezi
hezi / 1.README.md
Last active August 29, 2015 14:24 — forked from varemenos/1.README.md

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
var memwatch = require('memwatch-next');
var heapdump = require('heapdump');
memwatch.on('leak', function(info) {
console.error(info);
var file = '/tmp/myapp-' + process.pid + '-' + Date.now() + '.heapsnapshot';
heapdump.writeSnapshot(file, function(err){
if (err) console.error(err);
else console.error('Wrote snapshot: ' + file);
});
//------------------------------------------------
//--- 010 Editor v10.0.2 Binary Template
//
// Authors: Jorge Cohen <me@jorgecohen.codes>
//
//------------------------------------------------
typedef struct
{
WORD MZSignature <comment="IMAGE_DOS_SIGNATURE = 0x5A4D",format=hex>;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// #include <malloc.h>
// #include <windows.h>
#ifdef GCC32HACK
#include "win32gcc.h"
#endif