This file contains hidden or 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 werkzeug.utils import secure_filename | |
from flask import Flask, render_template, request | |
@app.route("/my-upload-endpoint", methods=["POST"]) | |
def my_upload_function(): | |
if request.files.get("my-file-field-name") is None: | |
return render_template("my_error_page.html", an_optional_message="Error uploading file") | |
# Put here some other checks (security, file length etc...) | |
f = request.files["my-file-field-name"] | |
f.save(secure_filename(f.filename)) |
This file contains hidden or 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
find . -type f -exec du -b {} + | grep something.txt |
This file contains hidden or 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
git checkout . | |
git clean -xdf |
This file contains hidden or 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
# List containers | |
lxc-ls -f -Fname,pid | |
# Get container pid | |
lxc-ls -f -Fpid mycontainer | |
# Access file system | |
cat /proc/containerpid/root/ |
This file contains hidden or 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
% sudo apt-get install software-properties-common | |
% sudo apt-add-repository ppa:swi-prolog/stable | |
% sudo apt-get update | |
% sudo apt-get install swi-prolog | |
edge(1,2) | |
edge(2,3) | |
edge(3,4) | |
edge(2,6) | |
edge(6,7) |
This file contains hidden or 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
export PS1="\[\033[35m\]\t\[\033[m\]-\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ " |
This file contains hidden or 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
# Thanks to https://github.com/twbs/bootstrap/issues/27124#issuecomment-509009622 | |
.accordion div.card:only-child { | |
border-bottom: 1px solid rgba(0, 0, 0, 0.125); | |
border-radius: calc(0.25rem - 1px); | |
} |
This file contains hidden or 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
UPDATE tbl | |
SET field_to_update = CASE | |
WHEN (SELECT COUNT(*) FROM (SELECT * FROM tbl) AS copy WHERE copy.field=<condition> HAVING COUNT(*)>0) THEN "this_value_if_true" | |
ELSE field_to_update | |
END |
This file contains hidden or 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
// Add to your html header | |
<script src="https://momentjs.com/downloads/moment.js"></script> | |
// Add these two functions | |
function buildInterval(start, end){ | |
var range = []; | |
var time = moment.duration(start).asSeconds(); | |
if(end<=start) | |
var endtime = moment.duration(end).asSeconds()+86400; | |
else |
This file contains hidden or 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
<script> | |
//Checkout my improvement on StackOverflow: https://stackoverflow.com/a/34699164/6303265 | |
var tmr = 0; | |
var islong = 0; | |
$(element).mousedown(function () { | |
tmr = setTimeout(function () { | |
// Handle the long-press | |
alert("You clicked for 1 second!"); | |
console.log("You clicked for 1 second!"); | |
islong=1; |