Skip to content

Instantly share code, notes, and snippets.

View cwlsn's full-sized avatar

Connor Wilson cwlsn

View GitHub Profile
@cwlsn
cwlsn / index.js
Created October 10, 2018 00:42
Rendering Content with Gatsby StaticQuery
import React from "react";
import { StaticQuery, graphql } from "gatsby";
const HomePage = () => (
<StaticQuery
query={graphql`
query HomePage {
contentfulHomePage {
title
date
@cwlsn
cwlsn / gastby-config.js
Created October 10, 2018 00:28
Basic Contentful Source Gatsby Config
const dotenv = require("dotenv");
if (process.env.ENVIRONMENT !== "production") {
dotenv.config();
}
const { spaceId, accessToken } = process.env;
module.exports = {
plugins: [
@cwlsn
cwlsn / .editorconfig
Created March 23, 2018 18:10
.editorconfig
# http://editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = tab
insert_final_newline = true
max_line_length = 80

Greetings prospective front end developer! I've put together a quick exercise as a basic test for some of the skills we use everyday. This is a Fiddle that fetches my starred GitHub repos and displays them. This is done in a straightforward way of creating the elements needed and adding them into the DOM. I've set the Javascript window to use Babel and the styles are in SCSS.

Exercise

Recreate the Fiddle using React! Have a poke around and see how the elements are structured and styled. Use any methods of styling and layout you want. Recently I've been enjoying Styled Components if you want to take a crack at that.

@cwlsn
cwlsn / kiosk.js
Last active August 29, 2015 14:27
/* - */
'use strict';
var amtMaps = MapArray.length;
var icon = "fa fa-circle-o";
var iconActive = "fa fa-circle";
MapArray.forEach( function ( floor ) {
var switches = document.getElementById( 'switches' );
var maps = document.getElementById( 'maps_container' );
var z = MapArray.indexOf( floor );
var listItem = document.createElement( 'li' );
<?php
function dateOrNaw($date) {
$date = date_parse($date);
return ($date["error_count"] == 0 && checkdate($date["month"], $date["day"], $date["year"])) ? true : false;
}
@cwlsn
cwlsn / radioToggleMultiple.js
Created June 1, 2015 15:49
Have 3+ radio buttons that correspond to additional infomation/form elements. The value of each radio button corresponds to a div in the #grounds_more div. This hides all visible divs, then shows the desired one. Toggle doesn't cut it for 3+ items.
$("input[name='grounds']:radio").change( function () {
var val, obj;
val = $(this).val();
obj = $('#' + val);
$("#grounds_more > div:visible").fadeOut(300, function () {
obj.fadeIn(300);
});
});
@cwlsn
cwlsn / RSSFeedAsList.php
Created December 4, 2014 01:29
Grab an RSS feed and parse it into an unordered list with PHP.
<?php
function RSSFeedAsList($feedUrl) {
$content = file_get_contents($feedUrl);
$items = new SimpleXmlElement($content);
echo "<ul>";
foreach($items->channel->item as $entry) {