Skip to content

Instantly share code, notes, and snippets.

View shankarnakai's full-sized avatar
🤓
System programming, Rust, low latency, Databases

Shankar Nakai Gonçalves dos Santos shankarnakai

🤓
System programming, Rust, low latency, Databases
View GitHub Profile
@jsundram
jsundram / cull.py
Last active April 5, 2023 15:22
Check if lat long is inside the bounds of the continental US (box model, not shape)
# http://en.wikipedia.org/wiki/Extreme_points_of_the_United_States#Westernmost
top = 49.3457868 # north lat
left = -124.7844079 # west long
right = -66.9513812 # east long
bottom = 24.7433195 # south lat
def cull(latlngs):
""" Accepts a list of lat/lng tuples.
returns the list of tuples that are within the bounding box for the US.
NB. THESE ARE NOT NECESSARILY WITHIN THE US BORDERS!
@langmi
langmi / CustomSqlParameterSourceProvider.java
Created September 30, 2011 09:14
simple example CustomSqlParameterSourceProvider which constructs a MapSqlParameterSource with given item
/**
* CustomSqlParameterSourceProvider, constructs {@link MapSqlParameterSource} with
* given item.
*
* @author Michael R. Lange <michael.r.lange@langmi.de>
*/
public class CustomSqlParameterSourceProvider implements ItemSqlParameterSourceProvider<YourItemObject> {
@Override
public SqlParameterSource createSqlParameterSource(final YourItemObject item) {
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 21, 2024 20:54
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@brigand
brigand / GDIpHelper.ahk
Created October 23, 2012 20:28
Helper Library for GDIp library Based On Tic's tutorial #1
JustTheBasics() {
global
; Start gdi+
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
@albrow
albrow / confirm.go
Last active April 16, 2023 03:03
Go (golang): How to ask for user confirmation via command line
import (
"fmt"
"log"
"os"
"sort"
)
// askForConfirmation uses Scanln to parse user input. A user must type in "yes" or "no" and
// then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as
// confirmations. If the input is not recognized, it will ask again. The function does not return
@mflatt
mflatt / functional.rkt
Created January 16, 2014 17:13
Programs by Jay and Matthew at Lambda Lounge Utah, 14 Jan 2014: * "functional.rkt" is from Jay's introduction to functional programming * "web.rkt" and "page.rkt" are from Matthew's explanation of Racket macros & modules
#lang racket
(require rackunit)
;; A singly linked list is either
;; - NULL
;; - pointer to data and a pointer a sll
(struct node (data-ptr next-ptr))
(define n4 (node 4 null))
@andreberg
andreberg / PoE-Macros.ahk
Last active June 21, 2022 18:16
[Path of Exile Autohotkey Macros] Shows how to bind some (really outdated!) commands to hotkeys. #pathofexile #poe #ahk #autohotkey #macros
#IfWinActive, Path of Exile ahk_class Direct3DWindowClass
#SingleInstance force
; Menu tooltip
Menu, tray, Tip, Path of Exile Macros
; NOTE: Adjust this path so it is correct.
; If you are using my PoE-Item-Info script you can find
; the tray icons inside its data directory.
Menu, tray, Icon, PoE Item Info\data\poe-web.ico
@srsudar
srsudar / background.html
Created July 27, 2014 18:00
Pasting from the system clipboard using a Chrome extension.
<!DOCTYPE html>
<html>
<head>
<script src="background.js"></script>
</head>
<body>
<textarea id="sandbox"></textarea>
</body>
@justmoon
justmoon / custom-error.js
Last active June 26, 2024 09:36 — forked from subfuzion/error.md
Creating custom Error classes in Node.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = message;
this.extra = extra;
};
require('util').inherits(module.exports, Error);
import java.security.MessageDigest
import java.util
import javax.crypto.Cipher
import javax.crypto.spec.SecretKeySpec
import org.apache.commons.codec.binary.Base64
/**
* Sample:
* {{{
* scala> val key = "My very own, very private key here!"