Skip to content

Instantly share code, notes, and snippets.

Avatar

Santosh Kumar santosh

View GitHub Profile
@santosh
santosh / AsteroidGrid.js
Created Aug 2, 2021
Event passing to parent and back.
View AsteroidGrid.js
// requires Vue.js and Bootstrap
Vue.component('asteroid-grid', {
props: ['asteroids', 'header'],
data: function () {
return {
showSummary: true
}
},
computed: {
numAsteroids: function () {
@santosh
santosh / vue.html
Created Aug 2, 2021
Fetching API, handing events, doing CSS animations.
View vue.html
<!DOCTYPE html>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<style>
[v-clock] {
display: none;
}
.highlight {
border: solid 3px red;
color: 'red'
@santosh
santosh / vue.html
Created Aug 2, 2021
Props and slots. Slot scopes.
View vue.html
<!DOCTYPE html>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<style>
[v-cloak] {
display: none;
}
</style>
<div id="app">
@santosh
santosh / vue.html
Created Aug 2, 2021
Fetching API, handing events, doing CSS animations.
View vue.html
<!DOCTYPE html>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<style>
[v-clock] {
display: none;
}
.highlight {
border: solid 3px red;
color: 'red'
@santosh
santosh / main.go
Created Jun 17, 2021
Multiplexing concurrency pattern
View main.go
package main
import (
"fmt"
"math/rand"
"time"
)
func boring(msg string) <-chan string { // Returns receive-only channel of strings.
c := make(chan string)
@santosh
santosh / main.go
Created Jun 17, 2021
Generator concurrency pattern.
View main.go
package main
import (
"fmt"
"math/rand"
"time"
)
func boring(msg string) <-chan string { // Returns receive-only channel of strings.
c := make(chan string)
@santosh
santosh / main.go
Last active Jun 17, 2021
progressively learning goroutines
View main.go
package main
import (
"fmt"
"math/rand"
"time"
)
func boring(msg string, c chan string) {
for i := 0; ; i++ {
@santosh
santosh / index1.html
Created Apr 16, 2021
CSS Grid for beginners.
View index1.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Grid</title>
<style>
.container {
display: grid;
View README.md

Authenticate A Golang API With JSON Web Tokens

JSON Web Tokens refresher

The client sends login credentials, the server checks matches the credentials

@santosh
santosh / find_command.md
Last active Sep 19, 2020
Useful find command.
View find_command.md

Note this command.

find . -not -path '*/\.*' -iname '*' -maxdepth 1 -mtime -1

Let's cut it open and see what's happening.

  1. find .: This says find in the current directory (. is cwd).
  2. -not -path '*/\.*': This says not to match dot (hidden) files.
  3. -iname '*': This says match * (any name). The i in iname is for case-insensitive.
  4. -mtime -1: This says only match files which are modified less than 1 day(s) ago. If - is turned to +, it will say only match files which are not modified after one day which is same as matching every file which are modified after one day.