Skip to content

Instantly share code, notes, and snippets.

View AlphaGit's full-sized avatar

Alpha AlphaGit

View GitHub Profile
@AlphaGit
AlphaGit / 01-on-instance.sh
Created April 3, 2022 17:38
Setting up Blender on P2 instances
sudo apt-get update
# need the same gcc-compiler as the kernel uses, or so NVidia says
sudo apt install -y gcc=4:9.3.0-1ubuntu2 make libgl1-mesa-glx libxi6 libxrender1
# download and install the NVidia drivers
wget https://us.download.nvidia.com/XFree86/Linux-x86_64/470.94/NVIDIA-Linux-x86_64-470.94.run
chmod +x NVIDIA-Linux-x86_64-470.94.run
sudo ./NVIDIA-Linux-x86_64-470.94.run
# manually go through the install options
@AlphaGit
AlphaGit / Dockerfile
Created July 29, 2018 18:33
screaming-bot Dockerfile
FROM python:3.7
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN python -m spacy download en
@AlphaGit
AlphaGit / tumblr_client.py
Created July 29, 2018 18:21
Tumblr API client example
import requests
import oauth2
import urllib
from settings import auth
def get(url):
request = requests.get(url)
json = request.json()
response = json['response']
@AlphaGit
AlphaGit / load_tumblr_posts.py
Created July 29, 2018 18:18
Loading tumblr posts
# inspired in https://github.com/veggiedefender/miraculousladybot/blob/master/log.py
import requests
import re
import tumblr_client
from html2text import html2text
from datetime import datetime
from settings import blogs_to_search, posts_per_blog, tags_to_search, posts_per_search
@AlphaGit
AlphaGit / generate_post.py
Created July 29, 2018 18:13
Generating shitposts from tumblr/Gutenberg corpora
import markovify
import tumblr_client
import settings
import re
import nltk
class NltkText(markovify.Text):
def word_split(self, sentence):
words = re.split(self.word_split_pattern, sentence)
if words[0] != "":
@AlphaGit
AlphaGit / crontab
Last active November 5, 2017 17:13
Executing worklogger
# log hours to destination systems each day at noon
0 12 * * * /home/myUser/scripts/log-daily-hours.sh
# generate monthly report of worklogs each month, 1st day at 8 AM
0 8 1 * * /home/myUser/scripts/log-monthly-hours.sh
@AlphaGit
AlphaGit / goodExample.js
Created September 13, 2017 14:09
Good code / bad code: good code
function checkoutCart(session) { // this is the code that executes on checkout
trackActivity(session, ACTIONS.CHECKED_OUT); // it tracks that the user is checking out
return getUserInfo(session.userId) // gets the user info with the user id
.then(user => getDiscountAmount(user)) // then it gets the discount for the user
.then(discAmt => addDiscountIfAny(session, discAmt)) // then it applies the discount
.then(getPaymentScreenConfig) // then it gets the payment screen configuration
.then(payScrCfg => new PaymentScreen(payScrCfg, session.cart)); // and it returns the payment screen
}
function getDiscountAmount(user) { // this is the code that gets the discount amount
@AlphaGit
AlphaGit / badExample.js
Last active September 13, 2017 14:09
Good code / bad code: bad code
function checkOutCart(session, cb) { // this is the code that executes on checkout
getUserInfo(session.userId, function(err, user) { // it'll get the user information
if (err) { return cb(err); } // if it has any error, it will call back with it
if (user.hasDiscountedProfile) { // if the user has a profile for discounts
retrieveDiscount(user.profileId, function(err, discAmt) { // it will retrieve that discount
if (err) { return cb(err); } // on error, it aborts the operation
session.cart.addDiscount(discAmt); // adds the discount to the cart
getPaymentScreenConfig(function(err, payScrCfg) { // it retrieves the configuration from the payment screen
if (err) { return cb(err); } // on error, it aborts
cb(null, new PaymentScreen(payScrCfg, session.cart)); // creates a payment scree
@AlphaGit
AlphaGit / CleanupDocker.ps1
Last active September 2, 2017 23:13
Cleanup docker
$ErrorActionPreference = "SilentlyContinue"
kill -force -processname 'Docker for Windows', com.docker.db, com.docker.slirp, com.docker.proxy, com.docker.9pdb, moby-diag-dl, dockerd
kill -force -processname com.docker.service
try {
pushd "C:\Program Files\Docker\Docker\Resources"
./MobyLinux.ps1 -Destroy
popd
} Catch {}
@AlphaGit
AlphaGit / titanic tree.markdown
Last active July 29, 2017 18:25
Decision tree breakdown of the Titanic survivor data