Skip to content

Instantly share code, notes, and snippets.

View hrlai's full-sized avatar
🛰️
Open the portbay door, please

Lai Hao Ran hrlai

🛰️
Open the portbay door, please
View GitHub Profile
@logical-and
logical-and / README.md
Last active October 22, 2023 13:02 — forked from pcworld/_README.md
Linux Spotify Ad Mute

We all love Spotify, but sometimes people (like us) want to throw a party without having to listen to interrupting ads before having bought Spotify Premium. Well, with this killer project, now you can!

This is for testing purposes ONLY! Spotify is a fantastic service and worth every penny. This script is NOT meant to circumvent buying premium! Please do consider switching to premium to support Spotify - especially if you're going to use it on mobile. If the script does not work for you, help us improve it!

Usage

wget -O spotify-mute-ads.sh https://gist.githubusercontent.com/logical-and/825bab160d604d82bf6ad9ebd3a6410d/raw/84f77518f6fa8980e73fcf1fadd30d223f2100a1/spotify-mute-ads.sh
chmod ug+x spotify-mute-ads.sh
./spotify-mute-ads.sh 
#' NDC caching for cross-facet plot elements
#'
#' Useful when using [layout()] and drawing things *between* different
#' plots. Motivated by https://stackoverflow.com/q/49464991/3358272.
#'
#' @details
#'
#' When adding plot "things" (lines, points, arrows) between facets of
#' a `layout` combination, in addition to `x` and `y`, you simply
#' provide the plot number within the sequence. (Since this is the
@lopspower
lopspower / README.md
Last active July 26, 2024 10:57
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@jschaub30
jschaub30 / gist:a5f687a922c8c41baa64
Created May 15, 2015 23:01
Convert JSON to CSV in R
#https://www.kaggle.com/c/yelp-recruiting/forums/t/4116/convesio-of-json-files-to-csv-or-r-data-format
library(plyr)
library(RJSONIO)
con <- file('data.json', "r")
df <- ldply(fromJSON(con), data.frame)
close(con)
@EconometricsBySimulation
EconometricsBySimulation / gist:d0af8273f15b6ccb85a4
Last active September 12, 2023 04:23
Rapidly sample from arbitrary pdf
I recently found myself in need of a function to sample randomly from an arbitrarily defined probability density function. An excellent post by Quantitations shows how to accomplish this using some of Rs fairly sophisticated functional approximation tools such as integrate and uniroot. The only problem with this excellent post was that the machine cost was enormous with samples of 1000 draws taking 10 seconds on my machine and repeated samples of 100,000+ draws (which I was after) clearly being unworkable.
Thus I decided to take my own crack at it. First let us review the basics of drawing random variables from non-uniform distributions. The standard method I think most algorithms use works as follows:
Assumptions
1. You can draw pseudo-random uniform variable u
2. You can integrate the pdf to construct a cdf
$$p = F(x) = \int_{-\infty}^\infty f(x) dx$$
3. You can invert the cdf in order to solve for p
$$G(F(x))=F^{-1}(F(x))=F^{-1}(p)=x$$
@gavinsimpson
gavinsimpson / derivSimulCI.R
Last active March 21, 2019 08:23
First derivatives and simultaneous confidence intervals for GAM spline terms
`derivSimulCI` <- function(mod, n = 200, eps = 1e-7, newdata, term,
samples = 10000) {
stopifnot(require("MASS"))
if(inherits(mod, "gamm"))
mod <- mod$gam
m.terms <- attr(terms(mod), "term.labels")
if(missing(newdata)) {
newD <- sapply(model.frame(mod)[, m.terms, drop = FALSE],
function(x) seq(min(x), max(x) - (2*eps), length = n))
names(newD) <- m.terms
@davharris
davharris / boot.R
Created June 12, 2014 20:17
code for plotting bootstrap predictions from a nonlinear model
set.seed(1)
# Create fake data
x = runif(100, 0, 5)
y = .25 * x^3 - x^2 + rnorm(length(x))
data = data.frame(x = x, y = y)
# Identify 500 points to include in the plots
x.sequence = seq(0, 5, length = 500)
@gitaarik
gitaarik / git_submodules.md
Last active July 26, 2024 13:44
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
@pcworld
pcworld / _README.md
Last active June 19, 2024 03:06
Linux Spotify Ad Mute