Skip to content

Instantly share code, notes, and snippets.

@pallavtrivedi03
pallavtrivedi03 / app.js
Created January 7, 2019 14:03
App.js file for Moviepedia
const express = require('express');
const bodyParser = require('body-parser');
const graphqlHttp = require('express-graphql');
const {buildSchema} = require('graphql');
const mongoose = require('mongoose');
const movieSchema = require('./models/movie-schema');
const Movie = require('./models/movie');
var app = express();
@pallavtrivedi03
pallavtrivedi03 / SlashCommand.js
Created March 15, 2019 07:46
Slash command route (for SlackAppDemo)
router.post('/SlackAppDemo',function(req,res) {
try {
const response = {
response_type: 'in_channel',
channel: req.body.channel_id,
text: 'Hey there...:',
attachments: [{
text: 'What would you like to know in this project?',
fallback: 'What would you like to know in this project?',
color: '#2c963f',
@pallavtrivedi03
pallavtrivedi03 / QueryOptions.js
Created March 15, 2019 07:49
Query options for SlackAppDemo
const queryOptions = [{
text: 'Open Issues',
value: 'opneIssues'
}, {
text: 'Closed Issues',
value: 'closedIssues'
}, {
text: 'Milestones',
value: 'milestones'
}, {
@pallavtrivedi03
pallavtrivedi03 / Aciton.js
Created March 15, 2019 09:13
Route for handling user action (SlackAppDemo)
router.post('/actions', async (req, res) => {
try {
const payload = JSON.parse(req.body.payload);
console.log("###slack request is "+payload);
var response = "";
if (payload.callback_id === 'query_selection') {
console.log("option selected is "+payload.actions[0].selected_options[0].value);
switch (payload.actions[0].selected_options[0].value) {
case "openIssues":
import UIKit
import AuthenticationServices
class LoginViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
setupAppleSignIn()
}
import Foundation
struct MovieInfo: Codable {
let name: String?
let releaseDate: String?
let daysSinceRelease: Int?
let collection: String?
let posterUrl: String?
enum CodingKeys: String, CodingKey {
struct MovieInfoEntry: TimelineEntry {
public let date: Date
public let movieInfo: MovieInfo
}
struct Provider: TimelineProvider {
let dummyData = MovieInfo(name: "Some latest movie", releaseDate: "Release Date", daysSinceRelease: 1, collection: "Collection in Cr", posterUrl: "https://popcornusa.s3.amazonaws.com/placeholder-movieimage.png")
func placeholder(in context: Context) -> MovieInfoEntry {
MovieInfoEntry(date: Date(), movieInfo: dummyData)
}
func getSnapshot(in context: Context, completion: @escaping (MovieInfoEntry) -> ()) {
let entry = MovieInfoEntry(date: Date(), movieInfo: dummyData)
struct BoxOfficeWidgetEntryView : View {
var entry: Provider.Entry
@Environment(\.widgetFamily) var family
@ViewBuilder
var body: some View {
switch family {
case .systemSmall:
ZStack {
moviePosterView()
@main
struct BoxOfficeWidget: Widget {
let kind: String = "BoxOfficeWidget"
var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: Provider()) { entry in
BoxOfficeWidgetEntryView(entry: entry)
}
.configurationDisplayName("Box Office")
.description("Box office collection of latest movies")