Skip to content

Instantly share code, notes, and snippets.

View yratof's full-sized avatar
🍊
Eating an orange

Andrew yratof

🍊
Eating an orange
View GitHub Profile
@yratof
yratof / vars.css
Created March 15, 2018 09:21
Common css variables used
:root {
--ease-in-out-quart: cubic-bezier(0.77, 0, 0.175, 1);
}
@yratof
yratof / light_loop.js
Created March 12, 2018 11:41
micro:bit light looping
let pos = 0
let colour = 0
let len = 0
let stretch = 0
let item: neopixel.Strip = null
let LED_Count = 0
LED_Count = 90
item = neopixel.create(DigitalPin.P0, LED_Count, NeoPixelMode.RGB)
item.clear()
item.easeBrightness()
@yratof
yratof / hugo-ajax.js
Created March 9, 2018 13:28
Load hugo pages with ajax
// TODO: 'use strict'
function loadPage(newUrl) {
var httpRequest = new XMLHttpRequest();
httpRequest.onreadystatechange = function() {
if (httpRequest.readyState !== XMLHttpRequest.DONE)
return;
// TODO: UI for this error
var newDocument = httpRequest.responseXML;
if (newDocument === null)
return;
@yratof
yratof / minify.php
Created March 6, 2018 12:30
Minify wordpress
<?php
/**
* Minify HTML
*/
class drivkraft_compression {
/* Run compression */
static function run() {
@yratof
yratof / Tilting.js
Last active February 23, 2018 17:56
Cosplay Tutorial with Micro:Bit
let colour = 0
let stretch = 0
let X = 0
let item: neopixel.Strip = null
let LED_Count = 0
function RED() {
for (let index2 = 0; index2 <= LED_Count; index2++) {
for (let list2 = 0; list2 <= stretch; list2++) {
colour = neopixel.rgb(Math.abs(255 / index2), Math.abs(30 / index2), 0)
item.setPixelColor(index2 + list2, colour)
@yratof
yratof / index.php
Created December 21, 2017 15:34
/var/www/html/index.php contents
<html>
<div style="position: absolute; left: 50%; top: 50%; transform: translate( -50%, -50% ); text-align: center; font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',sans-serif; font-weight: 600; border-bottom: 2.5vw solid red; font-size: 13vw;">
BRAND NAME
</div>
</html>
@yratof
yratof / composer.sh
Created December 20, 2017 14:30
Update all composer dependancies to latest
composer require \
composer/installers \
example/package \
example/package \
...
example/package \
example/package --sort-packages --update-with-dependencies
@yratof
yratof / remove.sql
Created December 10, 2017 22:16
Remove duplicate products
DELETE a.*
FROM wp_posts AS a
INNER JOIN (
SELECT post_title, MIN( id ) AS min_id
FROM wp_posts
WHERE post_type = 'product'
AND post_status = 'publish'
GROUP BY post_title
HAVING COUNT( * ) > 1
) AS b ON b.post_title = a.post_title
@yratof
yratof / permissions.sh
Last active August 12, 2021 08:07
Correct .git permissions for wordpress based systems
chown -R `whoami` * # Let Apache be owner
find . -type d -exec chmod 755 {} \; # Change directory permissions rwxr-xr-x
find . -type f -exec chmod 644 {} \; # Change file permissions rw-r--r--
# For servers
chown -R www-data:www-data .
find . -type d -exec chmod 570 {} \; # Change directory permissions rwxr-xr-x
find . -type f -exec chmod 460 {} \; # Change file permissions rw-r--r--
@yratof
yratof / file_checker.sh
Created December 6, 2017 13:46
Get a list of all the files that have changed in the last 14 days
# Find all files changed since yesterday
find ./wp-content/ -mtime -14 -not -path "*/.git/*" \
-not -path "*.scssc" \
-not -path "*/uploads/*" \
-not -path "*/.sass-cache/*" \
-not -path "*/vendor/*" -ls;
# Check if .css files have changed recently.
find ./wp-content/themes/ -name "*.css" -mtime -14 \
-not -path "*/node_modules/*" -ls;