Skip to content

Instantly share code, notes, and snippets.

View anirudhamahale's full-sized avatar

Anirudha Mahale anirudhamahale

View GitHub Profile
public createTask(req: Request, res: Response): Observable<mongoose.Document> {
const body = req.body
const self = this
const task = body.task
const projectId = body.projectId
const moduleId = body.moduleId
const timeRequired = body.timeRequired
return Observable.create(function(observer: Observer<mongoose.Document>) {
var d = $;var x = $('.c-box-list.c-box-list--linked.c-video-player__lesson-list.c-video-player__lesson-list--open').children
for(var i = 0;i<x.length; i++) {
var z = x[i];
(function() {
var y = z.children[0];
setTimeout(function() {
console.log('Switching to ' + y);
y.click();
setTimeout(function() {
@anirudhamahale
anirudhamahale / vipera.swift
Last active August 4, 2018 06:18
Viper Files Creator
//
// DetailEventsBuilder.swift
// DetailEventsBuilder
//
// Created by Tibor Bödecs
// Copyright © 2018. Tibor Bödecs. All rights reserved.
//
// Modified by Anirudha Mahale
// Copyright © 2018. Anirudha Mahale. All rights reserved.
//
@anirudhamahale
anirudhamahale / MainActivity.kt
Last active June 2, 2018 11:53
Retrofit enque function
val apiClient = APIClient().getAPIClient().create(APICallsInterface::class.java)
apiClient.getFeeds().enqueue(object : Callback<ResponseBody> {
override fun onFailure(call: Call<ResponseBody>?, t: Throwable?) {
println("Failed")
}
override fun onResponse(call: Call<ResponseBody>?, response: Response<ResponseBody>?) {
println("Result: ${response!!.body().toString()}")
data = response.body()!!
loadRecyclerView()
// Set date somewhere
UserDefaults.standard.set(Date(), forKey:"creationTime")
extension Date {
func isBeyond24Hours() -> Bool {
if let date = UserDefaults.standard.object(forKey: "creationTime") as? Date {
if let diff = Calendar.current.dateComponents([.hour], from: date, to: Date()).hour, diff > 24 {
return true
}
return false
@anirudhamahale
anirudhamahale / Date+Extension.swift
Last active February 27, 2020 11:21
Compare Date
// Set date somewhere
UserDefaults.standard.set(Date(), forKey:"creationTime")
extension Date {
func isBeyond24Hours() -> Bool {
if let date = UserDefaults.standard.object(forKey: "creationTime") as? Date {
if let diff = Calendar.current.dateComponents([.hour], from: date, to: Date()).hour, diff > 24 {
return true
}
return false
// Set date somewhere
UserDefaults.standard.set(Date(), forKey:"creationTime")
extension Date {
func isBeyond24Hours() -> Bool {
if let date = UserDefaults.standard.object(forKey: "creationTime") as? Date {
if let diff = Calendar.current.dateComponents([.hour], from: date, to: Date()).hour, diff > 24 {
return true
}
return false
@anirudhamahale
anirudhamahale / Error+Extension.swift
Last active April 11, 2018 04:10
An extension of Error generic from Swift
extension Error {
var code: Int { return (self as NSError).code }
var domain: String { return (self as NSError).domain }
var userInfo: [String : Any] { return (self as NSError).userInfo }
}
@anirudhamahale
anirudhamahale / UINavigationBar+Extension.swift
Created March 22, 2018 10:55
This contains the useful extensions for the UINavigationBar
extension UINavigationBar {
func hideShadowImage() {
self.shadowImage = UIImage()
if self.barStyle != .black {
self.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
}
}
}
// Here is the usage.
@anirudhamahale
anirudhamahale / AMLayout.swift
Created October 12, 2017 05:34
Layout Services
//
// LayoutServices.swift
// AMLayout
//
// Created by Anirudha on 10/10/17.
// Copyright © 2017 Anirudha Mahale. All rights reserved.
//
import UIKit