Skip to content

Instantly share code, notes, and snippets.

Pedro Enrique pec1985

Block or report user

Report or block pec1985

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pec1985
pec1985 / main.cpp
Created Feb 21, 2015
Usage of std::mutex
View main.cpp
#include <thread>
#include <memory>
#include <mutex>
#include <iostream>
#include <vector>
#define USE_MUTEX 1
class Foo
@pec1985
pec1985 / app.js
Last active Jan 30, 2018
Array indexOf vs for loop
View app.js
function Pe(){};
var len = 1000000;
var half = len / 2;
var array = [];
var last = new Pe();
while(len--) {
array.push(new Pe());
}
array.push(last);
@pec1985
pec1985 / app.js
Created Sep 23, 2014
Events on buttons
View app.js
var win = Ti.UI.createWindow();
var btn = Ti.UI.createButton({
title: 'click me'
});
win.add(btn);
win.open();
btn.addEventListener('click', function () {
Ti.API.info('First "click" event on the button fired!');
});
@pec1985
pec1985 / ti.error.view.m
Last active Aug 29, 2015
Playing around with autolayout in iOS
View ti.error.view.m
- (void)loadView
{
self.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor redColor];
[view setBackgroundColor:[UIColor redColor]];
[self setView:view];
UIButton *dismissButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
@pec1985
pec1985 / listview_index_column.js
Last active Dec 28, 2015
Index column in the listview
View listview_index_column.js
/* Ever wondered how to get the nice column of letters in the right side
* of the list view?
*
* Here is an example:
* 1. We take a list of names from a json file
* 2. We need to sort them by either first name or last name
* 3. We need to create a row header once in a while, when the first letter changes
* 4. We need to create a table index
*
*/
@pec1985
pec1985 / RHelper.java
Created Jun 24, 2013
Helper to get R. in Titanium Android
View RHelper.java
package com.pec1985.tigolf;
import org.appcelerator.titanium.util.TiRHelper;
import org.appcelerator.titanium.util.TiRHelper.ResourceNotFoundException;
public class RHelper {
public static int getString(String str){
try {
return TiRHelper.getApplicationResource("string."+str);
@pec1985
pec1985 / app.js
Created May 16, 2013
Simple script to create a lot of ACS Users with Titanium
View app.js
var json = {"HasMore":false,"FuelStations":[{"StationId":"POIID-2011Q1_32035298","FuelPrice":[{"FuelType":1,"CapacityPrice":{"Value":4.139,"Units":"GAL","Currency":"USD"},"PriceTimestampLocal":"2013-05-10T12:17:00.000+0000","PriceTimestampGMT":"2013-05-10T19:17:34.000+0000"},{"FuelType":4,"CapacityPrice":{"Value":4.259,"Units":"GAL","Currency":"USD"},"PriceTimestampLocal":"2013-05-13T17:03:00.000+0000","PriceTimestampGMT":"2013-05-14T00:03:30.000+0000"},{"FuelType":3,"CapacityPrice":{"Value":4.159,"Units":"GAL","Currency":"USD"},"PriceTimestampLocal":"2013-05-13T17:03:00.000+0000","PriceTimestampGMT":"2013-05-14T00:03:30.000+0000"},{"FuelType":2,"CapacityPrice":{"Value":4.099,"Units":"GAL","Currency":"USD"},"PriceTimestampLocal":"2013-05-14T14:25:00.000+0000","PriceTimestampGMT":"2013-05-14T21:25:45.000+0000"}],"Brand":"76","LastUpdateTimestamp":"2013-05-16T04:06:26.000+0000","Routing":{"href":"http://fuel.si.public.devbln.europe.nokia.com/1.0/routing/calculateroute?waypoint=37.332332611083984,-122.0312194824
@pec1985
pec1985 / app.js
Created May 10, 2013
Double Slider
View app.js
var Slider = require('slider');
var win = Ti.UI.createWindow();
var slider = Slider({
left: 10,
right: 10,
height: 40
});
@pec1985
pec1985 / TiUIScrollViewProxy+Extended.h
Created May 5, 2013
Extension to TiUIScrollView to get content size
View TiUIScrollViewProxy+Extended.h
//
// TiUIScrollViewProxy+Extended.h
// TiGoodies
//
// Created by Pedro Enrique on 4/8/13.
//
//
#define USE_TI_UISCROLLVIEW
#import "TiUIScrollViewProxy.h"
@pec1985
pec1985 / dd.js
Last active Dec 16, 2015
BlackBerry generate setters
View dd.js
// Sample setters
var setters = [
'currentPage'
, 'disableBounce'
, 'overScrollMode'
, 'overlayEnabled'
, 'pagingControlAlpha'
, 'pagingControlColor'
, 'pagingControlHeight'
You can’t perform that action at this time.