Skip to content

Instantly share code, notes, and snippets.

View 0xced's full-sized avatar

Cédric Luthi 0xced

View GitHub Profile
INSERT INTO 'snippets' ('title', 'body') VALUES
(':+1:', '👍'),
(':-1:', '👎'),
(':100:', '💯'),
(':1234:', '🔢'),
(':8ball:', '🎱'),
(':a:', '🅰'),
(':ab:', '🆎'),
(':abc:', '🔤'),
(':abcd:', '🔡'),
@benstiglitz
benstiglitz / EvilCast.h
Last active December 27, 2015 00:29
Safe bounded casting between types.
#if __has_extension(c_generic_selections) && __has_extension(c_static_assert)
#import "EvilCastImpl.h"
// Returns the value of s, clamping it to the bounds of type t. s and d must either both be integers
// or both be floating-point values.
#define EvilBoundedCheckedCast(t, s) __EvilChecked(t, s, Cast)
// Tries to assign the value of s to d, returning 1 if s is within the bounds of s and 0 if not.
// s and d must either both be integers or both be floating-point values.
#define EvilCheckedAssign(d, s) __EvilChecked(d, s, Assign)
#else
@walesmd
walesmd / IconServiceAgent.md
Last active April 18, 2025 13:38
A lot of people are having issues with com.apple.IconServicesAgent. Since this is a very new issue, Google was no help and `man iconservicesd` is even more hilarious. I eventually fixed it, when I was working on a completely different issue (that is still not fixed). The instructions are below and on the Apple Support Forum, https://discussions.…

I was chasing down another issue (slow "Save As") and thought these two issues may have been related (with QuickLook being the common broken link). Unfortunately, my "Save As" dialog is still miserably slow on the initial load; but IconServicesAgent hasn't gone above 30MB and he rarely makes an appearance in the Console!

Some of these steps may not be necessary, but here are all of the steps I took that inadverdently put IconServicesAgent back in its place. Note: all commands are a single-line, if they appear to be multiple that's just the forum formatting.

  1. Check for any QuickLooks related .plist files. In a terminal: mdfind com.apple.quicklook. -name .plist

  2. I only had files at the system level (specifically within /System/Library/LaunchAgents/). If you have others, modify the directions below to take that into account (re-introducing plist files from the system level back up to the user).

  3. Make some temporary directories to store these plist files, just in case: mkdir ~/tmp-quicklook

@iamleeg
iamleeg / UIColor_literal.mm
Last active December 29, 2015 03:09
UIColor literals.
#import <UIKit/UIKit.h>
UIColor * operator"" _c(unsigned long long color)
{
unsigned long long redComponent = (color & 0xff0000 >> 16);
unsigned long long greenComponent = (color & 0x00ff00) >> 8;
unsigned long long blueComponent = color & 0xff;
float red = redComponent / 255.0;
float green = greenComponent / 255.0;
float blue = blueComponent / 255.0;
sbx()
{
echo '(version 1) (trace "/tmp/traceout.sb")' > /tmp/tracein.sb
sandbox-exec -f /tmp/tracein.sb "$@"
sandbox-simplify /tmp/traceout.sb > /tmp/tracesimple.sb
open -a "Sublime Text" /tmp/tracesimple.sb
}
@chrismiles
chrismiles / reveal.py
Last active September 2, 2021 00:26
Lazy script to wrap Reveal lib load/start commands in one LLDB command.
""" File: reveal.py
Add to ~/.lldbinit:
command script import ~/.lldb-scripts/reveal.py
Q: Want to automatically load the Reveal lib on launch while debugging from Xcode?
A: In Xcode:
Add a Symbolic Breakpoint
Symbol: "UIApplicationMain"
Action: Debugger Command with value "reveal"
@rostreim
rostreim / MultiStreamWriter.cs
Last active November 20, 2024 21:20
A text writer implementation that supports writing to multiple writers in one operation
//
// Copyright 2014, Desert Software Solutions Inc.
// MultiStreamWriter.cs: https://gist.github.com/rostreim/9441193
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
@steipete
steipete / Macros.h
Last active January 6, 2024 07:24
Declare on your main init that all other init methods should call. It's a nice additional semantic warning. Works with Xcode 5.1 and above. Not tested with earlier variants, but should just be ignored. A reference to this macro shortly appeared in https://developer.apple.com/library/ios/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObj…
#ifndef NS_DESIGNATED_INITIALIZER
#if __has_attribute(objc_designated_initializer)
#define NS_DESIGNATED_INITIALIZER __attribute((objc_designated_initializer))
#else
#define NS_DESIGNATED_INITIALIZER
#endif
#endif
@d-ronnqvist
d-ronnqvist / Thoughts on removedOnCompletion in SparkRecordingCircle.md
Last active May 16, 2020 02:51
What I think is wrong with the Spark Recording Circle code and why

There was [a tweet][tweetSoto] a couple of days ago that resulted in a discussion/question about what it wrong with the usage of removedOnCompletion = NO in the [SparkRecordingCircle code][code] for that [Subjective-C post][post].

We all kept saying that the explanation doesn't fit in a tweet, so here is my rough explanation about the issues.

But, let me first say that I think that the Subjective-C articles are reallt cool and useful to learn from. This is trying to reason about the general usage of removedOnCompletion = NO, using that code as an example, since that was what was discussed on twitter.


The root problem, as [Nacho Soto pointed out][rootProblem], is that removedOnCompletion = NO in combination with fillMode = kCAFillModeForwards is almost always used when you are not updating the model layer. This means that after the animation has finished, what you see on screen is not reflected in the property of the layer. The biggest issue that this can cause is that all the

@rodionovd
rodionovd / xcodeargdumper.mm
Last active August 29, 2015 14:04
Xcode plugin snippet for dumping compiler/linker arguments for the given file(s)
#include <objc/runtime.h>
void dump_compiler_and_linker_args_for_file(NSString *file)
{
Class PBXReference = NSClassFromString(@"PBXReference");
if (! PBXReference) return;
id file_ref = [[PBXReference alloc] initWithPath: file];