Skip to content

Instantly share code, notes, and snippets.

View arpit's full-sized avatar

Arpit Mathur arpit

View GitHub Profile
@arpit
arpit / find-replace
Created November 28, 2014 20:06
Find pattern to read all public vars in a swift model and replace in your json parser
View find-replace
//Find:
var\s([A-Za-z_]+):\s?[A-Za-z!_\\?]+
//Replace:
if(g[i]["$1"] != nil && g[i]["$1"] as? NSNull == nil){
goal.$1 = g[i]["$1"] as AnyObject? as String!
}
View layout.md

Figured out my layout issue: I had set the frame on a UIView and added it to a parent view. Under the hood, iOS translated the frame rectangle to constraints (cause I hadn't set "setTranslatesAutoresizingMaskToConstraints" to false). So when the parent view was resized later, the child view stretched along with it. Unlike the default behavior views with frames set that just stay that size regardless.

View AIR InvokeEvent Bug?
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" width="400" height="300" creationComplete="minimizeToDock()">
<mx:Label text="Dockable" horizontalCenter="0" verticalCenter="0">
</mx:Label>
<mx:Script>
<![CDATA[
private function minimizeToDock():void{
nativeWindow.addEventListener(Event.CLOSING, function(event:Event):void{
View Displacement_map.as
import flash.filters.DisplacementMapFilter;
import flash.display.BitmapData;
import flash.geom.Matrix;
import flash.geom.Point;
var str = 100;
this.addEventListener (Event.ENTER_FRAME,enterframe);
@arpit
arpit / gist:666010
Created November 7, 2010 07:50
Spec for Todo List
View gist:666010
<Project name="">
<Task>
<label></label>
<description></description>
<priority></priority>
<due_date></due_date>
<depends_on></depends_on>
<recurring></recurring>
<location></location>
<tags></tags>
@arpit
arpit / gist:674571
Created November 12, 2010 19:50
Readability JavaScript
View gist:674571
javascript:(function(){readConvertLinksToFootnotes=false;readStyle='style-newspaper';readSize='size-medium';readMargin='margin-wide';_readability_script=document.createElement('script');_readability_script.type='text/javascript';_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());document.documentElement.appendChild(_readability_script);_readability_css=document.createElement('link');_readability_css.rel='stylesheet';_readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';_readability_css.type='text/css';_readability_css.media='all';document.documentElement.appendChild(_readability_css);_readability_print_css=document.createElement('link');_readability_print_css.rel='stylesheet';_readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';_readability_print_css.media='print';_readability_print_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_readability_prin
View gist:1244268
<!doctype html>
<html>
<head>
<title>Hello Canvas</title>
<style>
#can{
background:#dfdfdf;
}
@arpit
arpit / gist:1269327
Created October 7, 2011 02:55
Minimize an application to dock in Adobe AIR
View gist:1269327
private function minimizeToDock():void{
nativeWindow.addEventListener(Event.CLOSING, function(event:Event):void{
event.preventDefault();
nativeWindow.visible = false;
nativeApplication.addEventListener(InvokeEvent.INVOKE, function(event:InvokeEvent):void{
trace(" Invoking...");
nativeWindow.visible = true;
});
});
}
@arpit
arpit / AndroidUI.md
Created February 26, 2012 18:45
A list of apps updated with Android UI guidelines
View AndroidUI.md

Astrid app:

Stumbleupon:

@arpit
arpit / AndroidImageUtils.java
Created March 1, 2012 19:26
Android Image Util
View AndroidImageUtils.java
private Bitmap getBitmapFromAsset(String strName) throws IOException
{
AssetManager assetManager = getAssets();
InputStream istr = assetManager.open(strName);
Bitmap bitmap = BitmapFactory.decodeStream(istr);
return bitmap;
}