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 / add.c
Created January 10, 2017 13:02 — forked from dbalan/add.c
cgo sample code
#include "add.h"
int add_two_numbers(int x, int y) {
return x + y;
}
int add_fzed_two_numbers(int x, int y) {
return add_two_numbers(FuzzNumber(x),
FuzzNumber(y));
}
@jmptrader
jmptrader / cgo-sample.go
Created January 10, 2017 13:02 — forked from 3d0c/cgo-sample.go
cgo samples
package main
/*
#include <string.h>
void write_int(int *len) {
*len = 10;
}
void write_int_array(int *sizes[]) {
@jmptrader
jmptrader / BUILD
Created January 10, 2017 13:04 — forked from wangkuiyi/BUILD
Go invokes C samples
cc_plugin(
name = 'lda',
srcs = ['lda.c'],
deps = ['#pthread']
)
@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"]
}
},
@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 / 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 / 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 / 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 / gts.md
Created February 19, 2019 03:17 — forked from Divya1425/gts.md
@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.