Skip to content

Instantly share code, notes, and snippets.

View Pegolon's full-sized avatar

Markus Kirschner Pegolon

View GitHub Profile
@Pegolon
Pegolon / Repair a corrupt sqlite database
Created March 15, 2011 18:38
If you get an error like SQLite error code:11, 'database disk image is malformed' you can try to dump and reload the database with these commands
cd "$DATABASE_LOCATION"
echo '.dump'|sqlite3 $DB_NAME|sqlite3 repaired_$DB_NAME
mv $DB_NAME corrupt_$DB_NAME
mv repaired_$DB_NAME $DB_NAME
@mattetti
mattetti / fsevents.rb
Created March 18, 2011 07:19
FSEvents API implementation in MacRuby
if RUBY_ENGINE == 'macruby'
framework 'CoreServices'
WATCHED_EXTS = "rb,builder,erb,nokogiri"
PASSENGER_RESTART_FILE = File.expand_path(File.join(File.dirname(__FILE__), "..", "tmp", "restart.txt"))
DELAY = 3
def modified_files(path)
Dir.glob("#{File.expand_path(path)}/*.{#{WATCHED_EXTS}}").map do |filename|
begin
@nvkv
nvkv / uncrustify.cfg
Created May 4, 2011 09:08
Nulana's Uncrustify config for Objective-C/C++
indent_align_string=false
indent_braces=false
indent_braces_no_func=false
indent_brace_parent=false
indent_namespace=false
indent_extern=false
indent_class=false
indent_class_colon=false
indent_else_if=false
indent_func_call_param=false
@boctor
boctor / BaseViewController.m
Created May 5, 2011 02:08
A base view controller class that when running on the simulator in debug mode, will auto simulate a memory warning every time the view controller's viewDidAppear is called
//
// BaseViewController.m
//
// Created by Peter Boctor on 5/4/11.
//
// Copyright (c) 2011 Peter Boctor
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@Pegolon
Pegolon / gist:1550345
Created January 2, 2012 11:26
Remove extra space from ObjC method signature
Find: ^([+-] \(.* \*\))( )
Replace: \1
@robertripoll
robertripoll / README.md
Last active September 23, 2020 18:08
Telnet Server C#
@danielpunkass
danielpunkass / XcodeBuildLogParser
Created January 16, 2015 14:29
Example configuration file for Jenkins's build log parser plugin, including some rules for Xcode quirks
# don't treat any of these as errors, warnings or info
ok /setenv /
# ignore TidyXML warnings
ok /line [0-9]+ column [0-9]+ - Error:/
ok /line [0-9]+ column [0-9]+ - Warning:/
ok /[0-9]+ warning.+ error.+ found!/
# ignore weird warnings about build variables in Info.plist:
# e.g. "warning: ignoring operator ':rfc1034Identifier' on 'RSWebClientCore' for macro 'PRODUCT_NAME'"
@steipete
steipete / NSData+PSPDFFoundation.m
Last active March 21, 2017 16:00
Haven't done much with dispatch_io yet so I'd appreciate a few more eyeballs on this. Am I closing things correctly in all error conditions? Are there other knobs I could change to make things even faster? (I know I've been lazy on the NSError's)
static NSData *PSPDFCalculateSHA256FromFileURL(NSURL *fileURL, CC_LONG dataLength, NSError **error) {
NSCParameterAssert(fileURL);
dispatch_queue_t shaQueue = dispatch_queue_create("com.pspdfkit.sha256-queue", DISPATCH_QUEUE_SERIAL);
__block dispatch_io_t readChannel;
void (^processIntError)(int intError) = ^(int intError) {
if (intError != 0) {
PSPDFLogWarning(@"Stream error: %d", intError);
if (error) *error = [NSError errorWithDomain:@"SHA256Error" code:100 userInfo:@{NSLocalizedDescriptionKey: @"failed to open file for calculating SHA256."}];
@Pegolon
Pegolon / debug.swift
Created June 21, 2018 15:53
Cast pointer to Swift object (eg. print out current URL for webView from view debugger)
expr -l Swift -- import UIKit
expr -l Swift -- let $webview = unsafeBitCast(0x7b500026ca00, to: UIWebView.self)
expr -l Swift -- print($webview.request.url)