Skip to content

Instantly share code, notes, and snippets.

View amine2233's full-sized avatar

Amine Bensalah amine2233

View GitHub Profile
@kristopherjohnson
kristopherjohnson / unzip.swift
Last active December 10, 2022 14:21
zip(), zip3(), unzip(), and unzip3() for Swift
// Given array of 2-tuples, return two arrays
func unzip<T, U>(array: [(T, U)]) -> ([T], [U]) {
var t = Array<T>()
var u = Array<U>()
for (a, b) in array {
t.append(a)
u.append(b)
}
return (t, u)
}
@seyhunak
seyhunak / request.swift
Last active February 4, 2020 06:14
NSURLRequest in Swift
import Foundation
class Request : NSObject {
var url : NSURL? = nil
var request : NSMutableURLRequest? = nil
var response : NSHTTPURLResponse? = nil
var data: NSMutableData? = nil
var done: (NSError?, NSData, NSString?) -> () = { (_, _, _) -> () in }
@staltz
staltz / introrx.md
Last active July 24, 2026 00:55
The introduction to Reactive Programming you've been missing
@xpepper
xpepper / Some tools and tweaks on Mac OS X.md
Last active May 6, 2025 14:52 — forked from g3d/gist:2709563
Some tools and tweaks on Mac OS X
public function autocomplete() {
$this->request->params['named']['filter'] = $this->request->data[$this->modelClass]['filter'];
if (!empty($this->request->params['named']['filter']) || $this->request->params['named']['filter'] !== '') {
$this->Prg->commonProcess();
$this->Paginator->settings = array(
'conditions' => $this->Location->parseCriteria($this->Prg->parsedParams()),
);
$this->set('locations', $this->Paginator->paginate());
}
$this->render('autocomplete', 'ajax');
@janikvonrotz
janikvonrotz / Convert SSL certificates.md
Created March 7, 2014 15:12
Ubuntu: Convert SSL certificates #OpenSSL #Markdown

Requirements

  • Get a free verified SSL certificate from StartSSL (optional)

Instructions

When buying a certificate from you CA (Certification Authority) e.g. a wildcard certificate for *.example.org, you have to convert this file to different formats in order to use them with your webserver installation.

To convert these files use OpenSSL.

Keynote I guess pushed an update that doesn't take hightlighted code from xCode anymore. So, I googled around and found highlight. It is a super useful utitlity to do syntax highlighting from the command line.

$ brew install highlight

If you are on Mavericks you may need to brew link lua to get it working right.

Hightlight has support for all kinds of languages and themes and it can wrap the code with line numbers, which is great.

@ariok
ariok / [CoreData]EntriesBetweenDates.m
Created November 29, 2013 17:01
Get Core Data entries between a date range
+ (NSArray*)allEntriesInContext:(NSManagedObjectContext*)context fromDate:(NSDate*)fromDate toDate:(NSDate*)toDate{
// Create the request
NSFetchRequest *request = [[NSFetchRequest alloc]initWithEntityName:@"Entry"];
// Build the predicate
NSPredicate *predicate = [NSPredicate predicateWithFormat: @"date >= %@ && date <= %@ ", fromDate, toDate];
request.predicate = predicate;
// Define sorting
NSSortDescriptor *sortDesc = [NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES];
request.sortDescriptors = @[sortDesc];
@cconstable
cconstable / singleton.m
Created October 8, 2013 16:06
Generic Obj-C Singleton Code Snippet
+ (instancetype)sharedUtilities
{
__strong static id sharedUtilities;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedUtilities = [[self alloc] init];
});
return sharedUtilities;
}
ACTION
AD_HOC_CODE_SIGNING_ALLOWED
ALTERNATE_GROUP
ALTERNATE_MODE
ALTERNATE_OWNER
ALWAYS_SEARCH_USER_PATHS
ALWAYS_USE_SEPARATE_HEADERMAPS
APPLE_INTERNAL_DEVELOPER_DIR
APPLE_INTERNAL_DIR
APPLE_INTERNAL_DOCUMENTATION_DIR