Skip to content

Instantly share code, notes, and snippets.

@luisrudge
luisrudge / file.js
Created January 30, 2020 22:24
trigger an error in a React ErrorBoundary from a hook
const TheComponent = () => {
const [error, setError] = React.useState();
React.useEffect(() => {
const asyncOperation = async () => {
// do something async
};
asyncOperation().catch(e => {
setError(() => {
@luisrudge
luisrudge / Products.js
Created September 12, 2019 15:02
api hooks
const Products = () => {
const { loading, data: products, refetch } = useApiGET(`/products`);
const api = useApi();
if (loading) {
return <Loading />;
}
return (
<div>
{products.map(p => (
@luisrudge
luisrudge / auth0-react-wrapper.ts
Created August 2, 2019 17:21
[WIP / non-official] typescript version of the react wrapper for auth0-spa-js
import React, { useState, useEffect, useContext } from "react";
import createAuth0Client from "@auth0/auth0-spa-js";
import Auth0Client from "@auth0/auth0-spa-js/dist/typings/Auth0Client";
interface Auth0Context {
isAuthenticated: boolean;
user: any;
loading: boolean;
popupOpen: boolean;
loginWithPopup(options: PopupLoginOptions): Promise<void>;
import 'loaders.css/loaders.css';
import './index.scss';
import React, { PropTypes } from 'react';
const LoadingIndicator = React.createClass({
propTypes: {
children: PropTypes.func.isRequired,
isLoading: PropTypes.bool.isRequired
},
render: function() {
@luisrudge
luisrudge / .gitlab-ci.yml
Created June 4, 2016 05:45
docker-alpine
```yml
before_script:
- apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/main --repository http://dl-cdn.alpinelinux.org/alpine/edge/community docker
- docker -v
- service docker start
```
@luisrudge
luisrudge / Windows10-Setup.ps1
Created January 6, 2016 16:01 — forked from NickCraver/Windows10-Setup.ps1
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
##################
# Privacy Settings
##################
# Privacy: Let apps use my advertising ID: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1
# Privacy: SmartScreen Filter for Store Apps: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0
@luisrudge
luisrudge / bem-test.html
Created May 15, 2015 23:13
is this right according to BEM?
<aside class="sidebar">
<nav class="menu">
<div class="menu-item">
<a href="" class="menu-item__link">
<span class="menu-item__icon">
<i class="ion-ios-home-outline"></i>
</span>
<span class="menu-item__text">
Home
</span>
@luisrudge
luisrudge / boxstarter-after-visual-studio
Last active August 29, 2015 14:04
boxstarter-after-visual-studio
Update-ExecutionPolicy Unrestricted
cinst ncrunch2.vs2013
cinst resharper
choco install GitDiffMargin
Install-ChocolateyVsixPackage WebEssentials2013 http://visualstudiogallery.msdn.microsoft.com/56633663-6799-41d7-9df7-0f2a504ca361/file/105627/37/WebEssentials2013.vsix
Install-ChocolateyVsixPackage BuildVision http://visualstudiogallery.msdn.microsoft.com/23d3c821-ca2d-4e1a-a005-4f70f12f77ba/file/95980/7/BuildVisi