Skip to content

Instantly share code, notes, and snippets.

Avatar
💭

Jordane Angelo Gengo jgengo

💭
View GitHub Profile
@jgengo
jgengo / latest_iterm2.py
Created Nov 28, 2021
Gist for https://youtu.be/HTF6rhp_LXE, using Postman and Python to find latest iTerm2 version
View latest_iterm2.py
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
@jgengo
jgengo / discord.js
Created Mar 20, 2021
discord.js on message
View discord.js
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 / discord.js
Created Mar 20, 2021
discord.js file v1
View discord.js
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 / database.js
Last active Mar 20, 2021
database.js file
View database.js
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 / main.go
Created May 22, 2020
small / tiny web server to test my clients
View main.go
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 / ratelimit.go
Last active Mar 26, 2020
Golang, Slack API and rate limit
View ratelimit.go
package main
import (
"github.com/slack-go/slack"
"golang.org/x/time/rate"
)
var s = newSlackTask()
// SlackTask ...