Skip to content

Instantly share code, notes, and snippets.

View JakeSidSmith's full-sized avatar
💭
Being awesome 😎

Jake 'Sid' Smith JakeSidSmith

💭
Being awesome 😎
View GitHub Profile
@JakeSidSmith
JakeSidSmith / patterns.css
Last active December 22, 2015 14:58
Creating patterns with CSS on a single element (with at least IE9+ support)
// Demo: https://jsfiddle.net/ajgp31ra/2/
// Note: No pseudo elements (:before / :after)
.grid-3x3 {
display: inline-block;
box-sizing: content-box;
margin: 8px;
width: 4px;
height: 4px;
@JakeSidSmith
JakeSidSmith / regex.md
Last active March 21, 2016 17:09
List of useful javascript regular expressions

Validation

Password

Contains lowercase character

/[a-z]/

Contains uppercase character

@JakeSidSmith
JakeSidSmith / index.js
Last active March 31, 2016 02:07
Speed test - joining arrays with commas
var testCount = 10000;
var arr = ['a', 'b', 'c'];
var str = '';
var prevDate = new Date().getTime();
for (var i = 0; i < testCount; i += 1) {
str = '';
for (var t = 0; t < arr.length; t += 1) {
str += arr[t];
if (t < arr.length - 1) {
@JakeSidSmith
JakeSidSmith / star.js
Last active May 18, 2016 22:47
Plotting perfect stars
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
function plotStar (x, y, r, s) {
var offset = Math.PI * 2 / (s * 2);
var cross = Math.cos(offset * 2) * r;
var r2 = cross / Math.cos(offset);
for (var i = 0; i < s * 2 + 1; i += 1) {
@JakeSidSmith
JakeSidSmith / indentation.md
Last active August 25, 2016 11:30
Discussion about preferable indentation

I have the following variables: type, collection

And the utility function: ReactTableUtilities.hasOnlyZeroValues

I must return null, if type is any of the following: 'ACCOUNT', 'GROUP', 'FORMULA', and (inclusive) if all of the values in this collection are zero values.

How would you write this conditional return?

Leave a comment with your code and reasoning.

@JakeSidSmith
JakeSidSmith / index.js
Last active August 25, 2016 11:53
Canvasimo methods
/*
Once inspired by: https://github.com/scalableminds/fluent-canvas#tapcallback
*/
// All methods are bound to the canvasimo object
canvasimo
.tap(function () {
@JakeSidSmith
JakeSidSmith / indentation.md
Last active August 26, 2016 09:07
Discuss indentation linting

So, the way I see it, is we have 2 options for chain indentation

Indented, and not indented

There are 3 examples of each below

Bare in mind, that you can still chain inline (unless we enforce newlines for multi-chains) http://eslint.org/docs/rules/newline-per-chained-call

And that the linter does not lint for variable declarations: "Any indentation is permitted in variable declarations and assignments."

@JakeSidSmith
JakeSidSmith / index.css
Last active October 13, 2016 11:12
Select an image, and draw in onto a canvas
canvas {
background-color: white;
}
@JakeSidSmith
JakeSidSmith / css-icon-drag-corner.css
Last active November 11, 2016 13:05
A corner drag icon made with pure CSS
// https://jsfiddle.net/7Ldmmrjd/1/
span {
display: inline-block;
width: 12px;
height: 12px;
}
span,
span::before,
@JakeSidSmith
JakeSidSmith / jswat.md
Last active December 9, 2016 14:19
Crazy javascript madness questionnaire

jswat

All of the following questions are about javascript. Simply let me know what the value of answer is. Don't forget to add appropriate quotes for string values.

The first 15 questions are worth 1 point. Question 16 is worth 5 points.

  1. var answer = 0.1 + 0.2;