Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

KhoPhi seanmavley

🏠
Working from home
View GitHub Profile
@seanmavley
seanmavley / generate_thumbnails_from_video.py
Created Jan 21, 2021
Generate thumbnails from list of .mp4 videos in folder
View generate_thumbnails_from_video.py
# run as
# python generate_thumbnails_from_video.py path/to/directory
import os
import sys
# using moviepy
from moviepy.editor import *
from PIL import Image
@seanmavley
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
seanmavley / filterchips.dart
Last active Jun 27, 2018
Dynamic list for FilterChips
View filterchips.dart
class ActorFilterEntry<Widget> {
const ActorFilterEntry(this.id, this.name);
final String name;
final int id;
}
class InterestsFilterPage extends State<InterestPage> {
...
List<Widget> actorWidgets(interest) {
@seanmavley
seanmavley / freeradius_monit
Created Dec 22, 2016
Monitor freeradius with Monit
View freeradius_monit
check process freeradius with pidfile /var/run/freeradius/freeradius.pid
start program = "/etc/init.d/freeradius start"
stop program = "/etc/init.d/freeradius stop"
if failed host 127.0.0.1 port 1812 type udp protocol radius secret testing123 then alert
if failed host 127.0.0.1 port 1812 type udp protocol radius secret testing123 then alert
@seanmavley
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() {
View phpStrtime in javascript.js
// first day of the month
var firstDayThisMonth = moment(firstDayThisMonth).startOf('month').toDate();
Go back and forth using the subtract() and add() with the endOf() and startOf():
// last day of previous month
var yesterMonthLastDay = moment(yesterMonthLastDay).subtract(1,'months').endOf('month').toDate();
@seanmavley
seanmavley / network_available.js
Created Mar 29, 2016
check network connectivit
View network_available.js
// Register listeners
window.addEventListener("offline", function(){
$('#globalDiv').hide();
$("#message").html('WARNING: Internet connection has been lost.').show();
});
window.addEventListener("online", function(){
$("#message").empty().hide();
$('#globalDiv').show();
});
@seanmavley
seanmavley / forms for meteor.js
Created Mar 23, 2016
gather all form elements
View forms for meteor.js
<script>
(function() {
var form = document.getElementById('form_837299');
form.addEventListener('submit', function(event) {
// Prevent normal form submit
event.preventDefault();
});
View manual-backup-script.sh
#!/bin/bash
# backup using https://github.com/deajan/osync
# Usage:
# ./backup-script nameOfFolder
# e.g
# ~$ ./backup-script Folder SecondFolder
echo "Starting backup"
for i
@seanmavley
seanmavley / enable_mongo.sh
Created Jan 23, 2016 — forked from sgnn7/enable_mongo.sh
Mongodb 3.2 on Ubuntu 15.10
View enable_mongo.sh
echo '[Unit]
Description=High-performance, schema-free document-oriented database
After=syslog.target network.target
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod -f /etc/mongod.conf
[Install]