Skip to content

Instantly share code, notes, and snippets.

View mpociot's full-sized avatar

Marcel Pociot mpociot

View GitHub Profile
@mpociot
mpociot / TiTwitterModule.m
Created December 26, 2011 20:34
Titanium Twitter module request method
-(void)request:(id)args
{
ENSURE_UI_THREAD(request,args);
NSDictionary * params = [args objectAtIndex:0];
NSString *urlString = [params objectForKey:@"url"];
ENSURE_STRING(urlString);
NSDictionary * paramDict = [params objectForKey:@"params"];
NSLog(@"[INFO] params is: %@",paramDict);
@mpociot
mpociot / app.js
Created December 26, 2011 20:50
Twitter module call
requestButton.addEventListener('click',function(e){
module.request({
params: {
screen_name: 'marcelpociot',
count: 10
},
url: "http://api.twitter.com/1/statuses/user_timeline.json",
method: 'get',
success: function(e){
alert(e);
@mpociot
mpociot / gist:1788369
Created February 10, 2012 10:09
simplified button animation
- (IBAction)btn_reg_onClick:(id)sender {
reg_animation_modus = !(reg_animation_modus);
int k;
if( reg_animation_modus ){
k = 1;
[btn_einloggen setTitle:@"Registrieren" forState:UIControlStateNormal];
} else {
k = -1;
[btn_einloggen setTitle:@"Einloggen" forState:UIControlStateNormal];
}
@mpociot
mpociot / form.js
Created February 29, 2012 10:21
form validation
for( var key in req ){
var value = req[key];
$('input[type="text"][name="'+key+'"]').val(value);
$('input[type="checkbox"][name^="'+key+'"]').removeAttr('checked');
$('input[type="checkbox"][name="'+key+'"][value="'+value+'"]').attr('checked','checked');
if( typeof value === 'object' ){
for(var i=0;i<value.length;i++){
var check = value[i];
$('input[type="checkbox"][name^="'+key+'"][value="'+check+'"]').attr('checked','checked');
}
@mpociot
mpociot / gist:3787399
Created September 26, 2012 11:12
Simple commonJS datastorage
// Private variable data
var data = {};
function setValue(key,value){
data[key] = value;
}
function getValue(key){
return data[key];
}
@mpociot
mpociot / Request.class.php
Created June 28, 2013 12:14
HTTP Request wrapper class
<?php
/**
* HTTP Request
* Wrapper Class
*
* @author Marcel Pociot
* @copyright Marcel Pociot 2009-2013
*/
namespace CR;
@mpociot
mpociot / gist:6608305
Last active December 23, 2015 08:29
Show the current git branch in your bash prompt

Installation

Install the git-prompt script using curl:

curl https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh -o ~/.git-prompt.sh

Load the git-prompt.sh script in your ~/.bash_profile

Place these two lines in your bash_profile

@mpociot
mpociot / ad1.lua
Created May 19, 2014 14:50
Example demonstrating the issue mentioned on the corona forum: http://forums.coronalabs.com/topic/47975-admob-only-shows-first-banner/
local composer = require( "composer" )
local scene = composer.newScene()
local ads = require "ads"
local widget = require "widget"
local nextScene = function()
composer.gotoScene("ad2")
end
function scene:create( event )
@mpociot
mpociot / app.js
Created August 28, 2014 17:30
beforeload example
var win = Ti.UI.createWindow();
var webView = Ti.UI.createWebView({
url: 'test.html'
});
webView.addEventListener( "beforeload", function(e)
{
Ti.API.info( e.url );
});
win.add( webView );
win.open();
<!--
This should use the "ListView" Alloy parser, to support Templates, but it should use the 'createCollectionView' method
instead of createListView, createListSection, etc...
Is this possible?
-->
<ListView id="listView" defaultItemTemplate="template" ns="require('de.marcelpociot.collectionview')">
<Templates>
<ItemTemplate name="template">
<ImageView bindId="pic" id="icon" />