Skip to content

Instantly share code, notes, and snippets.

@rougier
rougier / mu4e-fast-folding.el
Last active October 10, 2022 18:23
Blazing fast mu4e thread folding
;; mu4e thread fast folding -*- lexical-binding: t; -*-
;; This file is not part of GNU Emacs.
;;
;; This program is free software: you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, either version 3 of the
;; License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
@dduan
dduan / bird.swift
Created November 14, 2020 22:16
Flappy bird as a CLI app written in Swift.
// This is the code for the Flappy Bird game running in a Unix terminal.
// Demo: https://twitter.com/daniel_duan/status/1327735679657250816?s=21
// To run it, simply do "swift bird.swift" in a Unix command line.
#if canImport(Darwin)
import Darwin
#else
import Glibc
#endif
enum RawModeError: Error {
@kastiglione
kastiglione / beta-run.sh
Last active July 30, 2019 15:26
Build & Run iPhone simulator code outside of Xcode
#!/bin/bash
set -e
_xcrun() {
DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer \
xcrun -sdk iphonesimulator \
"$@"
}
@CMCDragonkai
CMCDragonkai / memory_layout.md
Last active November 11, 2024 13:39
Linux: Understanding the Memory Layout of Linux Executables

Understanding the Memory Layout of Linux Executables

Required tools for playing around with memory:

  • hexdump
  • objdump
  • readelf
  • xxd
  • gcore
@detro
detro / 1password.conf
Created August 10, 2015 21:19
1PasswordAnywhere + Dropbox + Upstart = 1Password for Ubuntu
description "Starts a SimpleHTTPServer to host 1 Password Anywhere"
author "Ivan De Marino <[email protected]>"
version "1.0.0"
# When to start/stop
start on runlevel [2345]
stop on runlevel [016]
# Keep it running
respawn
@mattt
mattt / UIImageForSwatchOfColorWithSize.h
Created September 27, 2013 01:25
Create a UIImage swatch of a color with a specified size.
static UIImage * UIImageForSwatchOfColorWithSize(UIColor *color, CGSize size) {
UIImage *image = nil;
CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
UIGraphicsBeginImageContext(rect.size);
{
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(c, [color CGColor]);
@orta
orta / gist:6138581
Last active April 19, 2020 15:52
Objective-C Documentation discussion
TLDR
If you want the simplest option just start /** [content] */ slashes in your header files. Do it before the @implementation for class comments and above methods for method documentation.
Doing this is the minimal for support in LLVM and Appledoc, which means you get CocoaDocs & XCode support.
Not TLDR
Good examples:
https://github.com/marcransome/MRBrew/blob/master/MRBrew/MRBrew.h
https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking/AFHTTPClient.h
@n-b
n-b / selfcompile.m
Last active April 29, 2019 03:43
A simple self-compiling objective-c file
/*/../bin/ls > /dev/null
COMPILED=${0%.*}
clang $0 -o $COMPILED -framework Foundation;
$COMPILED; rm $COMPILED; exit;
*/
#import <Foundation/Foundation.h>
int main(int argc, char *argv[])
@ndarville
ndarville / business-models.md
Last active October 23, 2024 17:18
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@andrewsardone
andrewsardone / gist:3740504
Created September 17, 2012 23:58
CGRectDivide

CGRectDivide is handy for slicing up a rectangle.

Example of getting a slice and the remaining area of a rectange.

CGRect rect = CGRectMake(0, 0, 240, 150);
  
CGRect remainder, slice;
    
CGRectDivide(rect, &amp;slice, &amp;remainder, 120, CGRectMinYEdge);