Skip to content

Instantly share code, notes, and snippets.

View crobinson42's full-sized avatar
🏠
Working from home

Cory Robinson crobinson42

🏠
Working from home
  • American Software
  • Northwest USA
View GitHub Profile
@khalidx
khalidx / node-typescript-esm.md
Last active April 17, 2024 12:32
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@sidola
sidola / pubsub.ts
Last active January 24, 2023 05:13
Basic typesafe pub-sub implementation in Typescript
/* ------------------------------------------
Alternative impl. as a class can be found here: https://gist.github.com/sidola/eaf987d8c4c7e8445b61dc07c33a842f
Has a way smaller footprint and less typescript magic to grasp.
------------------------------------------ */
/**
* Defines the function type of the publish function.
*
@jlevy
jlevy / simple-hash.js
Last active April 12, 2024 16:06
Fast and simple insecure string hash for JavaScript
// These hashes are for algorithmic use cases, such as bucketing in hashtables, where security isn't
// needed and 32 or 64 bits is enough (that is, rare collisions are acceptable). These are way simpler
// than sha1 (and all its deps) or similar, and with a short, clean (base 36 alphanumeric) result.
// A simple, *insecure* 32-bit hash that's short, fast, and has no dependencies.
// Output is always 7 characters.
// Loosely based on the Java version; see
// https://stackoverflow.com/questions/6122571/simple-non-secure-hash-function-for-javascript
const simpleHash = str => {
let hash = 0;
@falvarez
falvarez / docker-shell.sh
Created January 24, 2018 08:10
Run docker container, mount current working directory and get interactive shell
docker run -ti -v $(pwd):/tmp DOCKER_IMAGE /bin/bash
@guilouro
guilouro / bitbucket-pipelines.yml
Created May 15, 2017 16:55
publish npm with bitbucket pipeline
image: node:7
pipelines:
default:
- step:
script:
- printf "//`node -p \"require('url').parse(process.env.NPM_REGISTRY_URL || 'https://registry.npmjs.org').host\"`/:_authToken=${NPM_TOKEN}\nregistry=${NPM_REGISTRY_URL:-https://registry.npmjs.org}\n" >> ~/.npmrc
- npm publish
@chourobin
chourobin / 0-bridging-react-native-cheatsheet.md
Last active April 11, 2024 15:02
React Native Bridging Cheatsheet
@crobinson42
crobinson42 / dillon_task_filter_input.js
Created March 31, 2017 18:05
Live filter input for Dillon task board
// tamper script to add a live filter input next to search
const $table = $('table.task-list')
const $tableBody = $table.find('tbody')
const $filterInput = $('<input type="search" placeholder="filter"/>')
const filterInput = inputText => {
if (!inputText || inputText.length < 3) {
$tableBody.find('tr.hidden').map((i, el) => {
$(el).removeClass('hidden')
})
return
@yajra
yajra / axios-401-response-interceptor.js
Last active September 20, 2023 06:24
Axios 401 response interceptor.
// Add a 401 response interceptor
window.axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
if (401 === error.response.status) {
swal({
title: "Session Expired",
text: "Your session has expired. Would you like to be redirected to the login page?",
type: "warning",
showCancelButton: true,
@colemanw
colemanw / font-awesome-mime-type-icons.php
Last active March 11, 2024 04:21 — forked from guedressel/font-awesome-mime-type-icons.php
Font Awesome File Icons: Mapping MIME Types to correct icon classes
<?php
/**
* Get font awesome file icon class for specific MIME Type
* @see https://gist.github.com/guedressel/0daa170c0fde65ce5551
*
*/
function ($mime_type) {
// List of official MIME Types: http://www.iana.org/assignments/media-types/media-types.xhtml
$icon_classes = array(
@jarretmoses
jarretmoses / React Native Clear Cache
Last active March 11, 2024 10:20
Clearing the Cache of your React Native Project
RN < 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.50 - watchman watch-del-all && rm -rf $TMPDIR/react-native-packager-cache-* && rm -rf $TMPDIR/metro-bundler-cache-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache
RN >= 0.63 - watchman watch-del-all && rm -rf node_modules && npm install && rm -rf /tmp/metro-* && npm run start --reset-cache
npm >= 5 - watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
Windows - del %appdata%\Temp\react-native-* & cd android & gradlew clean & cd .. & del node_modules/ & npm cache clean --force & npm install & npm start -- --reset-cache