Skip to content

Instantly share code, notes, and snippets.

View PerishableDave's full-sized avatar

David Peredo PerishableDave

View GitHub Profile
@krzyzanowskim
krzyzanowskim / Demangle Swift
Created October 16, 2016 23:20
Hopper Disassembler Swift names demangle script
import subprocess
def looksLikeBeginning(doc,seg,adr):
if isinstance(seg.getNameAtAddress(adr), str):
label = seg.getNameAtAddress(adr)
pos = label.find("_T")
if pos != -1:
return label[pos:]
return None
@aaronjensen
aaronjensen / drain_stop.ex
Last active November 28, 2022 06:59
Phoenix Drain Stop
# ATTENTION: This is now supported in plug_cowboy as of 2.1.0:
# https://hexdocs.pm/plug_cowboy/Plug.Cowboy.Drainer.html
defmodule DrainStop do
@moduledoc """
DrainStop Attempts to gracefully shutdown an endpoint when a normal shutdown
occurs. It first shuts down the acceptor, ensuring that no new requests can be
made. It then waits for all pending requests to complete. If the timeout
expires before this happens, it stops waiting, allowing the supervision tree
to continue its shutdown order.
#!/Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -i -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
import Foundation
class JSON {
struct Path: Printable {
enum Element {
case Index(Int)
case Key(String)
// FILED: rdar://17240493
// Type constraint ignored on function type parameter
//
protocol BoolT {}
class TrueT : BoolT {}
class FalseT : BoolT {}
protocol Nat {
typealias IsZero
anonymous
anonymous / Trie.swift
Created June 7, 2014 07:23
//
// Trie.swift
// SceneTest
//
// Created by Greg Titus on 6/7/14.
// Copyright (c) 2014 The Omni Group. All rights reserved.
//
// This is essentially the same data structure as OFTrie in OmniFoundation, except that the OmniFoundation version is mutable and ephemeral,
// and this version is immutable and persistent. Every time you add a string to the trie, it replaces all the nodes along the string's path
@Myuzu
Myuzu / secure_random.ex
Last active August 7, 2022 20:09
Elixir ruby-like SecureRandom
# UPD from 2018:
# This gist was written for pre-1.0 version of Elixir and won't work on post-1.0 versions.
# You probably consider using something else!
defmodule SecureRandom do
@moduledoc """
Ruby-like SecureRandom module.
## Examples
@wbotelhos
wbotelhos / vagrant_cookbook_error.sh
Last active December 19, 2015 00:18
FATAL: NameError: undefined local variable or method `use_inline_resources' for #<Class:0xb709d348>
# If your Chef version is earlier than 11.0.0, use version 1.10.0 of this cookbook: https://github.com/opscode-cookbooks/apt/commit/dd29a85257161ff42c9595627dd370b02be2060f
vagrant halt
cd cookbooks/apt
git reset --hard 1.10.0
vagrant up
@jder
jder / Downscaling ALAssets
Last active March 20, 2018 06:51
A method for downscaling ALAssets
// For details, see http://mindsea.com/2012/12/18/downscaling-huge-alassets-without-fear-of-sigkill
#import <AssetsLibrary/AssetsLibrary.h>
#import <ImageIO/ImageIO.h>
// Helper methods for thumbnailForAsset:maxPixelSize:
static size_t getAssetBytesCallback(void *info, void *buffer, off_t position, size_t count) {
ALAssetRepresentation *rep = (__bridge id)info;
NSError *error = nil;
@malarkey
malarkey / Contract Killer 3.md
Last active May 24, 2024 23:38
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………