Skip to content

Instantly share code, notes, and snippets.

View Warry's full-sized avatar

Maxime Dantec Warry

View GitHub Profile
@Warry
Warry / Article.md
Created December 11, 2012 00:11
How to make faster scroll effects?

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows:

@Warry
Warry / propMap.elm
Last active November 19, 2019 04:15
Convert a List of objects into a Dict (≈ Map) using an object's property as key, in a type safe way with ELM
import Dict
-- The transformation function
listToDict : (a -> comparable) -> [a] -> Dict.Dict comparable a
listToDict getKey values = Dict.fromList (map (\v -> (getKey v, v)) values)
-- Demo type
type FooBar =
{ foo : String
, bar : Int
@Warry
Warry / jum-1.svg
Last active September 13, 2019 19:45
Just use monads
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Warry
Warry / MagicJson.elm
Last active May 31, 2019 12:39
unsafe elm json encoder+decoder
module MagicJson exposing (encode, decode, decoder)
import Json.Encode as Encode exposing (Value)
import Json.Decode as Decode exposing (Decoder)
import Http
encode : a -> Value
encode jsonEncodeElmValue =
@Warry
Warry / pipe.md
Last active August 9, 2016 15:50
Why do you use `(flip andThen)`?

Why do you use (flip andThen)?

TLDR; To use it with the pipe (|>) operator.

The actual andThen problem

Here is the signature for Task.andThen:

import Task exposing (andThen)
@Warry
Warry / demo.wooot.coffee
Last active December 22, 2015 01:59
Demo of wOOOt api
Todos =
# public properties
list: OOO.observableArray([])
# public methods
counter: OOO.computed ()->
@list.length + " remaining todos"
clear: ()->
@list.remove (_)-> _.done
@Warry
Warry / gist:3890290
Created October 15, 2012 00:36
Monitor
Monitor is a simple HTML/JS based application. It allows requesting JSON apis, with an history.
This gist is used to try the demo requests on start.
@Warry
Warry / gist:2362973
Created April 11, 2012 21:48
My thoughts about meteor.js

Lately, with the help of Julien Tournay, I wondered how can we resolve the model problem in the browser which is : there is no ONE true model, and one information can be duplicated in multiple places (eg: form, list, item). Finally, I found out that the real datas are from : the forms > the server > the DOM. Meteor solved this by keeping this order, and synchronize it all in real time ! That's truly great. But. There a hudge cost in this : you have an heavy fullstack architecture, and you can't have control on the async which is black magic. Also, It's made for realtime, so concurrency apps. With Node.js in one thread, I can't imagine an app with thousands of users at the same time managing as much states properly. There is no holly grail. Just code!

@Warry
Warry / README.md
Created January 24, 2011 09:08 — forked from NV/README.md

XRefresh for Chrome

Deprecated! Use LiveReload instead.

via xrefresh#17

How to use

  • ruby ws_dir_watcher.rb ~/my_site
  • Open chrome://extensions/
  • "Developer mode", then press "Load unpacked extension" button
@Warry
Warry / Refresh yourCSS: Bookrmarklet
Created October 27, 2010 14:06
Modify +R shortcut to refresh only the CSS files
javascript:void(function(){window.addEventListener("keydown",function(e){if(e.metaKey && e.keyCode==82){e.preventDefault();var i,a,s;a=document.getElementsByTagName('link');for(i=0;i<a.length;i++){s=a[i];if(s.rel.toLowerCase().indexOf('stylesheet')>=0 && s.href){var h=s.href.replace(/(&amp;|%5C?)forceReload=d+/,'');s.href=h+(h.indexOf('?')>=0?'&amp;':'?')+'forceReload='+(new Date().valueOf())}}return false}})})();