Skip to content

Instantly share code, notes, and snippets.

View navsing's full-sized avatar
🏠
Working from home

Navdeep Singh navsing

🏠
Working from home
View GitHub Profile
type Person {
title: String
name: String
}
apollo schema:download --endpoint=<your_endpoint>/graphql schema.json --header="x-api-key: <your-api-key"
import Foundation
import Apollo
class Network {
static let shared = Network()
let apollo: ApolloClient = {
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = [
"x-api-key": "da2-tbx2kgzvp5bmlo4jxzhriavg3i"
]
struct ImageUrlView: View {
@ObservedObject var remoteImageModel: RemoteImageModel
init(url: String?) {
remoteImageModel = RemoteImageModel(imageUrl: imageUrl)
}
var body: some View {
Image(uiImage: remoteImageModel.image ?? UIImage(named: "default-image-here")!)
.resizable()
class RemoteImageModel: ObservableObject {
@Published var displayImage: UIImage?
var imageUrl: String?
var cachedImage = CachedImage.getCachedImage()
init(imageUrl: String?) {
self.imageUrl = imageUrl
if imageFromCache() {
return
}
struct ImageContentView : View {
@State var url = "https://link-to-image"
var body: some View {
VStack {
ImageView(url: url)
}
}
import Combine
import SwiftUI
struct ImageViewController: View {
@ObservedObject var url: LoadUrlImage
init(imageUrl: String) {
url = LoadUrlImage(imageURL: imageUrl)
}
var body: some View {
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest();
const mysql = require('mysql');
const config = require('./config');
const pool = mysql.createPool({
connectionLimit: 10,
host: config.dbhost,
user: config.dbuser,
password: config.dbpass,
database: config.dbname
});
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest();
var fs = require('fs')
fs.readFile('birthdays', 'UTF-8', function ( err, contents ) {
var birthdays = contents.toString().split('\n');
const bdayPeople = birthdayToday(birthdays);
greetBirthday(bdayPeople);
})
function birthdayToday(birthdays) {
var results = []
const express = require('express')
const app = express()
var path = require('path')
var bodyParser = require('body-parser')
app.use(express.static(path.join(__dirname, 'build')));
var dataController = require('./dataController');
app.get('/api/data', dataController.getData);