Skip to content

Instantly share code, notes, and snippets.

View rajubd49's full-sized avatar

Md Harish Uz Jaman Mridha rajubd49

View GitHub Profile
@rajubd49
rajubd49 / code_review.doc
Created June 20, 2022 09:51
Teufel code review
Code review
12: MusicAlbum struct need to confirm Decodable protocol to decode response from url request
25: Initializer need to have albums initialized with default value like init(albums: [MusicAlbum] = [MusicAlbum]())
29: Function name should be in camel case instead of snake case
30: Url needs to be a valid format, otherwise url session will fail to load response
33: Before sink, we need make sure to publish values from main thread using .received(on: DispatchQueue.main)
34: Need to check completion with .finished and .failure case to show appropriate error message if exists.
37: After line 37, we need to store cancellables instance in specified collection
45: showDetailView needs to be a @State property, otherwise we can’t change it’s value inside struct
@rajubd49
rajubd49 / LinkedList.swift
Created August 5, 2019 10:48
Swift implementation of Linked List (Insert, Delete, Special insert).
import UIKit
// Linked List (Insert, Delete, Special insert)
class Node {
let value: Int
var nextNode: Node?
init(value:Int, nextNode: Node?) {
self.value = value
self.nextNode = nextNode
@rajubd49
rajubd49 / HashMap.swift
Last active August 5, 2019 10:47
Swift implementation of Hash Map
import UIKit
var string = "1337"
func convert(string: String) -> Int? {
var total = 0
let valueMap = [
"0" as Character : 0,
"1" : 1,
@rajubd49
rajubd49 / TopViewController.swift
Created July 10, 2018 09:55
Get Top ViewController for iOS using Swift
extension UIApplication {
class func topViewController(base: UIViewController? = UIApplication.sharedApplication().keyWindow?.rootViewController) -> UIViewController? {
if let nav = base as? UINavigationController {
return topViewController(base: nav.visibleViewController)
}
if let tab = base as? UITabBarController {
if let selected = tab.selectedViewController {
return topViewController(base: selected)
}
}
@rajubd49
rajubd49 / OOP.swift
Last active April 17, 2018 10:37
Swift 4 - Object Oriented Programming Playground
//: Playground - noun: a place where people can play
import UIKit
print("Object Oriented Programming")
// Protocal
protocol PurchaseItem {
func cost() -> Float
@rajubd49
rajubd49 / app.js
Created April 16, 2015 13:19
Image to PDF convertor-screenshot to pdf - Appcelerator Titanium
var PDF = require('bencoding.pdf');
var converters = PDF.createConverters();
var win = Ti.UI.createWindow({ backgroundColor:'#fff'});
var vwContent = Ti.UI.createView({
top:0, layout:'vertical'
});
win.add(vwContent);
vwContent.add(Ti.UI.createView({
@rajubd49
rajubd49 / app.js
Created April 16, 2015 13:18
Image Slideshow - Appcelerator Titanium
var win = Ti.UI.createWindow();
var loaderImage = Ti.UI.createImageView({
width:150,
height:150
});
// set the length of the images you have in your sequence
var loaderArrayLength=3;
// initialize the index to 1
@rajubd49
rajubd49 / app.js
Created April 16, 2015 13:03
How to rotate through a selection of colors - Appcelerator Titanium
var win = Ti.UI.createWindow({
fullscreen: true,
backgroundColor: 'blue',
});
setInterval(function(){
var backColor = win.backgroundColor;
if(backColor == 'blue'){
win.animate({backgroundColor: 'purple', duration: 1500});
win.backgroundColor = 'purple';
@rajubd49
rajubd49 / app.js
Created April 16, 2015 13:01
How to play audio randomly - Appcelerator Titanium
var win = Ti.UI.createWindow({
backgroundColor : '#000',
layout:'vertical'
});
var mp3_array = [];
mp3_array.push('music/sound1.mp3');
mp3_array.push('music/sound2.mp3');
mp3_array.push('music/sound3.mp3');
@rajubd49
rajubd49 / app.js
Created April 16, 2015 13:00
How to evaluate mathematical expression - Appcelerator Titanium
var win = Ti.UI.createWindow({backgroundColor : 'white'});
var txtFld = Ti.UI.createTextField({
height : 40,
width : 120,
backgroundColor : 'gray'
});
win.add(txtFld);
var numLbl = Ti.UI.createLabel({