Skip to content

Instantly share code, notes, and snippets.

View bloodyowl's full-sized avatar
🦉

Matthias Le Brun bloodyowl

🦉
View GitHub Profile
@bloodyowl
bloodyowl / gist:6543749
Created September 12, 2013 21:02
Jony Ive bullshit generator
;(function(){
var text = [
[
"Right from the beginning, it appeared to us that designing the new"
, "When we first thought about it, we understood that designing the new"
]
, [
" iPhone"
, " iMac"
@bloodyowl
bloodyowl / gist:5d8adcf50e890ebafb95
Last active September 30, 2023 16:49
ES6 tl;dr; for beginners
// ES6 tl;dr; for beginners
// 1. variables
// `const` & `let` are scoped at the block level
if(true) {
let foo = "bar"
}
foo // ReferenceError
function stripAccent( str ) {
var accents = "ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿñ"
, fixes = "aaaaaaceeeeiiiiooooouuuuyaaaaaaceeeeiiiioooooouuuuyyn"
, reg = new RegExp("(" + accents.split("").join("|") + ")", "g")
function replacement(a){
return fixes[accents.indexOf(a)] || ""
}
@bloodyowl
bloodyowl / redux-light-example.js
Created February 29, 2016 17:12
redux in 14 lines of code
const store = createStore((state = { counter: 0 }, action) => {
switch(action.type) {
case "INCREMENT":
return { counter: state.counter + 1 }
case "DECREMENT":
return { counter: state.counter - 1 }
default:
return state
}
})
@bloodyowl
bloodyowl / index.htm
Created December 1, 2012 15:43 — forked from kunalvarma05/index.htm
AJAX Contact Form with PHP
<!DOCTYPE HTML>
<html>
<head>
<title>Welcome to my Website</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="send.js"></script>
</head>
<body>
<h1>A Simple AJAX Contact Form</h1>
<form method="post" action="" id="contact_form">
@bloodyowl
bloodyowl / smoothScroll.js
Created June 29, 2012 09:52
smoothScroll explained
function (destination, duration) {
// destination (relative to window top) in px
// duration in ms
/* Variables */
var startPosition = "pageYOffset" in window ? window.pageYOffset : document.documentElement.scrollTop,
startTime = +new Date(),
endTime = startTime + duration,
// if top of element is outside the document, then define end point to document limit
// elsewhere, go the the top of the element
destinationSafe = document.height < (destination + window.innerHeight) ? document.height - window.innerHeight : destination,
@bloodyowl
bloodyowl / gist:41b1de3388c626796eca
Last active April 20, 2020 03:27
es6 event-emitter
var DEFAULT_MAX_LISTENERS = 12
function error(message, ...args){
console.error.apply(console, [message].concat(args))
console.trace()
}
class EventEmitter {
constructor(){
this._maxListeners = DEFAULT_MAX_LISTENERS
@bloodyowl
bloodyowl / gist:5729489
Created June 7, 2013 14:05
js bitwise cheat sheet

js bitwise cheat sheet

var INIT = 0x1      // 0 0 0 0 1
  , PENDING = 0x2   // 0 0 0 1 0
  , DONE = 0x4      // 0 0 1 0 0
  , ERROR = 0x8     // 0 1 0 0 0
  , SUCCESS = 0x10  // 1 0 0 0 0
  , ALL = 0x1f      // 1 1 1 1 1
@bloodyowl
bloodyowl / LICENSE.txt
Created October 26, 2012 17:04 — forked from 140bytes/LICENSE.txt
HTML5forIE
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Matthias Le Brun http://mlb.li
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
@bloodyowl
bloodyowl / 00.Intro.md
Last active December 13, 2017 13:36
Introduction to React

React

A JavaScript library that manages the UI.

What does it do?

React enables you to express in a declarative way what your UI should look like at any point in time; while building your app with little, reusable blocks: components.