Skip to content

Instantly share code, notes, and snippets.

@wuchengwei
wuchengwei / dataURL to blob and blob to dataURL
Last active May 12, 2024 21:49
dataURL to blob and blob to dataURL
//**dataURL to blob**
function dataURLtoBlob(dataurl) {
var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
while(n--){
u8arr[n] = bstr.charCodeAt(n);
}
return new Blob([u8arr], {type:mime});
}
@Ayke
Ayke / cuda-wsl2-ubuntu.md
Last active May 12, 2024 21:49
Everything About CUDA in WSL2 Ubuntu

Prerequisites, i.e. the most important things

  1. Time of writing: Jan 18, 2023. The following assume you're trying to install CUDA on WSL2 Ubuntu.

  2. Check support matrix first before you install any version of CUDA, because chances are the latest CUDA does not have cuDNN support yet, then you'll have to re-install older version if you found out later.

    https://docs.nvidia.com/deeplearning/cudnn/support-matrix/index.html#cudnn-cuda-hardware-versions

    At the time of writing, the latest cuDNN version is 8.7 and it supports CUDA 11.8.

  3. Windows 10 must be build 20145 or later.

@aluissp
aluissp / tailwind.config.js
Created February 12, 2023 20:45
Fade in animation in Tailwind CSS
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {
animation: {
fade: 'fadeIn .5s ease-in-out',
},
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Custom Scrollbar</title>
<style>
.scroll-box {
position: relative;
width: 300px; /* Adjust to fit your design */
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Custom Scrollbar</title>
<style>
.scroll-box {
position: relative;
width: 300px; /* Adjust to fit your design */
@saxxie-dev
saxxie-dev / tiktok-blockout-helper.js
Created May 12, 2024 21:37
Simple script for blocking people on the tiktok web search page. Be careful when copy-pasting code from the internet!
// Grab csrf token to get around XSS controls.
const csrfToken = JSON.parse(__UNIVERSAL_DATA_FOR_REHYDRATION__.textContent).__DEFAULT_SCOPE__["webapp.app-context"].csrfToken;
// Eavesdrop on search requests and create mapping between userId and sec_uid
const userIdMapping = new Map();
const realFetch = fetch;
window.fetch = (url, ...vars) => {
return realFetch(url, ...vars).then(async (res) => {
if (url.toString().match(/search\/user\/full/)) {
// After getting new results, add block button to them

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Custom Scrollbar</title>
<style>
.scroll-box {
position: relative;
width: 300px; /* Adjust to fit your design */

Comment to https://www.reddit.com/r/ProgrammingLanguages/comments/1cphrxp/is_this_a_sane_set_of_tokens_for_my_lexer_a_few/

Also, do you guys have any resources on algorithms on ASTs, for type checking, maybe about linear typing and borrow checking as well? That's assuming the AST is the place where I'm supposed to check this sort of stuff.

There are a number of different approaches to typechecking, so there isn't a single answer or direction to go. For systems that support strong type inference, there are two well-known approaches: Hindley-Milner (HM) and bidirectional (bidir) systems, and these approaches aren't entirely separate (HM is often put in bidirectional checking to help with generics). There is also the simpler unidirectional approach taken by older languages e.g. Java, and the simpler way of handling generics by annotating every generic function and datastructure.

Giving direction on typechecking is unfortunately difficult because it is opinionated, because there is a line to straddle with wh

@pauloromeira
pauloromeira / tlp
Last active May 12, 2024 21:36
My TLP config file (/etc/default/tlp) for ThinkPad
# ------------------------------------------------------------------------------
# tlp - Parameters for power saving
# See full explanation: http://linrunner.de/en/tlp/docs/tlp-configuration.html
# dir: /etc/default/tlp
# Hint: some features are disabled by default, remove the leading # to enable
# them.
# Set to 0 to disable, 1 to enable TLP.