Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Generates Gource config file from git submodules, starts Gource.
# Place to /usr/local/bin and run at the main repository root.
#
# (c) 2010 Mikael Lammentausta
# License is the same as Gource (GPLv3)
import os
import re
@jdewind
jdewind / convert.rb
Created February 24, 2012 21:53
OCMock to Kiwi
files = [ARGV[0] || Dir["*.m"]].flatten
files.each do |file|
content = File.read(file)
mapped_content = content.lines.map do |line|
[
{from: /\[\[\[(.+) (?:stub|expect)\] andReturn:(.+)\] (.+)/, to: "[[%s stubAndReturn:%s] %s"},
{from: /\[\[\[(.+) (?:stub|expect)\] andReturn\w+:(.+)\] (.+)/, to: "[[%s stubAndReturn:theValue(%s)] %s"},
{from: /\[(?:\(\w+\s*\*\)){,1}\[(.+) expect\] (.+)/, to: "[[[%s should] receive] %s"},
{from: /\[OCMockObject observerMock\]/, to: "[Kiwi observerMock]"},
@krzysztofzablocki
krzysztofzablocki / Asserts
Created July 3, 2013 18:52
My take on assertions, code sample accompanying blog post at http://merowing.info/2013/07/expanded-use-of-asserts/
typedef NS_ENUM(NSInteger, kErrorCode) {
kErrorCodeInternal = 431432,
};
//! generate error and log it.
extern NSError *pixle_NSErrorMake(NSString *message, NSUInteger code, NSDictionary *aUserInfo, SEL selector);
#define AssertTrueOrReturnBlock(condition, block) do{ NSAssert((condition), @"Invalid condition not satisfying: %s", #condition);\
if(!(condition)) { block(pixle_NSErrorMake([NSString stringWithFormat:@"Invalid condition not satisfying: %s", #condition], kErrorCodeInternal, nil, _cmd)); return;} }while(0)
@fabb
fabb / archive_ipa.sh
Created November 1, 2014 12:39
Script to archive an ipa from commandline - depends on xctool
#!/bin/bash
set -x
cd ${0%/*}/..
# codesigning and choosing of provisioning profile is configured via project settings and is dependent of build config
: ${BUILD_NUMBER:?"Need to set BUILD_NUMBER"}
WORKSPACE=<yourworkspace>.xcworkspace
@sanguis
sanguis / .gitconfig
Last active June 2, 2017 14:41
my .gitconfig file minus my name and email
[color]
ui = on
[core]
whitespace= fix,-indent-with-non-tab,-indent-with-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[alias]
df = !git diff --no-prefix && git diff --staged --no-prefix
clear = reset --hard
st = status
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
@steipete
steipete / PSPDFViewController.h
Last active June 6, 2017 03:56
This method will help to prevent a lot of emails about "weird bugs".
// Defines a yet undocumented method to add a warning if super isn't called.
#ifndef NS_REQUIRES_SUPER
#if __has_attribute(objc_requires_super)
#define NS_REQUIRES_SUPER __attribute((objc_requires_super))
#else
#define NS_REQUIRES_SUPER
#endif
#endif
@interface UIViewController (SubclassingWarnings)
@osv
osv / formikGotoErrorOnSubmitEffect.tsx
Last active March 4, 2019 07:24
React Formik, scroll to first element in DOM that is not valid and has error (Hook + Typescript version)
import { connect, FormikContext, getIn } from 'formik';
import * as React from 'react';
import { useEffectWhenCountIncremented } from './reactHooks';
import { PageContext } from './context';
const FormikGotoErrorOnSubmitEffectFn: React.FunctionComponent<{
formik?: FormikContext<any>;
}> = ({ formik }) => {

Haskell projects with lots of dependencies on Travis CI

If your Haskell project has lots of dependencies, you can find yourself reaching the timeout while compiling them - the free service has a timeout of 50 minutes. How do we address this?

First, a quick reminder of build statuses in Travis CI:

All builds finish with one of four possible statuses: succeeded, failed, errored, or (manually) cancelled. The difference between a failed and errored

import UIKit
class MyView: UIView {
fileprivate var myPreviewInteraction: Any? = nil
init() {
super.init(frame: CGRect.zero)
if #available(iOS 10.0, *) {
myPreviewInteraction = UIPreviewInteraction(view: self)
@hongrich
hongrich / gist:260fc8c36aaed3f2a63c0612ba9fc910
Last active June 3, 2019 20:29
App Store Review Guidelines
App Store Review Guidelines
Introduction
Apps are changing the world, enriching people’s lives, and enabling developers like you to innovate like never before. As a result, the App Store has grown into an exciting and vibrant ecosystem for millions of developers and more than a billion users. Whether you are a first time developer or a large team of experienced programmers, we are excited that you are creating apps for the App Store and want to help you understand our guidelines so you can be confident your app will get through the review process quickly.
The guiding principle of the App Store is simple - we want to provide a safe experience for users to get apps and a great opportunity for all developers to be successful. We do this by offering a highly curated App Store where every app is reviewed by experts and an editorial team helps users discover new apps every day. For everything else there is always the open Internet. If the App Store model and guidelines are not best for your app or business idea th