Skip to content

Instantly share code, notes, and snippets.

😸
:3

Tiago Rodrigues trodrigues

😸
:3
Block or report user

Report or block trodrigues

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View refactoring_css.md

After reading this tweet I thought I'd write some thoughts on why I disagree with the idea that CSS is unrefactorable.

I've done this before. I've taken a huge app, with a fairly complicated Jenga tower of CSS using lots of SASS nesting and turned it into something clean and maintainable. It took time, it was difficult and it took lots of discipline, but it's doable. And yeah, this probably won't always work, but here's the approach I took.

  • Start by defining guidelines and a class naming system
    • How to structure files, what methodology you're using. Doesn't really matter which, but pick one.
    • Every time a new use case comes along where people are not sure how to apply the methodology, talk about it and document it as a use case
  • Have a styleguide
    • Helps maintain visual consistency
    • Helps with people not reinventing things all the time (sometimes it has to be done though)
@trodrigues
trodrigues / twitlistmanager_labels.js
Created Mar 6, 2016
Bookmarklet for twitlistmanager.com which places labels for lists next to each checkbox
View twitlistmanager_labels.js
// Bookmark twitlistmanager.com on your browser, then edit the URL and replace with the line below
javascript:(function (){ var titles = []; function doCol(colType) { $(colType).each(function(idx, item){ $(item).find('td').each(function(idxCol, col) { if(idxCol>1) { var html = col.innerHTML; col.innerHTML='<label for="'+$(col).find('input').attr('id')+'">'+ html +titles[idxCol-2]+'</label>'; } }); }); } $('tr.title .columnHead img').each(function(idx, item){ titles.push(item.getAttribute('src').split('=')[1]); }); doCol('.lightYellow');doCol('.rowData');})();
View gist:8aba8273198d63cbdd4a
// webpack.config.js
module.exports = {
entry: {
main: [
'./bootstrap.js'
]
},
output: {
path: __dirname,
filename: '[name].bundle.js'
@trodrigues
trodrigues / gist:173239e316afb91ac81f
Created May 28, 2015
timing reporter for jasmine
View gist:173239e316afb91ac81f
var timingReporter = {
suites: [{
id: 'root',
description: 'Entire Suite',
children: []
}],
getCurrentSuite: function () {
return _.last(this.suites);
@trodrigues
trodrigues / gist:6cbe73943baae57e2e2a
Created Apr 6, 2015
Mocking all sorts of stuff in angular (assumes lodash exists)
View gist:6cbe73943baae57e2e2a
var mocks = angular.module('yourapp/mocks', []);
mocks.config(['$provide', '$controllerProvider', function ($provide, $controllerProvider) {
$provide.stubDirective = function (name, definition) {
$provide.factory(name + 'Directive', function () {
return [_.extend({
name: name,
restrict: 'A',
priority: 0,
}, definition)];
View gist:3a575d78e552cec785e6
Fluxxor
Tuxedo
nexus-flux
Marty
Reflux
Fluxy
@trodrigues
trodrigues / gist:3220a4a3ed110f3b30cd
Created Feb 9, 2015
Running docker on a file watcher
View gist:3220a4a3ed110f3b30cd
/* Dockerfile */
FROM nodesource/node:trusty
COPY . /src
WORKDIR /src
VOLUME .:/src
RUN npm install -g watchy
RUN npm install
/* Build it */
docker build -t sdm_client .
@trodrigues
trodrigues / gist:4aead044ab1a81f1cf02
Created Dec 5, 2014
Deep object diff matcher for Jasmine 2
View gist:4aead044ab1a81f1cf02
// use with https://www.npmjs.org/package/deep-diff
toEqualObj: function () {
var KINDS = {
'N': 'newly added property/element',
'D': 'property/element was deleted',
'E': 'property/element was edited',
'A': 'change occurred within an array'
};
View gist:f7cf379e5dd9ebf89cc1

Loading a remote file through commonjs wouldn't be possible because commonjs is just the module format, not exactly a file loader. Require.js for instance is both: it's an implementation of the AMD module format AND a file loader. browserify for instance is just an implementation of the commonjs module format.

So you'd have to load the file separately, and when it's ready you could require it.

Let's say you have remote_module.js which goes:

exports.module = function(){};

and then somewhere else you'd have to do something like

View gist:0a8dd8ffd84cd4206c68
for i in `find sourcefolder -name "config"|grep ".git/config"` ; do
echo "[user]" >> $i
echo "\tname = First Last" >> $i
echo "\temail = first@last.com" >> $i
done
You can’t perform that action at this time.