Skip to content

Instantly share code, notes, and snippets.

View ErlendEllingsen's full-sized avatar
☁️

Erlend Ellingsen ErlendEllingsen

☁️
View GitHub Profile
var exec = require('exec');
var colors = require('colors');
function fixDevice() {
console.log(colors.red('Usb device error... Resetting...'));
exec('sudo /home/pi/work/usbreset /dev/bus/usb/001/005', function(err, out, code) {
console.log(colors.blue('Usb device error... Resetting...'));
setTimeout(updatepic, 3000);
});
@ErlendEllingsen
ErlendEllingsen / phonegap-plugin-push-android-build-issue.MD
Created September 20, 2017 08:41
Cordova build error caused by conflict between Google Play Services update and phonegap-plugin-push

phonegap plugin push gradle build error

Status: Active/relevant
Importance: BLOCKER
Reported to developer: Yes

Date reported: 20.09.2017
Date solved: N/A

Hotfix available: Yes
@ErlendEllingsen
ErlendEllingsen / auto-script-url.php
Created January 29, 2018 13:42
PHP Auto script web url
<?php
//Create web link
$linkPrefix = (APP_ENVIRONMENT == APP_ENVIRONMENT_PROD ? 'https://' : 'http://');
define('APP_WWW_PATH', $linkPrefix . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']));
?>
<?php
class InFields {
/**
* Fetches value from POST.
* $fields array with post fields to be fetched
* $strict if strict mode is enabled, the fields will be required (if not, they will be added, but have null as value)
* $stringFilter if the stringFilter is enabled, the variables are ran through filter_var with FILTER_SANITIZE_STRING
*
<?php
class BasePathGenerator {
private static $isSet = false;
private static $foundBasePath = null;
public static function get() {
if (self::$isSet) return self::$foundBasePath;
if (!isset($_SERVER['REQUEST_URI'])) return false;
$jumps = explode('/', $_SERVER['REQUEST_URI']);
$c = count($jumps);
$c--; //Remove first element
<?php
class BasePathGenerator {
private static $isSet = false;
private static $foundBasePath = null;
public static function get() {
if (self::$isSet) return self::$foundBasePath;
if (!isset($_SERVER['REQUEST_URI'])) return false;
$jumps = explode('/', $_SERVER['REQUEST_URI']);
$c = count($jumps);
$c--; //Remove first element
@ErlendEllingsen
ErlendEllingsen / email-link-decoder.js
Created December 28, 2018 14:31
Decode email links
@ErlendEllingsen
ErlendEllingsen / price
Last active September 27, 2022 05:19
Price example
// Command:
/price <itemname|itemid>
/stackprice <itemname|itemid>
// Example
/price flask of titans
/stackprice dreamfoil
@ErlendEllingsen
ErlendEllingsen / crafting-price
Last active September 27, 2022 05:19
Crafting price
// Syntax
/craftprice <itemname|itemid>
// Examples
/craftprice Major Mana Potion
/craftprice Brilliant Wizard Oil