Skip to content

Instantly share code, notes, and snippets.

#*-*encoding: utf-8*-*
from peewee import *
import os, sys, io
import re
import pickle, json
import csv
import time
import urllib
from datetime import datetime
from urllib.parse import urlparse
$ docker-compose -f docker-compose.yml -f docker-compose.development.yml build
$ docker-compose -f docker-compose.yml -f docker-compose.development.yml up
var productTabs = document.getElementById('products');
var tabs = productTabs.querySelectorAll('li');
var l = tabs.length
var delay = 5000
var i = 0
function cycle() {
setTimeout(function() {
tabs[i].firstElementChild.click();
i++;
// for loops are the most performant, but these methods are useful given specific tasks
const items = [
{ name: 'Bike', price: 100 },
{ name: 'TV', price: 200 },
{ name: 'Album', price: 10 },
{ name: 'Book', price: 5 },
{ name: 'Phone', price: 500 },
{ name: 'Computer', price: 1000 },
{ name: 'Keyboard', price: 25 },
class MetaInfo(models.Model):
AVAILABLE_DATATYPES = (('int', 'Integer'),
('floa', 'float'),
('str', 'string'),)
key = models.CharField(max_length=25)
value = models.CharField(max_length=100)
datatype = models.CharField(max_length=4, choices=AVAILABLE_DATATYPES, default='int')
description = models.CharField(max_length=200)
$( document ).ready()
document.addEventListener('DOMContentLoaded', function() {});
nCols = 4;
for (var c=0; c<nCols; c++) {
iStart = (c/nCols).toFixed(1)
iEnd = ( (c+1) /nCols).toFixed(1)
console.log(
iStart, iEnd
)
JavaScript Wildcard
- doesn't exist, but can use starts with and ends with:
elem = document.querySelectorAll('form[id^="form"][id$="-s"]');
queryselector mathcing one id but excluding the other
document.querySelectorAll('[id^="primary_container"]:not([id="primary_container-__prefix__"])')
# note that in __init__ method, I have updated an HTML class attribute with form-control to every field of the
# form so that Bootstrap gets enabled on every field.
from .models import Friend
from django import forms
import datetime
class FriendForm(forms.ModelForm):
## change the widget of the date field.
dob = forms.DateField(
@ronaldgreeff
ronaldgreeff / how-to-extract-tar-git-linux
Last active July 8, 2020 09:06
Extract tar tar.gz tar.gz2 using Linux / Git-Windows
Tar is an archiving utility in Linux. Extract various archived files in Linux using this utility.
Type the following commands in terminal (Keyboard short cut: Ctrl+Alt+T in Ubuntu):
Extracting .tar.bz2:
tar xvjf filename.tar.bz2 location
Extracting .tar.gz:
tar xvzf filename.tar.gz location
Where:
x — extract