Skip to content

Instantly share code, notes, and snippets.

View PatricNox's full-sized avatar
🔰
Open-Source enthusiast

PatricNox PatricNox

🔰
Open-Source enthusiast
View GitHub Profile
@PatricNox
PatricNox / dev-bash_profile
Last active October 17, 2023 07:01
Update my dev config to the latest
## General shorthands.
alias update='source ~/.bashrc'
alias sshkey="cat ~/.ssh/id_rsa.pub | pbcopy"
alias httpdconf="code /usr/local/etc/httpd/httpd.conf"
alias ll='ls -la'
alias serve='yarn install && yarn serve'
alias eserve='yarn install && yarn electron:serve'
alias ylint='yarn lint --fix && yarn lint'
alias sshconfig="code ~/.ssh/config"
alias bashprofile="code ~/.bash_profile"
@PatricNox
PatricNox / vue2-datepicker.d.ts
Created February 3, 2022 09:24
type file for vue2-datepicker
declare module "vue2-datepicker" {
import { Component } from "vue/types/options";
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/interface-name-prefix */
interface IShortcuts {
text: string;
start: Date;
end: Date;
}
@PatricNox
PatricNox / change-author-of-pushed-commits.sh
Last active October 7, 2020 08:40
Change author of pushed commits in git
git filter-branch -f --env-filter '
OLD_EMAIL="patric.johansson@ucsit.se"
CORRECT_NAME="PatricNox"
CORRECT_EMAIL="hello@PatricNox.info"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
@PatricNox
PatricNox / db-init.sh
Created February 11, 2020 15:22
Database Init script for Wordpress sites through Docker
#!/bin/sh
#
# This file needs to be executed once a new database is imported.
# What this does, is updating database to tell wordpress that the site should
# be runned on localhost.
#
## Supress warning.
export MYSQL_PWD=wordpress
@PatricNox
PatricNox / init.sh
Created February 11, 2020 15:18
Init script for Wordpress sites through Docker
#!/bin/sh
#
# This file needs to be executed once a new file system is imported.
# What this does, is updating project settings to have localhost as root.
#
# Dev settings & htaccess.
if [ -f "src/wp-config.php" ]; then
rm src/wp-config.php
@PatricNox
PatricNox / input_type_time-calculate-difference.js
Last active January 16, 2020 09:57
Calculate the difference between two html time field types
<!-- HTML fields -->
<input type="time" class="field--time-period-from">
<input type="time" class="field--time-period-to">
<input type="text" class="field--time-difference" disabled>
<script>
// Get the inputs.
let timeField = document.querySelector('.field--time-difference');
let from = document.querySelector('.field--time-period-from').value;
let to = document.querySelector('.field--time-period-to').value;
@PatricNox
PatricNox / _match_array_content.php
Last active September 12, 2019 12:31
Find identical content between two arrays.
<?php
/**
* Find identical content between two arrays.
*
*
* @param Array $first_array
* @param Array $second_array
* @return Array
**/
@PatricNox
PatricNox / insane-darude-sandstorm.ino
Last active September 3, 2019 11:30
insane darude sandstorm - Processor & Arduino
#define NOTE_B0 31
#define NOTE_C1 33
#define NOTE_CS1 35
#define NOTE_D1 37
#define NOTE_DS1 39
#define NOTE_E1 41
#define NOTE_F1 44
#define NOTE_FS1 46
#define NOTE_G1 49
#define NOTE_GS1 52
#!/bin/sh
#####
# These two shell commands goes through all subfolders in the current standing folder
# and deletes vendor & node_module folder.
####
# Recursively find and delete all folders called: "node_modules"
### Used by npm.
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
@PatricNox
PatricNox / sunrise_sunset.php
Created September 3, 2019 09:34
PHP - Get the sunrise/sunset time with accuracy
<?php
/*
* Calculate the sunrise/sunset time for Gothenburg, Sweden
*
* Latitude: 57.696991
* Longitude: 11.986500)
*/
$date_sun_info = date_sun_info(strtotime("2019-09-03"), 57.696991, 11.986500);