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 / install-docker
Created August 23, 2022 18:05
Installing docker, docker-compose into linux
# Installing Git
sudo apt install git
# Update the local packages
sudo apt-get update
sudo apt full-upgrade
# Installing docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
@ratulSharker
ratulSharker / RestConfiguration.java
Last active September 6, 2021 20:31
RestTemplate wrapper for REST call in spring boot.
package your.package.name.here;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestConfiguration {
pgloader --no-ssl-cert-verification mysql://{USER}:{PASSWORD}@{HOST}:3306/{DB_NAME} {HEROKU_DB_URL}?sslmode=require
@ratulSharker
ratulSharker / RouteTree.js
Last active February 27, 2020 05:39
Express route tree
const endpoints = ["/businesses/:businessId/banks/:bankInfoId" ,"/businesses/mine/banks/:bankInfoId"] //,"/businesses/sales/:businessId/banks/:bankInfoId","/publicnotifications/:publicNotificationId","/publicnotifications/:userPublicNotificationId","/pushtokens","/users/me/phones/:userPhoneId","/accounting/businesses/:businessId/summary","/accounting/migrate/payables","/accounting/migrate/paymentmetainfo","/accounting/orders/:orderId","/accounting/orders/:orderRefId","/accounting/paid","/accounting/paid/summary","/accounting/payables","/accounting/payables/summary","/accounting/receivables","/accounting/receivables/:accountReceivableId/refundbreakdown","/accounting/receivables/summary","/accounting/received","/accounting/received/summary","/accounting/withdraws","/accounting/withdraws/:withdrawRequestId","/accounting/withdraws/summary","/acl/register","/acl/routes","/activitylogs","/activitylogs/:activityLogId","/addons/:addonId","/analytics","/analytics/businesses/mine","/analytics/businesses/mine/custom/ord
@ratulSharker
ratulSharker / JSObjDiff.js
Last active January 24, 2020 18:47
JS Data model difference calculator.
// Base model
function BaseModel() {
}
BaseModel.prototype.difference = function(latestModel, arrDiffActual = false) {
const difference = {};
const self = this;
Object.keys(this).forEach( function(key) {
if(self[key] instanceof BaseModel) {
// kind of another base model
const keyValueDifference = self[key].difference(latestModel[key]);
@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
@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 / 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 / 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 / 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? {