Skip to content

Instantly share code, notes, and snippets.

View Niraj-Fonseka's full-sized avatar
📚

Niraj Fonseka Niraj-Fonseka

📚
View GitHub Profile
@staberas
staberas / interactive_websearch_chat.py
Last active August 7, 2024 04:40
interactive_websearch_chat.py
# This script requires to have some basic Python skills
# - Install python dependencies (thanks to TitwitMuffbiscuit on reddit) :
# pip install nltk beautifulsoup4 googlesearch-python trafilatura wolframalpha
#
# If you get this error "Resource punkt not found", it's because Punkt sentence tokenizer for Natural Language Toolkit is missing.
# Edit the file and add this before
# from nltk.tokenize import word_tokenize ,
# it will download the necessary english.pickle:
# import nltk
# nltk.download('punkt')
import network
import socket
import time
import struct
from machine import Pin
NTP_DELTA = 2208988800
host = "pool.ntp.org"
@jpwilliams
jpwilliams / README_secure_gpg_transfer.md
Last active July 6, 2022 14:35
Securely transferring files with GPG keys

Secure data transfer using GPG keys

Sometimes you need a secure way to pass a file from one place to another, ensuring that only the intended recipient can read its contents. We can achieve this simply using GPG keys.

The flow is:

  1. Recipient generates a GPG key
  2. Recipient exports a public key
  3. Recipient sends public key to sender
  4. Sender receives public key from recipient
@ryochack
ryochack / serial_sample.go
Created November 8, 2020 21:43
Serial Write/Read sample using golang
package main
import (
"fmt"
"log"
"os"
"time"
"github.com/tarm/serial"
)
  1. apt install bbswitch
  2. /etc/modprobe.d/bbswitch.conf
        options bbswitch load_state=0 unload_state=1
    To run bbswitch without bumblebeed on system startup, do not forget to add bbswitch to /etc/modules-load.d.
    nano /etc/modules-load.d
        bbswitch
@mosquito
mosquito / README.md
Last active November 14, 2024 08:39
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/[email protected]. SystemD calling binaries using an absolute path. In my case is prefixed by /usr/local/bin, you should use paths specific for your environment.

[Unit]
Description=%i service with docker compose
PartOf=docker.service
After=docker.service
@xndc
xndc / tunejack.sh
Last active November 4, 2024 17:50
Instant radio streaming script using the TuneIn API
#!/bin/bash
# tunejack.sh uses the TuneIn public API (at opml.radiotime.com) to search for
# a radio station, print out its details and try to play it somehow.
if [ "$#" -eq 0 ]; then
echo "$0: search for a radio station using the TuneIn API"
echo "Usage: $0 PATTERN"
exit 1
fi
@denji
denji / golang-tls.md
Last active November 7, 2024 05:58 — forked from spikebike/client.go
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)
@yanofsky
yanofsky / LICENSE
Last active October 17, 2024 22:49
A script to download all of a user's tweets into a csv
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@hSATAC
hSATAC / gist:5343225
Created April 9, 2013 05:38
Http Redirect in Golang
package main
import (
"log"
"net/http"
)
func redirect(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "http://www.google.com", 301)