Skip to content

Instantly share code, notes, and snippets.

View ShawonAshraf's full-sized avatar
🐈
I'm simply not there.

Shawon Ashraf ShawonAshraf

🐈
I'm simply not there.
View GitHub Profile
@ShawonAshraf
ShawonAshraf / update-final.js
Created August 3, 2019 20:15
Code for mongodb-nodejs-medium article
const docToUpdate = { name: 'Halo MCC' };
const updateTerm = { $set: { name: 'Halo Master Chief Collection' } };
console.log('Before update :');
let haloMcc = await db.collection('games').findOne(docToUpdate);
console.log(haloMcc);
await updateDoc(db, docToUpdate, updateTerm);
// check
@ShawonAshraf
ShawonAshraf / deletedoc.js
Last active August 3, 2019 20:12
Code for mongodb-nodejs-medium article
// filter
const filter = {
name: 'Red Dead Redemption 2',
platform: 'XBOXONE'
};
await deleteDoc(db, filter);
const deleteDoc = async(db, filter) => {
try {
await db.collection('games').findOneAndDelete(filter);
@ShawonAshraf
ShawonAshraf / at-gen-8.swift
Created July 3, 2019 14:34
swift-associated-type-generic 8
let adder = DoubleAdder()
print(adder.add(a: 34.67, b: 89.23)) // 123.9
@ShawonAshraf
ShawonAshraf / at-gen-7.swift
Created July 3, 2019 14:33
swift-associated-type-generic 7
class DoubleAdder: Adder {
typealias Number = Double
func add(a: Double, b: Double) -> Double {
return a + b
}
}
@ShawonAshraf
ShawonAshraf / at-gen-6.swift
Created July 3, 2019 14:32
swift-associated-type-generic 6
func add(a: Double, b: Double) -> Double {
return a + b
}
@ShawonAshraf
ShawonAshraf / at-gen-5.swift
Created July 3, 2019 14:31
swift-associated-type-generic 5
class DoubleAdder: Adder {
typealias Number = Double
}
@ShawonAshraf
ShawonAshraf / at-gen-4.swift
Created July 3, 2019 14:30
swift-associated-type-generic 4
protocol Adder {
associatedtype Number
func add(a: Number, b: Number) -> Number
}
@ShawonAshraf
ShawonAshraf / at-gen-3.swift
Created July 3, 2019 14:29
swift-associated-type-generic 3
let adder = IntAdder()
print(adder.add(a: 55, b: 45)) // prints 100
@ShawonAshraf
ShawonAshraf / at-gen-2.swift
Created July 3, 2019 14:29
swift-associated-type-generic 2
class IntAdder: Adder {
func add(a: Int, b: Int) -> Int {
return a + b
}
}
@ShawonAshraf
ShawonAshraf / at-gen-1.swift
Created July 3, 2019 14:26
swift-associated-type-generic 1
protocol Adder {
func add(a: Int, b: Int) -> Int
}