Skip to content

Instantly share code, notes, and snippets.

View manuelbieh's full-sized avatar
⚛️
Available for hire! Berlin. React.

Manuel Bieh manuelbieh

⚛️
Available for hire! Berlin. React.
View GitHub Profile
@manuelbieh
manuelbieh / document.getElementsByStyle()
Last active August 29, 2015 14:01
Might be useful for debugging ("where is this f*ing margin coming from?!?").
/*! document.getElementsByStyle()
*
* Returns an array (not a NodeList!!) containing all elements matching certain
* computed style rules.
*
* Usage:
* var blockElements = document.getElementsByStyle('display: block');
*
* PS: I know it might not be the best idea to extend HTMLElement/HTMLDocument since it
* returns an array not a NodeList (like getElementsByTagName). But I recommend to use
@manuelbieh
manuelbieh / SassMeister-input.scss
Created January 12, 2015 15:27
Generated by SassMeister.com.
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
@mixin font-headline($type, $color: "") {
@if $type == h1 {
$font-size-headline: 28;
} @else if $type == h2 {
@manuelbieh
manuelbieh / SassMeister-input.scss
Created January 12, 2015 15:34
Generated by SassMeister.com.
// ----
// Sass (v3.4.9)
// Compass (v1.0.1)
// ----
@mixin font-headline($type, $color: "") {
$font-size-headline: 0 !default;
@if $type == h1 {
@manuelbieh
manuelbieh / ua-test.js
Last active August 29, 2015 14:17
node-phantom-simple userAgent bug
var phantom = require('node-phantom-simple');
phantom.create(function(err,ph) {
return ph.createPage(function(err,page) {
page.setFn('onConsoleMessage', function(msg) {
console.log(msg);
});
@manuelbieh
manuelbieh / distance.js
Created October 20, 2011 10:57
node.js Geolib Example
var app = require('express').createServer(),
fs = require('fs'),
geolib = require('./geolib').geolib,
http = require('http');
app.get('/distance/:lat1/:lng1/:lat2/:lng2', function(req, res){
var distance = geolib.getDistance({latitude: req.params.lat1, longitude: req.params.lng1 }, {latitude: req.params.lat2, longitude: req.params.lng2});
res.send('Distance from ' + req.params.lat1 + ',' + req.params.lng1 + ' to ' + req.params.lat2 + ',' + req.params.lng2 + ' is ' + distance + ' km');
});
@manuelbieh
manuelbieh / gist:2593403
Created May 4, 2012 08:50
Install node.js on ubuntu
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
@manuelbieh
manuelbieh / allowscale.js
Last active October 13, 2015 08:28
Allow scaling on iPhone when viewport has user-scalable=no
javascript:(function() { var v = document.querySelector("meta[name=viewport]"); var vc = v.content; if(!!vc.match('user-scalable')) { var as = vc.replace(/user-scalable\s*=\s*no/,'user-scalable=yes'); } else { var as = vc + ',user-scalable=yes'; } if(!!vc.match(/maximum-scale/)) { as = as.replace(/(,?)\s*maximum-scale\s*=\s*(.*)/,'$1maximum-scale=3') } else { as += ',maximum-scale=3'; } v.content = as; })();
@manuelbieh
manuelbieh / sequelize-associations.js
Last active October 16, 2015 09:55
Sequelize n:m test
var Sequelize = require('sequelize');
var sequelize = new Sequelize(
'test',
'root',
'', {
host: 'localhost',
logging: false, // console.log,
define: {
charset: 'utf8',
@manuelbieh
manuelbieh / sequelize-limit-error.js
Last active October 19, 2015 23:35
Sequelize hasMany error when used with limit
import Sequelize from 'sequelize';
let sequelize = new Sequelize('test', 'root', '', {
host: 'localhost',
dialect: 'mysql',
logging: console.log,
}
);
// DEFINE MODELS
@manuelbieh
manuelbieh / sequelize-limit-error-sqlite.js
Last active October 19, 2015 23:43
Sequelize hasMany error when used with limit
import Sequelize from 'sequelize';
let sequelize = new Sequelize('test', 'root', '', {
host: 'localhost',
dialect: 'sqlite',
storage: __dirname + '/database.sqlite',
logging: console.log,
}
);