This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use client'; | |
| import React, { useEffect, useState } from 'react'; | |
| function JsonTester() { | |
| const [json, setJson] = useState(''); | |
| useEffect(() => { | |
| const getJson = async () => { | |
| var response = await fetch('https://swapi.dev/api/people/1'); | |
| if (response.ok) { | |
| setJson(JSON.stringify(await response.json())); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3.8' | |
| services: | |
| mongo: | |
| image: mongo:7.0 | |
| environment: | |
| MONGO_INITDB_ROOT_USERNAME: mongadmin | |
| MONGO_INITDB_ROOT_PASSWORD: LikeAndSubscribe | |
| ports: | |
| - 27017:27017 | |
| volumes: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class TodoContext : DbContext | |
| { | |
| private readonly IConfiguration config; | |
| public TodoContext(DbContextOptions options, IConfiguration config) : base(options) | |
| { | |
| this.config = config; | |
| } | |
| public DbSet<Todo> Todos { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Create a new database called 'SBDemo' | |
| -- Connect to the 'master' database to run this snippet | |
| USE master | |
| GO | |
| -- Create the new database if it does not exist already | |
| IF NOT EXISTS ( | |
| SELECT [name] | |
| FROM sys.databases | |
| WHERE [name] = N'SBDemo' | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Diagnostics; | |
| var numTasks = 10; | |
| var taskTimeMs = 1000; | |
| Console.WriteLine($"Running {numTasks} tasks at {taskTimeMs} ms each."); | |
| Stopwatch stopWatch = new Stopwatch(); | |
| await DoSlow(); | |
| await DoFast(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build-env | |
| # Copy csproj and restore as distinct layers | |
| COPY ./TodoAPI/TodoAPI.csproj ./TodoAPI/TodoAPI.csproj | |
| COPY *.sln . | |
| RUN dotnet restore | |
| # Copy everything else and build | |
| COPY . ./ | |
| RUN dotnet publish -c Release -o build --no-restore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM node:16.14.0 as build | |
| WORKDIR /source | |
| # Copy the package lock file into the container | |
| COPY package*.json ./ | |
| # Run ci only for the production dependencies | |
| RUN npm ci | |
| # Copy the rest of the files into the container and build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| steps: | |
| - name: gcr.io/cloud-builders/docker | |
| args: | |
| - build | |
| - '-t' | |
| - '$_GCR_HOSTNAME/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA' | |
| - . | |
| - name: gcr.io/cloud-builders/docker | |
| args: | |
| - push |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, OnInit } from '@angular/core'; | |
| import { Person } from './person.model'; | |
| import { PersonService } from './person.service'; | |
| @Component({ | |
| selector: 'app-person', | |
| template: ` | |
| <div>Selected Person: <span *ngIf="selected$ | async as person">{{person.name}}</span></div> | |
| <div *ngFor="let per of people$ | async" (click)="select(per)"> | |
| <div>Name: {{per.name}}</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Injectable } from '@angular/core'; | |
| import { HttpClient } from '@angular/common/http'; | |
| import { Person } from './person.model'; | |
| import { environment } from 'environments/environment'; | |
| import { StoreService } from 'app/core/services/store.service'; | |
| @Injectable({ | |
| providedIn: 'root' | |
| }) | |
| export class PersonService extends StoreService<Person> { |
NewerOlder