Skip to content

Instantly share code, notes, and snippets.

@MilesMcBain
MilesMcBain / cloud_view.R
Created June 27, 2022 23:50
cloud_view()
cloud_view <- function(obj) {
withr::with_options(
list(viewer = function(url, ...) {
get_url_dir <- function(url) gsub("file://|/index.html", "", url)
server <- servr::httd(
dir = get_url_dir(url),
verbose = TRUE,
browser = FALSE
)
.vsc.browser(server$url, ...)
@ruby0x1
ruby0x1 / hash_fnv1a.h
Last active May 29, 2024 17:19
FNV1a c++11 constexpr compile time hash functions, 32 and 64 bit
#pragma once
#include <stdint.h>
//fnv1a 32 and 64 bit hash functions
// key is the data to hash, len is the size of the data (or how much of it to hash against)
// code license: public domain or equivalent
// post: https://notes.underscorediscovery.com/constexpr-fnv1a/
inline const uint32_t hash_32_fnv1a(const void* key, const uint32_t len) {
@daniel-j-h
daniel-j-h / pgo.sh
Last active May 2, 2024 19:05
pgo: profile guided optimization with gcc
# Instrument binaries, pgo data to /data/pgo, serial make is important to not confuse the pgo generator
env CXXFLAGS='-march=native -fprofile-dir=/data/pgo -fprofile-generate=/data/pgo' cmake .. -DCMAKE_BUILD_TYPE=Release
make -j 1
# Run instrumented program, generate and write pgo data
./runIt
# Use profile data and feed into gcc, correct for threading counter noise, serial make is important to not confuse the pgo generator
env CXXFLAGS='-march=native -fprofile-dir=/data/pgo -fprofile-use=/data/pgo -fprofile-correction' cmake .. -DCMAKE_BUILD_TYPE=Release
make -j 1
@cyio
cyio / README.md
Last active January 9, 2021 02:55
【用户脚本】国内视频网站自动调用HTML5播放器

这是一个油猴脚本,代码引用自zythum/mama2,我(Oaker)只是搬运。

功能:访问国内主流视频网站时,自动调用HTML播放器。暂时只做了初步的网址匹配。

@jennybc
jennybc / 2014-09-18_numeric-index-gotcha.md
Last active August 29, 2015 14:06
How quickly indexing with numeric can burn you

Inspired by recent @johnmyleswhite tweets on indexing (though they focus more on NA stuff)

My standard advice to R novices is "don't worry about numeric vs integer too much, for now", but I just created an indexing example that scares me.

I did not realize it was sooo easy to create this gotcha when indexing with numeric (which I know is not a great idea).

@rmflight
rmflight / post-commit
Last active March 29, 2024 19:43
useful commit hooks for R package dev
#!/path/2/Rscript
# License: CC0 (just be nice and point others to where you got this)
# Author: Robert M Flight <rflight79@gmail.com>, github.com/rmflight
#
# This is a post-commit hook that after a successful commit subsequently increments the package version in DESCRIPTION
# and commits that. Analogous to the pre-commit at https://gist.github.com/rmflight/8863882, but useful if you only have
# good reasons for not doing it on the pre-commit.
#
# To install it, simply copy this into the ".git/hooks/post-commit" file of your git repo, change /path/2/Rscript, and make
@andreyvit
andreyvit / tmux.md
Created June 13, 2012 03:41
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a