Skip to content

Instantly share code, notes, and snippets.

View rintoandrews90's full-sized avatar
:octocat:

Rinto Andrews rintoandrews90

:octocat:
View GitHub Profile
@rintoandrews90
rintoandrews90 / CallBackNode.js
Created August 11, 2019 05:46
Callback in node.js
const geoCode = (address,callback) => {
setTimeout(() => {
const data = {
latitude:0,
longitude:0
}
callback(data)
}, 2000);
}
@rintoandrews90
rintoandrews90 / ErrorHandlingNode.js
Created August 11, 2019 05:34
Error handling in node.js
const request = require('request')
const url = "https://api.darksky.net/forecast/fb190dafa7914f0bb56e65287631fad9/37.8267,-122.4233"
request({url:url,json:true}, (error,response) => {
if (error) {
console.log('Unable to connect to wheather API')
} else if (response.body.error){
console.log('Error to connect to wheather API')
@rintoandrews90
rintoandrews90 / HTTPRequestNode.js
Last active August 11, 2019 05:25
Make http request in node.js
//Install HTTP Request
// npm init -y
// npm i request
const request = require('request')
const url = "https://api.darksky.net/forecast/fb190dafa7914f0bb56e65287631fad9/37.8267,-122.4233"
@rintoandrews90
rintoandrews90 / AsyncTaskNode.js
Last active August 10, 2019 18:54
Async Task Node.js
console.log('Starting')
setTimeout( () => {
console.log('2 Second Timer')
},2000) //2 Secondes
setTimeout( () => {
console.log('0 Second Timer')
},0) //2 Secondes
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>compileBitcode</key>
<true/>
<key>method</key>
<string>development</string>
<key>provisioningProfiles</key>
<dict>
xcodebuild -scheme schemename -workspace workspacename.xcworkspace/ build
xcodebuild -workspace workspacename.xcworkspace -scheme scheme name -destination generic/platform=iOS build
xcodebuild -workspace workspacename.xcworkspace -scheme scheme name clean archive -configuration debug -sdk iphoneos -archivePath ~/Downloads/archivename.xcarchive
xcodebuild -exportArchive -archivePath ~/Downloads/archivename.xcarchive -exportPath ~/Downloads -exportOptionsPlist ~/Downloads/ExportOptions.plist
@rintoandrews90
rintoandrews90 / convertBacktoJSON.swift
Last active August 17, 2019 05:53
Convert to JSON form Model
let json = try? JSONEncoder().encode(model)
extension UserInfo: Encodable {
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(userId, forKey: .userId)
try container.encode(jobTitleName, forKey: .jobTitleName)
try container.encode(preferredFullName, forKey: .preferredFullName)
try container.encode(employeeCode, forKey: .employeeCode)
try container.encode(region, forKey: .region)
try container.encode(phoneNumber, forKey: .phoneNumber)
let decoder = JSONDecoder()
let model = try? decoder.decode(User.self, from:jsonData)
struct Name: Codable {
var firstname: String
var lastname: String
}
struct User: Codable {
var userId: String
{
"userId": "rirani",
"jobTitleName": "Developer",
"name": {
"firstname": "rinto",
"lastname": "andrews"
}
}