Skip to content

Instantly share code, notes, and snippets.

View akozlik's full-sized avatar

Andrew Kozlik akozlik

View GitHub Profile
@akozlik
akozlik / gist:86dc73a68f6ad9ee86dbc947faf21fd0
Last active December 30, 2018 04:25
Bandersnatch (org 3000)
org 3000
runLoop
pop cn
push bd a,5
bd (hl),a
inc hl
cp 191
jr uk
ld de,5
@akozlik
akozlik / multicast.go
Last active August 29, 2015 14:23 — forked from fiorix/gist:9664255
package main
import (
"encoding/hex"
"log"
"net"
"time"
)
const (
@akozlik
akozlik / gist:f6b82cd2779a3fbe7c72
Created April 20, 2015 18:50
Wordpress Search and Replace
// NOTE: All URLs must contain their protocol and must NOT have trailing slashes
// Set the path for all JS / CSS / template imports
update wp_options set option_value = 'new_domain' where option_id in (1, 2)
// Update all links
UPDATE wp_posts SET guid = replace(guid, 'old_url','new_url');
// Replace URL references in post content
UPDATE wp_posts SET post_content = replace(post_content, 'old_url', 'new_url');
@akozlik
akozlik / gist:2093209326b40e615aba
Created April 4, 2015 04:08
Loop through an array of objects with dates and group by week
$weeks = array();
$index = 0;
while (count($tmp_logs) > 0) {
$log = array_shift($tmp_logs);
$date = $log['date'];
$sunday = strtotime('last Sunday', $date);
$saturday = strtotime('Saturday 11:59pm', $date);
$done = false;
@akozlik
akozlik / gist:12521fe329c69f28f9e9
Created January 27, 2015 15:10
iOS 7 and 8 notification backwards compatibility
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
} else {
stop_id,stop_name,stop_lat,stop_lon,location_type
175,ROSEMONT SUPERSTOP, 28.6085340000, -81.4282110000,0
178,SPRINGS VILLAGE SHOPPING CTR, 28.6882790000, -81.4065090000,0
214,KOA ST AND MONTEREY RD, 28.1566130000, -81.4820430000,0
553,1700 17TH ST AND CONNECTICUT AVE, 28.2424240000, -81.2879670000,0
554,4500 US 192 HWY AND COMMERCE CENTER DR, 28.2548600000, -81.3190380000,0
555,ST CLOUD WAL-MART, 28.2541690000, -81.3148810000,0
556,4200 US 192 HWY AND KISSIMMEE PARK RD, 28.2508540000, -81.3130770000,0
561,2700 10TH ST AND LOUISIANA AVE, 28.2488240000, -81.2993230000,0
562,2400 10TH ST AND TENNESSEE AVE, 28.2488950000, -81.2964650000,0
@akozlik
akozlik / gist:11241740
Created April 24, 2014 04:42
Zoom MapKit out to fit pins
-(void)zoomToFitMapAnnotations:(MKMapView*)mapView
{
if([mapView.annotations count] == 0)
return;
CLLocationCoordinate2D topLeftCoord;
topLeftCoord.latitude = -90;
topLeftCoord.longitude = 180;
CLLocationCoordinate2D bottomRightCoord;
@akozlik
akozlik / gist:9555349
Created March 14, 2014 19:45
Dynamic Cell Height w/AutoLayout
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
static UITableViewCell *cell;
if (cell == nil) {
cell = [tableView dequeueReusableCellWithIdentifier:@"ClueCell"];
}
[self configureCell:cell forIndexPath:indexPath];
return [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height + 1.0f;
@akozlik
akozlik / gist:9296627
Created March 1, 2014 20:24
Useful MySQL command line instructions
// Dump an entire database
mysqldump --opt -u [uname] -p[pass] [dbname] > [backupfile.sql]
// Dump specific tables from a database
mysqldump -u root -p [dbname] [table1] [table2] > [backupfile.sql]
// Restore database from sql file
mysql -u [uname] -p[pass] [db_to_restore] < [backupfile.sql]
@akozlik
akozlik / gist:8874959
Created February 8, 2014 00:51
Batch convert videos to mp4 using ffmpeg
for i in *.avi; do name=`echo $i | cut -d'.' -f1`; echo $name; ffmpeg -i $i $name.mp4 done