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 / CSSDeclarationBlockToJSObject.js
Created August 5, 2015 11:58
Transform CSS declaration block into JavaScript Object
function toSpaceCase (string) {
return string.replace(/[\W_]+(.|$)/g, function (matches, match) {
return match ? ' ' + match : '';
});
}
function toCamelCase(string) {
string = toSpaceCase(string).replace(/\s(\w)/g, function (matches, letter) {
return letter.toUpperCase();
});
@MoOx
MoOx / .travis.yml
Last active May 12, 2016 01:16
Run tap/tape tests using saucelabs
language: node_js
node_js:
- iojs
env:
global:
# https://docs.saucelabs.com/ci-integrations/travis-ci/
# SAUCE_USERNAME
- secure: Daa...
@MoOx
MoOx / "computed".css
Created July 16, 2015 09:23
custom properties allow more than variables, it's true, but this can provide a similar usage
selector {
prop: value;
}
@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 / cleanup-svg.js
Last active April 18, 2020 19:12
Cleanup svg
cleanupSvg(svg) {
return [
// some useless stuff for us
// that svgo doesn't remove
/<title>.*<\/title>/gi,
// remove hardcoded dimensions
/ +width="\d+(\.\d+)?(px)?"/gi,
/ +height="\d+(\.\d+)?(px)?"/gi,
@MoOx
MoOx / index.js
Last active February 9, 2024 22:44
Export/import github labels
// go on you labels pages
// eg https://github.com/cssnext/cssnext/labels
// paste this script in your console
// copy the output and now you can import it using https://github.com/popomore/github-labels !
var labels = [];
[].slice.call(document.querySelectorAll(".label-link"))
.forEach(function(element) {
labels.push({
name: element.textContent.trim(),
@MoOx
MoOx / .eslintrc
Created March 19, 2015 15:03
my eslintrc
---
# babel support more syntax stuff than eslint for now
parser: babel-eslint
ecmaFeatures:
modules: true
jsx: true
env:
es6: true
@MoOx
MoOx / index.md
Last active August 29, 2015 14:17
OS X IRC apps
@MoOx
MoOx / index.js
Last active August 29, 2015 14:15
requirebin sketch
var postcss = require("postcss")
alert(postcss.rule({selector: "a"}).source)
(function (root, factory) {
if (typeof exports === 'object') {
// CommonJS
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
// AMD
define([], function () {
return (root.BROWSER = factory());
});
} else {