Skip to content

Instantly share code, notes, and snippets.

View jgengo's full-sized avatar
💭

Jordane Angelo Gengo jgengo

💭
View GitHub Profile
@jgengo
jgengo / ratelimit.go
Last active March 26, 2020 00:46
Golang, Slack API and rate limit
package main
import (
"github.com/slack-go/slack"
"golang.org/x/time/rate"
)
var s = newSlackTask()
// SlackTask ...
@jgengo
jgengo / main.go
Created May 22, 2020 12:25
small / tiny web server to test my clients
package main
import (
"fmt"
"log"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "%s %s %s\n", r.Method, r.URL, r.Proto)
@jgengo
jgengo / database.js
Last active March 20, 2021 15:45
database.js file
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('./database.db', [sqlite3.OPEN_CREATE, sqlite3.OPEN_READWRITE], (err) => {
if (err) console.error(err.message)
});
db.run(`create table if not exists users (id text, name text)`)
db.run(`
create table if not exists logs(
@jgengo
jgengo / discord.js
Created March 20, 2021 15:18
discord.js file v1
const Discord = require('discord.js')
const db = require('./database')
const config = require("./config")
const client = new Discord.Client()
client.config = config;
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
@jgengo
jgengo / discord.js
Created March 20, 2021 16:06
discord.js on message
client.on("message", (msg) => {
const isDM = msg.channel.type == 'dm'
if (isDM) {
// add users in db if never seen.
if (msg.author.id !== client.user.id) {
db.get("SELECT id from users where id=?", [msg.author.id], (err, row)=> {
if (err) console.error(err.message)
if (row.length == 0) {
db.run("INSERT INTO users (id, name) values (?, ?)", msg.author.id, msg.author.username)
@jgengo
jgengo / latest_iterm2.py
Created November 28, 2021 14:20
Gist for https://youtu.be/HTF6rhp_LXE, using Postman and Python to find latest iTerm2 version
import requests
from xml.etree import ElementTree as ET
url = "https://iterm2.com/appcasts/final_modern.xml"
res = requests.get(url).text
xml_data = ET.fromstring(res)
attribs = xml_data.find("channel/item/enclosure").attrib