Skip to content

Instantly share code, notes, and snippets.

View jamesmcm's full-sized avatar

James McMurray jamesmcm

View GitHub Profile
@AravindaM
AravindaM / SHA256HMAC.scala
Last active March 2, 2022 20:51
Generate HMAC using SHA256 in Scala
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
Object HMACgen {
def generateHMAC(sharedSecret: String, preHashString: String): String = {
val secret = new SecretKeySpec(sharedSecret.getBytes, "SHA256") //Crypto Funs : 'SHA256' , 'HmacSHA1'
val mac = Mac.getInstance("SHA256")
mac.init(secret)
val hashString: Array[Byte] = mac.doFinal(preHashString.getBytes)
@subfuzion
subfuzion / curl.md
Last active April 30, 2026 08:42
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.

@aslotnick
aslotnick / point_in_polygon.sql
Last active February 6, 2018 17:28
Simple point-in-polygon UDF for Amazon Redshift based on http://geospatialpython.com/2011/08/point-in-polygon-2-on-line.html
CREATE FUNCTION point_in_polygon(point_x float, point_y float, polygon_wkt varchar(max))
RETURNS boolean IMMUTABLE AS
$$
### begin section copied from http://geospatialpython.com/2011/08/point-in-polygon-2-on-line.html (I modifed to return boolean)
# Improved point in polygon test which includes edge
# and vertex points
def point_in_poly(x,y,poly):
@gene1wood
gene1wood / all_aws_lambda_modules_python.md
Last active June 6, 2026 09:55
AWS Lambda function to list all available Python modules for Python 2.7 3.6 and 3.7
@pathikrit
pathikrit / SudokuSolver.scala
Last active April 12, 2024 15:00
Sudoku Solver in Scala
val n = 9
val s = Math.sqrt(n).toInt
type Board = IndexedSeq[IndexedSeq[Int]]
def solve(board: Board, cell: Int = 0): Option[Board] = (cell%n, cell/n) match {
case (r, `n`) => Some(board)
case (r, c) if board(r)(c) > 0 => solve(board, cell + 1)
case (r, c) =>
def guess(x: Int) = solve(board.updated(r, board(r).updated(c, x)), cell + 1)
val used = board.indices.flatMap(i => Seq(board(r)(i), board(i)(c), board(s*(r/s) + i/s)(s*(c/s) + i%s)))
@svanellewee
svanellewee / blockmove.go
Last active April 21, 2019 17:09
Get a block to move with SDL2 and GoLang
package main
import (
"fmt"
"github.com/veandco/go-sdl2/sdl"
"os"
)
var winTitle string = "Go-SDL2 Events"
var winWidth, winHeight int = 800, 600
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 7, 2026 11:54
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: