Skip to content

Instantly share code, notes, and snippets.

@skratchdot
skratchdot / arrayBufferToString.js
Created March 3, 2016 04:43
Array Buffer -> String and String -> ArrayBuffer conversions in javascript
// source: http://stackoverflow.com/a/11058858
function ab2str(buf) {
return String.fromCharCode.apply(null, new Uint16Array(buf));
}
@dineshsprabu
dineshsprabu / forever_npm_start
Last active June 9, 2022 12:58
Forever for NPM applications starting with 'npm start'
/*
If your package.json file contains "start": "node ./bin/www"
Use the following command to bring up your app with forever
*/
forever start --minUptime 1000 --spinSleepTime 1000 ./bin/www
/* Check list of forever process using the command */
forever list
@oshliaer
oshliaer / .en.md
Last active September 30, 2020 02:33
Create a Gmail draft with attachments via Google Apps Script #gas #gmail
@bang590
bang590 / linkmap.js
Last active August 19, 2023 15:24
XCode Linkmap Parser
var readline = require('readline'),
fs = require('fs');
var LinkMap = function(filePath) {
this.files = []
this.filePath = filePath
}
LinkMap.prototype = {
start: function(cb) {
@qnoid
qnoid / gist:6140282
Created August 2, 2013 14:29
Animate an UIBarButtonItem that has been assigned a UIButton as its customview. The UIButton uses an image that is mirrored on the X axis hence appear as if it's rotating.
-(IBAction)tap:(id)sender
{
UIBarButtonItem *refresh = self.navigationItem.rightBarButtonItem;
CALayer *layer = ((UIButton*)refresh.customView).imageView.layer;
CABasicAnimation *rotate = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotate.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear];
rotate.fromValue = @(0);
rotate.toValue = @(2 * M_PI);
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
/**
* Several macros simplifying use of weak references to self inside blocks
* which goal is to reduce risk of retain cycles.
*
* Example:
* @code
@interface Example : NSObject{
int _i;
}
@fmtonakai
fmtonakai / UIImage+Blur.h
Created November 26, 2012 02:59
UIImage Blur
//
// UIImage+Blur.h
// HTTPLoaderTest
//
// Created by masaki.fuke on 12/08/14.
// Copyright (c) 2012年 masaki.fuke. All rights reserved.
//
#import <UIKit/UIKit.h>