Skip to content

Instantly share code, notes, and snippets.

View n3ps's full-sized avatar

Francis Nepomuceno n3ps

View GitHub Profile
@n3ps
n3ps / relay-helper.jsx
Created January 5, 2023 04:25
Relay helper for React Testing Library
import { RelayEnvironmentProvider, useLazyLoadQuery } from 'react-relay';
import { createMockEnvironment } from 'relay-test-utils';
import { render } from '@testing-library/react';
/*
Usage:
const query = graphql`
query Query @relay_test_operation {
@n3ps
n3ps / array-range.js
Created July 20, 2021 18:49
Array range
function range (start, stop) {
const len = stop - start + 1
return Array(len).fill().map((_, i) => start + 1)
}
// Usage
range(10, 12) // [10, 11, 12]
@n3ps
n3ps / machine.js
Created April 22, 2021 18:36
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@n3ps
n3ps / google-drive.reg
Last active June 6, 2020 02:24
Pin Google Drive to Windows Explorer - make sure to replace %USERPROFILE% with full path
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\CLSID\{81539FE6-33C7-4CE7-90C7-1C7B8F2F2D41}]
@="Google Drive"
"System.IsPinnedToNamespaceTree"=dword:00000001
"SortOrderIndex"=dword:00000042
[HKEY_CURRENT_USER\Software\Classes\CLSID\{81539FE6-33C7-4CE7-90C7-1C7B8F2F2D41}\InProcServer32]
@=hex(2):25,00,53,00,59,00,53,00,54,00,45,00,4D,00,52,00,4F,00,4F,00,54,00,\
25,00,5C,00,73,00,79,00,73,00,74,00,65,00,6D,00,33,00,32,00,5C,00,73,00,68,\
@n3ps
n3ps / enzyme_render_diffs.md
Created May 8, 2020 21:57 — forked from fokusferit/enzyme_render_diffs.md
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@n3ps
n3ps / commands.txt
Created April 28, 2020 19:54 — forked from theparticleman/commands.txt
Node, .NET Core, Python, Ruby, Rust, Kotlin and Swift build/runtime environments in Docker
docker run -v [local path]:/code -it node bash
cd /code
echo "console.log('Hello, World');" > app.js
node app.js
docker run -v [local path]:/code -it microsoft/dotnet bash
cd /code
dotnet new console
dotnet run
@n3ps
n3ps / index.js
Created April 4, 2020 20:19
Simple node-selenium demo
// here we are importing packages
var webdriver = require('selenium-webdriver');
var chromedriver = require('chromedriver');
var filesystem = require('fs');
var driver = new webdriver.Builder().forBrowser('chrome').build()
// specify which url
var url = 'https://www.google.com';
@n3ps
n3ps / angularjs-simple-filter2.html
Last active April 4, 2020 19:16
Angular 1.x simple filter example 2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Quickest auto-filter</title>
</head>
<body ng-app="app" ng-controller="Main as vm">
<input type="seach" ng-model="search" placeholder="type a Beatles name" />
<ul>
@n3ps
n3ps / angularjs-simple-filter.html
Last active April 4, 2020 19:13
Angular 1.x simple filter example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Quickest auto-filter</title>
</head>
<body ng-app="app" ng-controller="Main as vm">
<input type="seach" ng-model="search" placeholder="type a Beatles name" />
<ul>
@n3ps
n3ps / remove-space.js
Created January 30, 2020 05:46
JavaScript tidbits
// replace() expects a RegEx pattern
'some string'.replace(/ /g, '')
// or /\s/g for *all* kinds of whitespace