Skip to content

Instantly share code, notes, and snippets.

View csndra0504's full-sized avatar
🔼
Building with NextJS

Cassandra Wilcox csndra0504

🔼
Building with NextJS
View GitHub Profile
@csndra0504
csndra0504 / composing-js-objs.js
Created October 2, 2017 18:34
Composing JS Objects
const a = 'a';
const b = 'b';
const oA = { a }; // ES6 shortcut, same as const oA = { a: a };
const oB = { b };
//composing objects with ES6 spread operator
const c = {...oA, ...oB}; // { a: 'a', b: 'b' }
//composing objects with Object.assign()
const d = Object.assign({}, oA, oB); // { a: 'a', b: 'b' }
@csndra0504
csndra0504 / gist:d5ad7ea308546afee51ff0bfef80dae0
Last active March 12, 2017 17:51
Sum Squares from 1 to n with JavaScript (ES6)
// sum the squares from 1 to N
const square = x => x * x;
const add = (a, b) => a + b;
const sumSquares = n => Array.from(Array(n+1).keys())
.map(square)
.reduce(add);
console.log(sumSquares(5));
@csndra0504
csndra0504 / add-curried.js
Created February 18, 2017 02:39
ES6 Add Curried
const add = x => y => x+y;
console.log(add(2)(5)); //7
@csndra0504
csndra0504 / Javascript: JQ Mobile Template
Created December 13, 2012 13:53
Jqery Mobile Starter Template
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
@csndra0504
csndra0504 / CSS: Drop Cap
Created December 12, 2012 20:02
CSS Drop Cap
p:first-letter{
display:block;
margin:5px 0 0 5px;
float:left;
color:#000;
font-size:60px;
font-family:Georgia;
}
@csndra0504
csndra0504 / CSS: Sticky Footer
Created December 12, 2012 20:01
Sticky Footer
@csndra0504
csndra0504 / CSS: FullScreen Background Image
Created December 12, 2012 19:58
Fullscreen Background Image
html {
background: url(../img/your-background-image.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
@csndra0504
csndra0504 / CSS: Message Boxes
Created December 12, 2012 19:55
Css message boxes: Info, Success, Warning, Error, Validation
<!DOCTYPE HTML>
<html>
<head>
<style>
body{
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
}
.info, .success, .warning, .error, .validation {
border: 1px solid;
@csndra0504
csndra0504 / Javascript: Clear all Text Fields
Created December 12, 2012 19:47
Clear all input fields
$(document).ready(function(){
$("#checkboxall").change(function(){
var checked_status = this.checked;
$("input[name=checkall]").attr("checked", checked_status);
});
});
@csndra0504
csndra0504 / Javascript: Check all Checkboxes
Created December 12, 2012 19:44
Check all checkboxes
var tog = false; // or true if they are checked on load
$('a').click(function() {
$("input[type=checkbox]").attr("checked",!tog);
tog = !tog;
});