Skip to content

Instantly share code, notes, and snippets.

View proactive-solutions's full-sized avatar

Pawan Sharma proactive-solutions

View GitHub Profile
@proactive-solutions
proactive-solutions / PDFToUIImage.swift
Created February 4, 2022 10:04 — forked from manmal/PDFToUIImage.swift
PDF to UIImage (with capability to resize)
import Foundation
import UIKit
/// Renders the first page of the given PDF file to a `UIImage`. If
/// `maxLength` is given, then the resulting image is scaled to a
/// matching size.
///
/// Example: If `maxLength` is set to `100.0`, this might result in
/// the following dimensions (since aspect ratio is preserved):
///
@proactive-solutions
proactive-solutions / clean_code.md
Created May 22, 2018 06:08 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

Javascript Shorthand Coding Techniques

My (@pongstr) opinion about shorthand coding techniques

Shorthand code is not really a replacement for normal coding but it is very handy and useful in some cases. There are tons of opinions and debates around this but, again it all comes down what is necessary for your codebase and using it responsibly.

@proactive-solutions
proactive-solutions / handler.js
Created January 1, 2018 08:57 — forked from jeffrafter/handler.js
Simple HTTP Server and Router in node.js
exports.createHandler = function (method) {
return new Handler(method);
}
Handler = function(method) {
this.process = function(req, res) {
params = null;
return method.apply(this, [req, res, params]);
}
}
@proactive-solutions
proactive-solutions / TooltipView.swift
Created June 12, 2017 05:17 — forked from simonwuyts/TooltipView.swift
Customizable Tooltips
//
// TooltipView.swift
// Customizable Tooltips
//
// Copyright © 2017 Simon Wuyts
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

Videos

@interface PingThread : NSThread
@property (nonatomic, assign) BOOL pingTaskIsRunning;
@property (nonatomic, strong) dispatch_semaphore_t semaphore;
@end
@proactive-solutions
proactive-solutions / StructToJSON.swift
Last active December 2, 2016 08:22
Creates JSON representation from the swift struct. Code was copied from this blog, all the credit goes to the original author of the blog http://codelle.com/blog/2016/5/an-easy-way-to-convert-swift-structs-to-json/
protocol JSONRepresentable {
var JSONRepresentation: Any { get }
}
protocol JSONSerializable: JSONRepresentable {
}
extension JSONSerializable {
var JSONRepresentation: Any {
@proactive-solutions
proactive-solutions / NSBundle+Language.h
Last active July 5, 2016 12:01
Use localisation in application without need to change the device language setting by user. Particularly useful in app which supports more than one languages.
#import <Foundation/Foundation.h>
@interface NSBundle (Language)
+(void)setLanguage:(NSString*)language;
@end