Skip to content

Instantly share code, notes, and snippets.

View md2perpe's full-sized avatar

Per Persson md2perpe

View GitHub Profile
@md2perpe
md2perpe / jag-skams-inte.md
Last active April 27, 2021 21:38
Jag skäms inte

Jag skäms inte

Jag skäms inte över att vara svensk.
Men jag skäms över hur vissa ser ned på dem som vill bli svenskar.

Jag skäms inte över den svenska flaggan.
Men jag skäms över hur den används mot dem som vill hissa den.

Jag skäms inte över Sverige.
Men jag skäms över hur vissa anser sig ha ensamrätt till landet.

@md2perpe
md2perpe / suggestion.md
Created November 18, 2012 18:55
Suggestion of alternative "implements interface" declaration

Suppose that two interfaces clash:

interface Alpha
{
	function foo();
}

interface Beta
{
	function foo();

Merry Christmas in different languages

Spanish
English Merry Christmas
<?php
// Returns a cer encoded SSL certificate
function create_identity_cer(
$countryName, $stateOrProvinceName, $localityName, $organizationName,
$organizationalUnitName, $commonName, $emailAddress, $foafLocation)
{
// Create the DN array for the openssl function calls
$fields = array(
'countryName',
'stateOrProvinceName',
@md2perpe
md2perpe / permutations.js
Created January 1, 2014 18:54
Function for generating permutations of a list.
function permutations(list)
{
// Empty list has one permutation
if (list.length == 0)
return [[]];
var result = [];
for (var i=0; i<list.length; i++)
@md2perpe
md2perpe / gist:9683372
Last active August 29, 2015 13:57
Idea of new operator in PHP

Got an idea of a new assignment operator ?= in PHP.

Instead of writing

if (!$x)
    $x = $y;

one could use ?= and write

$x ?= $y;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@md2perpe
md2perpe / Shapes
Created June 23, 2015 19:36
Square as a subclass of Rectangle
class Rectangle
{
protected double width, height;
constructor(double width, double height)
{
this.width = width;
this.height = height;
}
class Safe
{
protected $value;
public function __construct($value) { $this->value = $value; }
public function __call($method, $args)
{
if (is_object($this->value) && method_exists($this->value, $method)) {
return new self(call_user_func_array([$this->value, $method], $args);
package main
import "fmt"
const s="package main%cimport %cfmt%c%cconst s=%c%s%c%cfunc main() {fmt.Printf(s,10,34,34,10,34,s,34,10,10)}%c"
func main() {fmt.Printf(s,10,34,34,10,34,s,34,10,10)}