Skip to content

Instantly share code, notes, and snippets.

View danielt69's full-sized avatar
:octocat:
Focusing

Daniel danielt69

:octocat:
Focusing
View GitHub Profile
@danielt69
danielt69 / gist:aed3683aa7121c2fe654d9879bb057bf
Created November 2, 2020 10:02
ps1.txt ( add to ~/.bashrc )
export PS1="\[\033[38;5;197m\]\u\[$(tput sgr0)\]@\[$(tput sgr0)\]\[\033[38;5;14m\]\H\[$(tput sgr0)\] \t \d:\[$(tput sgr0)\]\[\033[38;5;202m\][\w]\[$(tput sgr0)\]: \[$(tput sgr0)\]"
#!/bin/bash
# Before you start this script, edit the following file: /etc/wsl.conf
#
# [automount]
# enabled = true
# options = "metadata"
#
FULL_NAME=""
@danielt69
danielt69 / .htaccess
Created October 12, 2020 22:03 — forked from alexsasharegan/.htaccess
Apache Config for React Router - react .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
@danielt69
danielt69 / copy to clipboard.js
Last active August 18, 2020 15:12
copy to clipboard simple JS function
const copyToClipboard = str => {
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
@danielt69
danielt69 / manage-etc-hosts.sh
Created May 9, 2020 17:03 — forked from irazasyed/manage-etc-hosts.sh
Bash Script to Manage /etc/hosts file for adding/removing hostnames.
#!/bin/sh
# PATH TO YOUR HOSTS FILE
ETC_HOSTS=/etc/hosts
# DEFAULT IP FOR HOSTNAME
IP="127.0.0.1"
# Hostname to add/remove.
HOSTNAME=$1
version: '2'
services:
wordpress:
image: wordpress:latest
networks:
- front
- back
ports:
- 8080:80
environment:
@danielt69
danielt69 / matrixDigitalRain.js
Last active April 2, 2020 11:01
Matrix rain animation using HTML5 canvas and javascript
// https://codepen.io/P3R0/pen/MwgoKv
var matrix = (function(){
var init = function() {
document.body.style.background = 'black';
var mdr = document.createElement('canvas');
mdr.id = "mdr";
mdr.style.display = 'block';
mdr.style.position = 'fixed';
mdr.style.top = '0';
mdr.style.left = '0';
@danielt69
danielt69 / addEventListener_passive.js
Last active May 23, 2019 12:15
a better (performance) event listener
/* Feature detection */
var passiveIfSupported = false;
try {
window.addEventListener("test", null, Object.defineProperty({}, "passive", { get: function() { passiveIfSupported = { passive: true }; } }));
} catch(err) {}
window.addEventListener('scroll', function(event) {
/* do something */
// can't use event.preventDefault();
@danielt69
danielt69 / hideWPadminbar,js
Created May 10, 2019 09:16
hide wp admin bar in iframe
window.addEventListener('DOMContentLoaded', (event) => {
if (window != top) {
document.getElementsByTagName("html")[0].setAttribute('style', "margin-top: 0 !important");
document.getElementById("wpadminbar").remove();
}
});
@danielt69
danielt69 / document.ready.js
Last active January 9, 2019 09:28
document.ready my version of JQuery's $(document).ready()
document.ready = function(f){
f = f || function(){};
if (document.readyState == "interactive" || "complete") {
f();
} else {
document.addEventListener("DOMContentLoaded", function(e) {
f();
});
}
}