Skip to content

Instantly share code, notes, and snippets.

@taylanpince
taylanpince / gist:01e701dca986648de364
Created December 21, 2014 13:32
Arduino OV7670 Port Register Integration
#include <avr/io.h>
#include <avr/interrupt.h>
static inline void serialWrB(uint8_t dat){
while(!( UCSR0A & (1<<UDRE0))); //wait for byte to transmit
UDR0=dat;
while(!( UCSR0A & (1<<UDRE0))); //wait for byte to transmit
}
static void StringPgm(char * str){
@taylanpince
taylanpince / gist:28e483c2dc81f99e95aa
Created December 20, 2014 21:05
OV7670 Arduino UNO Simple Test
// OV7670+FIFO Simple Data Test
//
// OV7670 Arduino
// 3V3 3.3V
// GND GND
// SYNC 2
// D0-D7 6-13
//
void setup() {
@taylanpince
taylanpince / iphone_checker.py
Created October 18, 2014 21:05
iPhone Availability Checker
import urllib2
import json
from twilio.rest import TwilioRestClient
EATON_STORE_CODE = "R121"
IPHONE6_SILVER_128_CODE = "MG3F2CL/A"
IPHONE6_GREY_128_CODE = "MG3E2CL/A"
APPLE_RESERVATION_URL = "https://reserve.cdn-apple.com/CA/en_CA/reserve/iPhone/availability.json"
@taylanpince
taylanpince / gist:4ddd7f1b1e20fd0eee23
Created May 6, 2014 15:23
Mark file as "Do Not Backup" in iOS
#include <sys/xattr.h>
const char *filePath = [[storeURL path] fileSystemRepresentation];
const char *attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
@taylanpince
taylanpince / gist:8096410
Created December 23, 2013 12:37
Address geocoding with geopy
import simplejson as json
from geopy.geocoders.googlev3 import GoogleV3
from urllib import urlopen
from django.conf import settings
from django.contrib.gis.geos import GEOSGeometry
from django.db.models import signals
from specials.models import Special
@taylanpince
taylanpince / s3.py
Created June 27, 2013 13:41
Async Tornado S3 uploader, doesn't block, continues uploading after the request is closed
import hashlib, hmac, mimetypes, os, time
from base64 import b64encode, b64decode
from calendar import timegm
from datetime import datetime
from email.utils import formatdate
from urllib import quote
from tornado.gen import coroutine, Return
from tornado.httpclient import AsyncHTTPClient, HTTPError
@taylanpince
taylanpince / gist:2714573
Created May 16, 2012 22:34
Mark Files in Directory with Do Not Backup Attribute
#include <sys/xattr.h>
- (NSInteger)markFilesInDirectoryAsDoNotBackup:(NSString *)path {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSDirectoryEnumerator *directoryEnumerator = [fileManager enumeratorAtPath:path];
NSString *filePath = nil;
NSInteger count = 0;
const char *attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
@taylanpince
taylanpince / gist:2575090
Created May 2, 2012 08:31
NSArray reorder
static NSInteger compareListingTypesAccordingToStaticOrder(ListingType *type1, ListingType *type2, void *context) {
static NSArray *orderedTypes = nil;
if (orderedTypes == nil) {
orderedTypes = [[NSArray alloc] initWithObjects:
@"Everything", @"Restaurants", @"Bars",
@"Cafes", @"Bakeries", @"Fashion Stores",
@"Design Stores", @"Bookstores", @"Art Galleries",
@"Fitness Clubs", @"Grocery", @"Hotels", @"Services", nil];
}
@taylanpince
taylanpince / gist:2488911
Created April 25, 2012 10:47
Pull to Refresh
#pragma mark - Scroll View Delegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[super scrollViewDidScroll:scrollView];
if (_refreshInProgress) return;
if (self.tableView.contentOffset.y > 50.0 && self.tableView.contentOffset.y < 140.0) {
if (self.tableView.contentOffset.y <= 90.0) {
[(RefreshView *)self.tableView.tableHeaderView displayInstructions];