Git: Discard Changes Back to Last Commit
Posted on May 3rd, 2013 by webninjataylor
git reset –hard HEAD~ Fixes the annoying “Your branch is ahead by blahblahblah commits.”
Posted on May 3rd, 2013 by webninjataylor
git reset –hard HEAD~ Fixes the annoying “Your branch is ahead by blahblahblah commits.”
Posted on May 1st, 2013 by webninjataylor
To get back to a specific commit type… git reset –hard fe8ef61119454071e87095e4ff8b24c6833cb0c6 …where “fe8ef61119454071e87095e4ff8b24c6833cb0c6” represents the commit’s SHA number.
Posted on May 1st, 2013 by webninjataylor
Install the Grunt command line tool (requires node.js installed on your machine)… sudo npm install grunt-cli -g Create package.json in root of project (list of Grunt plugin dependencies) npm install (install the dependencies) Create Gruntfile.js in root of project (configuration) Basically, you need three different functions to work with Grunt: grunt.initConfig, grunt.loadNpmTasks, and grunt.registerTask Resources Grunt: A Build Tool […]
Posted on April 30th, 2013 by webninjataylor
This pattern is essentially the same as the Module Pattern, except all of the functions and variables are defined in the private scope, and we return an object with pointers to the private functionality that we wish to make public. var myRevealingModule = function () { var privateCounter = 0; function privateFunction() { privateCounter++; } […]
Posted on April 30th, 2013 by webninjataylor
Use decimals cautiously because JavaScript uses Binary Floating Point numbers, so 0.1 + 0.2 = 0.30000000000000004. To get around this issue, you can multiply your numbers to remove the decimal portion. var hamburger = 8.20; var fries = 2.10; var total = hamburger + fries; console.log(total); //Outputs 10.299999999999999 hamburger = hamburger * 100; fries = fries * […]
Posted on April 17th, 2013 by webninjataylor
If you’re not using Modernizr to pull in the shiv, just add a call to the shiv directly in the head of the HTML… <!–[if lt IE 9]><script src=”http://html5shiv.googlecode.com/svn/trunk/html5.js”></script><![endif]–>
Posted on April 17th, 2013 by webninjataylor
This works for a solid-color background you want transparent to some degree… background-color:rgb(128,193,255); /* Fallback for IE8 */ background-color:rgba(128,193,255,0.6); Support: IE10+
Posted on April 17th, 2013 by webninjataylor
Shift + Cmd + L adds multiple cursors to the page Cmd + D selects additional occurrences of current selection Ctrl + Cmd + G selects ALL occurrences of current selection Ctrl + Cmd + U + S shows the SFTP activity panel (SFTP package required)
Posted on April 11th, 2013 by webninjataylor
You can scope this in JavaScript through call(), apply(), or bind().
Posted on April 11th, 2013 by webninjataylor
RequireJS loads scripts asynchronously and out of order for speed Define modules with dependencies Written in JS, so “.js” is not needed when declaring scripts to load <script src=”/Scripts/require.js” data-main=”/Scripts/app/main.js”></script> Contents of main.js could look like this… require([ “mylibs/utils”, “mylibs/palette” ], function(utils, palette){ // The app is loaded… } ); Defining dependencies in a JS […]
Posted on April 11th, 2013 by webninjataylor
Posted on April 11th, 2013 by webninjataylor
Node is written in C, not JavaScript Node is a server-side program which handles the grunt work of networking Node processes JavaScript which makes writing server-side code somewhat easier Node commands start with npm in the terminal
Posted on April 10th, 2013 by webninjataylor
Posted on April 9th, 2013 by webninjataylor
PHP will download in your localhost, instead of rendering, if your .htaccess file in the htdocs root doesn’t have this line commented out… # Use PHP5 Single php.ini as default # AddHandler application/x-httpd-php5s .php # (WNT) Removed above line which actually caused PHP to download instead of render.
Posted on April 3rd, 2013 by webninjataylor
Overview Views observe Models The traditional controller role is performed by the template, not by the Backbone View Model persistence is the storage and synchronization of data A group of Models is a Collection A Model or Collection may have multiple Views observing it for changes Collections are useful for performing any aggregate computations across […]
Posted on April 3rd, 2013 by webninjataylor
Good for building single-page applications with a complex user interface (heavy lifting for view rendering) and for reducing the number of HTTP requests (data manipulation). Web applications such as GMail, LinkedIn, and Facebook. Do you want the page/view rendering handled by the browser or server? Resources Addy Osmani, Developing Backbone.js Applications (O’Reilly, 2013)
Posted on March 29th, 2013 by webninjataylor
Google recommends $150/month for advertising through them and they list the estimated clicks you can expect based on your budget. You can also customize how much you can spend each month on advertising.
Posted on March 25th, 2013 by webninjataylor
Remove HTML <!– comments –> from your WordPress content. WordPress seems to choke on it and remove content following the comment even though it’s closed properly.
Posted on March 18th, 2013 by webninjataylor
The CSS3 :nth-child pseudo selector can be used to add special rules to specific elements in a set, for example… .myList li:nth-child(3n+3) { color: #ffffff; } …sets the color of every 3rd list item to red (3, 6, 9, …). Specifying just a single number would only effect that element in the set… .myList li:nth-child(5) { color: #ffffff; } […]
Posted on March 18th, 2013 by webninjataylor
Layman’s Terms Images need alt attributes Videos need closed captioning Information still needs to be conveyed well in black & white Page needs to makes sense with CSS disabled Client-side image maps are preferred… If not, then server-side image maps need duplicate text links on the page Client-side image maps are preferred… If not, then […]
Posted on March 18th, 2013 by webninjataylor
Start with a global object variable declaration and extend that object with properties… var wnt = {}; //Start with the global declaration wnt.util = {}; //Add a new level (if desired) wnt.util.urlparameter = function(name) { return decodeURI( (RegExp(name + ‘=’ + ‘(.+?)(&|$)’).exec(location.search)||[,null])[1] ); }; //Turn a level into a method alert(eval(wnt.util.urlparameter(‘page’))-1); //assumes URL ends with […]
Posted on March 18th, 2013 by webninjataylor
Writing this… if (index === 2) { return null } else { return value; } Is the same as saying… //return [test condition] ? [return this if true] : [return this if false] return index === 2 ? null : value; OR var myVariable = condition ? this_if_true : that_if_false;
Posted on March 18th, 2013 by webninjataylor
A JavaScript library that helps you write less and do more. $() is the same as jquery() Selectors: $(#id), $(element), $(.class), $(#multiple .selectors), $(p:first), $(p:last), $(p)[0] Adding .eq(#) counts 0-based forward or backwards from beginning or end of a set .size() method returns number of elements in the set $(document).ready(function(){…}); is the same as using […]
Posted on March 18th, 2013 by webninjataylor
$git add -u
Posted on March 18th, 2013 by webninjataylor
Creating a new alias (shortcut) in Terminal… Edit profile vim ~/.bash_profile Create alias alias mynewalias=’does this; and this’ Control+o (or esc) … :wq Save profile source ~/.bash_profile My list of aliases… alias aliasnew=’vim ~/.bash_profile’ alias aliassave=’source ~/.bash_profile’ alias an=’vim ~/.bashrc’ alias as=’source ~/.bashrc’ alias checkcss=’./scripts/verify_css.sh’ alias clear=’pip install -i http://23.20.194.155/simple -r setup/requirements.txt; source virtualenvwrapper.sh’ alias […]