Skip to content

Instantly share code, notes, and snippets.

View Victa's full-sized avatar
🏠
Working from home

Victor Coulon Victa

🏠
Working from home
View GitHub Profile
@cjohansen
cjohansen / gist:4135065
Created November 23, 2012 10:43
Naming this in nested functions

tl;dr

If you must nest functions in a way that requires access to multiple this', alias outer this to something meaningful - describe the value it's holding. Treat this as the invisible first argument.

In general though, avoiding the situation (nested functions and frivolous use of this) will frequently produce clearer results.

Naming this in nested functions

I was accidentally included in a discussion on how to best name this in nested functions in JavaScript. +1's were given to this suggestion of using _this.

Giving style advice on naming nested this without a meaningful context isn't too helpful in my opinion. Examples below have been altered to have at least some context, although a completely contrived and stupid one.

@kaelig
kaelig / readme.md
Created November 7, 2012 11:28
My coding conventions

CSS Coding Styleguide

  • Use 2 spaces for indentation
  • Avoid descendent selectors (.my-module p {…})
  • With Sass avoid nesting too deeply
  • Avoid attaching classes to elements (div.category {…})
  • Avoid !important !!!
  • Use percentages and box-sizing when possible
  • Rely on the component library
  • Try not to write any CSS if you can
@redoPop
redoPop / tzAbbr.js
Last active June 6, 2023 21:22
JavaScript: friendly timezone abbreviations in the client ("EDT", "CST", "GMT", etc.)
/*
Given a date, tzAbbr returns a short, friendly name for the
user's time zone on that date, or an empty string if their
client's Intl support is missing or incomplete.
For example, a user in New York might see:
tzAbbr(new Date()) // => "EST"
Time zones are locale-dependent. Users traveling outside of
@sindresorhus
sindresorhus / more-mute-regex.md
Created October 18, 2012 08:14 — forked from jimmynotjim/more-mute-regex.md
Tweetbot can use regular expressions to mute tweets in your timeline and mentions.

##Simply annoying Tweets

Annoyingly extended words (4+ of the same letter in a phrase): OOOOHHHHMMMMYYYYGGGGOOOODDDD

([a-z])/1{4}

Tweet w/ just a single hashtag: #omgthissucks

^ *#[^ ]+$
@maximevalette
maximevalette / checkmail.js
Created October 14, 2012 08:00
Check mail in JS
function is_email(id){return (/^([\w!.%+\-\*])+@([\w\-])+(?:\.[\w\-]+)+$/).test(id);}
@anthonyshort
anthonyshort / grid.scss
Created October 10, 2012 02:54
Idea for Sass modules
@module grid {
$columns: 12;
$gutter: 30px;
$baseline: 20px;
$width: 60px;
@function columns($n, $size) {
}
@csswizardry
csswizardry / BEM-inuit.css.md
Created October 2, 2012 20:09
Thoughts on BEM for inuit.css

Bringing BEM to inuit.css

BEM is a methodology for naming and classifying CSS selectors in a way to make them a lot more strict, transparent and informative.

The naming convention follows this pattern:

.block{}
.block__element{}
.block--modifier{}
@maximevalette
maximevalette / retina.css
Created August 24, 2012 06:07
Capturer les écrans Retina avec une media query
@media
only screen and (-webkit-min-device-pixel-ratio: 1.3),
only screen and (min-device-pixel-ratio: 1.3),
only screen and (min-resolution: 120dpi) {
/* Votre code ici pour les écrans Retina */
}
@kewah
kewah / st-shortcuts-memo.md
Last active December 11, 2017 20:33
Sublime Text 2 - Shortcuts

HTML


  • alt+shift+w: Wrapping content with tag
  • super+shift+a: Select content into tag

Bookmarks


  • super+f2: Toggle bookmark
  • f2: Next bookmark
  • shift+f2: Previous bookmark
@juandazapata
juandazapata / mountain_lion_home_brew.md
Created July 26, 2012 15:07
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

After upgrading to Mountain Lion, I got this message when trying to run my local rails server:

Installing rmagick (2.13.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    Users/user/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby extconf.rb