Skip to content

Instantly share code, notes, and snippets.

View AlphaGit's full-sized avatar

JD Raimondi 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 / 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
@AlphaGit
AlphaGit / BigArray.cs
Last active May 24, 2017 11:43
BigArray.cs -- Allowing more than Int32.MaxValue elements in an array
namespace SomeLargeDataHolder
{
// adapted from https://blogs.msdn.microsoft.com/joshwil/2005/08/10/bigarrayt-getting-around-the-2gb-array-size-limit/
// Goal: create an array that allows for a number of elements > Int.MaxValue
class BigArray<T>
{
// These need to be const so that the getter/setter get inlined by the JIT into
// calling methods just like with a real array to have any chance of meeting our
// performance goals.
@AlphaGit
AlphaGit / question.markdown
Last active February 13, 2017 02:19
Protractor and Travis, cross-platform scripts

(Note: this post was originally a question in StackOverflow, but has been removed as the question received no answers or activity in over a year, and was deemed an abandoned question.)

Protractor and Travis, cross-platform scripts

"...and other horror stories."

I've been trying for the past few days to get this to work with no luck. As such, I have a long story to tell but I'll break it down to parts so that it is easier to understand.

My goal:

@AlphaGit
AlphaGit / MySingletonClass.cs
Created April 25, 2016 01:42
Typical Singleton Pattern
public class MySingletonClass {
private static MySingletonClass _instance;
// private constructor
private MySingletonClass() { }
// public accessor property that instantiates if needed
public static Instance => _instance ?? (_instance = new MySingletonClass());
}