Skip to content

Instantly share code, notes, and snippets.

@chrisballinger
chrisballinger / gist:3352890
Created August 14, 2012 20:50 — forked from quietcricket/gist:1593632
Fuzzy string match objective-c (Levenshtein Distance Algorithm)
-(float)compareString:(NSString *)originalString withString:(NSString *)comparisonString
{
// Normalize strings
[originalString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[comparisonString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
originalString = [originalString lowercaseString];
comparisonString = [comparisonString lowercaseString];
// Step 1 (Steps follow description at http://www.merriampark.com/ld.htm)
@return1
return1 / trim_enabler.txt
Last active August 25, 2023 02:59
TRIM Enabler for OS X Yosemite 10.10.3
#
# UPDATE for 10.10.4+: please consider this patch obsolete, as apple provides a tool called "trimforce" to enable trim support for 3rd party SSDs
# just run "sudo trimforce enable" to activate the trim support from now on!
#
# Original version by Grant Parnell is offline (http://digitaldj.net/2011/07/21/trim-enabler-for-lion/)
# Update July 2014: no longer offline, see https://digitaldj.net/blog/2011/11/17/trim-enabler-for-os-x-lion-mountain-lion-mavericks/
#
# Looks for "Apple" string in HD kext, changes it to a wildcard match for anything
#
# Alternative to http://www.groths.org/trim-enabler-3-0-released/
@tarcieri
tarcieri / semiprivate.md
Last active January 18, 2023 01:08
Ed25519-based semi-private keys

Semiprivate Keys

🚨 DANGER: INSECURE! 🚨

This may have seemed like a great idea in 2013, but the repeated "set/clear bits", a.k.a. clamping phases at each level of the hierarchy slowly subtract key strength.

Don't use this as described. Check out Ristretto.

Original text

Semi-private keys are an expansion of the traditional idea

@ericallam
ericallam / CLLocationManager+MockingLocation.h
Created June 1, 2013 03:57
Mocking out CLLocationManager
#import <CoreLocation/CoreLocation.h>
extern CLLocationDegrees kMockedLatitude;
extern CLLocationDegrees kMockedLongitude;
@interface CLLocationManager (MockingLocation)
+ (BOOL)custom_locationServicesEnabled;
+ (CLAuthorizationStatus)custom_authorizationStatus;
-(void)custom_startUpdatingLocation;
@sevastos
sevastos / aws-multipartUpload.js
Last active October 8, 2023 10:43
Example AWS S3 Multipart Upload with aws-sdk for Node.js - Retries to upload failing parts
// Based on Glacier's example: http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/examples.html#Amazon_Glacier__Multi-part_Upload
var fs = require('fs');
var AWS = require('aws-sdk');
AWS.config.loadFromPath('./aws-config.json');
var s3 = new AWS.S3();
// File
var fileName = '5.pdf';
var filePath = './' + fileName;
var fileKey = fileName;
@chrisballinger
chrisballinger / gist:7239932
Last active February 27, 2024 22:21
French Encryption Import Compliance

Starting in the first week of July, apps that meet the following criteria are required to comply with French Encryption Laws/Regulations if you intend to distribute your app in France.

This requirement applies to apps that use, access, implement, or incorporate:

  1. Any encryption algorithm that is yet to be standardized by international standard bodies such as IEEE, IETF, ISO, ITU, ETSI, 3GPP, TIA, etc. or not otherwise published; or
  2. Standard (e.g., AES, DES, 3DES, RSA) encryption algorithm(s) instead of or in addition to accessing or using the encryption in iOS and/or Mac OS X

Apple will require you to upload a copy of your approved French declaration when you submit your app to the App Store. Relevant French encryption regulations can be found at:

@labeneator
labeneator / ps_to_pdf_content_protected_pdfs.sh
Last active March 20, 2021 12:47
Getting around Adobe's document protection schemes
############ Adobe badness #############
# In your operating system, create a postscript printer whose address is 127.0.0.1
# Fake a postscript printer using netcat
$ nc -l 127.0.0.1 9100 > printout.ps
# Print your pdf using Adobe Reader to the postscript printer on 127.0.0.1
# Netcat will diligently dump the printout to printout.ps as a postscript file
@dferg
dferg / howto-tomato-l2tp-ipsec-server.markdown
Last active December 18, 2023 21:49
HOWTO: Install L2TP/IPsec Server on TomatoUSB

Introduction

This howto describes setting up a LT2P over IPsec VPN server on your router with TomatoUSB firmware. This should allow you to connect using the built-in client to your Mac, iPhone or Android device. (Not sure about Windows.)

At the end of this tutorial, you should have a L2TP/IPsec VPN server that starts automatically on boot. Mac/iPhone/Android devices can connect with their native client and will be assigned an IP address within your LAN subnet. They should be able to talk to other devices on your LAN and should be able to contact hosts on the Internet NAT'd behind your WAN IP address.

Requirements

  • Router running Shibby's fork of TomatoUSB
  • entware installed to a USB stick mounted at /opt (howto)
@rbranson
rbranson / gist:03d88e3733c6ee098a89
Last active July 25, 2017 15:17
My Thoughts on Rust

Rust is the first language that has emerged in the past few years that solves enough of my problems that it would be worth not only learning & teaching an entirely new language, but also sacrificing the maturity of the language ecosystems I’ve become accustomed to.

I highly suggest you read the "Guide" provided by the language developers or this won't make much sense. These are just some of my thoughts and are intended to highlight particular things that stand out to me. I am just a practitioner and not an expert in any of these languages, so I have probably made some incorrect assumptions and out-of-date assertions. Bare with me.

Rust feels like the first time momentum has gained behind a true systems programming language that uses modern PL design techniques to prevent common errors when dealing with memory. It seems like others have previously either been too anemic to be worth adopting or too abstract to provide proper control. The type system and assignment semantics are designed specifically to preven

//
// YapRTreeTest.swift
// YapDatabaseRTreeTest
//
// Created by Maël Primet on 06/19/15.
// Copyright (c) 2015 Snips. All rights reserved.
//
import Foundation