Skip to content

Instantly share code, notes, and snippets.

@juanfe
juanfe / flask.py
Created June 18, 2017 12:44 — forked from kageurufu/flask.py
Flask-WTF FieldLists with Dynamic Entries
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.wtf import Form
from flask.ext.babel import gettext
from wtforms import SelectField, TelField, TextField, FormField, Fieldlist, SubmitField
from wtforms.validators import Optional, Required
app = Flask(__name__)
db = SQLAlchemy(app)
@Phlow
Phlow / list-categories-count.liquid
Last active June 4, 2021 18:33
Jekyll: List all categories with according post count and show and link all post items listed in the according category
<h2>Categories</h2>
<ul>
{% assign categories_list = site.categories %}
{% if categories_list.first[0] == null %}
{% for category in categories_list %}
<li><a href="#{{ category | downcase | downcase | url_escape | strip | replace: ' ', '-' }}">{{ category | camelcase }} ({{ site.tags[category].size }})</a></li>
{% endfor %}
{% else %}
{% for category in categories_list %}
<li><a href="#{{ category[0] | downcase | url_escape | strip | replace: ' ', '-' }}">{{ category[0] | camelcase }} ({{ category[1].size }})</a></li>
@doobeh
doobeh / home.html
Created January 19, 2016 14:04
More complete example of FieldList with FormField
<form method="post" action="">
{{ form.name}}
{{ form.hidden_tag() }}
<br/>
{% for entry in form.hours %}
{{ loop.index0|dow }}
{{ entry() }}
{% endfor %}
<input type="submit"/>
</form>
@xXPhenomXx
xXPhenomXx / .gitignore
Created March 27, 2014 17:43
Good Default .gitignore for Mac developers
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store?
ehthumbs.db
@Fluepke
Fluepke / log_train.sh
Created November 12, 2022 15:16
Log train rides on german trains (location data, internet availability, speed, etc.)
#!/bin/bash
if ! command -v curl &> /dev/null; then
echo "This script needs curl. Please install curl."
exit -1
fi
if ! command -v jq &> /dev/null; then
echo "This script needs jq. Please install jq."
exit -1
@edysegura
edysegura / html5-validation-message.js
Last active April 28, 2023 06:22
How to prevent the browser from showing default HTML5 validation error message bubble?
document.addEventListener('invalid', (function(){
return function(e) {
//prevent the browser from showing default error bubble / hint
e.preventDefault();
// optionally fire off some custom validation handler
// myValidation();
};
})(), true);
@paulocheque
paulocheque / .bash_profile
Last active September 30, 2023 17:26
.bash_profile example
# EDITOR=nano sudo visudo
# Change the following line: (:i to insert + esc to go back + :w to save + :q to quit)
# Defaults env_reset
# to:
# Defaults env_reset,timestamp_timeout=960 # in minutes
export PATH=$PATH:.
# export PATH=$PATH:/usr/bin
@Pezmc
Pezmc / fake-scan-automator.sh
Last active October 6, 2023 08:26 — forked from andyrbell/scanner.sh
Make a pdf look scanned with macOS automator as a quick action
#!/bin/bash
# This script takes a PDF or list of PDFs and outputs a file(s)
# named <file>_scanned.pdf that looks like it has been scanned
#
# Requires imagemagic and popper to be installed (brew install imagemagick poppler)
#
# Accepts: a list of files
# Usage: ./<scriptfilename> pdf1.pdf pdf2.pdf
#
# To use as a macOS automator quick action you need to:
@ravasthi
ravasthi / _config.yml
Created February 15, 2012 08:59
Multiple authors on Jekyll
authors:
hanzou:
name: Hanzou Hattori
display_name: Hanzou
gravatar: c66919cb194f96c696c1da0c47354a6a
email: hanzou@company.com
web: http://company.com
twitter: company
github: hhattori
jorgen:
@arjunsharma97
arjunsharma97 / m4atowav.py
Created April 1, 2018 06:36
Python script to convert m4a files to wav files
# Packages reqd: pydub, ffmpeg
# pydub - pip install pydub
# ffmpeg:
# sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
# sudo apt-get update
# sudo apt-get install ffmpeg
## Load the m4a files (in M4a_files.tar.gz)