Skip to content

Instantly share code, notes, and snippets.

View louisremi's full-sized avatar

Louis-Rémi Babé louisremi

View GitHub Profile
@louisremi
louisremi / app.js
Last active May 17, 2022 15:30
Get rid of forest/ folder with this one weird trick
const Express = require('express');
const Liana = require('forest-express-sequelize');
const config = require('./config');
const models = require('./models');
const smartCollections = require('./smart-collections');
const app = Express();
const {Schemas} = Liana;
// - Hijack Schemas.perform to load Liana collections ourselves
(function(jQuery){
var parsedCache = [],
_filter = jQuery.filter;
jQuery.filter = jQuery.multiFilter = function( expr, elems, not ) {
var parsed = [], split, re, matches = [], match, l, i;
// We are looking for simple selectors of the form "div", ".class" or "div.class"
// We'll try to minimize the extra-processing for complex selectors
@louisremi
louisremi / crappy.html
Created April 27, 2011 10:21
problematic display rule
<style>
/* Annoying rule that hides those elements and make it
* impossible to retrieve their default display value
*/
address, figcaption, mark, ruby {
display: none;
}
</style>
<script>
// Animate the opacity of the logo to make the address visible
<!DOCTYPE html>
<html>
<!--
<== The code that creates the glyph is in script.js
-->
<head>
<meta charset="utf-8" />
<link href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.css" rel="stylesheet" />
textarea {
width: 100%;
height: 300px;
margin: 0;
padding: 20px;
border: 0;
border-radius: 0;
@louisremi
louisremi / insertAdjacentHTML.js
Created August 18, 2011 16:29
insertAdjacentHTML API
// HTML inserted before elem in the DOM
elem.insertAdjacentHTML( "beforebegin", ... )
// inside elem, before its first child
elem.insertAdjacentHTML( "afterbegin", ... )
// inside elem, after its last child
elem.insertAdjacentHTML( "beforeend", ... )
// HTML inserted after elem in the DOM
elem.insertAdjacentHTML( "afterend", ... )
@louisremi
louisremi / which form.js
Created February 23, 2011 07:39
Why is IE9 Another Thorn in our Side?
/*
* margin-top or marginTop?
* When to use lower-case and camel-case property names in JavaScript.
*/
// Setting style: camel-case
elem.style.marginTop = '10px';
// Getting style: camel-case
var value = elem.style.marginTop;
@louisremi
louisremi / appcacheReload.js
Created October 6, 2011 09:35
appcache reload
(function( w, d ) {
// feature detection
if ( w.applicationCache ) {
// this script shouldn't run on first load
if ( localStorage.hasAppcache === "true" ) {
// display a loader and block interaction if an update is available
applicationCache.addEventListener("downloading", function() {
@louisremi
louisremi / example.component.jsx
Last active October 18, 2020 11:35
react-select-places Address autocomplete component built on top of React-Select and Algolia Places
import React from 'react';
import Places from './places.components.jsx';
export default class Example extends React.Component {
constructor(props) {
super(props);
this.state = {address: {}};
this.handleChange = this.handleChange.bind(this);
const sequelize = new Sequelize('database', 'username', 'password', {
dialect: 'mysql',
host: "my.server.tld",
port: 9821,
})
const Project = sequelize.define('project', {
title: Sequelize.STRING,
description: Sequelize.TEXT,
});