Skip to content

Instantly share code, notes, and snippets.

View xsaamiir's full-sized avatar
🟡
xoē

sāmīr xsaamiir

🟡
xoē
View GitHub Profile
@xsaamiir
xsaamiir / restaurant-menu.json
Last active January 29, 2023 13:51
example of a restaurant's menu in json from https://codebeautify.org/jsonviewer/cb51497a
{
"array":{
"type":"Restaurant Menu",
"restaurant-info":{
"id":"121721",
"sponsored":"0",
"user-favourite":"",
"name":"Nandos Banani",
"address":"Road-11, Banani, Dhaka",
"rating":"0.00",
@xsaamiir
xsaamiir / redux.js
Created January 1, 2018 13:50
to help remeber the redux usage pattern
import { createStore, combineReducers, applyMiddleware } from 'redux'
import { createLogger } from 'redux-logger'
const mathReducer = (state = {
result: 1,
lastValues: []
}, action) => {
switch (action.type) {
case "ADD":
state = {
@xsaamiir
xsaamiir / index.html
Created January 5, 2018 11:07
React: scrollIntoView
<div id="list"></div>
@xsaamiir
xsaamiir / fish_shell.md
Created February 15, 2018 10:31 — forked from idleberg/fish_shell.md
Instructions on how to install Fish shell on Mac OS X, including Oh My Fish!. Also includes several useful functions.

Installation

  1. Install fish via Brew
  2. Optionally install Oh My Fish!
  3. Add fish to known shells
  4. Set default shell to fish
brew install fish  
curl -L https://get.oh-my.fish | fish
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: admin-user
@xsaamiir
xsaamiir / actor.kt
Last active January 5, 2021 11:48
KotlinConf 2018 - Kotlin Coroutines in Practice by Roman Elizarov code Code https://youtu.be/a3agLJQ6vt8
const N_WORKERS = 5
class Content
class Location
class Reference {
fun resolveLocation(): Location = TODO()
}
data class LocContent(val location: Location, val content: Content)
@xsaamiir
xsaamiir / goroutines_cheatsheet.go
Last active January 17, 2023 01:12
Golang Goroutines cheatsheet
// from the talk https://www.youtube.com/watch?v=PTE4VJIdHPg
// futures
future := make(chan int, 1)
go func() {future <- process() }()
result := <-future
// async await
c := make(chan int, 1)
go func() { c <- process() }() // async
v := <-c // await
@xsaamiir
xsaamiir / mapvisit.go
Created January 27, 2019 19:21
A function to visit every node in a map[string]interface{}
func MapVisitor(mapToVisit map[string]interface{}) {
for k, v := range mapToVisit {
switch val := v.(type) {
case string:
fmt.Println(k, "is string -> ", val)
case float64:
fmt.Println(k, "is float64 -> ", val)
case map[string]interface{}:
MapVisitor(v.(map[string]interface{}))
case []interface{}:
@xsaamiir
xsaamiir / sem.go
Created January 29, 2019 08:51
Golang goroutines semaphores
package main
import "fmt"
// sem is a channel that will allow up to 10 concurrent operations.
var sem = make(chan int, 10)
func main() {
for {
sem <- 1 // will block if there is MAX ints in sem