Skip to content

Instantly share code, notes, and snippets.

View icodeforlove's full-sized avatar
:octocat:
Indefinitely In Bangkok

Chad icodeforlove

:octocat:
Indefinitely In Bangkok
View GitHub Profile
@matsuda
matsuda / NSData+AES.h
Created February 25, 2014 07:14
Objective-C code for encrypt and decrypt by AES-128 encryption.
/**
http://mythosil.hatenablog.com/entry/20111017/1318873155
http://blog.dealforest.net/2012/03/ios-android-per-aes-crypt-connection/
*/
@interface NSData (AES)
- (NSData *)AES128EncryptedDataWithKey:(NSString *)key;
- (NSData *)AES128DecryptedDataWithKey:(NSString *)key;
- (NSData *)AES128EncryptedDataWithKey:(NSString *)key iv:(NSString *)iv;
@cowboy
cowboy / unbind.js
Last active June 20, 2018 19:59
JavaScript: Function.prototype.unbind (for @jugglinmike)
Function.prototype.bind = (function(origBind) {
return function() {
var fn = origBind.apply(this, arguments);
fn.__origFn__ = this.__origFn__ || this;
return fn;
};
}(Function.prototype.bind));
Function.prototype.unbind = function() {
return this.__origFn__;
@neilmendoza
neilmendoza / gist:4512992
Last active June 9, 2023 14:22
Function to return matrix for rotation about an arbitrary axis in GLSL.
mat4 rotationMatrix(vec3 axis, float angle)
{
axis = normalize(axis);
float s = sin(angle);
float c = cos(angle);
float oc = 1.0 - c;
return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
@KartikTalwar
KartikTalwar / Documentation.md
Last active April 13, 2024 23:09
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@danveloper
danveloper / html5-thumbnail-iframe.html
Created September 27, 2012 18:59
HTML5 Thumbnail Processing in IFRAME
<!DOCTYPE html>
<html>
<head>
<script>
window.onload = function() {
// Must be server-side images; non-origin images will result in a security exception
var images = ["img.jpg"];
for (var i=0;i<images.length;i++) {
thumbnailify(images[i]);
@taonico
taonico / SafariCookiesArc.m
Created July 24, 2012 05:09
Safari Cookies Cookies.binarycookies (ARC)
//clang -fobjc-arc -framework Foundation -o safari-cookies SafariCookiesArc.m
#import <Foundation/Foundation.h>
int main(int argc, char *argv[])
{
@autoreleasepool {
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie *c in [cookieStorage cookies])
{
@Coeur
Coeur / Get iOS MAC address.m
Created November 30, 2011 17:11
Get iOS MAC address #
/* Original source code courtesy John from iOSDeveloperTips.com */
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_dl.h>
+ (NSString *)getMacAddress
{
int mgmtInfoBase[6];