This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}!`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/slack-go/slack" | |
"golang.org/x/time/rate" | |
) | |
var s = newSlackTask() | |
// SlackTask ... |