Skip to content

Instantly share code, notes, and snippets.

-- Check the fields of target table first
select column_name from information_schema.columns where table_schema = DATABASE() AND table_name='TestTable';
-- Migrate the data to the trash
INSERT INTO Trash (model, modelId, eventId, content, createdAt, createdBy, updatedAt, updatedBy)
SELECT 'tablename', id as modelId, eventId, JSON_OBJECT("field1", field1, "field2", field2), CURRENT_TIME, 'test', CURRENT_TIME, 'test' from TestTable
WHERE id IN (123);
-- Remve the data from original table
@bamoo456
bamoo456 / nodejs-tcp-example.js
Created April 21, 2018 02:34 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@bamoo456
bamoo456 / main.go
Last active March 2, 2025 06:36
[Golang] execute long running job and streaming the realtime output
func main() {
cmd := exec.Command("sh", "-c", "cd ../../bin/worker; ./run.sh")
// some command output will be input into stderr
// e.g.
// cmd := exec.Command("../../bin/master_build")
// stderr, err := cmd.StderrPipe()
stdout, err := cmd.StdoutPipe()
if err != nil {
fmt.Println(err)
}
@bamoo456
bamoo456 / curl.md
Created June 13, 2017 08:49 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@bamoo456
bamoo456 / yourservice.conf
Created August 30, 2016 14:46 — forked from c4milo/yourservice.conf
upstart example script
# Ubuntu upstart file at /etc/init/yourservice.conf
pre-start script
mkdir -p /var/log/yourcompany/
end script
respawn
respawn limit 15 5
start on runlevel [2345]
@bamoo456
bamoo456 / .jshintrc.js
Created July 17, 2016 02:08 — forked from connor/.jshintrc.js
jshintrc example
// NOTE: I added the .js extension to this gist so it would have syntax highlighting. This file should have NO file extension
{
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 100, // Maximum error before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
@bamoo456
bamoo456 / notes.md
Created June 21, 2016 03:47 — forked from pulkitsinghal/notes.md
Loopback: How to log any errors via a global error handler?

Pitfalls

The REST adapter for strong-remoting sets up its own error handler! So you cannot accomplish this for REST API related calls by replacing:

  1. app.use(loopback.errorHandler()); in server/server.js
  2. or, loopback#errorHandler in middleware.json

So don't waste your time there.

Deeper Understanding

@bamoo456
bamoo456 / node-cluster-messaging.js
Created May 9, 2016 08:39 — forked from jpoehls/node-cluster-messaging.js
Simple message passing between cluster master and workers in Node.js
var cluster = require('cluster');
if (cluster.isWorker) {
console.log('Worker ' + process.pid + ' has started.');
// Send message to master process.
process.send({msgFromWorker: 'This is from worker ' + process.pid + '.'})
// Receive messages from the master process.
@bamoo456
bamoo456 / readme.md
Created April 8, 2016 10:10 — forked from coolaj86/how-to-publish-to-npm.md
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "[email protected]"
npm set init.author.url "http://yourblog.com"

npm adduser

@bamoo456
bamoo456 / .vimrc
Last active March 14, 2016 05:37 — forked from joegoggins/.vimrc
Mac Vim .vimrc file
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" ================ General Config ====================
set number "Line numbers are good
set backspace=indent,eol,start "Allow backspace in insert mode
set history=1000 "Store lots of :cmdline history
set showcmd "Show incomplete cmds down the bottom