Skip to content

Instantly share code, notes, and snippets.

View mbonaci's full-sized avatar

Marko Bonaći mbonaci

View GitHub Profile
@undoZen
undoZen / less-middleware-with-sourcemap.js
Last active December 18, 2015 15:49
a simple less middleware with source map, usage: app.use(lessMiddleware(path.join(__dirname))); -- only works for __dirname right now.
var less = require('less');
var fs = require('fs');
var path = require('path');
var SourceMapGenerator = require('source-map').SourceMapGenerator
function errfn(callback) {
return function (err) {
if (err) callback.call(this, err);
else callback.apply(this, [].slice.apply(arguments).slice(1));
}
@garthk
garthk / profile
Created June 21, 2015 23:51
boot2docker 1.7.0 cert fix
wait4eth1() {
CNT=0
until ip a show eth1 | grep -q UP
do
[ $((CNT++)) -gt 60 ] && break || sleep 1
done
sleep 1
}
wait4eth1
/**
* Simple userland CPU profiler using v8-profiler
* Usage: require('[path_to]/CpuProfiler').init('datadir')
*
* @module CpuProfiler
* @type {exports}
*/
var fs = require('fs');
var profiler = require('v8-profiler');
@gaearon
gaearon / connect.js
Last active November 14, 2024 08:35
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (