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 / 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 / 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 / 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 / AppDelegate.cs
Created July 7, 2020 05:07 — forked from dannycabrera/AppDelegate.cs
Get notified when user takes screenshot on Xamarin.iOS
using Foundation;
using UIKit;
namespace YourApp
{
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
NSObject _screenshotNotification = null;
@jmptrader
jmptrader / golang-tls.md
Created August 31, 2020 21:02 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples
Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@jmptrader
jmptrader / reader.go
Created September 9, 2020 07:27 — forked from jedy/reader.go
processes communicate with shared memory in golang
package main
// #include <stdlib.h>
// #include "wrapper.c"
import "C"
import "unsafe"
import "fmt"
func read(filename string) string {
f := C.CString(filename)
@jmptrader
jmptrader / SSL.md
Created May 16, 2021 17:02 — forked from gangsta/SSL.md
How to Setting Up a Comodo SSL Cert

How to Setting Up a Comodo SSL Cert

  • I advice you to buy SSL Certs from officially Comodo only , or some SSL reseller whose you trust.

These are the steps I went through to set up an SSL cert. Purchase the cert

Prior to purchasing a cert, you need to generate a private key, and a CSR file (Certificate Signing Request). You’ll be asked for the content of the CSR file when ordering the certificate:

openssl req -new -newkey rsa:2048 -nodes -keyout example_com.key -out example_com.csr
@jmptrader
jmptrader / redirectExample.go
Created May 19, 2021 05:25 — forked from knibals/redirectExample.go
How to redirect HTTP to HTTPS with a golang webserver.
package main
import (
"net/http"
)
func redirect(w http.ResponseWriter, req *http.Request) {
http.Redirect(w, req,
"https://" + req.Host + req.URL.String(),
http.StatusMovedPermanently)
}
@jmptrader
jmptrader / deepcopy.go
Created October 3, 2021 20:21 — forked from soroushjp/deepcopy.go
Golang: deepcopy map[string]interface{}. Could be used for any other Go type with minor modifications.
// Package deepcopy provides a function for deep copying map[string]interface{}
// values. Inspired by the StackOverflow answer at:
// http://stackoverflow.com/a/28579297/1366283
//
// Uses the golang.org/pkg/encoding/gob package to do this and therefore has the
// same caveats.
// See: https://blog.golang.org/gobs-of-data
// See: https://golang.org/pkg/encoding/gob/
package deepcopy