Skip to content

Instantly share code, notes, and snippets.

@avdyushin
avdyushin / Stack.swift
Created February 1, 2016 09:03
Stack data structure via linked lists using Swift enums
indirect enum LinkedList<T> {
case Empty
case Node(value: T, next: LinkedList<T>)
init() { self = .Empty }
}
extension LinkedList {
func cons(x: T) -> LinkedList<T> {
return .Node(value: x, next: self)
//
// RBResizer.swift
// Locker
//
// Created by Hampton Catlin on 6/20/14.
// Copyright (c) 2014 rarebit. All rights reserved.
// Updated by Justin Winter on 11/29/15.
//
extension UIImage {
@aldo-jlaurenstin
aldo-jlaurenstin / MakeTransparentHoleOnOverlayView.swift
Last active May 27, 2024 12:09
Make a Transparent Hole on an Overlay UIView
//
// MakeTransparentHoleOnOverlayView.swift
//
// Created by James Laurenstin on 2015-04-10.
// Copyright (c) 2015 Aldo Group Inc. All rights reserved.
//
import UIKit
class MakeTransparentHoleOnOverlayView: UIView {
@eyesofkids
eyesofkids / factorial.swift
Last active March 4, 2023 15:51
factorial.swift
func factorial(a: Int) -> Int {
let n = a
if(n == 1){
return 1
}else{
return n*factorial(n-1)
}
}
factorial(5)
@dyerw
dyerw / assetcleaner.py
Last active February 28, 2024 05:09
AssetCleaner - Removes all unused assets from an XCode project
USAGE = \
"""
Searches an XCode project to determine which image
assets aren't being used then removes them.
WARNING: This will delete things permanently if your
project is not under source control.
"""
import os
@kythanh
kythanh / How to delete all Archive binaries generated by XCode
Created August 7, 2014 07:03
How to delete all Archive binaries generated by XCode
1. Open Terminal, then goto this folder: cd ~/Library/Developer/Xcode/Archives
2. Perform delete all folders and files: rm -rf *
You may need root permission to perform delete.
@dankogai
dankogai / peekFunc.swift
Last active February 28, 2023 15:38
Get the internal function pointer in swift
/// See
/// https://github.com/rodionovd/SWRoute/wiki/Function-hooking-in-Swift
/// https://github.com/rodionovd/SWRoute/blob/master/SWRoute/rd_get_func_impl.c
/// to find why this works
func peekFunc<A,R>(f:A->R)->(fp:Int, ctx:Int) {
let (hi, lo):(Int, Int) = reinterpretCast(f)
let offset = sizeof(Int) == 8 ? 16 : 12
let ptr = UnsafePointer<Int>(lo+offset)
return (ptr.memory, ptr.successor().memory)
}
@mkuliszkiewicz
mkuliszkiewicz / UIView+GetColor.swift
Last active May 28, 2023 13:22
UIView extension which allows to get colour of any point inside
//
// UIView+GetColor.swift
// SwiftPick
//
// Created by Maciej Banasiewicz, Michał Apanowicz on 06/07/14.
//
//
import UIKit
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active April 22, 2025 20:08
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@adamjohnson
adamjohnson / publickey-git-error.markdown
Last active January 30, 2025 00:44
Fix "Permission denied (publickey)" error when pushing with Git

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "[email protected]". Th