Skip to content

Instantly share code, notes, and snippets.

@46bit
46bit / deriving-mersenne-twister-state-from-outputs.txt
Last active October 14, 2023 10:59
Deriving how to reverse the output of a Mersenne Twister PRNG into the internal state, as used in https://github.com/46bit/pinocchio.
func (m *MersenneTwister) Urand32() uint32 {
if m.index == 0 {
m.generate_numbers()
}
y := m.State[m.index]
y = y ^ (y >> 11) //
y = y ^ ((y << 7) & 2636928640) //
y = y ^ ((y << 15) & 4022730752) //
y = y ^ (y >> 18) // "y XOR leftmost 14 bits of y"
@didge
didge / coderesign.sh
Last active September 24, 2022 02:25 — forked from WeptunUser/floatsign.sh
Script to resign .ipa files with options to change the provisioning file, app name, and bundle id.
#!/bin/bash -x
# Copyright (c) 2011 Float Mobile Learning
# http://www.floatlearning.com/
# Extension Copyright (c) 2013 Weptun Gmbh
# http://www.weptun.de
# Extension Copyright (c) 2013 FoundryLogic LLC
# http://foundrylogic.com
#
# Extended by Ronan O Ciosoig January 2012
@venkatperi
venkatperi / gist:209b9fa2946a7151efc0
Created June 4, 2014 15:53
Closure Currying in Swift
struct S0<V> {
typealias F = () -> V
}
struct S1<T1,V>{
typealias F = (T1) -> V
}
//0, 0
func curry<T1, V>(f: S1<T1, V>.F, a1:T1) -> S0<V>.F {
@turowicz
turowicz / swift-json-class.md
Last active February 21, 2017 07:00
Apple Swift strong type object serialization to JSON
@faithfracture
faithfracture / boost.sh
Last active September 14, 2024 14:23
Boost build script for iOS (armv7, armv7s, arm64), iOS Simulator (i386, x86_64), and OSX (i386, x86_64)
#===============================================================================
# Filename: boost.sh
# Author: Pete Goodliffe
# Copyright: (c) Copyright 2009 Pete Goodliffe
# Licence: Please feel free to use this, with attribution
# Modified version
#===============================================================================
#
# Builds a Boost framework for iOS, iOS Simulator, and OSX.
# Creates a set of universal libraries that can be used on an iOS and in the
func encode<T>(var value: T) -> NSData {
return withUnsafePointer(&value) { p in
NSData(bytes: p, length: sizeofValue(value))
}
}
func decode<T>(data: NSData) -> T {
let pointer = UnsafeMutablePointer<T>.alloc(sizeof(T.Type))
data.getBytes(pointer)
@chaitanyagupta
chaitanyagupta / re-sign-ios-app.md
Last active November 5, 2024 10:25
How to re-sign an iOS app with another developer account

WARNING These steps are probably out dated and will not work.

To re-sign an iOS app with another developer account, ensure that the following are in place first.

  1. Distribution certificate of the other developer account
  2. A provisioning profile from the other developer account

Note that the Apple requires bundle IDs to be globally unique, even across accounts. So a bundle ID i.e. CFBundleIdentifier from one account can't be used in a different account, even though the team id/prefix would be different.

Ensure that the new distribution certificate is in your keychain and the new provisioning profile on your disk.

@natecook1000
natecook1000 / NSTimer+Closure.swift
Last active July 12, 2024 05:11
Scheduled NSTimer with a Swift closure
extension NSTimer {
/**
Creates and schedules a one-time `NSTimer` instance.
- Parameters:
- delay: The delay before execution.
- handler: A closure to execute after `delay`.
- Returns: The newly-created `NSTimer` instance.
*/
@natecook1000
natecook1000 / NSScanner+Swift.swift
Created March 3, 2015 20:13
Swift-friendly NSScanner methods
// NSScanner+Swift.swift
// A set of Swift-idiomatic methods for NSScanner
//
// (c) 2015 Nate Cook, licensed under the MIT license
import Foundation
extension NSScanner {
// MARK: Strings
@kch
kch / infix-functions.swift
Last active July 17, 2016 20:30
Use any binary function as infix operator in Swift
infix operator « { precedence 131 associativity left }
func «<A,B,C>(a:A, f:(A,B) -> C) -> B -> C { return { f(a,$0) } }
infix operator » { precedence 131 associativity left }
func »<B,C>(f:(B) -> C, b:B) -> C { return f(b) }
infix operator < { precedence 131 associativity left }
func <<A,B,C>(a:A, f:(A,B) -> C) -> B -> C { return { f(a,$0) } }
infix operator > { precedence 131 associativity left }