Skip to content

Instantly share code, notes, and snippets.

View MoOx's full-sized avatar
:shipit:
Freelance React / React Native Expert, Cross-platform fanboy (native, web...)

Max Thirouin MoOx

:shipit:
Freelance React / React Native Expert, Cross-platform fanboy (native, web...)
View GitHub Profile
@MoOx
MoOx / less2stylus.js
Created August 27, 2012 17:37 — forked from lancejpollard/less2stylus.coffee
Convert LESS to Stylus
// Usage : less2stylusDir('../src/css/');
var fs = require('fs');
// this less 2 stylus conversion script make a stylus easy to read syntax
// - let the braces
// - replace the @ for var as $
// - let semicolons
function less2stylus(less)
@MoOx
MoOx / README.md
Created September 19, 2017 15:21
Keybase github proof

Your username on Github: MoOx Please publicly post the following Gist, and name it keybase.md

Keybase proof

I hereby claim:

  • I am moox on github.
  • I am moox (https://keybase.io/moox) on keybase.
  • I have a public key ASDqDbkch-cnPEc4XlbDhaYbLywxshF_E0wDNfUBz7GLIAo
@MoOx
MoOx / media-queries-width.scss
Created May 30, 2012 05:03
predefined sass media queries
//
// Predefined Media Queries Mixins
//
// @require sass-3.2 (you need eventually to do "sudo gem install sass --pre")
//
// @author Maxime Thirouin <maxime.thirouin@gmail.com>
//
// @link https://gist.github.com/2028061
// @link http://www.metaltoad.com/blog/simple-device-diagram-responsive-design-planning
@MoOx
MoOx / autoscroll.js
Last active June 21, 2019 01:40
Auto scroll to proper active (form) element when keyboard open (may be useless on iOS, but useful on Android)
// auto scroll to proper active (form) element when keyboard open
// may be useless on iOS, but useful on Android
function scrollToActiveElement() {
if (document.activeElement && document.activeElement.scrollIntoViewIfNeeded) {
document.activeElement.scrollIntoViewIfNeeded()
}
}
window.addEventListener("resize", () => {
setTimeout(scrollToActiveElement, 200)
setTimeout(scrollToActiveElement, 1000) // just in case browser is slow
@MoOx
MoOx / background.scss
Created December 12, 2012 08:54
Is there a sort of ternary operator in #Sass ?
//...
$background: null; // if you don't do this, background is undefined out of the @if/else scope
@if ($direction) {
$background: linear-gradient($direction, $color, $color2);
}
@else {
$background: linear-gradient($color, $color2);
}
//...
@MoOx
MoOx / index.web.js
Last active January 7, 2019 16:36
react-native-web partial Picker implementation (using react-native-web@0.0.44) https://github.com/necolas/react-native-web/issues/195
// @flow
// partial dirty implementation of react-native Picker
// should match http://facebook.github.io/react-native/docs/picker.html
// https://github.com/necolas/react-native-web/issues/184
import createDOMElement from "react-native-web/dist/modules/createDOMElement"
import PickerItem from "./item.web.js"
@MoOx
MoOx / svgicon.css
Last active December 3, 2018 08:50
Svg icons with React.js with webpack loader (svg: raw-loader)
.SVGIcon {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
/* fix webkit/blink poor rendering issues */
transform: translate3d(0,0,0);
/* it's better defined directly because of the cascade shit
width: inherit;
height: inherit;
@MoOx
MoOx / Hoverable.js
Created September 29, 2016 08:53
Hoverable HoC for React components
// @flow
import React, { Component } from "react"
type Props = {
onMouseEnter?: Function | boolean,
onMouseLeave?: Function | boolean,
}
type State = {
@MoOx
MoOx / es5.js
Last active August 26, 2018 16:16
es5 string vs es6 template string
Renderer.prototype.image = function(href, title, text) {
var out = '<img src="' + href + '" alt="' + text + '"';
if (title) {
out += ' title="' + title + '"';
}
out += this.options.xhtml ? '/>' : '>';
return out;
};
@MoOx
MoOx / .flowconfig
Last active July 12, 2018 01:44
flow config webpack adjustements to avoid the "Required module not found" for png, css, svg etcc
# ...
[options]
# webpack loaders
module.name_mapper='.*\.css$' -> '<PROJECT_ROOT>/flow/stub/css-modules.js'
module.name_mapper='.*\.\(svg\|png\|jpg\|gif\)$' -> '<PROJECT_ROOT>/flow/stub/url-loader.js'