Skip to content

Instantly share code, notes, and snippets.

@OrionReed
OrionReed / dom3d.js
Last active May 9, 2024 01:03
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@RyanNielson
RyanNielson / TrackTargets.cs
Created March 30, 2014 20:15
A orthographic camera script for Unity that keeps all targets in frame by adjusting orthographic size and camera position.
using UnityEngine;
public class TrackTargets : MonoBehaviour {
[SerializeField]
Transform[] targets;
[SerializeField]
float boundingBoxPadding = 2f;
@anddam
anddam / xsrf.interceptor.ts
Last active May 9, 2024 01:02
Angular HttpClientXsrfModule example
import { Injectable } from '@angular/core';
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpXsrfTokenExtractor } from '@angular/common/http';
import { Observable } from 'rxjs';
@Injectable()
export class HttpXSRFInterceptor implements HttpInterceptor {
constructor(private tokenExtractor: HttpXsrfTokenExtractor) {
}
@mi-lee
mi-lee / unlike-delete-hide-facebook-posts.js
Last active May 9, 2024 01:00
Bulk delete, unlike, hide, or remove Facebook actions (in Activity Feed) by year.
// DISCLAIMER: I'VE ONLY RUN THIS SCRIPT ON MY OWN ACCOUNT ONLY. PROCEED/USE WITH RISK! I MADE THIS SCRIPT IN 20 MINUTES SO BE WARNED!
// On the other hand, I've deleted 50,000 comments in a matter of minutes so it's been pretty damn handy
// 1. Go to Activity feed, like facebook.com/<username>/allactivity
// 2. Navigate to specific section of FB, like "Likes and Reactions" or "Comments",
// like https://www.facebook.com/<username>/allactivity?privacy_source=activity_log&log_filter=cluster_<clusterid>
// 3. Navigate to year that you want to batch delete. You may need to scroll a little bit to let it load
// 4. Once you enter this there's no going back!!
@importRyan
importRyan / whenHovered.md
Last active May 9, 2024 00:57
Reliable SwiftUI mouse hover

Reliable mouseEnter/Exit for SwiftUI

Kapture 2021-03-01 at 14 43 39

On Mac, SwiftUI's .onHover closure is not always called on mouse exit, particularly with high cursor velocity. A grid of targets or with finer target shapes will often have multiple targets falsely active after the mouse has moved on.

It is easy to run back to AppKit's safety. Below is a SwiftUI-like modifier for reliable mouse-tracking. You can easily adapt it for other mouse tracking needs.

import SwiftUI
@Nxtra
Nxtra / delete-all-models.py
Created January 17, 2020 07:38
Delete all sagemaker models
import boto3
from pprint import pprint
client = boto3.client('sagemaker')
def main():
model_names = []
for key in paginate(client.list_models):
from math import sin
import sdcardio
import storage
import audiobusio
import audiocore
import audiomixer
import audiomp3
import board
import time
import math
@ricardodantas
ricardodantas / validacao+mascara.js
Last active May 9, 2024 00:46
Máscara e validação de RG, CNPJ, CPF, etc...
// JavaScript Document
// adiciona mascara para rg
// Cada estado têm regras e quantidades diferentes de números no registro. Por isso,
// não há uma maneira confiável de fazer a validação do mesmo.
function MascaraRg(v0,errChar='?'){
const v = v0.toUpperCase().replace(/[^\dX]/g,'');
return (v.length==8 || v.length==9)?
v.replace(/^(\d{1,2})(\d{3})(\d{3})([\dX])$/,'$1.$2.$3-$4'):
(errChar+v0)
@mblondel
mblondel / statistical_tests.py
Last active May 9, 2024 00:46
t-test and wilcoxon-test examples in Python
# Mathieu Blondel, February 2012
# License: BSD 3 clause
# Port to Python of examples in chapter 5 of
# "Introductory Statistics with R" by Peter Dalgaard
import numpy as np
from scipy.stats import ttest_1samp, wilcoxon, ttest_ind, mannwhitneyu
# daily intake of energy in kJ for 11 women
@laloe74
laloe74 / hamster.yaml
Last active May 9, 2024 00:46
仓输入法 微信键盘布局+配色
# 仓输入法
#「微信键盘配色」+ 「微信键盘布局」
# 可以导入在线定义平台,按需求修改 <https://lost-melody.github.io/hamster-tools/>
#
# 完整方案 <https://github.com/laloe74/rime-settings>
#
# Bug
# 黑暗模式中,如果背景是大面积白色(例如在窗口中登录谷歌账号),「字母按键背景」将和「键盘背景」几乎同色,不易区分。
# 要解决以上问题,需将「键盘背景」设为不透明,但又会使得「键盘背景」和「键盘底部条」有色差,视觉效果不统一。
# 目前是将「键盘背景」设为透明,这样大部分场景视觉效果较好。