Skip to content

Instantly share code, notes, and snippets.

View TakesTheBiscuit's full-sized avatar

Paul TakesTheBiscuit

  • United Kingdom
  • 23:06 (UTC +01:00)
View GitHub Profile
@TakesTheBiscuit
TakesTheBiscuit / ImportProductsCommand.php
Created May 1, 2024 11:05 — forked from nicanaca0/ImportProductsCommand.php
Simple CSV Product importer for Sylius. Includes the product, the variant, channel pricing, taxons images and associations (1.0.0-beta.2)
<?php
namespace AppBundle\Command;
use Sylius\Component\Core\Model\ChannelPricingInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Product\Model\ProductAssociationInterface;
use Sylius\Component\Product\Model\ProductAssociationTypeInterface;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
@TakesTheBiscuit
TakesTheBiscuit / form-filling.js
Last active July 2, 2023 19:36
form-filling.js
$('#someoneelse').click();
$('#patient_firstnames').val('Peter');
$('#patient_lastname').val('Drumda');
$('#patient_postcode').val('OX1 1AA');
$('#patient_dobd').val('01');
$('#patient_dobm').val('12');
$('#patient_doby').val('1981');
$('#patient_dob').val(${$('#patient_dobd').val()}/${$('#patient_dobm').val()}/${$('#patient_doby').val()});
$('#contact_female').click();
$('#proxy_relationship').val('Spouse');
@TakesTheBiscuit
TakesTheBiscuit / vowels.js
Created April 20, 2023 16:10
Check for vowels in a string in javascript
const input = 'Hello World';
const filterArr = ['a','e','i','o','u'];
let counted = getCountFromFilteredInput(input,filterArr);
// 3
console.log(counted.length);
// ["e", "o", "o"]
console.log(counted);
// Passed
if (assertSame(counted.length, 3)) {
@TakesTheBiscuit
TakesTheBiscuit / websocket.js
Created April 19, 2023 20:35
websocket.js using node and ws package
'use strict';
import { WebSocketServer } from 'ws';
const wss = new WebSocketServer({ port: 8080 });
wss.on('connection', function connection(ws) {
ws.on('error', console.error);
ws.on('message', function message(data) {
@TakesTheBiscuit
TakesTheBiscuit / abt-modify-prices.php
Created January 28, 2022 18:00
Woocommerce remove VAT for non GB / UK
<?php
/*
Plugin Name: Abikething modify pricing display
Plugin URI: http://pauldrage.co.uk
Description: This plugin over rides the pricing display to handle GB versus ROW for tax. Requires plugin woocommerce_set_country to set $_SESSION wc_country_iso
Version: 1.0.0
Author: Paul Drage
Author URI: http://pauldrage.co.uk
License: GPL2 etc
License URI: https://
@TakesTheBiscuit
TakesTheBiscuit / run_me.php
Created March 18, 2019 20:52
PHP Copy when locked out of wordpress
<?php
// i cant remember where wp-plugins live, lets assume we want everything from the level above?
$output = shell_exec('scp -r ../ your_username@remotehost.edu:/some/remote/directory/bar');
// Display the scp output
echo "<pre>$output</pre>";
?>
@TakesTheBiscuit
TakesTheBiscuit / PythonBants.py
Created October 22, 2018 21:49
Python example of a class, picture a terrible version of GTA - yeah, this isn't it
class PoliceMan:
def __init__(self, health, attack, speed):
self.health = health
self.attack = attack
self.speed = speed
self.name = 'PoliceManDEPT101'
# slow fat one has 100 hp, 10 attack, and moves at 25 speed
SlowFatOne = PoliceMan(100.00,10.00,25.00)
@TakesTheBiscuit
TakesTheBiscuit / open_and_close_cd_tray.py
Last active January 2, 2024 16:52 — forked from ricardo-valerio/open_and_close_cd_tray.py
Open and close CD/DVD Tray in python with Windows fix specific drive letter
#!/usr/bin/python3
from platform import system as platform_name
from os import system
import ctypes
platforms_dictionary = {
"Windows": { #
"open" : 'ctypes.windll.WINMM.mciSendStringW(u"open L: type CDAudio alias L_drive", None, 0, None); ctypes.windll.WINMM.mciSendStringW(u"set L_drive door open", None, 0, None)',
"close": 'ctypes.windll.WINMM.mciSendStringW(u"open L: type CDAudio alias L_drive", None, 0, None); ctypes.windll.WINMM.mciSendStringW(u"set L_drive door closed", None, 0, None)'
@TakesTheBiscuit
TakesTheBiscuit / continuous-servo-until-limit-arduino
Last active December 3, 2022 09:18
Continuous servo until limit switch arduino
#include <Servo.h>
#define TURN_TIME 1200
Servo toolheadServo;
int toolheadHome = 0;
boolean toolheadGoingHome = false;
int discContact = 0;
@TakesTheBiscuit
TakesTheBiscuit / toolhead home position sketch
Created August 21, 2018 22:10
monitoring digital pins continuously
void setup() {
//start serial connection
Serial.begin(9600);
//configure pin 2 as an input and enable the internal pull-up resistor
pinMode(2, INPUT_PULLUP);
pinMode(13, OUTPUT);
}
void loop() {