Skip to content

Instantly share code, notes, and snippets.

View jlnr's full-sized avatar

Julian Raschke jlnr

View GitHub Profile
@steipete
steipete / UITableViewMore.m
Last active January 29, 2018 14:19
Using the "More" button. Of course the simple way that Apple uses in Mail/iOS is not public. rdar://16600859
- (NSString *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"More";
}
- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"I wanted to be a pretty public API, but then time ran out and they forgot me...");
// Hide the More/Delete menu.
[self setEditing:NO animated:YES];
}
@justecorruptio
justecorruptio / 2048.c
Created April 4, 2014 03:49
Tiny 2048 in C!
M[16],X=16,W,k;main(){T(system("stty cbreak")
);puts(W&1?"WIN":"LOSE");}K[]={2,3,1};s(f,d,i
,j,l,P){for(i=4;i--;)for(j=k=l=0;k<4;)j<4?P=M
[w(d,i,j++)],W|=P>>11,l*P&&(f?M[w(d,i,k)]=l<<
(l==P):0,k++),l=l?P?l-P?P:0:l:P:(f?M[w(d,i,k)
]=l:0,++k,W|=2*!l,l=0);}w(d,i,j){return d?w(d
-1,j,3-i):4*i+j;}T(i){for(i=X+rand()%X;M[i%X]
*i;i--);i?M[i%X]=2<<rand()%2:0;for(W=i=0;i<4;
)s(0,i++);for(i=X,puts("\e[2J\e[H");i--;i%4||
puts(""))printf(M[i]?"%4d|":" |",M[i]);W-2
@alloy
alloy / README.md
Last active August 29, 2015 13:57
Fix system Ruby (2.0.0) on OS X 10.9.
@myokoym
myokoym / Gosu-Ruby-Tutorial-Japanese.md
Last active March 8, 2018 04:43
The Japanese translation of https://github.com/jlnr/gosu/wiki/Ruby-Tutorial (GosuのRubyチュートリアルの日本語訳)

Rubyチュートリアル

※この文書は、Ruby Tutorial · jlnr/gosu Wikiの日本語訳です。

翻訳

このチュートリアルの翻訳(中国語、スペイン語、フランス語)へのリンクについては、Homeページを参照してください。

ソースコード

@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>
/*! hsv_to_hsl.scss | MIT License | https://gist.github.com/voxpelli/1069204 */
@function max($v1, $v2) {
@return if($v1 > $v2, $v1, $v2);
}
@function min($v1, $v2) {
@return if($v1 < $v2, $v1, $v2);
}
@function hsv_to_hsl($h, $s: 0, $v: 0) {
@jpwatts
jpwatts / xcode-git-version.sh
Created May 11, 2011 16:42
This Xcode 4 build phase script automatically sets the version and short version string of an application bundle based on information from the containing Git repository.
#!/bin/bash
# This script automatically sets the version and short version string of
# an Xcode project from the Git repository containing the project.
#
# To use this script in Xcode 4, add the contents to a "Run Script" build
# phase for your application target.
set -o errexit
set -o nounset

Objective-C Coding Convention and Best Practices

Most of these guidelines are to match Apple's documentation and community-accepted best practices. Some are derived some personal preference. This document aims to set a standard way of doing things so everyone can do things the same way. If there is something you are not particularly fond of, it is encouraged to do it anyway to be consistent with everyone else.

This document is mainly targeted toward iOS development, but definitely applies to Mac as well.

Operators

NSString *foo = @"bar";
@gruber
gruber / Reply.scpt
Last active October 22, 2020 19:48
Prompt with options to "Reply" or "Reply All" when replying to a message with multiple recipients in Apple Mail for Mac OS X. Also does away with top-posting.
tell application "Mail"
set _sel to get selection
if (count of _sel) > 1 then
-- multiple message selection, usually a conversation thread
choose from list {"Reply", "Reply All"} with prompt "Unknown recipient count." default items {"Reply"}
try
set _menu_command to item 1 of the result
on error
return