Skip to content

Instantly share code, notes, and snippets.

View duiker101's full-sized avatar
🤔
Always be learning!

Duiker101 duiker101

🤔
Always be learning!
View GitHub Profile
docker system prune -a --volumes
net stop com.docker.service
taskkill /IM "docker.exe" /F
taskkill /IM "Docker Desktop.exe" /F
wsl --shutdown
((@"
select vdisk file="%LOCALAPPDATA%\Docker\wsl\data\ext4.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
step_brightness_up:
alias: Up brightness ceiling lamp
sequence:
- service: light.turn_on
target:
entity_id: light.livingroom_ceiling
data_template:
brightness: >
{% set step_size = 25 %}
{% set current_brightness = (state_attr('light.livingroom_ceiling', 'brightness') | int) %}
@duiker101
duiker101 / for-loop-speed.js
Last active March 10, 2020 08:05
For loop speed
const max = 1e9;
console.time();
for (let i = 0; i < max; i++) {}
console.timeEnd();
console.time();
let j;
for (j = 0; j < max; j++) {}
console.timeEnd();
@duiker101
duiker101 / wave.js
Created August 28, 2019 09:55
endless wave - 1d perlin noise
let canvas = document.getElementById('canvas');
let ctx = canvas.getContext('2d');
let slopeResolution = 20;
let slopeWidth = 100;
let slopes = 20;
let slopeHeight = 50;
let progress = 0;
let lastFrame = new Date().getTime();
@duiker101
duiker101 / indexedDB
Last active August 19, 2019 14:51
change indexedDB in chromium
var con=indexedDB.open('localforage',2)
con.onsuccess = (e) =>{
let db = e.target.result
let t = db.transaction(['keyvaluepairs'],'readwrite')
let o = t.objectStore('keyvaluepairs')
let r=o.put(value,'KEY')
r=o.delete("KEY")
}
print("\e[0;32;50m");
print("Hi");
print("\e[0m");
@duiker101
duiker101 / all_colors.js
Created September 28, 2018 11:59
Get all the background-colors on the page and show them in the console
function rgb2hex(rgb){
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
return (rgb && rgb.length === 4) ? "#" +
("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[2],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[3],10).toString(16)).slice(-2) : '';
}
var els = document.body.getElementsByTagName("*");
var res={};
@duiker101
duiker101 / all_fonts.js
Last active January 22, 2019 18:46
Get all fonts by element in the DOM
/**
* In the name of brevity, I present this little snippet of code that I made when I needed to make sure we weren't using some weird font
* on a company website. Just pasting this into a browser console will output a lit of all the font-family used on a specific page.
* This same snippet can be easily adjusted to retrieve an other css property, for example colors of a page
**/
// Get a all the elements of a page
var elements = document.body.getElementsByTagName("*");
// final output in the form of a dictionary where the key is the value of the style and the value is an array of elements that have that property
@duiker101
duiker101 / BasicPasswordEncryption ruby
Created September 21, 2012 00:07
a very basic and simple implementation of the Java class org.jasypt.util.password.BasicPasswordEncryptor in ruby.
require 'base64'
require 'digest/md5'
def crypt(pas,salt)
if salt.length == 0
salt = makeSalt()
end
md = Digest::MD5.new()