Skip to content

Instantly share code, notes, and snippets.

@eventomer
eventomer / .tmux.conf
Last active March 14, 2022 12:28
tmux
# Remap prefix to screens
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# Quality of life stuff
set -g history-limit 10000
set -g allow-rename off
## Join Windows
@eventomer
eventomer / gist:7657464
Created November 26, 2013 12:19
hex value to UIColor macro
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
//example use: self.view.backgroundColor = UIColorFromRGB(0xD2691E);
/**
* Returns the destination point from this point having travelled the given distance (in km) on the
* given initial bearing (bearing may vary before destination is reached)
*
* see http://williams.best.vwh.net/avform.htm#LL
*
* @param {Number} brng: Initial bearing in degrees
* @param {Number} dist: Distance in km
* @returns {LatLon} Destination point
*/
@eventomer
eventomer / gist:7133972
Last active December 26, 2015 09:59
This is how I tried to implement ipmcc's answer to this question http://stackoverflow.com/questions/19540713/imagewithcgimage-gcd-memory-issue I added the asset library to make sure that the asset object get released and it is not retained somewhere else.
NSURL *asseturl = [_asset valueForProperty:ALAssetPropertyAssetURL];
__block ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
[assetslibrary assetForURL:asseturl resultBlock:^(ALAsset *asset) {
__block ALAsset *weakAsset = [asset retain];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
@autoreleasepool {
@eventomer
eventomer / gist:4754589
Last active December 12, 2015 09:49
server response time:(near by ads on 3g)
(1) loading the first page of 4 ads:
4 Ad objects (3.335s).
4 Ad objects (1.100s).
4 Ad objects (1.352s).
4 Ad objects (1.000s).
4 Ad objects (1.929s).
4 Ad objects (4.163s).
4 Ad objects (1.008s).
4 Ad objects (1.865s).
String.prototype.fulltrim = function(){
return this.replace(/(?:((?:^|\n)(?:\s|,|\.|!)+)|((?:\s|,|\.|!)+(?:$|\n)))/g,'');
};
Parse.Cloud.beforeSave("Ad", function(request, response) {
var itemDesc = request.object.get("itemDesc");
request.object.set("itemDesc", itemDesc.fulltrim());
response.success();
});
Parse.Cloud.define("NearByAds", nearByAds);
Parse.Cloud.define("myAds", myAds);
var locationUtil = require('cloud/latlon.js');
/*
* limit is kInitialObjectsPerPageNum(100)
* oredered by descending adDate and createdAt
* kSpecialPropertyKeyApproved(approved) is YES
* kSpecialPropertyKeyDeleted(deleted) is NO
/*
* limit is kInitialObjectsPerPageNum(100)
* oredered by descending adDate and createdAt
* kSpecialPropertyKeyApproved(approved) is YES
* kSpecialPropertyKeyDeleted(deleted) is NO
* not showing ads with price under 100
*
* params:
* kSpecialPropertyKeyUserID(userID)
* location_lat, location_long for kSpecialPropertyKeyLocation(location)
@eventomer
eventomer / gist:4531152
Last active December 11, 2015 02:29
'great finds' are given preferred sorting, their sort order is cut in half.
...
mainQuery.find({
success:function(results){
//'great finds' are given preferred sorting, their sort order is cut in half.
for(var i = 0; i<results.length; i++){
if(results[i].get('ribbon')=='GREAT_FIND'){
results.insert(i/2,results.remove(i).pop());
}
}
@eventomer
eventomer / gist:3938093
Created October 23, 2012 10:33
removeStreetNumber
//removes the last word number in an expression
-(NSString *)removeStreetNumber:(NSString *)string{
string = [string stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
// /s+:whitspace atleast one time, [0-9]*:as many time of numbers as you wish, $:the end of expression
NSRange range = [string rangeOfString:@"\\s+[0-9]*$" options:NSRegularExpressionSearch];
if (range.length>0) {
return [string stringByReplacingCharactersInRange:range withString:@""];