Skip to content

Instantly share code, notes, and snippets.

View nesk's full-sized avatar

Johann Pardanaud nesk

View GitHub Profile
@nesk
nesk / LICENSE.txt
Created May 30, 2011 06:48 — forked from 140bytes/LICENSE.txt
Get ready to go epileptic !
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Johann PARDANAUD : http://plune.fr
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@nesk
nesk / LICENSE.txt
Created June 17, 2011 13:31 — forked from 140bytes/LICENSE.txt
Detect CSS 3 transitions support
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Johann PARDANAUD : http://plune.fr
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@nesk
nesk / unicode-interpretation.js
Created June 10, 2016 14:43
Interpreting Unicode values and writing them to a string to render the corresponding Emoji
// Based on this amazing article:
// http://crocodillon.com/blog/parsing-emoji-unicode-in-javascript
function findSurrogatePair(point) {
var offset = point - 0x10000,
lead = 0xd800 + (offset >> 10),
trail = 0xdc00 + (offset & 0x3ff);
return [lead.toString(16), trail.toString(16)];
}
@nesk
nesk / index.html
Created April 8, 2017 14:00
Initializing Smooch makes some icons disappear
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdn.smooch.io/smooch.min.js"></script>
<style>
@nesk
nesk / Handler.php
Created January 16, 2018 10:39
Laravel default error page (1/2)
<?php
/**
* Render the given HttpException.
*
* @param \Symfony\Component\HttpKernel\Exception\HttpException $e
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpException $e)
{
@nesk
nesk / Handler.php
Last active January 16, 2018 10:54
Laravel default error page (2/2)
<?php
/**
* Render the given HttpException.
*
* @param \Symfony\Component\HttpKernel\Exception\HttpException $e
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpException $e)
{
@nesk
nesk / weak-references.php
Last active February 1, 2018 12:02
Circular references: weak references
<?php
class ParentClass
{
public function __construct()
{
$this->child = new ChildClass($this);
}
}
@nesk
nesk / dereferencing-method.php
Created February 1, 2018 12:06
Circular references: dereferencing method
<?php
class ParentClass
{
public function __construct()
{
$this->child = new ChildClass($this);
}
public function destroy()
@nesk
nesk / mapping.js
Created March 16, 2018 14:40
Mapping objects in JavaScript (ES5)
const data = {
a: 1,
b: 2,
};
const newData = Object.keys(data)
.map(function (key) {
return {
key: '_' + key,
value: data[key] + 1,
@nesk
nesk / mapping.js
Created March 16, 2018 14:40
Mapping objects in JavaScript (ES2015)
const data = {
a: 1,
b: 2,
};
const newData = Object.keys(data)
.map(key => ({ [`_${key}`]: data[key] + 1 }))
.reduce((obj, item) => Object.assign(obj, item), {});