Skip to content

Instantly share code, notes, and snippets.

View obarisk's full-sized avatar

鐘翊修 obarisk

View GitHub Profile
@JustinSDK
JustinSDK / Map.go
Last active April 22, 2022 07:52
Go 介面:Map 實現
package main
import "fmt"
type Indicable interface {
Len() int
Idx(i int) any
}
type AnySlice []any
@JustinSDK
JustinSDK / Map.go
Created March 24, 2022 03:09
Go 泛型:Map 實現
package main
import "fmt"
func Map[T any](arr []T, fn func(T) T) []T {
newArr := make([]T, len(arr))
for i := 0; i < len(arr); i++ {
newArr[i] = fn(arr[i])
}
return newArr
@elico
elico / nftables-lb-wan.sh
Created August 25, 2020 03:07
Dual WAN Flow Base PCC nftables load balancing example script
#!/usr/bin/env bash
DEST_NET="192.168.111.0/24"
NEXT_HOPS="2"
NEXT_HOP_1="192.168.126.202"
NEXT_HOP_2="192.168.126.203"
NEXT_HOP_1_TABLE="202"
@goll
goll / README.md
Last active May 2, 2024 11:59
Docker nftables configuration for Debian 10
@shubhamagarwal92
shubhamagarwal92 / get_bert_embeddings.py
Created July 22, 2019 21:49
Use pytorch-transformers from hugging face to get bert embeddings in pytorch
import torch
import logging
from pytorch_transformers import BertModel, BertTokenizer
from pytorch_transformers import *
from typing import List
CLS_TOKEN = "[CLS]"
SEP_TOKEN = "[SEP]"
logger = logging.getLogger(__name__)
@timelyportfolio
timelyportfolio / Readme.md
Last active November 14, 2018 01:05
R Shiny + vuejs treeview

vuejs + Shiny

More Advanced Example

vuejs is beautiful and works extremely well with R, since vuejs does not require and all-in contract to use it. I have played quite a bit with R htmltools and vuejs, but until today, I have not explored Shiny with vuejs. This earlier gist R Shiny and Vue Simple Example offers a very simple illustration of how Shiny and vuejs can be best friends. Now, let's build from that example and get a TreeView of a Shiny plot brush.

Code

library(shiny)
@timelyportfolio
timelyportfolio / Readme.md
Last active July 21, 2021 14:36
R Shiny and Vue Simple Example

Shiny == good & Vue == good | Shiny + Vue == good?

Shiny Shiny.shinyapp.$inputValues acts like a store of state. I thought it would be fun to let vuejs react to changes in Shiny input values. This example is intentionally very simple to hopefully self-explain.

vueR

I have assembled vueR package, like d3r and reactR, to offer helpers for vuejs. For this example please install vueR, or just add tags$script(src = "https://unpkg.com/vue@2.2.6") to the tagList().

devtools::install_github("timelyportfolio/vueR")`
@drmalex07
drmalex07 / README-setup-tunnel-as-systemd-service.md
Last active May 4, 2024 15:04
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/secure-tunnel@.service. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target
@rasmusab
rasmusab / tensorflow_in_r_using_rpython.R
Last active April 25, 2018 02:35
An example of building a TensorFlow model from R using rPython
### An example of building a TensorFlow model from R using rPython ###
# For this script you need to
# 1. Have python 2.7 installed.
# 2. Install the rPython package in R.
# 3. Install Google's TensorFlow library as per these instructions:
# http://www.tensorflow.org/get_started/os_setup.md#binary_installation
### Here is how to setup and run a trivial TensorFlow model ###
# Load TensorFlow (I couldn't get this to work without setting sys.argv... )
@trestletech
trestletech / server.R
Last active February 2, 2022 09:47
A Shiny app combining the use of dplyr and SQLite. The goal is to demonstrate a full-fledged, database-backed user authorization framework in Shiny.
library(shiny)
library(dplyr)
library(lubridate)
# Load libraries and functions needed to create SQLite databases.
library(RSQLite)
library(RSQLite.extfuns)
saveSQLite <- function(data, name){
path <- dplyr:::db_location(filename=paste0(name, ".sqlite"))