Skip to content

Instantly share code, notes, and snippets.

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

Will Dent WillDent

🏠
Working from home
View GitHub Profile
@WillDent
WillDent / DestructiveActionGuard.tsx
Created April 15, 2024 02:41 — forked from MarceloPrado/DestructiveActionGuard.tsx
An easy way of seeking user confirmation before proceeding with a destructive action. Demo: https://twitter.com/marceloterreiro/status/1779657639745798411
import type { ReactElement } from "react";
import { cloneElement, memo, useCallback } from "react";
import { AlertV2 } from "@/components/AlertV2/alertV2Helpers";
export interface DestructiveActionGuardProps {
children: ReactElement<{ onPress: () => void }>;
confirmationTitle?: string;
confirmationDescription?: string;
}
@WillDent
WillDent / example-of-custom-policies-hook.js
Created April 8, 2016 12:07 — forked from mikermcneil/example-of-custom-policies-hook.js
example of using a hook to apply policies to specific shadow routes that were injected by another hook (specifically the swagger hook, in this case)
// For info on setting up this hook, check out the docs here: http://sailsjs.org/#!/documentation/concepts/extending-sails/Hooks/usinghooks.html
module.exports = function (sails) {
return {
routes: {
before: {
// If you want to protect the home route as it is exposed by the swagger hook (i.e. rather than protecting a particular action)
// you can do so by setting a shadow route here. Note however that this hook must run BEFORE the swagger hook does.

Install Elasticsearch with Service Wrapper

# This code snippet is runnable

# Download Elasticsearch zip
curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.7.zip

# Unzip to desired location
unzip elasticsearch-0.90.7.zip -d $HOME
@WillDent
WillDent / pm2_ubuntu.sh
Last active February 2, 2022 13:34
Installation of PM2 on Ubuntu so it autostarts scripts
# Requirements:
# Node Installed
# Safe User that is running as node
#1) Install pm2
sudo npm install -g pm2
#2) Set-up PM2 to autostart upon server rebooting
#sudo env PATH=$PATH:/usr/local/bin pm2 startup <platform> -u <safe_user_not_root>
sudo env PATH=$PATH:/usr/local/bin pm2 startup ubuntu -u ubuntu
@WillDent
WillDent / node_centos_install
Created July 24, 2012 19:46 — forked from jbowles/node_centos_install
Install Node.js on CentOS
# this is a work in progress!!
######################################################
# I'm on a CentOS dev VM provided by my company #
######################################################
#uname -a
#Linux ------- 2.6.18-128.el5 ----- x86_64 x86_64 x86_64 GNU/Linux
# OR
#cat /proc/version
#Linux version 2.6.18-128.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)) ----
@WillDent
WillDent / hello-node.js
Created July 7, 2012 03:53 — forked from nf/hello-node.js
Hello world web server that scales across multiple processors
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {