Skip to content

Instantly share code, notes, and snippets.

Working from home

KhoPhi seanmavley

Working from home
View GitHub Profile
from django import forms
from django.contrib.auth.models import User
class UserProfileForm(forms.ModelForm):
class Meta:
model = User
fields = ['first_name', 'last_name', 'email']
seanmavley / unlike your youtube
Created Mar 30, 2021
Unlike all your YouTube videos via YouTube Data API v3
View unlike your youtube
import os
import time
import google_auth_oauthlib.flow
import googleapiclient.discovery
import googleapiclient.errors
scopes = [""]
def main():
# Disable OAuthlib's HTTPS verification when running locally.
seanmavley /
Created Jan 21, 2021
Generate thumbnails from list of .mp4 videos in folder
# run as
# python path/to/directory
import os
import sys
# using moviepy
from moviepy.editor import *
from PIL import Image
seanmavley / sensible basic form.validation.react.tsx
Last active Nov 11, 2020
Material UI Form with React Hook Form with Validation using Yup
View sensible basic form.validation.react.tsx
import React from "react";
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
import Paper from '@material-ui/core/Paper';
import Grid from '@material-ui/core/Grid';
import Box from '@material-ui/core/Box';
import TextField from '@material-ui/core/TextField';
import Typography from '@material-ui/core/Typography';
import { Button } from '@material-ui/core';
import { useForm } from 'react-hook-form';
import * as yup from 'yup';
seanmavley / filterchips.dart
Last active Jun 27, 2018
Dynamic list for FilterChips
View filterchips.dart
class ActorFilterEntry<Widget> {
const ActorFilterEntry(,;
final String name;
final int id;
class InterestsFilterPage extends State<InterestPage> {
List<Widget> actorWidgets(interest) {
View CBV for Mulitple Inline formsets
from django.db import models
class Recipe(models.Model):
title = models.CharField(max_length=255)
description = models.TextField()
class Ingredient(models.Model):
View logECG model
def get_total_hours(self):
'''Sum of all hours ever added'''
return GhanaECG.objects.all().aggregate(Sum('off_hours'))
def get_today_hours(self):
'''Sum of all hours submitted today'''
end_time =
start_time = datetime(end_time.year,end_time.month,
seanmavley / freeradius_monit
Created Dec 22, 2016
Monitor freeradius with Monit
View freeradius_monit
check process freeradius with pidfile /var/run/freeradius/
start program = "/etc/init.d/freeradius start"
stop program = "/etc/init.d/freeradius stop"
if failed host port 1812 type udp protocol radius secret testing123 then alert
if failed host port 1812 type udp protocol radius secret testing123 then alert
View start dev server on reboot
cd /path/to your/virtual environment #path to your virtual environment
. bin/activate #Activate your virtual environment
cd /path/to your/project directory #After that go to your project directory
python runserver #run django server
After that save this file with .sh extension. I have saved this file as in the following example.
Run following command in terminal for giving execution permission to your script
seanmavley / gulpfile.js
Created Jun 20, 2016
Reset build folder before gulp build then restart browser
View gulpfile.js
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var del = require('del'); // rm -rf
var browser = require('browser-sync').create();
var port = process.env.SERVER_PORT || 3000;
gulp.task('clean', function() {