Skip to content

Instantly share code, notes, and snippets.

View AshMartian's full-sized avatar
🌎
Kinder world with code

Ash Martian AshMartian

🌎
Kinder world with code
View GitHub Profile
@AshMartian
AshMartian / addStars.js
Created July 12, 2023 18:54
Randomized Star Generator
function addStar() {
var s = document.createElement('div')
s.className = Math.random() > 0.5 ? 'star' : 'star2';
var color = Math.random();
s.style.backgroundColor = color > 0.6 ? '#08c6dc' : color > 0.3 ? '#fd98ab' : 'white';
s.style.setProperty('--size', Math.random()*5 + 1 + 'vmin')
s.style.left = Math.floor(Math.random()*100) + '%'
s.style.top = (window.scrollY + Math.floor(Math.random()*(window.innerHeight-200))) + 'px'
// Make the animation duration random between 1s and 3s
s.style.animationDuration = Math.random() * 2 + 1 + 's';
@AshMartian
AshMartian / BrowserSupported.tsx
Created September 13, 2022 04:13
Fully customizable React Hook to check for supported browsers.
import { detect } from 'detect-browser';
import { useEffect } from 'react';
let browser = detect();
let supported = !!browser && browser.name !== 'ie';
/**
* Supported versions of browsers
*/
const supportedVersions: { [key: string]: number } = {
@AshMartian
AshMartian / intuit-oauth.d.ts
Last active February 7, 2022 22:48
Intuit OAuth Typescript definition
/* eslint-disable max-classes-per-file */
declare module 'intuit-oauth' {
import csrf from 'csrf';
interface TokenData {
realmId?: string;
token_type?: string;
access_token?: string;
refresh_token?: string;
expires_in: number;
@AshMartian
AshMartian / m567-a-b-converter.py
Last active February 13, 2021 05:56
Convert GCode M678 to Sailfish A/B extrusion values
#!/usr/bin/env python
import sys
import os
AFactor = 0.8
BFactor = 0.2
ALast = 0.0
BLast = 0.0
ELast = 0
@AshMartian
AshMartian / OSRAM-SmartApp.groovy
Last active October 27, 2022 02:46
Smartthings OSRAM RGBW Device Handler Smart App (To toggle Color Loop + extras)
/**
* OSRAM RGBW pulse
*
* Install OSRAM RGB Device Handler FIRST! Go into "My Devices", click "Edit" and change the Device Type to "OSRAM RGBW", this seems to work on a wide range on Zigbee bulbs including Sengled.
* https://community.smartthings.com/t/updated-osram-lightify-rgbw-a19-br30-us-version-ha-dth/57774
*
*
* Copyright 2020 Brandon Martin
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
@AshMartian
AshMartian / mx_classify.py
Created January 12, 2019 06:15
Vector Sees
import argparse
import matplotlib.pyplot as plt
from mxnet import nd, image, img
from mxnet.gluon.data.vision import transforms
from gluoncv.model_zoo import get_model
from gluoncv.data.transforms.presets.imagenet import transform_eval
@AshMartian
AshMartian / dind.yaml
Created August 16, 2018 19:19
dind kubernetes service
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
run: docker
name: docker
namespace: gitlab-managed-apps
spec:
replicas: 1
selector:
@AshMartian
AshMartian / Dockerfile
Created June 21, 2018 17:39
php-fpm-imagic
FROM php:7.1-fpm
MAINTAINER Brandon Martin
VOLUME /usr/share/nginx/www/wordpress/
#WORKDIR /code
RUN apt-get update && apt-get install -y wget gnupg libmagickwand-dev imagemagick libzip-dev
RUN pecl install imagick
RUN pecl install zip
RUN docker-php-ext-install mysqli && \
docker-php-ext-install pdo_mysql && \
@AshMartian
AshMartian / wordpress-change-domain-migration.sql
Last active June 29, 2018 16:32 — forked from chuckreynolds/wordpress-change-domain-migration.sql
Use this SQL script when changing domains on a WordPress site. Whether you’re moving from an old domain to a new domain or you’re changing from a development domain to a production domain this will work. __STEP1: always backup your database. __STEP2: change the ‘oldsite.com’ and ‘newsite.com’ variables to your own. __STEP3: make sure your databa…
SET @oldsite='psd401.net';
SET @newsite='lauri-dev.psd401.net';
DROP PROCEDURE IF EXISTS setoptions;
DELIMITER $$;
CREATE PROCEDURE setoptions()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE site VARCHAR(255) DEFAULT NULL;
# Create shell script, place ffmpeg / youtube-dl / CocoaDialog in the /Applications/Utilities folder
loggedInUser=$(/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }')
cd /Users/$loggedInUser/Desktop/
DESKTOP="/Users/$loggedInUser/Desktop"
RS=`/Applications/Utilities/CocoaDialog.app/Contents/MacOS/CocoaDialog inputbox --informative-text "Youtube URL" --text "Paste Youtube URL here" --button1 "MP3" --button2 "MP4" --button3 "Close" -title "Youtube Downloader"`
URL=$(echo $RS | cut -c 3-)
ANS=$(echo $RS | cut -c 1-1)