Skip to content

Instantly share code, notes, and snippets.

@barseghyanartur
barseghyanartur / README.rst
Last active January 24, 2017 13:41
Browser tests using Selenium with Firefox and PhantomJS drivers

Browser tests using Selenium with Firefox and PhantomJS drivers

Selenium

Although there are many options available, I prefer to use either Firefox or PhantomJS.

PhantomJS is faster (twice as fast), but Firefox tells you more. Both cases

@barseghyanartur
barseghyanartur / select_requirements.py
Created May 14, 2017 21:26 — forked from pombredanne/select_requirements.py
Select Python pip requirements files based on os, platform or else
#!/usr/bin/python
# #
# Copyright (c) 2014 by nexB, Inc. http://www.nexb.com/ - All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@barseghyanartur
barseghyanartur / aggregate_concat.py
Created May 17, 2017 15:03 — forked from ludoo/aggregate_concat.py
Django aggregates GROUP_CONCAT support for MySQL
"""
From http://harkablog.com/inside-the-django-orm-aggregates.html
with a couple of fixes.
Usage: MyModel.objects.all().annotate(new_attribute=Concat('related__attribute', separator=':')
"""
from django.db.models import Aggregate
from django.db.models.sql.aggregates import Aggregate as SQLAggregate
@barseghyanartur
barseghyanartur / tetris.py
Created June 5, 2017 00:34 — forked from silvasur/tetris.py
Tetris implementation in Python
#!/usr/bin/env python2
#-*- coding: utf-8 -*-
# NOTE FOR WINDOWS USERS:
# You can download a "exefied" version of this game at:
# http://hi-im.laria.me/progs/tetris_py_exefied.zip
# If a DLL is missing or something like this, write an E-Mail (me@laria.me)
# or leave a comment on this gist.
# Very simple tetris implementation
@barseghyanartur
barseghyanartur / Kibana-readonly.md
Created September 8, 2017 13:07 — forked from r0mdau/Kibana-readonly.md
Kibana readonly over internet

#Kibana Readonly

With this tip, kibana can't be modified. So you can share the uri to anyone on the internet. It's a network method to protect kibana from changes of anonymous.

##Quick start

  1. You need to have a working kibana exposed over http on internet
  2. On the same elasticsearch server, install nginx : apt-get install nginx
  3. In the directory /etc/nginx/sites-available, create a new file and edit it, for example : vi /etc/nginx/sites-available/kibana-readonly
  4. Write the following configuration :
@barseghyanartur
barseghyanartur / snake.py
Created September 19, 2017 22:54 — forked from sanchitgangwar/snake.py
Snakes Game using Python
# SNAKES GAME
# Use ARROW KEYS to play, SPACE BAR for pausing/resuming and Esc Key for exiting
import curses
from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN
from random import randint
curses.initscr()
win = curses.newwin(20, 60, 0, 0)
@barseghyanartur
barseghyanartur / nginx.conf
Created September 25, 2017 13:55 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@barseghyanartur
barseghyanartur / faker_addons.py
Created September 29, 2017 21:18
Faker UUID4 emails
# coding=utf-8
from __future__ import unicode_literals
import uuid
from faker.providers.internet import Provider as InternetProvider
__all__ = ('UUIDInternetProvider',)

Install dlib and face_recognition on a Raspberry Pi

Instructions tested with a Raspberry Pi 2 with an 8GB memory card. Probably also works fine on a Raspberry Pi 3.

Steps

Download the latest Raspbian Jessie Light image. Earlier versions of Raspbian won't work.

Write it to a memory card using Etcher, put the memory card in the RPi and boot it up.

@barseghyanartur
barseghyanartur / pyqt_opencv.py
Created November 19, 2017 00:05 — forked from saghul/pyqt_opencv.py
Render OpenCV video on a PyQt widget
# coding=utf8
# Copyright (C) 2011 Saúl Ibarra Corretgé <saghul@gmail.com>
#
# Some inspiration taken from: http://www.morethantechnical.com/2009/03/05/qt-opencv-combined-for-face-detecting-qwidgets/
import cv
import sys