Skip to content

Instantly share code, notes, and snippets.

@0xced
0xced / CLAlert.h
Last active January 17, 2021 13:26
CLAlert
/*
* CLAlert is a drop-in replacement for NSAlert
*
* A CLAlert is exactly the same as a NSAlert, except for the alert style behavior
*
* - An alert with the informational style (NSInformationalAlertStyle) will always display a "Note icon" (kAlertNoteIcon)
* - An alert with the warning style (NSWarningAlertStyle) will always display a "Caution icon" (kAlertCautionIcon)
* - An alert with the critical style (NSCriticalAlertStyle) will always display a "Stop icon" (kAlertStopIcon)
*
* Tested on Mac OS X 10.5.8, 10.6.1 and 10.11.5
@interface NSImage (GIF)
- (BOOL)isGifImage;
- (BOOL)saveAnimatedGIFToFile:(NSString*)filepath;
@end
@implementation NSImage (GIF)
- (BOOL)isGifImage
{
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active May 3, 2024 12:59
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@anselmh
anselmh / clearfix.css
Created February 24, 2014 08:11
This is a decent but well working CSS clearfix as used in HTML5-Boilerplate (https://github.com/h5bp/html5-boilerplate/blob/master/css/main.css#L173)
/*
* Clearfix for modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* `contenteditable` attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that receive the `clearfix` class.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
@sketchytech
sketchytech / piechart.swift
Created February 15, 2016 16:39
Simple pie chart drawing code for iOS using CAShapeLayer and UIBezierPath
extension CGFloat {
func radians() -> CGFloat {
let b = CGFloat(M_PI) * (self/180)
return b
}
}
extension UIBezierPath {
convenience init(circleSegmentCenter center:CGPoint, radius:CGFloat, startAngle:CGFloat, endAngle:CGFloat)
{
@shawnthroop
shawnthroop / NSRange+SurrogatePairAdjustable.swift
Last active April 18, 2018 15:26
Adjusting ranges retrieved from an API (App.net, pnut.io, etc.) for use with NSAttributedString
// Swift 4.0.3
import Foundation
extension NSRange: SurrogatePairAdjustable {
func adjusted(for pairs: [String.SurrogatePair]) -> NSRange {
if pairs.isEmpty {
return self
}
@33mhz
33mhz / reverse_markdown.md
Created October 6, 2017 13:26
reverse markdown from pnut entities

Setup

This is pseudocode.

post has been retrieved from the API.

Be sure to make substrings and other string operations by "multibyte" divisions.

Operation

let monospaced = UIFont.monospacedDigitSystemFont(ofSize: UIFont.systemFontSize, weight: .bold)
let fontMetrics = UIFontMetrics(forTextStyle: .body)
runtime.font = fontMetrics.scaledFont(for: monospaced)
@joshbetz
joshbetz / Webview.swift
Created February 12, 2020 15:36
A simple SwiftUI Webview
import SwiftUI
import WebKit
struct ContentView: View {
var body: some View {
Webview(url: URL(string: "https://google.com")!)
}
}
struct Webview: UIViewRepresentable {
//Orginal code from: https://gist.github.com/mecid/f8859ea4bdbd02cf5d440d58e936faec
//I just made some modification in appearnce, show monthly navigator and weekdays.
import SwiftUI
struct ContentView: View {
@Environment(\.calendar) var calendar
private var year: DateInterval {
calendar.dateInterval(of: .month, for: Date())!