Skip to content

Instantly share code, notes, and snippets.

View mattorb's full-sized avatar
🎯
Always trying to find more time for reading and experiments.

Matt Smith mattorb

🎯
Always trying to find more time for reading and experiments.
View GitHub Profile
@pholser
pholser / regex-crossword.mzn
Created March 17, 2021 02:27
MiniZinc model to solve a regex crossword
% https://jimbly.github.io/regex-crossword/
enum LETTER = {
A, B, C, D, E, F, G, H, I, J, K, L, M,
N, O, P, Q, R, S, T, U, V, W, X, Y, Z
};
array[1..7] of var LETTER: row1;
array[1..8] of var LETTER: row2;
array[1..9] of var LETTER: row3;
@OdNairy
OdNairy / main.m
Last active December 21, 2015 00:28
// Source: https://devforums.apple.com/message/866487#866487
typedef int (*PYStdWriter)(void *, const char *, int);
static PYStdWriter _oldStdWrite;
int __pyStderrWrite(void *inFD, const char *buffer, int size)
{
if ( strncmp(buffer, "AssertMacros: queueEntry", 24) == 0 ) {
return 0;
@Marlunes
Marlunes / hide_status_bar
Created July 16, 2013 07:54
FORCE HIDE STATUS BAR FOR IOS 7 AND 6
//viewDidload
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self prefersStatusBarHidden];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
@steipete
steipete / PSPDFThreadSafeMutableDictionary.m
Last active December 10, 2022 09:37
Simple implementation of a thread safe mutable dictionary. In most cases, you want NSCache instead, but it can be useful in situations where you want to manually control what is evicted from the cache in low memory situations.**Warning:** I only use this for setting/getting keys. Enumeration is not thread safe here and will still throw exception…
//
// PSPDFThreadSafeMutableDictionary.m
//
// Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
//
// 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
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@asus4
asus4 / ImageAlphaBatching.sh
Last active July 10, 2016 06:37
imagealpha と imageoptim バッチ処理です。
/Applications/ImageAlpha.app/Contents/MacOS/pngquant --speed 1 --force --ext .png 32 *.png; open -a imageoptim *.png
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active April 19, 2024 11:00
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@jamztang
jamztang / LICENSE
Last active November 2, 2019 22:33
UINibDecoderProxy - Use NSProxy to observe what's encoded when views and controllers are created in Interface Builder.
Copyright (c) 2013 Jamz Tang <jamz@jamztang.com>
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
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@InitoryDad
InitoryDad / Unity2Dframeworks.txt
Created August 12, 2012 22:30 — forked from prime31/Unity2Dframeworks.txt
Unity 2D framework comparison
Key:
"-" negative point
"+" positive point
"+-" could go either way depending on your opinion or if it functions or not
Background Info: the last project we worked on needed basic 2D functionality (sprites and animations) and SpriteKit was born to fill this need (http://www.youtube.com/watch?v=cabAr2CdLmc). It has no fancy editors and was really made to fit a specific need and as of yet it has not been extended much further than the video shows. Something a bit more full featured is required for a new prototype and instead of spending a bunch of time extending SpriteKit we went on a search for alternatives. None of the below frameworks are perfect and they all have pluses and minuses. One thing SpriteKit had that none of the others do is automatic texture selection based on screen resolution. That is one thing I would like to see incorporated in every 2D framework and it kind of surprises me that it isn't one of the first features added when making a 2D framework.
@odrobnik
odrobnik / gist:2769082
Created May 22, 2012 13:32
A physical jump/bounce animation as CAKeyframeAnimation
+ (CAKeyframeAnimation *)jumpAnimation
{
// these three values are subject to experimentation
CGFloat initialMomentum = 150.0f; // positive is upwards, per sec
CGFloat gravityConstant = 250.0f; // downwards pull per sec
CGFloat dampeningFactorPerBounce = 0.6; // percent of rebound
// internal values for the calculation
CGFloat momentum = initialMomentum; // momentum starts with initial value
CGFloat positionOffset = 0; // we begin at the original position