Skip to content

Instantly share code, notes, and snippets.

View alinz's full-sized avatar
🎯
¯\_(ツ)_/¯

Ali Najafizadeh alinz

🎯
¯\_(ツ)_/¯
View GitHub Profile
@alinz
alinz / router.go
Created July 7, 2019 14:48
router with cors
import (
"net/http"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/goware/cors"
)
func New() chi.Router {
cors := cors.New(cors.Options{
@alinz
alinz / Fetcher.js
Created July 7, 2019 13:49
A simple Fetch implementation
const baseURL = process.env.API_ADDR || 'http://localhost/api'
export type Pagination<T> = {
meta: {
total: number
}
data: T
}
export interface Fetcher {
@alinz
alinz / Makefile
Created May 29, 2019 18:44
WebAssembly on Node.js
build:
emcc test.c -O3 -s WASM=1 -s EXPORTED_FUNCTIONS='["_add"]' -s SIDE_MODULE=1 -o test.wasm
run:
node index.js
@alinz
alinz / golang-tls.md
Created April 4, 2019 02:53 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@alinz
alinz / main.c
Created February 26, 2019 15:45 — forked from mochja/main.c
Yoga + OpenGL Example
#include <GLFW/glfw3.h>
#include <yoga/Yoga.h>
#include <stdlib.h>
int main(void)
{
GLFWwindow* window;
/* Initialize the library */
if (!glfwInit())
@alinz
alinz / product.js
Created February 22, 2019 18:40 — forked from cybercase/product.js
Python-like itertools.product function in javascript
function product() {
var args = Array.prototype.slice.call(arguments); // makes array from arguments
return args.reduce(function tl (accumulator, value) {
var tmp = [];
accumulator.forEach(function (a0) {
value.forEach(function (a1) {
tmp.push(a0.concat(a1));
});
});
return tmp;
@alinz
alinz / client.go
Created January 18, 2019 04:23 — forked from hakobe/client.go
golang unix domain socket
package main
import (
"io"
"log"
"net"
"time"
)
func reader(r io.Reader) {
@alinz
alinz / brew-permission.md
Last active December 9, 2018 18:56
Brew Permission issue

run the following command:

sudo mkdir -p $(brew --prefix)/include
sudo mkdir -p $(brew --prefix)/Cellar
sudo mkdir -p $(brew --prefix)/lib
sudo mkdir -p $(brew --prefix)/opt

sudo chown -R $(whoami) $(brew --prefix)/*
@alinz
alinz / styled.js
Last active February 24, 2018 17:48
Styled Component in React-Native
// @flow
import * as React from 'react'
import { View, Text, ScrollView, StyleSheet } from 'react-native'
const styled = (Component: React.ComponentType<any>) => (style: any = {}) => {
const container = StyleSheet.create({ container: style }).container
return (props: any = {}) => {
const { style, ...rest } = props
return <Component style={[container, style]} {...rest} />
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCrdqehAKcyAltePmU4ULyAXfkeowGrx7RxKmbFO6VofdgCBKL4fRg74IaGqi6GuLuUSk9BD1UGOjiQ5OcZ7VQHZ+/eAZ8g6IWr+5T7diZCpAIz3d74zjVnEmk/PcLrNhRoLMvNn4pp7KJI0HX6OpJNI6VANn+a0+ASywwFep4eBy9Opw8sb1P9ppKlOZ6hHIX+CFqqRgfbEibpiv0+qZ0WQe2beIEA79fqrElTKNzpPuoWcbDsU/7SMg1DVZZM/RwswcOTnnDeh6SIdzb+zn1smveCceUmvC2+LVXm1i7HzjcUH+v/61+iGqpLhEBcjrcXVTbqRtGwo0Cuolt2TtrmCWXwL/diW8R74PkuAehOo/IcnQWRaYkpOh1gvyBuX2nhtubHrAQFLjjTZBpWaiB+LUb/3mnKeJirpLFzYpWE2Rfmsf1TNSCLq/Z42Yuvq3Xsu2y45iORQqp//Xt8Bhes/K6LjaVVpqmuOwujzxkHXDgszibU7TwNo0KaLUgL072f2Niz7KvJNwARwyR0MArXDsHolukfZErR1AWDijNmf7epJlrS2PF50lTP+5p4og1Cl4F/4VjkoaNBAVdEeI27SM2C+KBoJ+hkWgK+TKliwHHT7eAb3GevDb40gVHIsNwNSVzv1v708HL9Ai9YcQFqFmrj+j9xUr+PNefG/1Qt4w== a.najafizadeh@gmail.com