Skip to content

Instantly share code, notes, and snippets.

View IcodeNet's full-sized avatar
😀

Byron Thanopoulos IcodeNet

😀
View GitHub Profile
@denieler
denieler / test-utils.js
Created January 10, 2019 19:50
Custom render function for react-testing-library for jest snapshots with jss
import React from 'react'
import { render } from 'react-testing-library'
import JssProvider from 'react-jss/lib/JssProvider'
const generateClassName = (rule, styleSheet) =>
`${styleSheet.options.classNamePrefix}-${rule.key}`
const customRender = (node, options) => {
return render(
<JssProvider generateClassName={generateClassName}>
@cdeutsch
cdeutsch / webpack.config.js
Last active March 26, 2019 12:57
Caching Webpack v4 css-loader CSS Modules with LESS
module: {
rules: [
{
test: /\.less$/,
use: [
...(process.env.NODE_ENV === 'production'
? [
{
loader: MiniCssExtractPlugin.loader,
},
@ibreathebsb
ibreathebsb / upload.js
Last active May 15, 2025 20:29
file upload from dataUrl with axios
// Note: only for modern browser
import axios from 'axios'
// helper function: generate a new file from base64 String
const dataURLtoFile = (dataurl, filename) => {
const arr = dataurl.split(',')
const mime = arr[0].match(/:(.*?);/)[1]
const bstr = atob(arr[1])
let n = bstr.length
const u8arr = new Uint8Array(n)
@oreofeolurin
oreofeolurin / webpack.config.dev.js
Created February 16, 2018 14:17
Webpack file for configuring SCSS with React (create-react-app)
'use strict';
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');
# Interview Question Practice
## Iteration 1
- Describe the difference between a cookie, sessionStorage and localStorage. [-hint-](https://github.com/turingschool/lesson_plans/blob/3ee469be5fdc94c926a88ca510106848b0339731/ruby_04-apis_and_scalability/client_side_storage.markdown) [web APIs]
- What are `data-` attributes good for? [-hint-](https://css-tricks.com/almanac/selectors/a/attribute/) [html]
- Have you used or implemented media queries or mobile specific layouts/CSS? [-hint-](http://frontend.turing.io/lessons/module-1/intro-responsive.html) [css]
@mbixby
mbixby / materialUiStyles.js
Created April 26, 2017 14:34
Extending Material UI styles
import { merge } from 'lodash'
// This module allows us to completely customize all of Material UI's JSS stylesheets
// to define our own theme.
//
// Note that you Material UI's JSS is often tied to application logic and you may
// deviate from the official Material UI spec.
//
// Unlike using the `overrides` feature of jss-theme-reactor, here you have access to
// the original calculated styles and theme. Notably you can do deep merge (lodash.merge)
@scottopolis
scottopolis / splice-object-array.js
Last active July 4, 2025 13:21
Remove object from array of objects in Javascript
// we have an array of objects, we want to remove one object using only the id property
const apps = [{id:34,name:'My App',another:'thing'},{id:37,name:'My New App',another:'things'}];
// get index of object with id of 37
const removeIndex = apps.findIndex( item => item.id === 37 );
// remove object
apps.splice( removeIndex, 1 );
@kndt84
kndt84 / authorize.js
Last active May 17, 2024 03:11
Sample code: how to refresh session of Cognito User Pools with Node.js and Express
const AWS = require('aws-sdk');
const CognitoUserPool = require('amazon-cognito-identity-js-node').CognitoUserPool;
const CognitoUserSession = require('amazon-cognito-identity-js-node').CognitoUserSession;
const CognitoUser = require('amazon-cognito-identity-js-node').CognitoUser;
const CognitoIdToken = require('amazon-cognito-identity-js-node').CognitoIdToken;
const CognitoAccessToken = require('amazon-cognito-identity-js-node').CognitoAccessToken;
const CognitoRefreshToken = require('amazon-cognito-identity-js-node').CognitoRefreshToken;
const cfg = require('config').config;
const COGNITO_IDENTITY_POOL_ID = cfg.COGNITO_IDENTITY_POOL_ID;
@ChadKillingsworth
ChadKillingsworth / e2e-shadowdom.md
Last active July 6, 2023 06:54
Selenium Testing with Shadow DOM

End-to-end Testing with Shadow DOM

As the web component specs continue to be developed, there has been little information on how to test them. In particular the /deep/ combinator has been deprecated in Shadow DOM 1.0. This is particularly painful since most end-to-end testing frameworks rely on elements being discoverable by XPath or calls to querySelector. Elements in Shadow DOM are selectable by neither.

WebDriver.io

Webdriver.io has the standard actions by selectors, but also allows browser executable scripts to return an element

@tonysneed
tonysneed / Mac OS X: Open in Visual Studio Code
Last active March 29, 2025 18:40
Add a command to Finder services in Mac OSX to open a folder in VS Code
- Open Automator
- File -> New -> Service
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- Save it as something like "Open in Visual Studio Code"