Skip to content

Instantly share code, notes, and snippets.

@adeel
adeel / UILabel+withString.h
Created July 21, 2011 22:36
UILabel category that adds a method to easily make labels on the fly.
//
// UILabel+withString.h
//
#import <Foundation/Foundation.h>
@interface UILabel (withString)
+ (UILabel *)labelWithString:(NSString *)string
font:(UIFont *)font
@huandu
huandu / class.js
Created August 15, 2011 05:14
A way to define javascript class. support multiple base class and static method.
(function(window, undefined) {
var Abstract = function() {
return arguments.callee;
},
Static = function(cb) {
this.cb = cb;
},
/**
* define your class.
*
@psineur
psineur / UIWebViewWithDebug.m
Created December 12, 2011 17:35
UIWebView with js Debugger.
/** @class UIWebViewWithDebug UIWebView with additional js error on DEBUG.
* Tested on iPad with 4.3.5 & 5.0
*/
@interface UIWebViewWithDebug : UIWebView {} @end
#ifdef DEBUG
@class WebView;
@class WebScriptCallFrame;
@class WebFrame;
@rednaxelafx
rednaxelafx / java_error_28522.short.extra.log
Created May 3, 2012 09:05
A HotSpot crash log example of a crash caused by a bug in the C2 compiler (7070134)
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00002aaf0d11c031, pid=28522, tid=1104951616
#
# JRE version: 6.0_23-b05
# Java VM: Java HotSpot(TM) 64-Bit Server VM (19.0-b09 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# V [libjvm.so+0x593031]
#
diff --git a/Source/JavaScriptCore/runtime/ArrayPrototype.cpp b/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
index 818895c..4b1278a 100644
--- a/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
+++ b/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
@@ -383,7 +383,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncJoin(ExecState* exec)
UString separator;
if (!exec->argument(0).isUndefined())
- separator = exec->argument(0).toString(exec)->value(exec);
+ separator = fastJSValuetoUString(exec->argument(0), exec);
@steipete
steipete / ARCCheck.m
Created December 5, 2011 22:26
Don't be a fool and wonder why nothing is working... ADD THIS CHECK.
// ARC is compatible with iOS 4.0 upwards, but you need at least Xcode 4.2 with Clang LLVM 3.0 to compile it.
#if !defined(__clang__) || __clang_major__ < 3 || !__has_feature(objc_arc)
#error This project must be compiled with ARC (Xcode 4.2+ with LLVM 3.0 and above)
#endif
@rednaxelafx
rednaxelafx / .hotspot_compiler
Created March 6, 2012 13:18
Example (XS) of adding an intrinsic method to HotSpot C2. Patch against HS20-b12
exclude Main main
dontinline Main doTest
compileonly Main doTest
compileonly FxIntrinsics *
@rednaxelafx
rednaxelafx / log1
Created July 14, 2011 03:49
analyzing an endless loop problem caused by concurrent access to HashMap.get()
$ top -H
...
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
19115 root 25 0 576m 217m 9432 R 99.7 5.3 1357:12 java
28347 root 25 0 576m 217m 9432 R 99.7 5.3 1191:05 java
26912 root 25 0 576m 217m 9432 R 99.3 5.3 114:58.57 java
5607 root 25 0 576m 217m 9432 R 99.0 5.3 54:49.02 java
@rednaxelafx
rednaxelafx / StackOverflowCrashDemo.h
Created May 2, 2012 06:27
demo of a Java-level stack overflow causing a native crash
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class StackOverflowCrashDemo */
#ifndef _Included_StackOverflowCrashDemo
#define _Included_StackOverflowCrashDemo
#ifdef __cplusplus
extern "C" {
#endif
/*
@stuartcarnie
stuartcarnie / main.m
Created March 4, 2011 19:59
Demonstrates we can now support limited JIT compilation on recent versions of iOS (assuming Apple approves entitlements at some future point)
//
// main.m
// ProtectTest
// Demonstrates newer versions of iOS now support PROT_EXEC pages, for just-in-time compilation.
//
// Must be compiled with Thumb disabled
//
// Created by Stuart Carnie on 3/4/11.
// Copyright 2011 Manomio LLC. All rights reserved.
//