Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / main.go
Last active August 8, 2023 07:41
[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 / 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');
-- 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 / dep.md
Created July 6, 2018 08:17 — forked from subfuzion/dep.md
Concise guide to golang/dep

Overview

This gist is based on the information available at golang/dep, only slightly more terse and annotated with a few notes and links primarily for my own personal benefit. It's public in case this information is helpful to anyone else as well.

I initially advocated Glide for my team and then, more recently, vndr. I've also taken the approach of exerting direct control over what goes into vendor/ in my Dockerfiles, and also work from isolated GOPATH environments on my system per project to ensure that dependencies are explicitly found under vendor/.

At the end of the day, vendoring (and committing vendor/) is about being in control of your dependencies and being able to achieve reproducible builds. While you can achieve this manually, things that are nice to have in a vendoring tool include:

@bamoo456
bamoo456 / go-os-arch.md
Created July 12, 2018 15:19 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.8.3 darwin/amd64.

A list of valid GOOS values

(Bold = supported by go out of the box, ie. without the help of a C compiler, etc.)

  • android
  • darwin
@bamoo456
bamoo456 / check_net_ports.sh
Created August 6, 2018 13:08
For showing current server listen ports
sudo lsof -iTCP -sTCP:LISTEN | grep sshd
lsof -i -P -n
@bamoo456
bamoo456 / download.py
Created August 8, 2018 00:35 — forked from mie00/download.py
pdf free books
# -*- coding: utf-8 -*-
import re
import urllib
from multiprocessing import Pool
import requests
import progressbar
CHUNK_SIZE = 1024 * 1024 # 1MB
def download(i):