Skip to content

Instantly share code, notes, and snippets.

@thetallweeks
thetallweeks / CSSComb Alphabetical (Sublime Text 2)
Last active December 16, 2015 06:39
Paste this in user settings to reorder css alphabetically. There are some exceptions - notably I follow shorthand and order padding-top, padding-right, padding-bottom, and padding-left (even though this is not alphabetical). I also kept the prefixed items next to each other.
{
"custom_sort_order": true,
"sort_order": [
"-webkit-animation",
"-moz-animation",
"-ms-animation",
"-o-animation",
"animation",
"-webkit-animation-name",
"-moz-animation-name",
@thetallweeks
thetallweeks / text-sources
Last active December 25, 2015 22:49
Sublime Text 2 Sources
ActionScript: source.actionscript.2
AppleScript: source.applescript
ASP: source.asp
Batch FIle: source.dosbatch
C#: source.cs
C++: source.c++
Clojure: source.clojure
CoffeeScript: source.coffee
CSS: source.css
D: source.d
@thetallweeks
thetallweeks / 1-FirstReverse.js
Last active December 26, 2015 09:48
Coderbyte Reverse string Challenge
// http://coderbyte.com/CodingArea/GuestEditor.php?ct=First%20Reverse&lan=JavaScript
function FirstReverse(str) {
var string = [];
for(i = 0; i <= str.length; i++) {
string[i] = str[str.length - i];
}
// code goes here
return string.join("");
}
@thetallweeks
thetallweeks / 2-FirstFactorial.js
Last active December 26, 2015 12:19
Coderbyte Factorial function
function FirstFactorial(num) {
var factorial = 1;
// code goes here
for(i = 2; i <= num; i++) {
factorial *= i;
}
return factorial;
}
@thetallweeks
thetallweeks / 3-LongestWord.js
Last active December 26, 2015 12:19
Coderbyte Longest Word in a string
function LongestWord(sen) {
longest = "";
// code goes here
var words = sen.split(" ");
for(i = 0; i < words.length; i++) {
if(words[i].length > longest.length) {
longest = words[i];
}
}
return longest;
function SimpleAdding(num) {
var total = 0;
for(i = 1; i <= num; i++) {
total += i;
}
// code goes here
return total;
}
function CheckNums(num1,num2) {
if(num2 > num1) {
return true;
} else if(num1 === num2) {
return -1;
} else {
return false
}
}
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
@thetallweeks
thetallweeks / better-for-loop.js
Last active December 28, 2015 03:09
This is a better way to do a for loop. It stores the array length in a variable so the javascript doesn't have to get the array length every iteration.
var names = ['George',
'Ringo',
'Paul',
'John'];
for(var i = 0, j = names.length; i < j; i++) {
doSomethingWith(names[i]);
}
@thetallweeks
thetallweeks / github-pygments.css
Created November 14, 2013 16:33
Pygments syntax highlighting from github
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #999988; font-style: italic } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #000000; font-weight: bold } /* Keyword */
.highlight .o { color: #000000; font-weight: bold } /* Operator */
.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #999999; font-weight: bold; font-style: italic } /* Comment.Preproc */
.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */