Skip to content

Instantly share code, notes, and snippets.

View XD-DENG's full-sized avatar
🪂

Xiaodong DENG XD-DENG

🪂
View GitHub Profile
@XD-DENG
XD-DENG / simplified_consistent_hashing_ring.py
Created August 4, 2020 07:40
A simplified Consistent Hashing Ring Implementation based on Mike Bayer (zzzeek)'s Python 2 code
# Reference:
# https://techspot.zzzeek.org/2012/07/07/the-absolutely-simplest-consistent-hashing-example/
# Changes done on top of Mike Bayer's original Implementation
# - Remove replica concept to (over)simplify the code
# - Address Python2 -> Python3 changes
import bisect
import hashlib
@XD-DENG
XD-DENG / server.R
Created May 24, 2016 01:48 — forked from trestletech/server.R
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"))
@XD-DENG
XD-DENG / server.R
Created May 24, 2016 01:44 — forked from withr/server.R
Encrypt password with md5 for Shiny-app.
library(shiny)
library(datasets)
Logged = FALSE;
PASSWORD <- data.frame(Brukernavn = "withr", Passord = "25d55ad283aa400af464c76d713c07ad")
# Define server logic required to summarize and view the selected dataset
shinyServer(function(input, output) {
source("www/Login.R", local = TRUE)
observe({
if (USER$Logged == TRUE) {
// TMP36 Pin Variables
// the analog pin the TMP36's Vout (sense) pin is connected to
// the resolution is 10 mV / degree centigrade with a
// 500 mV offset to allow for negative temperatures
int sensorPin = 0;
void setup()
{
Serial.begin(9600); //Start the serial connection with the computer
//to view the result open the serial monitor
}
@XD-DENG
XD-DENG / global.R
Created March 26, 2016 15:26 — forked from SachaEpskamp/global.R
A general shiny app to import and export data to R. Note that this can be used as a starting point for any app that requires data to be loaded into Shiny.
library("shiny")
library("foreign")
@XD-DENG
XD-DENG / server.R
Created March 19, 2016 04:28 — forked from xiaodaigh/server.R
Shiny: Disable Button
library(shiny)
disableActionButton <- function(id,session) {
session$sendCustomMessage(type="jsCode",
list(code= paste("$('#",id,"').prop('disabled',true)"
,sep="")))
}
shinyServer(function(input, output,session) {
@XD-DENG
XD-DENG / prime_deng.cpp
Last active November 27, 2015 07:51
test
/*
// Skills included in this script:
// (1) FOR loop;
// (2) IF statement;
// (3) Get the current time;
// (4) Usage of vector (build, insert, size);
// (5) How to convert int into string;
// (6) Write into file;
// (7) Output;
*/
@XD-DENG
XD-DENG / gist:07c733e6555a10c01762
Created October 14, 2015 02:07
Python AES two-way encryption/decryption example
from Crypto.Cipher import AES
import base64
import os
# the block size for the cipher object; must be 16, 24, or 32 for AES
BLOCK_SIZE = 32
# the character used for padding--with a block cipher such as AES, the value
# you encrypt must be a multiple of BLOCK_SIZE in length. This character is
# used to ensure that your value is always a multiple of BLOCK_SIZE