Skip to content

Instantly share code, notes, and snippets.

View ratulSharker's full-sized avatar
:shipit:
Learning

Ratul sharker ratulSharker

:shipit:
Learning
View GitHub Profile
@ratulSharker
ratulSharker / UDPEchoClient.h
Last active January 9, 2022 10:33
UDP Echo client using objective-c CFSocket
#import <Foundation/Foundation.h>
@interface UDPEchoClient : NSObject
- (BOOL) sendData:(const char *)msg;
@end
@ratulSharker
ratulSharker / NSTimerBlock.h
Last active August 17, 2017 11:59
NSTimer does not support block until the release of ios 10. This gist can serve in that situation.
#import <Foundation/Foundation.h>
//
// HISTORY...
//
// from ios 10 simillar functionality is given which is initialized
// with a block, but we need to support the older version too,
// thats why this class is been introduced
//
@ratulSharker
ratulSharker / UICollectionView+Highlight.h
Created September 18, 2017 08:42
Highlighting a UICollectionViewCell while it's not been into the view window.
//
// UICollectionView+Highlight.h
//
// Created by Ratul Sharker on 9/18/17.
//
#import <UIKit/UIKit.h>
@interface UICollectionView (Highlight)
@ratulSharker
ratulSharker / Prime Factorization.cpp
Last active November 28, 2017 15:28
Finding the prime factorization of an integer
#include <map>
//
// @param number : Of which you want the prime factorization.
// @param freq : Where to store the prime factorization result.
//
void primeFactorization(unsigned long long number, std::map<int, int> &freq)
{
// initially divide via 2
// it has a special thing like
@ratulSharker
ratulSharker / UIImage+base64Encoding.swift
Created April 11, 2018 06:29
Extension for converting an UIImage into Base64 String
import UIKit
extension UIImage {
func base64EncodingString() -> String {
let imageData:Data = UIImagePNGRepresentation(self)!
return imageData.base64EncodedString()
}
}
@ratulSharker
ratulSharker / URL+PercentEncoding.swift
Created April 17, 2018 06:21
Extension for creating URL using non-supporting character like (whitespaces / unicode) etc.
//
// URL+PercentEncoding.swift
//
// Created by ratul sharker on 4/4/18.
//
import Foundation
extension URL {
static func initWithPercentEncoding(string : String) -> URL? {
@ratulSharker
ratulSharker / UITextField+WrapContent.swift
Created April 22, 2018 09:47
This gist set's all the padding and inset to zero, so that UITextView is ready to wrap the content in it.
import UIKit
extension UITextView {
func wrapToContent() {
self.contentInset = UIEdgeInsets.zero
self.scrollIndicatorInsets = UIEdgeInsets.zero
self.contentOffset = CGPoint.zero
self.textContainerInset = UIEdgeInsets.zero
self.textContainer.lineFragmentPadding = 0
}
@ratulSharker
ratulSharker / Django-REST-Shell-CheatSheet.sh
Last active May 6, 2018 06:02
This gist provide basic command line guideline for setting up Django rest framework
#
# Here it is assumed that you are in osx/linux/windows environment
# and you have already installed python3
#
#
# Creating a virtual environment
#
# osx/linux
@ratulSharker
ratulSharker / String+QueryStringParameter.swift
Last active April 7, 2019 05:10
Parsing the query string parameter from String.
import Foundation
extension String {
func getQueryValue(param: String) -> String? {
return URLComponents(string: self)?.queryItems?.filter({ (queryItem) -> Bool in
return queryItem.name == param
}).first?.value
}
}
@ratulSharker
ratulSharker / UIViewController+Swizzling.swift
Last active October 14, 2019 17:18
Swift-Obj-c Method swizzling for common task.
extension UIViewController {
@objc func analytics() {
print("Analytics related implementation")
analytics()
}
static func swizzle() {
// We will swizzle here