Skip to content

Instantly share code, notes, and snippets.

View ankitthakur's full-sized avatar

Ankit Thakur ankitthakur

View GitHub Profile
@ankitthakur
ankitthakur / DeviceDiskInformation.swift
Created June 10, 2019 06:41
iOS & Mac Device Disk Space Information
import Foundation
class ByteInfo {
class func GBFormatter(_ bytes: Int64) -> String {
let formatter = ByteCountFormatter()
formatter.allowedUnits = ByteCountFormatter.Units.useGB
formatter.countStyle = ByteCountFormatter.CountStyle.decimal
formatter.includesUnit = false
return formatter.string(fromByteCount: bytes) as String
#
# Be sure to run `pod lib lint ATLocationManager.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |spec|
spec.name = 'ATLocationManager'
{"success":true,"message":"","data":{"common":{"categories":{"151":{"id_category":"151","name":"Arts & Humanities","image":"Arts.png","color":"FCAE52","seo_url":"arts-humanities","tag_line":"The Soul of Human Evolution","keywords":["manchester united 1"],"meta_title":"Manchester United (Football Club) 123213213","meta_description":"1321323213 1321321321 Manchester United (Football Club)Manchester United (Football Club)Manchester United (Football Club)Manchester United (Football Club)Manchester United (Football Club)Manchester United (Football Club)Manchester United (Football Club)Manchester United (Football Club)"},"152":{"id_category":"152","name":"Commerce","image":"Commerce.png","color":"689BA1","seo_url":"commerce","tag_line":"Money Matters","keywords":["real madrid 1"],"meta_title":"Real Madrid 12321321321312","meta_description":"342434 32432432 Real Madrid Real Madrid Real Madrid Real Madrid Real Madrid Real Madrid Real Madrid Real Madrid Real Madrid "},"153":{"id_category":"153","name":"Engg and Tech",
@ankitthakur
ankitthakur / Network.swift
Created December 14, 2018 16:17
Swift Network Request
public class Network:NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLSessionDataDelegate {
internal static let sharedInstance = Network()
fileprivate var networkParams:Array<NetworkParams> = Array()
fileprivate func networkCall(_ request:URLRequest, completionBlock:@escaping NetworkCompletionBlock)
{
let configurationId = String(format: "Network%d", arc4random())
let configuration = URLSessionConfiguration.background(withIdentifier: configurationId)
configuration.timeoutIntervalForRequest = request.timeoutInterval
@ankitthakur
ankitthakur / MyClass.swift
Created November 13, 2018 19:26
Singleton Swift class
final class MyClass {
private init() {}
private static var _shared: MyClass?
public static var shared: MyClass {
get {
if _shared == nil {
DispatchQueue.global().sync(flags: .barrier) {
if _shared == nil {
_shared = MyClass()
}
@ankitthakur
ankitthakur / KafkaService.kt
Created September 6, 2018 05:48
Kafka Consumer based Service class listening to the kafka topic.
package com.thakur.kafkaclient.service
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
import com.thakur.kafkaserver.model.Person
import org.apache.kafka.clients.consumer.ConsumerRecord
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.kafka.annotation.KafkaListener
import org.springframework.stereotype.Component
@ankitthakur
ankitthakur / KafkaClientController.kt
Created September 6, 2018 05:46
Kafka Consumer based Rest Controller
package com.thakur.kafkaclient.controller
import com.thakur.kafkaclient.service.KafkaService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("kafka")
@ankitthakur
ankitthakur / application.yaml
Created September 6, 2018 05:42
kafka consumer yml file
spring:
cloud:
stream:
kafka:
binder:
brokers: localhost:9092
spring.kafka.topic: test
spring.kafka.topic.groupId: testgroup
@ankitthakur
ankitthakur / KafkaRestController.kt
Created September 3, 2018 13:46
Rest Controller
package com.thakur.kafkaserver.restcontroller
import com.thakur.kafkaserver.model.Person
import com.thakur.kafkaserver.service.KafkaService
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController
import java.util.*
@ankitthakur
ankitthakur / KafkaService.kt
Created September 3, 2018 13:41
Kafka Service class which will use Kafka Stream to send message as producer
package com.thakur.kafkaserver.service
import com.thakur.kafkaserver.config.KafkaServerStreams
import com.thakur.kafkaserver.model.Person
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.messaging.MessageHeaders
import org.springframework.messaging.support.MessageBuilder
import org.springframework.stereotype.Service
import org.springframework.util.MimeTypeUtils