Skip to content

Instantly share code, notes, and snippets.

@OrionReed
OrionReed / dom3d.js
Last active July 2, 2024 23:21
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; // ¯\\_(ツ)_/¯
@s417-lama
s417-lama / svg2pdf.bash
Created April 29, 2020 07:18
Reliable way to convert an SVG file to a PDF file using headless Chrome
#!/bin/bash
#
# Convert an SVG file to a PDF file by using headless Chrome.
#
if [ $# -ne 2 ]; then
echo "Usage: ./svg2pdf.bash input.svg output.pdf" 1>&2
exit 1
fi
@joielechong
joielechong / hosts
Last active February 2, 2022 23:29 — forked from eyecatchup/hosts
Disable Skype ads: 1.) Add hosts to your hosts file 2.) Flush DNS resolver cache (ipconfig /flushdns)
# On Windows 7, 8, 10 Hosts file is in c:\windows\system32\drivers\etc\hosts
#
# Block Skype ads
127.0.0.1 secure-sin.adnxs.com # On skype 7.*
127.0.0.1 *.adnxs.com # On skype 7.*
127.0.0.1 logi10.xiti.com # On skype 7.*
127.0.0.1 *.everesttech.net # On skype 7.*
127.0.0.1 pixel.everesttech.net # On skype 7.*
127.0.0.1 d.adroll.com # On skype 7.*
@pudquick
pudquick / python_sysctl.py
Last active June 10, 2024 04:01
Calling sysctl from python via ctypes
from ctypes import CDLL, c_uint, byref, create_string_buffer
from ctypes.util import find_library
libc = CDLL(find_library("c"))
def sysctl(name, isString=True):
size = c_uint(0)
# Find out how big our buffer will be
libc.sysctlbyname(name, None, byref(size), None, 0)
# Make the buffer
buf = create_string_buffer(size.value)
@eddiejaoude
eddiejaoude / most-active-users-on-github-2015.md
Last active November 30, 2017 10:30
Most active users on GitHub 2015

This is the top 1000 users on GitHub

Where are you on here?

For the first 6 months of 2015 (Jan - June).

Query used on Google's BigQuery with GitHubArchive Data

SELECT actor.login as user, COUNT(*) as total FROM (
@azam
azam / svg2ico.sh
Last active April 28, 2024 03:28
Convert SVG to ICO using ImageMagick, with transparent background and multi-size icons
convert -density 256x256 -background transparent favicon.svg -define icon:auto-resize -colors 256 favicon.ico
@bfroehle
bfroehle / With Magic Demo.ipynb
Last active December 16, 2015 07:49
%with / %endwith IPython extension
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@asmeurer
asmeurer / expressions.py
Created March 13, 2013 06:14
Large trig expressions These all simplify.
This file has been truncated, but you can view the full file.
from sympy import S
######## small size expression
smallExpr = S('(((-sin(q1)*sin(q3) + cos(q1)*cos(q2)*cos(q3))*sin(q4) - sin(q2)*cos(q1)*cos(q4))*sin(q1) - ((sin(q1)*cos(q2)*cos(q3) + sin(q3)*cos(q1))*sin(q4) - sin(q1)*sin(q2)*cos(q4))*cos(q1))*(ddq1*sin(q2)*sin(q3) - ddq2*((-sin(q1)*cos(q3) - sin(q3)*cos(q1)*cos(q2))*sin(q1) - (-sin(q1)*sin(q3)*cos(q2) + cos(q1)*cos(q3))*cos(q1)) - ddq3*(-(-sin(q1)*cos(q3) - sin(q3)*cos(q1)*cos(q2))*sin(q2)*cos(q1) - (-sin(q1)*sin(q3)*cos(q2) + cos(q1)*cos(q3))*sin(q1)*sin(q2) - sin(q2)*sin(q3)*cos(q2)) - ddq4*((-sin(q1)*cos(q3) - sin(q3)*cos(q1)*cos(q2))**2 + (-sin(q1)*sin(q3)*cos(q2) + cos(q1)*cos(q3))**2 + sin(q2)**2*sin(q3)**2) + dq1*dq2*sin(q3)*cos(q2) + dq1*dq3*sin(q2)*cos(q3) - dq2*(dq1*(-sin(q1)*cos(q3) - sin(q3)*cos(q1)*cos(q2))*cos(q1) + dq1*(-sin(q1)*sin(q3)*cos(q2) + cos(q1)*cos(q3))*sin(q1) - (-dq1*sin(q1)*cos(q3) - dq1*sin(q3)*cos(q1)*cos(q2) + dq2*sin(q1)*sin(q2)*sin(q3) - dq3*sin(q1)*cos(q2)*cos(q3) - dq3*sin(q3)*cos(q1))*cos(q1) + (dq1*sin(q1)*sin(q3)*co
@gromgull
gromgull / unmatchedgroup.py
Created October 20, 2012 06:01
Python "unmatched group" regex replace workaround
import re
def re_sub(pattern, replacement, string):
def _r(m):
# Now this is ugly.
# Python has a "feature" where unmatched groups return None
# then re.sub chokes on this.
# see http://bugs.python.org/issue1519638
# this works around and hooks into the internal of the re module...
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: