Skip to content

Instantly share code, notes, and snippets.

View nazywamsiepawel's full-sized avatar
:bowtie:
hummus is life

pawel.io nazywamsiepawel

:bowtie:
hummus is life
View GitHub Profile
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@m0wfo
m0wfo / gist:1101546
Created July 23, 2011 15:26
Round 2- parallel divide & conquer reduction function
- (id)reduceWithBlock:(id (^)(id memo, id obj))block andAccumulator:(id)accumulator withBaseLength:(NSUInteger)baseLength
{
__block id acc = [[accumulator copy] autorelease];
NSUInteger base_job_length = baseLength;
if (!baseLength) {
// Calculate the base job length
NSUInteger num_processors = [[NSProcessInfo processInfo] processorCount];
base_job_length = (NSUInteger)([self count] / sqrt(num_processors)); // (L = n / p squared)
}
@edwardtoday
edwardtoday / gist:2204864
Created March 26, 2012 12:54
PhoneGap sqlite working example
Hi
I hope this helps you all get started with phonegap and sqlite in your
application
Dean-O
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
@wh5a
wh5a / mp4.c
Created January 1, 2013 03:05
CUDA Array Sum with Reduction
// MP 4 Reduction
// Given a list (lst) of length n
// Output its sum = lst[0] + lst[1] + ... + lst[n-1];
// Due Tuesday, January 15, 2013 at 11:59 p.m. PST
#include <wb.h>
#define BLOCK_SIZE 512 //@@ You can change this
#define wbCheck(stmt) do { \
@tonyarnold
tonyarnold / mr-save-patterns.md
Last active October 21, 2023 00:55
Common save patterns for use with MagicalRecord

Common Save Patterns

Standard background save

Assuming that you don't care which NSManagedObjectContext is used, and you just want to make some changes and save them in the background, use the following method. 90% of the time, this is what you'll want.

NSManagedObjectSubclass *myObject = [NSManagedObjectSubclass MR_findFirst];

[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {
@aras-p
aras-p / preprocessor_fun.h
Last active June 21, 2024 12:20
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@tsiege
tsiege / The Technical Interview Cheat Sheet.md
Last active June 28, 2024 10:38
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

ANNOUNCEMENT

I have moved this over to the Tech Interview Cheat Sheet Repo and has been expanded and even has code challenges you can run and practice against!






\

@klaas
klaas / StreamReader.swift
Last active May 21, 2017 14:51
Xcode 6.1 version of source for this SO answer http://stackoverflow.com/a/24648951/292145
import Foundation
class StreamReader {
let encoding : UInt
let chunkSize : Int
var atEof : Bool = false
var fileHandle : NSFileHandle!
let buffer : NSMutableData!
//
// Genetics.swift
// Genetics
//
// Created by Julius Parishy on 12/1/14.
// Copyright (c) 2014 Julius Parishy. All rights reserved.
//
import Cocoa
import CoreGraphics
@Miserlou
Miserlou / cities.json
Created April 30, 2015 06:58
1000 Largest US Cities By Population With Geographic Coordinates, in JSON
[
{
"city": "New York",
"growth_from_2000_to_2013": "4.8%",
"latitude": 40.7127837,
"longitude": -74.0059413,
"population": "8405837",
"rank": "1",
"state": "New York"
},