Skip to content

Instantly share code, notes, and snippets.

View fuunnx's full-sized avatar
💭
🤯

Géraud Henrion fuunnx

💭
🤯
View GitHub Profile
@cjthompson
cjthompson / RobustPDO.php
Created February 3, 2014 19:52
Extended PDO class that detects dropped connections and reconnects
<?php
class RobustPDO extends PDO
{
/** Call setAttribute to set the session wait_timeout value */
const ATTR_MYSQL_TIMEOUT = 100;
/** @var array */
protected $config = [];
/** @var bool For lazy connection tracking */
@pch
pch / mac-vagrant-unison.md
Last active February 18, 2019 08:57
How to install Unison on Mac OS El Capitan & Vagrant

How to install Unison on Mac OS El Capitan & Vagrant - for Docker Sync

You can install Unison on the Mac via homebrew (brew install unison), but it's very likely that it won't work properly, resulting in errors like:

Unison failed: Uncaught exception Failure("input_value: bad bigarray kind")
Fatal error: Lost connection with the server
@staltz
staltz / helper.js
Created June 6, 2016 10:56
How to use Stanga (https://github.com/milankinen/stanga) as a wrapper, not as a driver
// Generic helper function that takes a main() (the top-level component)
// and wraps it with Stanga logic
function wrapWithStanga(main, initialState) {
return function (sources) {
const modProxy$ = new Subject();
const modelSource = Model(initialState)(modProxy$);
sources.model = modelSource;
const sinks = main(sources);
sinks.model.subscribe(modProxy$);
@oxpa
oxpa / webpack.config.js
Last active January 14, 2020 16:26
webpack configuration suitable for static content generator plugin and chunks
var path = require('path');
var StaticSiteGeneratorPlugin = require('static-site-generator-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var webpack = require('webpack');
var urlloader = require('url-loader');
var React = require("react");
var ReactDom = require("react-dom");
var Redux = require("redux");
@ericelliott
ericelliott / cancellable-wait.js
Last active October 8, 2019 08:06
Cancellable wait -- an ES6 promise example
const wait = (
time,
cancel = Promise.reject()
) => new Promise((resolve, reject) => {
const timer = setTimeout(resolve, time);
const noop = () => {};
cancel.then(() => {
clearTimeout(timer);
reject(new Error('Cancelled'));
@alexlafroscia
alexlafroscia / README.md
Last active August 6, 2018 19:13
Skate.js ShadyCSS Mixin

ShadyCSS Skate.js Mixin

Out of the box, Skate.js doesn't work that well with ShadyCSS. This is a mixin that helps bridge the gap.

Usage

The usage example below assumes you're using a build tool like Webpack to transform a CSS file into a string when loaded.

import Component from 'skatejs';
import React from "react";
import { render } from "react-dom";
import Task from "data.task";
import TaskComponent from "./TaskComponent";
const users = [
{ id: 1, name: "User A", points: 45 },
{ id: 2, name: "User B", points: 22 },
{ id: 3, name: "User C", points: 79 },
{ id: 4, name: "User D", points: 54 }
@mrehayden1
mrehayden1 / Touch.ts
Last active August 18, 2018 09:57
Mostjs Drag and Drop for touch devices.
import { Stream } from 'most';
import * as most from 'most';
type Maybe<T> = null | T
type Position = [number, number]
export function dragPositionStream(
touchStart$: Stream<TouchEvent>,
touchMove$: Stream<TouchEvent>,
touchEnd$: Stream<TouchEvent>
@pyrocto
pyrocto / overload.js
Last active June 5, 2024 16:13
A modest proposal for operator overloading in JavaScript
/*
It is a melancholy object-oriented language to those who walk through
this great town or travel in the country, when they see the JavaScript
programs crowded with method calls begging for more succinct syntax.
I think it is agreed by all parties, that whoever could find out a
fair, cheap and easy method of making these operators sound and useful
members of the language, would deserve so well of the publick, as
to have his statue set up for a preserver of the nation. I do therefore
humbly offer to publick consideration a pure JS library I've written
for overloading operators, which permits computations like these:
@jiraguha
jiraguha / deno-script.md
Last active December 21, 2023 14:19
Deno for scripting

Deno for scripting

Foreword

It is largely inspired by kscript. The idea is to leverage the scripting abilities of javascript using Deno. I feel that scripting can be so much fun with Deno as:

  • It can import modules from any location on the web,
  • It is secure by default. Imported module can run in sandbox.
  • It is Supports TypeScript out of the box.
  • It is much more that Node