Skip to content

Instantly share code, notes, and snippets.

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

JM jmptrader

🏠
Working from home
View GitHub Profile
@jmptrader
jmptrader / drop all objects SQLServer
Created May 24, 2020 23:51
SQLServer - this script cleans all views, SPS, functions PKs, FKs and tables.
/* Drop all non-system stored procs */
DECLARE @name VARCHAR(128)
DECLARE @SQL VARCHAR(254)
SELECT @name = (SELECT TOP 1 [name] FROM sysobjects WHERE [type] = 'P' AND category = 0 ORDER BY [name])
WHILE @name is not null
BEGIN
SELECT @SQL = 'DROP PROCEDURE [dbo].[' + RTRIM(@name) +']'
EXEC (@SQL)
@jmptrader
jmptrader / go-os-arch.md
Created July 24, 2019 06:56 — 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
@jmptrader
jmptrader / render_number.go
Created July 19, 2019 23:21 — forked from gorhill/render_number.go
A Go function to render a number to a string based on the following user-specified criteria: thousands separator, decimal separator, decimal precision. I didn't feel it was worth to publish a library just for this piece of code, hence the snippet. Feel free to reuse as you wish.
/*
Author: https://github.com/gorhill
Source: https://gist.github.com/gorhill/5285193
A Go function to render a number to a string based on
the following user-specified criteria:
* thousands separator
* decimal separator
@jmptrader
jmptrader / notify_event.sql
Created June 24, 2019 21:11 — forked from mminer/notify_event.sql
PostgreSQL trigger function to send notifications when table changes.
-- Adapted from http://coussej.github.io/2015/09/15/Listening-to-generic-JSON-notifications-from-PostgreSQL-in-Go/
CREATE OR REPLACE FUNCTION notify_event() RETURNS TRIGGER AS $$
DECLARE
data JSON;
notification JSON;
BEGIN
-- Skip notification if row doesn't actually change in UPDATE.
-- We can accomplish the same thing with a WHERE clause in the CREATE TRIGGER statement,
-- but only if the trigger watches exclusively for UPDATE events.
@jmptrader
jmptrader / gts.md
Created February 19, 2019 03:17 — forked from Divya1425/gts.md
@jmptrader
jmptrader / System Design.md
Created June 14, 2018 23:25 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@jmptrader
jmptrader / dotnet core .gitignore
Created May 17, 2018 16:00 — forked from vmandic/dotnet core .gitignore
A default .NET Core project .gitignore file
*.swp
*.*~
project.lock.json
.DS_Store
*.pyc
# Visual Studio Code
.vscode
# User-specific files
@jmptrader
jmptrader / journal.go
Created August 22, 2017 17:42 — forked from corny/journal.go
SQLite journal in Go (golang)
/*
Stores entries in a local SQLite database
until they have been processed by a submit function.
*/
package journal
import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
"sync"
@jmptrader
jmptrader / rob.go
Created April 15, 2017 13:59 — forked from Jxck/rob.go
gocon 2014
type errWriter struct {
w io.Writer
err error
}
func (e *errWriter) Write(p []byte) {
if e.err != nil {
return
}
_, e.err = e.w.Write(p)
@jmptrader
jmptrader / manifest.json
Created April 15, 2017 13:58 — forked from Jxck/manifest.json
Chrome Socket API Server
{
"manifest_version": 2,
"name": "Chrome Socket API Server",
"description": "listen & accept for socket",
"version": "0.1",
"app": {
"background": {
"scripts": ["server.js"]
}
},