This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The problem: | |
# A user has to be able to submit a form only once per day | |
# The solution - my approach | |
# A hidden form (connected to a kinda Control Model) is embedded in the normal form the user submits. | |
# Hidden form when submitted, triggers a save on a model ForeignKey'ed | |
# to the request.user | |
# Upon re-rendering form, Control Model is checked. If an object exist relating to user in context, | |
# no form shows in template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import time | |
import google_auth_oauthlib.flow | |
import googleapiclient.discovery | |
import googleapiclient.errors | |
scopes = ["https://www.googleapis.com/auth/youtube.force-ssl"] | |
def main(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActorFilterEntry<Widget> { | |
const ActorFilterEntry(this.id, this.name); | |
final String name; | |
final int id; | |
} | |
class InterestsFilterPage extends State<InterestPage> { | |
... | |
List<Widget> actorWidgets(interest) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models.py | |
from django.db import models | |
class Recipe(models.Model): | |
title = models.CharField(max_length=255) | |
description = models.TextField() | |
class Ingredient(models.Model): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@classmethod | |
def get_total_hours(self): | |
'''Sum of all hours ever added''' | |
return GhanaECG.objects.all().aggregate(Sum('off_hours')) | |
@classmethod | |
def get_today_hours(self): | |
'''Sum of all hours submitted today''' | |
end_time = datetime.now() | |
start_time = datetime(end_time.year,end_time.month,end_time.day) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
clear | |
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 manage.py runserver #run django server | |
After that save this file with .sh extension. I have saved this file as script.sh in the following example. | |
Run following command in terminal for giving execution permission to your script |
NewerOlder