Skip to content

Instantly share code, notes, and snippets.

@omorandi
omorandi / android_get_view_size.java
Last active December 14, 2020 20:51
Android: get the actual size of a match_parent/wrap_content view
view.post(new Runnable() {
@Override
public void run() {
int width = view.getWidth();
int height = view.getHeight();
//do something cool with width and height
}
});
@omorandi
omorandi / gist:6241406
Last active February 23, 2018 10:29
Add third party jni library to Android Titanium Module
From: http://developer.appcelerator.com/question/121573/how-do-i-use-so-library-in-module
Place .so files in mymodule/lib/armeabi
Add this to build.xml:
<target name="post.jar">
<copy todir="${libs}">
<fileset dir="lib">
<include name="**/*.so"/>
@omorandi
omorandi / gist:6209130
Created August 12, 2013 08:37
Tracing JSC calls with dtrace
sudo dtrace -n 'JavaScriptCore*:::profile-will_execute{ trace(arg0); trace(copyinstr(arg1)); trace(copyinstr(arg2)); trace(arg3) }' -n 'JavaScriptCore*:::profile-did_execute{ trace(arg0); trace(copyinstr(arg1)); trace(copyinstr(arg2)); trace(arg3) }'
arg0: profileGroup (int)
arg1: function (string)
arg2: file-url (string)
arg3: line (int)
@omorandi
omorandi / README.md
Last active December 10, 2015 22:18 — forked from vprtwn/README.md

Drag from an existing node to add a new node or link. Click to select/deselect nodes/links. Hit the DELETE key to remove the selected node or link. Drag to pan. Scroll to zoom.

Built with D3.js.

@omorandi
omorandi / app.js
Created March 13, 2012 15:36
simple profiling test with Ti Mobile iOS
Ti.include('included.js');
function launch_test1() {
test1();
}
@omorandi
omorandi / gist:1626791
Created January 17, 2012 14:23 — forked from jaraen/gist:1626498
Shadow property in TiUIView.m
-(void)setShadow_:(id)args
{
if(args != nil)
{
self.layer.masksToBounds = NO;
if ([args objectForKey:@"shadowOffset"] != nil) {
CGPoint p = [TiUtils pointValue: [args objectForKey:@"shadowOffset"]];
CGSize shadowOffset = {p.x,p.y};
+ (NSData*) resolveAppAsset:(NSString*)path;
{
static NSMutableDictionary *map;
if (map==nil)
{
map = [[NSMutableDictionary alloc] init];
//here the entry for app.js is created
//(I filled the hex string with garbage - it's only an example)
[map setObject:dataWithHexString @"DEADBEEF…" forKey:@"app_js"];
}
ip_addr = "localhost"
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
s.connect(("gmail.com",80))
ip_addr = s.getsockname()[0]
except socket.error, msg:
s.close()
s = None
+ (NSData*) resolveAppAsset:(NSString*)path;
{
NSString *ServerAddr = SERVER_ADDRESS;
NSString *ServerPort = SERVER_PORT;
NSString *path_url = [NSString stringWithFormat:@"http://%@:%@/%@",ServerAddr, ServerPort, path];
NSURL *url = [NSURL URLWithString:path_url];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request startSynchronous];
if ([request responseStatusCode] != 200)
@omorandi
omorandi / gist:1226220
Created September 19, 2011 09:37
Get asset files in Ti iOS modules
#define MODULE_ID @"your.module.id"
- (NSURL *)getAssetURL:(NSString*)resFile
{
NSString * filePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:[NSString stringWithFormat:@"modules/%@/%@",MODULE_ID, resFile]];
return [NSURL fileURLWithPath:filePath];
}