Skip to content

Instantly share code, notes, and snippets.

View agzuniverse's full-sized avatar
🚀
On a journey into myself

Aswin G agzuniverse

🚀
On a journey into myself
View GitHub Profile
package main
import (
"context"
"fmt"
"log"
"net/http"
"strings"
"github.com/dgrijalva/jwt-go"
)
func middleware(next http.Handler) http.Handler {
else {
jwtToken := authHeader[1]
token, err := jwt.Parse(jwtToken, func(token *jwt.Token) (interface{}, error) {
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
}
return []byte(SECRETKEY), nil
})
if claims, ok := token.Claims.(jwt.MapClaims); ok && token.Valid {
ctx := context.WithValue(r.Context(), "props", claims)
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
"entry": "./src/index.js",
"output": {
path: path.resolve(__dirname, 'dist'),
filename: "bundle.js"
},
module: {
import React from 'react';
class App extends React.Component {
render() {
return (
<div>Welcome to React!</div>
);
}
}
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
ReactDOM.render(<App />, document.getElementById('root'));
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>React App</title>
</head>
<body>
<div id="root"></div>
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
const path = require('path')
module.exports = {
"entry": "./src/index.js",
"output": {
path: path.resolve(__dirname, 'dist'),
filename: "bundle.js"
},
module: {
rules: [
{
"name": "test-project",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
#include <stdio.h>
float calcAvg(int a[], int n)
{
int total = 0;
for (int i = 0; i < n; i++)
total += a[i];
return (float)total / n;
}