The classic programming exercise.
For every integer in some range:
- Print "fizz" if the number is divisible by 3
- Print "buzz" if the number is divisible by 5
| const eris = require('eris') | |
| const bot = new eris('token') | |
| bot.on('guildMemberAdd', (member, guild) => { | |
| bot.getDMChannel(member.id).then(channel => { | |
| console.log(channel.id) | |
| }).catch(e => { | |
| console.log('Get channel fail\n' + e) | |
| }) | |
| }) |
| const Eris = require('eris') | |
| const request = require('superagent') | |
| const config = { | |
| token: 'HI PUT THINGS HERE', // the token used to run the bot | |
| frequency: 60, // frequency of server icon switch in minutes | |
| guildId: '149327211470520321', // the guild you want to change the icon of | |
| images: [ // an array of image URLs | |
| 'https://b.thumbs.redditmedia.com/AQ_47wQPWDOEuP0LohFeFYpoa3fdLcqWrgIxDYvU_PI.png' | |
| ] | |
| } |
| import csv | |
| import praw | |
| import re | |
| r = praw.Reddit(client_id="",client_secret="",username="",password="",user_agent="") | |
| submission = r.submission(id="") | |
| with open("file.csv", "r", encoding="utf-8") as file: | |
| apps_reader = csv.reader(file) | |
| for i, row in enumerate(apps_reader): |
| /*! | |
| * /r/anime custom page width + background userstyle/RES snippet | |
| * by /u/geo1088 | |
| * public domain | |
| * | |
| * If you use this style, please don't send modmails when it breaks | |
| * Instead, message /u/geo1088 directy: | |
| * <https://www.reddit.com/compose?to=geo1088> | |
| */ |
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJ/z3GFDb69oD3Ww+cEbpLUkLI1OWpGULEEitbLDo3wbvbi9A3YGmpDRGnXAgs4DpOW91XxZldDuR/7HbhAO2OPY/EgcJgVk+SPdL1bSoIIAAWJacPLk+qvgcUZk1Gf7NXD7NiT0HJHj9BVdHePzCYxavt6z8NoVGl0iCF1FbjwxyEi1cr9KFUS+QOg33TUclVIap1ypyO/MeVNZ9XogT4Z1MQIeHRKkYZMq1kfvWQZOzBYM3Gu84fn2fTyRfZCde0IHVAVZtTDm8PMBYy0ukKL0OtSHzi0BEg6pTnAL0ZkCmDpBLOCM1pwoYR+4u9azp/RBp0CAmrbFHiFPjUXhJ1 george@piina.local |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>DVTConsoleDebuggerInputTextColor</key> | |
| <string>0.960784 0.980392 1 1</string> | |
| <key>DVTConsoleDebuggerInputTextFont</key> | |
| <string>JetBrainsMono-Bold - 12.0</string> | |
| <key>DVTConsoleDebuggerOutputTextColor</key> | |
| <string>0.72549 0.745098 0.835294 1</string> |
| [Unit] | |
| Description=Web: Anime Awards Site | |
| ConditionPathExists=/home/george/animeawards-mkii | |
| After=network.target | |
| [Service] | |
| Type=simple | |
| LimitNOFILE=1024 | |
| Restart=on-failure |
This is a collection of templates/scripts I use to set up CD systems for my projects.
For each project I deploy, I create a user and a systemd service. The user account's home directory is where the project lives, and the systemd service defines how it's run and ensures that it stays running after failure or reboot. The user is given sudo permission only to interact with its own service, via a /etc/sudoers.d supplement. The user account isn't accessible via password auth, but it does have an SSH key that can be used to log into the account and automate updates.
deploysetup.sh automates this process. It creates a new user, configures its sudo and SSH permissions, generates an SSH key for it, and creates a template systemd service. After running the script, all I have to do is clone the project into the deploy user's home directory and configure the systemd service to run the project.
The actual CD is handled by a Github Actions workflow
| #!/bin/bash | |
| echo "Signing into 1password..." | |
| eval $(op signin $@) | |
| items=($(op list items | jq '.[] | select(.templateUuid == "110") | .uuid' --raw-output)) | |
| for uuid in "${items[@]}"; do | |
| item_data="$(op get item "$uuid")" | |
| private_key="$(echo "$item_data" | jq '.details.sections[0].fields[] | select(.t == "ssh private key") | .v' --raw-output)" | |
| item_title="$(echo "$item_data" | jq '.overview.title' --raw-output)" |