Skip to content

Instantly share code, notes, and snippets.

@algunning-hmh
algunning-hmh / worker-shutdown.ts
Created June 4, 2020 11:09 — forked from Dante-101/worker-shutdown.ts
Gist for graceful shutdown of workers
gracefulClusterShutdown = (signal: NodeJS.Signals) => async () => {
if (this.shutdownInProgress)
return
this.shutdownInProgress = true
this.hasCleanWorkerExit = true
log.info(`Got ${signal} on ${this.processStr}. Graceful shutdown start at ${new Date().toISOString()}`)
try {
@algunning-hmh
algunning-hmh / launch.json
Created June 6, 2019 11:19
Visual Studio Code - Launch debugger via npm script
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch via npm",
"type": "node",
"request": "launch",
@algunning-hmh
algunning-hmh / script.sh
Created July 12, 2018 16:41 — forked from vielhuber/script.sh
PostgreSQL: Backup and restore pg_dump with password on command line #sql
# best practice: linux
nano ~/.pgpass
*:5432:*:username:password
chmod 0600 ~/.pgpass
# best practice: windows
edit %APPDATA%\postgresql\pgpass.conf
*:5432:*:username:password
# linux
@algunning-hmh
algunning-hmh / postgres_queries_and_commands.sql
Last active July 3, 2018 10:51 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@algunning-hmh
algunning-hmh / encrypt_decrypt_example.js
Created January 19, 2018 17:51 — forked from erans/encrypt_decrypt_example.js
Example of encryption and decryption in node.js
var crypto = require("crypto")
function encrypt(key, data) {
var cipher = crypto.createCipher('aes-256-cbc', key);
var crypted = cipher.update(text, 'utf-8', 'hex');
crypted += cipher.final('hex');
return crypted;
}
@algunning-hmh
algunning-hmh / mysql_procedure_transaction.sql
Created November 29, 2017 09:48 — forked from julwong/mysql_procedure_transaction.sql
example for using transaction and essential error handling in a mysql store procedure
drop procedure store_sth;
DELIMITER $$
CREATE PROCEDURE `store_sth` (IN i INT)
BEGIN
DECLARE exit handler for sqlexception
BEGIN
var ReactTable = React.createClass({
getInitialState: function() {
return {currentData: this.props.data};
},
render: function() {
var key = Date.now();
@algunning-hmh
algunning-hmh / delay-promise.js
Created September 11, 2017 14:28 — forked from joepie91/delay-promise.js
ES6 Promise.delay
module.exports = function(duration) {
return function(){
return new Promise(function(resolve, reject){
setTimeout(function(){
resolve();
}, duration)
});
};
};
@algunning-hmh
algunning-hmh / AppConfig.java
Created February 28, 2017 15:00 — forked from ShigeoTejima/AppConfig.java
send mail to AWS SES using spring boot
package org.test.demo;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
@Configuration
public class AppConfig {
@Component
public class ClientAuthenticationProvider implements AuthenticationProvider {
static final List<GrantedAuthority> AUTHORITIES = new ArrayList<GrantedAuthority>();
static {
AUTHORITIES.add(new SimpleGrantedAuthority("ROLE_USER"));
}
@Override