Skip to content

Instantly share code, notes, and snippets.

View jonmorten's full-sized avatar

Jon-Morten Kristiansen jonmorten

View GitHub Profile
@jonmorten
jonmorten / main.go
Last active September 23, 2021 08:14
Random number in Go
package main
import (
crypto_rand "crypto/rand"
"encoding/binary"
"fmt"
math_rand "math/rand"
)
func main() {
const TestIntl = () => {
const t = useFormatMessage()
return (
<div>
{ t({ id: 'preferences' }) }
</div>
)
}
const App = () =>
@jonmorten
jonmorten / apache_ip_access.conf
Created January 18, 2016 12:19
Apache config for IP based access
# Certain URL
<Location /<URL>>
Order Deny,Allow
Deny from all
Allow from <IP>
</Location>
# Everything
<Location />
Order Deny,Allow
@jonmorten
jonmorten / template.html.twig
Last active August 29, 2015 14:28
eZ 5 link to root location / frontpage
<a href="{{ path(ezpublish.rootLocation) }}">
@jonmorten
jonmorten / template.html.twig
Created August 25, 2015 08:10
eZ 5 link to legacy module
{{ url('ez_legacy', {'module_uri': '/content/search'}) }}
@jonmorten
jonmorten / ezoe.ini.append.php
Created August 20, 2015 08:29
eZ OE (Legacy) custom presets
[EditorLayout_mini_extended]
Buttons[]
Buttons[]=bold
Buttons[]=italic
Buttons[]=underline
Buttons[]=|
Buttons[]=sub
Buttons[]=sup
Buttons[]=|
Buttons[]=undo
@jonmorten
jonmorten / FacebookDebugger.php
Last active August 29, 2015 14:27 — forked from FrostyX/FacebookDebugger.php
Facebook API - Force facebook to reload cache from your website
<?php
class FacebookDebugger
{
/*
* https://developers.facebook.com/docs/opengraph/using-objects
*
* Updating Objects
*
* When an action is published, or a Like button pointing to the object clicked,
* Facebook will 'scrape' the HTML page of the object and read the meta tags.
@jonmorten
jonmorten / jquery_validate_file_size_limit.js
Last active August 29, 2015 14:12
jQuery Validation Plugin (http://jqueryvalidation.org): File size limit
// `limit` is in bytes
jQuery.validator.addMethod('fileSizeLimit', function(value, element, limit) {
return !element.files[0] || (element.files[0].size <= limit);
}, 'File is too big');
jQuery('validatorElement').validate({
rules: {
someImageField: {
fileSizeLimit: 1000000
}
<?php
/**
* Turn a multi level associative array into a one level associative array.
* The key path of each value will be a dot separated key string in the new
* array.
*
* @example
* [
* 'a' => [
<?php
/**
* Reduce an array of one level associative arrays into
* a one level associative array.
*
* @example
* [
* ['id' => '14', 'name' => 'a', 'foo' => 'bar'],
* ['id' => '25', 'name' => 'b', 'foo' => 'baz'],