Skip to content

Instantly share code, notes, and snippets.

DreamPiggy dreampiggy

Block or report user

Report or block dreampiggy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dreampiggy
dreampiggy / curl.md
Created Oct 22, 2019 — forked from subfuzion/curl.md
curl POST examples
View curl.md

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

View decode-dyn-uti.swift
extension String
{
/// Creates a string by decoding a sequence of UTF-8 code units.
init?<S: Sequence>(utf8 input: S) where S.Iterator.Element == UTF8.CodeUnit {
var chars: [Character] = []
var decoder = UTF8()
var iter = input.makeIterator()
loop: while true {
switch decoder.decode(&iter) {
case .scalarValue(let scalar): chars.append(Character(scalar))
@dreampiggy
dreampiggy / cli-nsrunloop.m
Created Mar 29, 2019 — forked from syzdek/cli-nsrunloop.m
Creating an NSRunLoop for a command line utility.
View cli-nsrunloop.m
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSRunLoop * runLoop;
CLIMain * main; // replace with desired class
@autoreleasepool
{
// create run loop
View iOS-Hit-Testing.m
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
if (!self.isUserInteractionEnabled || self.isHidden || self.alpha <= 0.01) {
return nil;
}
if ([self pointInside:point withEvent:event]) {
for (UIView *subview in [self.subviews reverseObjectEnumerator]) {
CGPoint convertedPoint = [subview convertPoint:point fromView:self];
UIView *hitTestView = [subview hitTest:convertedPoint withEvent:event];
if (hitTestView) {
return hitTestView;
View PSPDFFastEnumeration.h
//
// PSPDFFastEnumeration.h
// PSPDFFoundation
//
// PSPDFKit is the leading cross-platform solution for integrating PDFs into your apps: https://pspdfkit.com.
// Try it today using our free PDF Viewer app: https://pdfviewer.io/
//
// This file is MIT licensed.
@protocol PSPDFFastEnumeration <NSFastEnumeration>
@dreampiggy
dreampiggy / GCDMacro.h
Created Apr 13, 2017
GCD main queue Macro
View GCDMacro.h
#ifndef dispatch_main_sync_safe
#define dispatch_main_sync_safe(block)\
if ([NSThread isMainThread]) {\
block();\
} else {\
dispatch_sync(dispatch_get_main_queue(), block);\
}
#endif
#ifndef dispatch_main_async_safe
@dreampiggy
dreampiggy / StringSwitchMacro.h
Created Apr 13, 2017
Objective-C NSString Switch Case Macro
View StringSwitchMacro.h
#ifndef TTD_SWITCH_STRING
#define TTD_SWITCH_STRING
#define TTD_CASE(str) if ([__s__ isEqualToString:(str)])
#define TTD_SWITCH(s) for (NSString *__s__ = (s); ; )
#define TTD_DEFAULT
#endif
@dreampiggy
dreampiggy / CategoryMacro.h
Created Apr 13, 2017
Objective-C Category Property Macro
View CategoryMacro.h
#ifndef TTD_CATEGORY_PROPERTY
#define TTD_CATEGORY_PROPERTY
#import <objc/runtime.h>
#define TTD_GET_PROPERTY(property) objc_getAssociatedObject(self, @selector(property));
#define TTD_SET_STRONG(property) objc_setAssociatedObject(self, @selector(property), property, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
#define TTD_SET_COPY(property) objc_setAssociatedObject(self, @selector(property), property, OBJC_ASSOCIATION_COPY_NONATOMIC);
#define TTD_SET_UNSAFE_UNRETAINED(property) objc_setAssociatedObject(self, @selector(property), property, OBJC_ASSOCIATION_ASSIGN);
#define TTD_SET_ASSIGN(property, value) objc_setAssociatedObject(self, @selector(property), value, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
#define TTD_SET_WEAK(property) id __weak __weak_object = property; \
id (^__weak_block)() = ^{ return __weak_object; }; \
@dreampiggy
dreampiggy / mov2webp.sh
Created Mar 6, 2017
ffmpeg MOV to Animated WebP
View mov2webp.sh
ffmpeg -i input.mov -vcodec libwebp -lossless 1 -q:60 -preset default -loop 0 -an -vsync 0 output.webp
@dreampiggy
dreampiggy / linkmap.js
Created Nov 28, 2016 — forked from bang590/linkmap.js
XCode Linkmap Parser
View linkmap.js
var readline = require('readline'),
fs = require('fs');
var LinkMap = function(filePath) {
this.files = []
this.filePath = filePath
}
LinkMap.prototype = {
start: function(cb) {
You can’t perform that action at this time.