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
def get_count(q): | |
count_q = q.statement.with_only_columns([func.count()]).order_by(None) | |
count = q.session.execute(count_q).scalar() | |
return count | |
q = session.query(TestModel).filter(...).order_by(...) | |
# Slow: SELECT COUNT(*) FROM (SELECT ... FROM TestModel WHERE ...) ... | |
print q.count() |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<script> | |
function lp() { | |
var http = new XMLHttpRequest(); | |
http.open('GET', '/lp', true); | |
http.onreadystatechange = function(event) { |
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
// ==UserScript== | |
// @name Pikabu-like navigation | |
// @namespace http://*.*/ | |
// @version 0.1 | |
// @author Efog | |
// @grant none | |
// ==/UserScript== | |
document.addEventListener("keydown", function(e) { | |
if (document.activeElement.nodeName == "BODY") { |
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
# Backup | |
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | |
# Restore | |
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE | |
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 __future__ import print_function | |
if 3/2 == 1: | |
input = raw_input | |
range = xrange | |
pretty_print = True | |
N = int(input()) |
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
#!/bin/bash | |
sshport=22 | |
sshcert=~/.ssh/id_rsa | |
remoteserver= # FILL IN, e.g [email protected] | |
localpath= # FILL IN without trailing slash, e.g ~/backups/server | |
usesudo= # FILL IN true or false | |
if [[ $usesudo == true ]]; then | |
rsyncargs=(-rlptzhu -e "ssh -p $sshport" --rsync-path="sudo rsync" --partial --delete-after --info=progress2) |