Skip to content

Instantly share code, notes, and snippets.

HelgeSverre /
Last active Jul 30, 2020
How to fix vue-moment locale issues and reactivity in Vue

Problem 1

If you are dynamically changing the locale of your vue application and setting the locale of moment js to that locale, your formatted dates will not be re-rendered, this is due to moments locale not being reactive (vue doesnt know that moment's internal state changed)


We need to create a custom renderless component that wraps the functionality we want, and whenever

HelgeSverre /
Last active Mar 21, 2020
How to make sorting work properly for Norwegian characters in MySQL - Æ Ø Å

If you have an issue with "order by " not working correctly with norwegian characters eg:

table: names

  • Andreas
  • Betty
  • Øystein
  • Ole martin
  • Ylvis
  • Åse Hansen
HelgeSverre / main.dart
Created Nov 2, 2019
utf8 decode error
View main.dart
import 'dart:convert';
import 'dart:typed_data';
void main() {
var name = "A string containing ø";
var bytes = Uint8List.fromList(name.codeUnits);
var decoded = json.decode(utf8.decode(bytes));
HelgeSverre / craft-save-plugin-settings.php
Last active Apr 4, 2018
How to update a setting attribute for a CraftCMS plguin
View craft-save-plugin-settings.php
$plugin = craft()->plugins->getPlugin('pluginHandle');
// This does NOT work.
$plugin->getSettings()->setAttribute("attributename", "attribute value");
// Do this instead!
View TenantHostnameScope.php
namespace App\Http\Middleware;
use App\Tenant;
use Closure;
use HipsterJazzbo\Landlord\Facades\Landlord;
class TenantHostnameScope
View TenantScope.php
namespace App\Http\Middleware;
use App\User;
use Auth;
use Closure;
use HipsterJazzbo\Landlord\Facades\Landlord;
class TenantScope
HelgeSverre / retry-for-loop.php
Created Feb 15, 2017
Simple Retrying for loop example
View retry-for-loop.php
$retries = 0;
$maxRetries = 3;
// Should fail this amount of times
$failCounter = 5;
for($i = 0; $i < 10; $i++) {
HelgeSverre / filter.js
Last active Feb 14, 2017
Simple class based jaavascript filtering solution using data attributes
View filter.js
$(".filters .filters__wrapper ul").on("click", "li", function () {
// Set clicked element as active
// Get the class to filter by
var filterClass = $(this).data("filter").trim();
// Get the grid this filter applies to (use data-grid="#some-id-here")
View array.php
$anArray = [
"stuff" => "stuff",
"stuff2" => "stuff",
"stuff3" => "stuff",
"stuff4" => "stuff",
View google-scraper.php
require_once "./vendor/autoload.php";
$client = new Goutte\Client();
$keywords = "helge sverre";
$crawler = $client->request('GET', '' . urlencode($keywords));