Skip to content

Instantly share code, notes, and snippets.

@swkidd
swkidd / index.html
Created April 5, 2020 15:42
qBdzVYM
<div id="current"></div>
<div class="container"></div>
@swkidd
swkidd / p.py
Last active April 23, 2020 14:21
create django app steps
#create django app steps
# https://docs.djangoproject.com/en/3.0/intro/tutorial01/
django-admin startproject mysite
django manage.py startapp appname
# create urls.py in app and templates/home.html
from django.urls import path
from . import views
@swkidd
swkidd / animation.js
Created April 24, 2020 04:34 — forked from threedaymonk/animation.js
Alternative animation implementation for beta.jisho.org, using an easing function to accelerate towards the middle of a stroke, and decelerate at the end
var Animation = Class(function Animation() {});
Animation.mixin(Canvas);
Animation.prototype.extend(Event.Listener);
Animation.prototype.extend({
reset: function() {
this.relativePosition = 0;
this.maxPosition = this.totalFrames - 1;
// first load the page so all reviews are showing (hold space bar until it stops loading reviews)
// then open up developer tools ctrl-l and type the following AFTER UNDERSTANDING WHAT IT DOES
// never paste code you don't understand into the developer tools
// grab all reviews (which have css class "we-customer-review"
let reviews = [...document.querySelectorAll(".we-customer-review")]
// grab the stars for each review
// stars have the css class "we-star-rating-stars"
// the last character of the full class string happens to have the number of stars
// GRAB USER REVIEWS FROM THE GOOGLE PLAY STORE (works as of 5/2020)
// first load the page so all reviews are showing (hold space bar until it stops loading reviews)
// then open up developer tools ctrl-l and type the following AFTER UNDERSTANDING WHAT IT DOES
// never paste code you don't understand into the developer tool
// Goolge generates their css classes on page load
// use XPATH to extract html based on content / position
// this wont change based on page load
const url = window.location
const detectChange = () => {
if (/^.*:\/\/.*youtube.com\/?$/.test(url)) {
}
else if (/^.*:\/\/.*youtube.com\/watch\?v=.*$/.test(url)) {
const related = document.querySelectorAll("#related").forEach(e => e.remove())
const endscreen = document.querySelector(".html5-endscreen")
endscreen && endscreen.remove()
const upnext = document.querySelector(".ytp-upnext")
@swkidd
swkidd / KeyboardShrinkingView.tsx
Created September 23, 2022 05:29
A React-Native view that shrinks and disappears when the keyboard opens
import React, {useEffect, useRef} from 'react';
import {
Keyboard,
Animated,
} from 'react-native';
function KeyboardShrinkingView({ children, startHeight="100%", endHeight="0%" }) {
const scaleValue = useRef(new Animated.Value(0)).current;
const scaleOut = Animated.timing(scaleValue, {
toValue: 1,