Skip to content

Instantly share code, notes, and snippets.

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 23, 2024 05:34
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@robacarp
robacarp / a_generator_framework.md
Last active October 12, 2015 06:18
Sane, Simple Rails Generator framework to replace FactoryGirl, Machinist, Fabrication, and Rails Fixtures

##Intro

Generator frameworks spend way too much time creating obscure and pointless DSL syntax just to make the code trendy and cute. This generator comes in the form of pure ruby, instantiates real model objects (which fire their pre-, post- and other hooks appropriately), and still allows for a simple syntax to override parameters of generated objects.

Standard Ruby syntax allows for easier adoption by new programmers and reinforces ruby paradigms, instead of breaking them down with a cute, often incomplete, and entirely superfluous DSL syntax.

Specific complaints against existing frameworks:

  • Rails fixtures: definition syntax (yaml) doesn't provide a powerful enough interface to rapidly creating objects.
  • FactoryGirl: Factories are evaluated at load-time, making some factories just awful to define. No further comment on DSLs.
@zspecza
zspecza / stylus-best-practices.md
Last active May 27, 2021 05:25
Stylus Best Practices

Stylus Best Practices

Introduction

This is a curated set of conventions and best practices for Stylus, an expressive, dynamic, robust and advanced CSS preprocessor. Frustrated with there not being a set of conventions set in place (that could be easily found), I set forth to find out on my own.

function initMap(lat, lng, zoom){
var mapOptions = {center: new google.maps.LatLng(lat, lng), zoom: zoom, mapTypeId: google.maps.MapTypeId.ROADMAP};
map = new google.maps.Map(document.getElementById('map'), mapOptions);
}
function addMarker(location){
var position = new google.maps.LatLng(location.lat, location.lng);
var marker = new google.maps.Marker({map:map, position:position, title:location.address});
markers.push(marker);
}
exports.db = function(fn){
MongoClient.connect(mongoUrl, function(err, db) {
if(err){throw err;}
global.nss = {};
global.nss.db = db;
global.nss.db.collection('listings').ensureIndex({'coordinates':'2dsphere'}, function(err, indexName){
console.log('Connected to MongoDB');
fn();
});
});
@jonathanconway
jonathanconway / addthis_reload.js
Created April 1, 2014 23:45
Reload (or initialize) addThis social share buttons. Useful when implementing addThis in a SPA (Single Page Application).
// Reload (or initialize) addThis social share buttons.
// IMPORTANT: make sure you put in a correct pubid on line 7.
window.addthis_reload = function () {
if (!window.addthis) {
// Load addThis, if it hasn't already been loaded.
window['addthis_config'] = { 'data_track_addressbar' : false };
$('body').append('<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid={YOUR PUBID HERE}"></script>');
} else {
// Already loaded? Then re-attach it to the newly rendered set of social icons.
// And reset share url/title, so they don't carry-over from the previous page.
@ericelliott
ericelliott / essential-javascript-links.md
Last active July 18, 2024 15:03
Essential JavaScript Links
@paulirish
paulirish / readme.md
Last active April 2, 2024 20:18
resolving the proper location and line number through a console.log wrapper

console.log wrap resolving for your wrapped console logs

I've heard this before:

What I really get frustrated by is that I cannot wrap console.* and preserve line numbers

We enabled this in Chrome DevTools via blackboxing a bit ago.

If you blackbox the script file the contains the console log wrapper, the script location shown in the console will be corrected to the original source file and line number. Click, and the full source is looking longingly into your eyes.