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 / index.php
Last active May 21, 2019 19:26
Example: Checkbox with values PHP
<?php
// If they selected the first checkbox!
if (isset($_POST['checkbox_1']) {
echo "You selected: $_POST['checkbox_1']";
}
// If they selected the second checkbox!
if (isset($_POST['checkbox_1'])) {
echo "You selected: $_POST['checkbox_1']";
@PatricNox
PatricNox / boss_noth.cpp
Created June 21, 2019 11:59
TrinityCore 3.3.5 Naxxramas BossScript
/*
* Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@PatricNox
PatricNox / PHP: Remove last part of String
Created August 9, 2019 09:11
PHP function that removes the last part of a string.
/**
* Remove the last part of a string.
*
* This function removes the last part of a string, conditioned on spaces
* inbetween the parts. Like words, in a sentence.
*
* @param String $string The string.
**/
function str_remove_lastpart($string) {
$string_parts = explode(' ',$string);
@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);
#!/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 / 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
@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 / 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 / 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 / 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