Skip to content

Instantly share code, notes, and snippets.

@adover
adover / drfc_reward.py
Created June 5, 2022 04:30
Deepracer Reward fn
import math
import traceback
class Reward:
SLOW_SPEED = 2.5
HIGH_SPEED = 3
WEIGHT_ON_TRACK = 9
WEIGHT_SPEED = 6
WEIGHT_HEADING = 4
WEIGHT_CORRECT_LANE = 3
@adover
adover / BlobImageOptim.ps1
Last active February 23, 2021 01:31
Azure Blob Storage Image Bulk Optimization - https://automys.com/library/asset/azure-blob-storage-image-bulk-optimization - Az module updated script
<#
.SYNOPSIS
Optimizes image file size for all PNG and JPG images in a Microsoft Azure blob storage
container by processing them locally and replacing their content with the optimized result.
.DESCRIPTION
Image files are often needlessly oversized and can be compressed without quality loss using
widely-available utilities. Microsoft Azure provides a blob storage service that can be used
to host publicly-accessible images for websites or other purposes. For containers with large
numbers of suboptimal images or for bulk optimization, this script optimizes all images in
@adover
adover / alert-override.js
Created February 19, 2019 19:17
Finding pesky alerts
var old = alert;
alert = function() {
console.log(new Error().stack);
old.apply(window, arguments);
};
@adover
adover / map-deep-keys.scss
Last active February 7, 2019 23:50
Map-Deep-Keys
/// @name map-deep-keys
/// @group functions
/// Find a list of keys buried deep in a nested map
@function map-deep-keys($map, $keys...) {
@for $i from 1 through length($keys) + 1 {
@if $i == length($keys) + 1 {
@return map-keys($map);
}
$key: nth($keys, $i);
@adover
adover / objectAdmin.ts
Created December 7, 2018 01:02
Admin for objects
/**
* Triggers all the methods below it to return a nicely
* formatted object.
* @param args
*/
sanitise(args) {
const flatParams = this.flatten(args);
const cleanParams = this.clean(flatParams);
return this.parseDates(cleanParams);
}
@adover
adover / fixCDPushUnitTests.ts
Created December 6, 2018 23:17
ChangeDetectionOnPush is a pain to unit test
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [FormsModule, ReactiveFormsModule],
declarations: [FormComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.overrideComponent(FormComponent, {
set: { changeDetection: ChangeDetectionStrategy.Default },
})
.compileComponents();
@adover
adover / buildRouteList.ts
Created November 25, 2018 21:24
Helper function to build basic angular routes
export const buildRouteList = (
lowerCasePathname: string,
component?: any,
inPage = false,
) => {
const pathName = lowerCasePathname.replace(/-/g, ' ');
return {
path: pathName,
...() => (component ? { component } : undefined),
#%%
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
# from sklearn.linear_model import LinearRegression
# from sklearn.linear_model import Ridge
# from sklearn.preprocessing import StandardScaler
# from sklearn.pipeline import Pipeline
# from sklearn.svm import SVC
#!/usr/bin/env bash
rm -rf output.txt
for i in $(cat $1); do
content="$(curl -I -L "$i")"
echo "----------------------" >> output.txt
echo "Curl request for $i" >> output.txt
echo "$content" >> output.txt
echo "----------------------" >> output.txt
const cron = require('node-cron');
const each = require('lodash/each');
/**
* Put all schedules in here so they get run through the validator
* You may wonder why these have specific names... ideally
* we don't ever want jobs to run together as thats
* risking putting load on the app unnecessarily
*/
const schedules = {