Skip to content

Instantly share code, notes, and snippets.

@raiscui
raiscui / fun.cpp
Created August 4, 2021 07:55 — forked from dant3/fun.cpp
Some fun with C++ 11 - fold, map, reduce, mkString for std::vector<T>
#include <iostream>
#include <sstream>
#include <functional>
#include <vector>
template <typename T, typename U>
U foldLeft(const std::vector<T>& data,
const U& initialValue,
const std::function<U(U,T)>& foldFn) {
typedef typename std::vector<T>::const_iterator Iterator;
@raiscui
raiscui / browserType.js
Last active March 26, 2020 07:13
BrowserType
export default function BrowserType() {
// 权重:系统 + 系统版本 > 平台 > 内核 + 载体 + 内核版本 + 载体版本 > 外壳 + 外壳版本
const ua = navigator.userAgent.toLowerCase();
const testUa = regexp => regexp.test(ua);
const testVs = regexp => ua.match(regexp)
.toString()
.replace(/[^0-9|_.]/g, "")
.replace(/_/g, ".");
// 系统
let system = "unknow";
function MakePlayConctrl(){
played = false;
function autoPlayAudio(video) {
// var video = document.getElementById(id).getElementsByTagName("video")[0];
if (window.WeixinJSBridge) {
WeixinJSBridge.invoke('getNetworkType', {}, function (e) {
played|| video.play().then(()=>{played=true});
@raiscui
raiscui / buffer.js
Created November 12, 2019 05:02 — forked from miguelmota/buffer.js
Node.js Buffer to ArrayBuffer
// @credit: http://stackoverflow.com/questions/8609289/convert-a-binary-nodejs-buffer-to-javascript-arraybuffer
// From Buffer to ArrayBuffer:
function toArrayBuffer(buffer) {
var ab = new ArrayBuffer(buffer.length);
var view = new Uint8Array(ab);
for (var i = 0; i < buffer.length; ++i) {
view[i] = buffer[i];
}
@raiscui
raiscui / wow_chroma.py
Created August 31, 2019 08:45 — forked from cb109/wow_chroma.py
Razer Chroma WoW Health and Mana
"""
Displays WoW health and mana status on a Razer Chroma keyboard.
Installation (Windows):
$ virtualenv venv
$ pip install requests
$ easy_install pillow
Usage:
- Run WoW client fullscreen on main monitor
// own.rim.db.gundb-graphdb-api-notes.js
// JavaScript based graph-DB module developer user guide wishes
// created by Leonard Pauli, 28 aug 2019
//
/* includes:
install/access module
(add, remove, change, traverse) values
get current value
simple data structures (set)
(subscribe, unsubscribe) to changes
@raiscui
raiscui / GunDBpermissionExample.js
Created August 20, 2019 23:18 — forked from ThinkingJoules/GunDBpermissionExample.js
GunDB group permissions example. Restrict reads and/or writes.
//CLIENT
Gun.on('opt', function (ctx) {
if (ctx.once) {
return
}
this.to.next(ctx)
ctx.on('auth', function(msg){
let to = this.to
clientAuth(ctx)
function clientAuth(ctx){
@raiscui
raiscui / reason-remote-data.re
Created August 7, 2019 06:11 — forked from busypeoples/reason-remote-data.re
ReasonML port remote-data
/*
remote-data ported to ReasonML
See also https://github.com/krisajenkins/remotedata
Tools for fetching data from remote sources (incl. HTTP).
*/
type remoteData 'e 'a
= NotAsked
| Loading
@raiscui
raiscui / Graph.re
Created August 7, 2019 06:09 — forked from busypeoples/Graph.re
Data Structures in ReasonML: #8 Graph
/* Graph */
exception Not_found;
type nodes = list(int);
type edges = list((int, int));
type graph =
| Empty
| Graph(nodes, edges);
@raiscui
raiscui / AvlTree.re
Created August 7, 2019 06:02 — forked from busypeoples/AvlTree.re
Data Structures in ReasonML: #6 AVL Tree
/* AVL Tree */
/* A balanced Binary Search Tree */
exception Undefined;
module type AvlTree = {
type t = int;
type height = int;
type tree('t) =
| Leaf
| Node(height, tree('t), 't, tree('t));