Skip to content

Instantly share code, notes, and snippets.

View twhite96's full-sized avatar
☢️
Cookin

tiff twhite96

☢️
Cookin
View GitHub Profile
$('a.link').click(function(){
// `this` is an anchor DOM element in this context
// but it's not wrapped in a jQuery wrapper and doesn't
// have access to any of jQuery's helper methods.
var $a = $(this);
// once you wrap it in jQuery, it has access to them,
// for example to `.attr()`, `.prop()`, `.val()`, etc.
console.log('Clicked on', $a.attr('href'));
});
// Bonfire: Reverse a String
// Author: @twhite96
// Challenge: http://www.freecodecamp.com/challenges/bonfire-reverse-a-string?solution=function%20reverseString(str)%20%7B%0A%20%20str%20%3D%20str.split(%27%27)%3B%0A%20%20str%20%3D%20str.reverse()%3B%0A%20%20str%20%3D%20str.join(%27%27)%3B%0A%20%20return%20str%3B%0A%7D%0A%0A%0A%0A%0A%0AreverseString(%22hello%22)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function reverseString(str) {
str = str.split('');
str = str.reverse();
str = str.join('');
return str;
@matty-digital
matty-digital / styleGuide.md
Created August 20, 2016 02:57
Style guide for writing code in cs0134 and cs1520

Introduction

This is the style guide that you will be required to follow for any and all code submissions in this class. There is a very good chance that, should you decide to venture out into the wild and develop software professionally, you will be required to follow some sort of coding standard. All submissions must adhere to this style guide, if they don't there will be penalties up to and including the submission not being accepted or cosidered for a grade. You're in luck though, as this is a relatively easy style guide to follow. Suggestions are always welcome and above all else, even if you hate style guides and vow solemnly never to follow one again in your whole life...just make sure your code is consistent. Your future self will thank you. On a side note, it will be relatively apparent to me if you don't follow the style guide.

If changes are made to this guide throughout the semester, I will be sure to let you know and discuss the change with you.

General

Indentation

Deploying Yeoman apps to Heroku

Prerequisites

This assumes you already have a Yeoman app and are ready for publishing

Build for Production

Create production directory & assets

@minamarkham
minamarkham / emoji.js
Created October 28, 2015 18:17
Add emojis to URL
function emoji() {
if (navigator.userAgent.indexOf('Mac OS X') != -1) {
window.location.hash = "💋";
}
};
emoji();
// only works on Macs 😞
@supalogix
supalogix / gulpfile.js
Created September 2, 2015 07:49
A gulp file for our demo project
var gulp = require('gulp');
var jasmine = require('gulp-jasmine');
var typescript = require('gulp-tsc');
var runSequence = require('run-sequence');
gulp.task('compile', function(){
return gulp.src(['src/ts/**/*.ts'])
.pipe(typescript())
.pipe(gulp.dest('src/js/'));
});
@derickfay
derickfay / TE recipient
Last active December 9, 2017 06:39
TextExpander snippet to add recipient's name to email
-- TextExpander snippet to add recipient's name to email
-- based on http://macsparky.com/blog/2015/6/automatically-add-recipients-name-to-email-with-textexapnder [sic]
-- updated to handle hyphenated first names properly
-- ( Original version would return Young for Young-Hee . This version returns Young-Hee. )
set theResult to ""
tell application "System Events"
tell process "Mail"
tell text field "To:" of window 1
@swyxio
swyxio / Timer fallback.js
Created November 14, 2018 01:25
Timer component for use as a Suspense fallback
function Timer() {
const startTime = React.useRef(performance.now());
const [time, setTime] = React.useState(performance.now());
React.useEffect(() => {
const id = setTimeout(() => {
ReactDOM.flushSync(() => {
setTime(performance.now());
});
}, 2);
@mpj
mpj / example1.js
Last active January 14, 2019 16:03
Examples for video "Closures - Part 5 of Functional Programming in JavaScript" (http://youtu.be/CQqwU2Ixu-U)
var me = 'Bruce Wayne'
function greetMe() {
console.log('Hello, ' + me + '!')
}
greetMe() // Hello, Bruce Wayne!
// Builds array of everything ahead of time
function collectAllItems() {
return [calculateFirst(), calculateSecond(), ...]
}
// This loop will end as soon as `isMatch(item)` is truthy.
// If the very first item in the array is a match, then we
// wasted all this time building the array in the first place.
for (let item of collectAllItems()) {
if (isMatch(item)) {