Skip to content

Instantly share code, notes, and snippets.

View netshade's full-sized avatar
🧛

Chris Zelenak netshade

🧛
View GitHub Profile
# For merbists that want to use Rails (or more appropriately, ActiveRecord) plugins that haven't yet
# been turned into gems
# Presumes that there exists a directory in your application root called "plugins"
def emulate_rails_plugins!
Merb.push_path(:plugins, Merb.root / "plugins", "*/lib/**/*.rb")
Dir[Merb.root / "plugins" / "*"].each do |entry|
$: << (entry / "lib")
if File.exists?(entry / "init.rb")
require(entry / "init.rb")
end
[TRACE] D/TiFileFactory( 285): (kroll$1) [1,3069] getting initial from parts: app://vendor/jester.js
[TRACE] I/KrollContext( 285): (kroll$1) [1,3070] evalFile: file:///android_asset/Resources/vendor/jester.js
[TRACE] I/KrollContext( 285): (kroll$1) [4,3074] ThreadId: 8 currentThreadId: 8
[TRACE] D/TiFileFactory( 285): (kroll$1) [2,3076] getting initial from parts: file:///android_asset/Resources/vendor/jester.js
[TRACE] D/dalvikvm( 285): GC freed 8227 objects / 622584 bytes in 103ms
[TRACE] I/global ( 285): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
[TRACE] I/dalvikvm( 285): Stack overflow, expanding (0x426ee200 to 0x426ee000)
[TRACE] E/dalvikvm( 285): Can't shrink stack: curFrame is in reserved area (0x426ee000 0x426ee1c8)
[TRACE] I/dalvikvm( 285): "kroll$1" prio=5 tid=15 RUNNABLE
[TRACE] I/dalvikvm( 285): | group="main" sCount=0 dsCount=0 s=N obj=0x43d21cb0 self=0x1355d0
To get Android working with 1.2.1 version of Titanium, I had to:
A) Create a new project with this new android.py file because the old one was broken ( http://developer.appcelerator.com/question/12431/12---android-brokenness---ks-never-loads-cant-launch-new-projects#29921 )
B) Make it so that all my js files where updated so that the android.py deployer would correctly recognize they needed to be sent to the phone ( zsh: for i in **/*.js; touch $i )
C) Fix some really weirdass startup exceptions (Note, to see the android log, change your log level in Titanium build window to Trace - lots of helpful info there. Or just use 'adb logcat' from the Android SDK.) http://developer.appcelerator.com/question/14701/javascript-parse-errors-on-android-with-function-closure-arguments
D) Ponder becoming an alcoholic.
E) Finally get my app to startup after refactoring all of our JS to avoid above problem, and then arrive at a blank screen.
F) Give up.
Also! You'll, want to upgrade your actual device to Android 1.6 or abo
#!/usr/bin/env ruby
file_path = ARGV[0] || 'go4_global_sub_navigation.html'
raise "#{file_path} does not exist, please specify which file you want to alter the navgo4_t_* on" unless File.exists?(file_path)
contents = File.read(file_path)
contents.gsub!(/<a(.+?)href\s*=\s*(['"].+?\?)navgo4_t_(.+?)(['"][^>]*)>(.+?)<\/a>/i) { |match| "<a href=#{$1}navgo4_t_#{$4.downcase.split(" ").join("_")}#{$3}>#{$4}</a>" }
wr = File.new(file_path, "w+")
wr.write(contents)
wr.close
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 40;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
UIView * fv = [[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 0.0, 0.0)] autorelease];
[fv setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[fv setContentMode:UIViewContentModeTopLeft];
[UIImageView *footer = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"footer_gradient.png"]] autorelease];
-(void)setupView:(GLView*)view
{
const GLfloat zNear = -0.01, zFar = 1000.0, fieldOfView = 45.0;
GLfloat size;
glMatrixMode(GL_PROJECTION);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
size = zNear * tanf(DEGREES_TO_RADIANS(fieldOfView) / 2.0);
@interface SomeSingleton {
uint8_t * someBlockOfMemory;
}
@property(readwrite, atomic, assign) uint8_t * someBlockOfMemory;
+(id) sharedInstnace;
@end
/*
With an open path this yields less than desirable results;
closed paths this technique should be fine with.
Screenshot: http://tinypic.com/view.php?pic=7301up&s=7
*/
- (void)drawRect:(CGRect)rect {
UIImage * bg = [UIImage imageNamed:@"bg.png"];
CGContextRef context = UIGraphicsGetCurrentContext();
@netshade
netshade / URL Redirection bug on Mobile Safari
Created February 17, 2011 15:05
Twitter Authorize-App "Don't Have a Twitter account" misdirection when using Mobile Safari
If you attempt to authorize an app to access your Twitter account using a Mobile Safari user-agent and arrive at the "Allow" / "Deny" screen while not currently logged in at Twitter, you are presented with a link that says "Don't have a Twitter account? Sign up Now!" . This link forwards you to:
http://api.twitter.com/account/new?oauth_token=<the-oauth-token-for-the-session>
which subsequently forwards you to:
http://mobile.twitter.com/account/new
which then forwards you to: