Skip to content

Instantly share code, notes, and snippets.

View CubexX's full-sized avatar
🐊
On vacation

Alexey Miroshnichenko CubexX

🐊
On vacation
View GitHub Profile
#!/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)
from __future__ import print_function
if 3/2 == 1:
input = raw_input
range = xrange
pretty_print = True
N = int(input())
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# 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
// ==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") {
@stroum
stroum / index.html
Last active December 19, 2017 14:09
Go Long Polling
<!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) {
@hest
hest / gist:8798884
Created February 4, 2014 06:08
Fast SQLAlchemy counting (avoid query.count() subquery)
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()