Skip to content

Instantly share code, notes, and snippets.

View alfiankan's full-sized avatar
🐍
Linting

alfiankan alfiankan

🐍
Linting
View GitHub Profile
@alfajrimutawadhi
alfajrimutawadhi / sftp.go
Last active February 28, 2024 16:23
golang connect sftp with ssh
package main
import (
"fmt"
"log"
"os"
"github.com/pkg/sftp"
"golang.org/x/crypto/ssh"
kh "golang.org/x/crypto/ssh/knownhosts"
@niw
niw / Vagrantfile
Last active May 19, 2024 18:06
A simple Vagrantfile to setup Ubuntu desktop environment with Google Chrome and Japanese input
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provider :virtualbox do |v|
v.gui = true
v.memory = 2048
end
# Currently "ubuntu/bionic64" on VirtualBox requires `type: "virtualbox"`
# to make synced folder works.
@David-Lor
David-Lor / MQTTSubscribe.sh
Created July 11, 2019 12:29
Shell Script to subscribe to MQTT and execute a callback
#!/bin/bash
# This script subscribes to a MQTT topic using mosquitto_sub.
# On each message received, you can execute whatever you want.
while true # Keep an infinite loop to reconnect when connection lost/broker unavailable
do
mosquitto_sub -h "127.0.0.1" -t "test" | while read -r payload
do
# Here is the callback to execute whenever you receive a message:
@fnky
fnky / ANSI.md
Last active July 3, 2024 02:40
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@iximiuz
iximiuz / keep-me-alive.js
Last active February 3, 2022 01:11
Node.js http server keep-alive behaviour test
const http = require('http');
const log = console.log;
console.log = (...args) => {
log.apply(console, [new Date().toISOString()].concat(args));
};
const port = process.argv[2];
const server = http.createServer((req, res) => {
console.log('Incoming request');
@vlasky
vlasky / point_in_polygon_using_winding_number.js
Last active June 21, 2024 07:00
JavaScript implementation of winding number algorithm to determine whether a point is inside a polygon
//JavaScript implementation of winding number algorithm to determine whether a point is inside a polygon
//Based on C++ implementation of wn_PnPoly() published on http://geomalgorithms.com/a03-_inclusion.html
function pointInPolygon(point, vs) {
const x = point[0], y = point[1];
let wn = 0;
for (let i = 0, j = vs.length - 1; i < vs.length; j = i++) {
let xi = vs[i][0], yi = vs[i][1];
let xj = vs[j][0], yj = vs[j][1];

Free O'Reilly books and convenient script to just download them.

Thanks /u/FallenAege/ and /u/ShPavel/ from this Reddit post

How to use:

  1. Take the download.sh file and put it into a directory where you want the files to be saved.
  2. cd into the directory and make sure that it has executable permissions (chmod +x download.sh should do it)
  3. Run ./download.sh and wee there it goes. Also if you do not want all the files, just simply comment the ones you do not want.
@zacharycarter
zacharycarter / wclwn.md
Last active March 12, 2024 12:45
Binding to C Libraries with Nim
@doubleyou
doubleyou / Makefile
Last active August 15, 2023 10:30
grpc-gateway python example
GATEWAY_FLAGS := -I. -I/usr/local/include -I$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I/usr/local/include
GRPC_FLAGS := --python_out=. --grpc_python_out=.
code:
python -m grpc_tools.protoc $(GRPC_FLAGS) $(GATEWAY_FLAGS) *.proto
gw:
protoc $(GATEWAY_FLAGS) \
--go_out=Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api,plugins=grpc:. \
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/input.h>
#include <linux/uinput.h>
#define die(str, args...) do { \