Skip to content

Instantly share code, notes, and snippets.

@Wang-Kai
Wang-Kai / ladon_vs_casbin.md
Last active April 29, 2024 10:40
ladon & casbin 两个 authorization 库的比较

通览了 casbin 的文档,结合先前对 AWS IAM 的理解,以及对 ladon SDK 的使用,总结对比一下 Ladon & Casbin 两个授权库。

1. 项目定位

先对比两个项目的简介:

ladon

A SDK for access control policies: authorization for the microservice and IoT age. Inspired by AWS IAM policies. Written for Go.

@douglasrizzo
douglasrizzo / tf_obj_tutorial.md
Last active November 15, 2023 22:36
TensorFlow Object Detection Model Training
@andrwng
andrwng / poweroftwochoices.py
Last active October 4, 2019 05:21
Power of two choices implementation for group selection in python
#!/usr/bin/python
import random
import numpy as np
from matplotlib import pyplot as plt
"""
Straight-forward implementation of PO2C.
"""
def po2c(num_buckets, num_groups, group_size):
@allwefantasy
allwefantasy / autoencoder-sentence-similarity.py
Last active April 28, 2020 02:39
使用自编码器网络实现语句相似度
import tensorflow as tf
import random
import numpy as np
import time
BASIC_HOME = "/Users/allwefantasy/Downloads"
WORD_VECTOR_FILE = BASIC_HOME + '/laiwen/zhuhl_laiwen_word_embedding'
WORD_FILE = BASIC_HOME + '/laiwen/zhuhl_laiwen_keywords2'
WORD_RESULT_VECTOR_FILE = BASIC_HOME + '/laiwen/WORD_RESULT_VECTOR_FILE4'
MODEL_SAVE_DIR = BASIC_HOME + '/laiwen/model/autoencoder'
@monikkinom
monikkinom / rnn-lstm.py
Last active September 3, 2019 04:44
Tensorflow RNN-LSTM implementation to count number of set bits in a binary string
#Source code with the blog post at http://monik.in/a-noobs-guide-to-implementing-rnn-lstm-using-tensorflow/
import numpy as np
import random
from random import shuffle
import tensorflow as tf
# from tensorflow.models.rnn import rnn_cell
# from tensorflow.models.rnn import rnn
NUM_EXAMPLES = 10000
@beeva-enriqueotero
beeva-enriqueotero / docker-neuraltalk2-demo-camera.sh
Last active December 24, 2021 10:19
docker-neuraltalk2 demo
# docker-neuraltalk2 demo with webcam support (Warning: docker-neuraltalk2 image size > 3GB)
# Launch interactive container:
docker run -i -t -p 8000:8000 --privileged -v /dev/video0:/dev/video0 beevaenriqueotero/docker-neuraltalk2 /bin/bash
# And then execute:
git clone https://github.com/Mithul/neuraltalk2.git neuraltalk2-camera
luarocks install camera
cd neuraltalk2-camera/vis
python -m SimpleHTTPServer &
cd ..
@joshnuss
joshnuss / app.js
Last active March 4, 2024 00:01
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@gregersrygg
gregersrygg / README.md
Last active July 28, 2020 17:01
Use a Raspberry Pi as a baby monitor

What you need:

  • Raspberry Pi RevB
  • Raspberry Pi NoIR camera

Download raspbian and install to SD-card. Here is a good guide on how to install the .img file to the card: https://www.andrewmunsell.com/blog/getting-started-raspberry-pi-install-raspbian

Connect ethernet or wifi, then boot the Raspberry Pi and follow configuration options. Make sure you enable the camera option.

When you get to the command-line:

@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@djangofan
djangofan / gist:3113588
Created July 14, 2012 21:50
Cron job script to give a disk space usage alert email
#!/bin/sh
# this script was initially written for Redhat/CentOS
# file is /etc/cron.daily/diskAlert.cron
# requires enabling outgoing sendmail from localhost to a valid
# smtp server, which is usually disabled by default
ADMIN="jausten@adomain.com,another@adomain.com"
THRESHOLD=90
df -PkH | grep -vE '^Filesystem|tmpfs|cdrom|media' | awk '{ print $5 " " $6 }' | while read output;
do