Skip to content

Instantly share code, notes, and snippets.

@deeja
deeja / Dockerfile
Created May 6, 2020 15:44
Dockerfile - Nuxt.js Generate - Nginx Serve
FROM node:alpine as builder
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn
COPY . ./
RUN yarn generate
FROM nginx
COPY --from=builder /usr/src/app/dist /usr/share/nginx/html
@deeja
deeja / Breed.js
Last active May 9, 2020 15:36
Node.js - Sequelize Model Setup
const { DataTypes } = require("sequelize");
module.exports = {
name: "Breed",
modelName: "breed",
schema: {
name: {
type: DataTypes.STRING,
allowNull: false,
}
@deeja
deeja / Program.cs
Last active May 27, 2020 10:33
UdpClient for local data receive - Works on dotnet core
internal class Program
{
private const int PORT = 4843;
private static void Main(string[] args)
{
Console.WriteLine("Packet Forwarding UP!");
var client = new UdpClient(PORT);
var ipEndPoint = new IPEndPoint(IPAddress.Loopback, PORT);
while (true)
@deeja
deeja / OneClient-NoPacketsReceived
Created June 23, 2020 13:40
Examples of UdpClient not working
using System;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace ForzaData.UdpClient
{
internal class Program
{
private const int FORZA_DATA_OUT_PORT = 5300;
@deeja
deeja / FirebaseVuexPlugin.js
Created July 13, 2020 13:19
Nuxt Firebase "@nuxtjs/firebase" plug in alternative for vuex that returns the JWT token and sets in Vuex
// Using the "@nuxtjs/firebase" module
import {mutationNames} from '@/data/StoreNames'
export default async ({ store, app }, inject) => {
// Sets up a listener, mutations and action for every onAuthStateChanged by Firebase.
// AND runs the functions once BEFORE the root Vue.js Application is instantiated.
const unsubscribe = await new Promise(resolve => {
const unsubscribe = app.$fireAuth.onAuthStateChanged(async user => {
@deeja
deeja / Example.vue
Last active August 2, 2020 09:42
Lazy loading image component for Nuxt.js
<template>
<div>
<!-- Properties automatically map -->
<LazyImage class="my-class" src="/some/asset.png" alt="" />
<!-- Can use property and event binding -->
<LazyImage class="my-class" :src="transform(myObj.imageSrc)" :alt="myObj.alt" @click="showMessage" />
</div>
</template>
@deeja
deeja / AddVisualStudioCodeShortCuts.reg
Created October 7, 2020 16:04
VSCode Context menu - Adds Visual Studio Code (VsCode) to the right click context menu in File Explorer (Change YOUR_USER_NAME)
Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Users\\YOUR_USER_NAME\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Users\\YOUR_USER_NAME\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\shell\vscode]
@deeja
deeja / logger.cs
Created November 16, 2020 09:58
Microsoft ILogger to Windsor ILogger and Factory
public class ThisLogger: ILoggerFactory
{
private readonly Microsoft.Extensions.Logging.ILoggerFactory _logger;
public ThisLogger(Microsoft.Extensions.Logging.ILoggerFactory logger)
{
_logger = logger;
}
public ILogger Create(Type type)
@deeja
deeja / FirebaseCertificateManager.cs
Last active January 17, 2021 17:00
Validating a Firebase JWT with .Net Core and SignalR (without .Net FirebaseAdmin)
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
@deeja
deeja / Program.cs
Created March 22, 2021 18:20
Kestrel self hosting .net core 3.1
private static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.UseKestrel((context, options) =>
{