Skip to content

Instantly share code, notes, and snippets.

View denis-trofimov's full-sized avatar

Denis Trofimov denis-trofimov

View GitHub Profile
@mtourne
mtourne / README.md
Last active August 7, 2024 01:56
zerorpc with zmq curve
@riteshreddyr
riteshreddyr / flask-admin many-to-many search.md
Last active July 19, 2021 07:21
Flask-admin Many-to-Many Search and Filtering

#Flask-admin Many-to-Many Search

Many-to-Many searches are not easily supported by Flask-admin. Read Here for more info

##Solution

  • Add the association tables to the list of join tables so that the join between the two tables can be made through the association table.
  • Reverse the tables to ensure that the association tables are processed before the other join table.

Tested on Flask-Admin 1.1.0

"""
Example of mandrill service in python (http://mandrill.com/)
Description of usage in python:
Russian: http://www.lexev.org/2014/send-email-django-project-mandrill-service/
English: http://www.lexev.org/en/2014/send-email-django-project-mandrill-service/
"""
# ======
# Django
@Kartones
Kartones / postgres-cheatsheet.md
Last active March 13, 2025 18:52
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@Meekohi
Meekohi / libpq_multirow_insert.cc
Last active July 30, 2018 21:27
Example of a multi-row insert using libpq
#include <stdio.h>
#include <iostream>
using namespace std;
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/nonfree/nonfree.hpp"
using namespace cv;
@dobrokot
dobrokot / write_png_to_memory_with_libpng.cpp
Created April 11, 2014 17:37
encode and write PNG to memory (std::vector) with libpng on C++
#include <png.h>
#include <vector>
#include <iostream>
#include <stdlib.h>
//encode and write PNG to memory (std::vector) with libpng on C++
typedef unsigned char ui8;
#define ASSERT_EX(cond, error_message) do { if (!(cond)) { std::cerr << error_message; exit(1);} } while(0)
@st4lk
st4lk / mandrill_email.py
Last active August 2, 2021 05:31
Python: send emails by mandrill. Django and standalone example
"""
Example of mandrill service in python (http://mandrill.com/)
Description of usage in python:
Russian: http://www.lexev.org/2014/send-email-django-project-mandrill-service/
English: http://www.lexev.org/en/2014/send-email-django-project-mandrill-service/
"""
# ======
# Django
@stuart11n
stuart11n / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@mwhite
mwhite / git-aliases.md
Last active March 14, 2025 05:27
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@medwards
medwards / commands.py
Created April 12, 2012 10:04
Adding custom commands to python setup.py
from setuptools import Command
class Compile(Command):
description = "run a custom compile command"
user_options = tuple()
def run(self):
print self.description
def initialize_options(self):