Skip to content

Instantly share code, notes, and snippets.

View devm33's full-sized avatar

Devraj Mehta devm33

View GitHub Profile
@devm33
devm33 / beforeExit.js
Created March 1, 2024 02:31
beforeExit
process.on('beforeExit', async () => {
const res = await fetch('https://copilot-proxy.githubusercontent.com/_ping');
console.log('beforeExit', res.status, await res.text());
});
process.on('SIGINT', () => {
console.log('SIGINT');
process.exit(1);
});
@devm33
devm33 / mcp9808wemos.ino
Created February 22, 2020 17:04
temp sensor
/**************************************************************************/
/*!
This is a demo for the Adafruit MCP9808 breakout
----> http://www.adafruit.com/products/1782
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
*/
/**************************************************************************/
@devm33
devm33 / settings.json
Created August 12, 2019 01:14
vscode settings file
{
"telemetry.enableTelemetry": false,
"editor.tabSize": 2,
"editor.lineNumbers": "relative",
"workbench.colorTheme": "Solarized Dark",
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"vim.leader": " ",
"[javascript]": {
@devm33
devm33 / exclusive.go
Created August 7, 2019 15:12
find items exclusive to two lists
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
package main
import "fmt"
func main() {
a := []int{1, 2, 3, 3, 2, 4, 2}
fmt.Printf("Local max of %v are %v\n", a, localMax(a))
}
func localMax(a []int) []int {
@devm33
devm33 / board.go
Created August 1, 2019 15:13
solving a boggle problem in go
package main
import "fmt"
func main() {
var board = [][]byte{
[]byte{'A', 'B', 'C', 'E'},
[]byte{'S', 'F', 'C', 'S'},
[]byte{'A', 'D', 'E', 'E'},
}
@devm33
devm33 / heap.go
Created July 15, 2019 16:52
K Closest Points to Origin
package main
import (
"fmt"
"strings"
)
func main() {
p := [][]int{
[]int{17, -45},
@devm33
devm33 / merge.go
Created July 3, 2019 20:06
Merge-sort in go
package main
import "fmt"
func main() {
a := createListNodes([]int{2, 3, 4, 0, 2, 8, 9})
fmt.Println("starting with", a)
fmt.Println("ending with", sortList(a))
}
@devm33
devm33 / sync.sh
Created December 3, 2018 01:21
A Determined Rsync
#!/bin/bash
host='remote'
path='/remote/path/to/dir'
while ! rsync --append-verify -Prz $host:$path .
do
sleep 1
done
@devm33
devm33 / changedates.sh
Created June 19, 2018 04:27
Change the accessed / modified (and created on mac if older) of a bunch of photos to sort by date
#!/bin/bash
for f in *.jpg
do
num=${f//[^0-9]/}
secs=${num:0:4}
mmss=$(printf '%02d%02d\n' $((10#$secs/60)) $((10#$secs%60)))
touch -mt 20180528${mmss} $f
touch -t 20180528${mmss} $f
done