This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
body { font: 12px Arial;} | |
path { | |
stroke: steelblue; | |
stroke-width: 2; | |
fill: none; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Chart = (function(window,d3) { | |
var svg, data, x, y, xAxis, yAxis, dim, chartWrapper, line, path, margin = {}, width, height, locator; | |
var breakPoint = 768; | |
d3.csv('data.csv', init); //load data, then initialize chart | |
//called once the data is loaded | |
function init(csv) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
If you have a horizontal (or vertical) scroll container and want to set the scroll to center a specific | |
element in the container you can use the following super simple technique. | |
I'm going to show you how it was derived, because it's important to know why, not just how. | |
*/ | |
/* | |
Setup: | |
[HTML] | |
<div class="outer"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Slightly improved version with destructuring working as expected | |
export default async function tryCatch<T>( | |
promise: Promise<T> | |
): Promise<{ error?: Error; data?: T }> { | |
try { | |
return { data: await promise }; | |
} catch (error) { | |
return { error }; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets all event-handlers from a DOM element. | |
* Events with namespace are allowed. | |
* | |
* @param {Element} node: DOM element | |
* @param {String} eventns: (optional) name of the event/namespace | |
* @return {Object} | |
*/ | |
function getEventHandlers(element, eventns) { | |
const $ = window.jQuery; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text.RegularExpressions; | |
namespace RegExTest | |
{ | |
static class MyExtensions | |
{ | |
public static void PrintMatch(this Regex re, string input) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { rest } from 'msw'; | |
import userEvent from '@testing-library/user-event'; | |
import { render, screen } from '../testUtils'; | |
import ItemsPage from '../pages/Items'; | |
import server from '../mocks/server'; | |
describe('given Items Page', () => { | |
test('fetches items from API on page load', async () => { | |
render(<ItemsPage />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Determine the possible characters that could result from a certain morse code word with some potentially unknown signals (?). | |
// ? is either dit (.) or dah (-) | |
// This is incomplete, sorry. | |
const possibilities = signal => { | |
const signals = signal.split(''); | |
console.log(`🚀`, signals); | |
const hasUnknownSignal = signals.includes('?'); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const https = require('https'); | |
https.get('https://coderbyte.com/api/challenges/json/json-cleaning', (resp) => { | |
let raw = ''; | |
const expected = {"name":{"first":"Daniel","last":"Smith"},"age":45, "items_removed": 1}; | |
// parse json data here... | |
let index = 1; | |
resp.on('data' , (chunk) => { | |
raw += chunk; |
OlderNewer