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
/*dragon*/var b=X=Y=T=L=0;document.addEventListener("click",function(a){a.preventDefault()},!0);document.addEventListener("mousedown",c);document.addEventListener("touchstart",c);function c(a){a.preventDefault();a.target!==document.documentElement&&a.target!==document.body&&(b=Date.now(),a.target.setAttribute("data-drag",b),a.target.style.position="relative",T=a.target.style.top.split("px")[0]||0,L=a.target.style.left.split("px")[0]||0);X=a.clientX||a.touches[0].clientX;Y=a.clientY||a.touches[0].clientY}document.addEventListener("mousemove",d);document.addEventListener("touchmove",d);function d(a){if(""!==b){var e=document.querySelector('[data-drag="'+b+'"]');e.style.top=parseInt(T)+parseInt((a.clientY||a.touches[0].clientY)-Y)+"px";e.style.left=parseInt(L)+parseInt((a.clientX||a.touches[0].clientX)-X)+"px"}}document.addEventListener("mouseup",f);document.addEventListener("touchend",f);function f(){b=""}document.addEventListener("mouseover",g);function g(a){a.target.style.cursor="move";a.target.style.boxShado |
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
case extract(isodow from ~~date~~) | |
when 1 then 'Mon ' || cast(~~date~~ as date) | |
when 2 then 'Tue ' || cast(~~date~~ as date) | |
when 3 then 'Wed ' || cast(~~date~~ as date) | |
when 4 then 'Thu ' || cast(~~date~~ as date) | |
when 5 then 'Fri ' || cast(~~date~~ as date) | |
when 6 then 'Sat ' || cast(~~date~~ as date) | |
when 7 then 'Sun ' || cast(~~date~~ as date) | |
end date |
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
git fetch origin 8fd8e58c2599a9d31f9ca8cad1fdb7524dc794e5:refs/remotes/origin/~~branch_name~~ |
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
var start = performance.now(); | |
var end = performance.now(); | |
console.log('Doing stuff took ' + (end-start) + 'ms'); |
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
select | |
schemaname, | |
tablename, | |
pg_size_pretty(size) as size_pretty, | |
pg_size_pretty(total_size) as total_size_pretty | |
from ( | |
select | |
*, | |
pg_relation_size(schemaname ||'.'|| tablename) as size, |
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
select schemaname||'.'||tablename | |
from pg_tables | |
where has_table_privilege ( | |
'~~user_name~~', | |
schemaname||'.'||tablename, | |
'~~permission_type~~' | |
) | |
and schemaname not in ( | |
'pg_catalog', | |
'information_schema' |
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
@app.route('/', methods=['GET'], defaults={'var': 'default'}) | |
@app.route('/<string:var>', methods=['GET']) | |
def page(var): | |
# do stuff with the given var or default | |
return render_template('page.html', var=var) |
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
var fs = require('fs'); | |
fs.appendFile(filePath, text, function(err) { | |
console.log('Error writing to file'); | |
}); |
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 functools import wraps | |
from flask import request, abort | |
def validate_post(validator, status_code): | |
"""Validate the POST request with the given validator function. | |
Abort with the given status_code upon validation failure. | |
""" | |
def decorator(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): |