Skip to content

Instantly share code, notes, and snippets.

View Brick85's full-sized avatar

Vital Belikov Brick85

View GitHub Profile
@Brick85
Brick85 / gist:3895340
Created October 15, 2012 20:47
FreeBSD edit php.ini
chflags nosunlnk php.ini; chflags noschg php.ini; replace "safe_mode = Off" "safe_mode = On" -- php.ini; replace "safe_mode_gid = On" "safe_mode_gid = Off" -- php.ini; replace "sql.safe_mode = On" "sql.safe_mode = Off" -- php.ini; chflags sunlnk php.ini; chflags schg php.ini
@Brick85
Brick85 / gist:3960024
Created October 26, 2012 17:14
Exim test mailsend
exim -bh IP
@Brick85
Brick85 / settings_initial.py
Last active October 12, 2015 07:48
Django initial
# settings.py
import os
rel = lambda *x: os.path.join(os.path.abspath(os.path.dirname(os.path.dirname(__file__))), *x)
gettext = lambda s: s
LANGUAGES = (
('ru', gettext('Russian')),
('en', gettext('English')),
('lv', gettext('Latvian')),
)
@Brick85
Brick85 / gist:4538097
Last active December 11, 2015 03:29
Django imports
from django.conf.urls.i18n import i18n_patterns
from django.core.urlresolvers import reverse
@Brick85
Brick85 / gist:5009046
Last active May 3, 2019 09:35
OpenCV Alpha Blending: Blend two cv::Mat with alpha mask. Poorly optimised.
void blendWithMask(cv::Mat &base, cv::Mat &src, cv::Mat &mask, cv::Mat &out){
char ch = base.channels();
double alpha = 0;
for( int y = 0; y < base.rows; y++ ){
uchar* pBS = base.ptr<uchar>(y);
uchar* pSR = src.ptr<uchar>(y);
uchar* pMK = mask.ptr<uchar>(y);
uchar* pOU = out.ptr<uchar>(y);
for( int x = 0; x < base.cols*ch; x++ ){
int ix = x / ch;
@Brick85
Brick85 / ubuntu
Last active December 16, 2015 19:19
Ubuntu hints
Resize terminal:
resize -s 25 80
Test HDD speed:
dd if=/dev/zero of=zeros bs=1M count=500 oflag=direct; unlink zeros
dd if=/dev/zero of=zeros bs=64k count=16k conv=fdatasync; unlink zeros
@Brick85
Brick85 / encrypt.py
Created July 16, 2013 17:09
python crypt and encrypt
from Crypto.Cipher import AES
from Crypto import Random
import base64
AESKEY = "jFa8*!9uiAS0!385&(lla$1dqae8#!da"
BS = 16
pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS)
unpad = lambda s: s[0:-ord(s[-1])]
# forms.py
class UserProfileForm(forms.ModelForm):
class Meta:
model = User
fields = ("email", "last_name", "first_name", "middle_name", 'avatar', 'age', 'hobbies', 'about', 'project_interes')
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request')
super(UserProfileForm, self).__init__(*args, **kwargs)
for fname in ("email", "last_name", "first_name", 'age'):
@Brick85
Brick85 / globalrequests.py
Created October 8, 2013 10:04
Global requests for Django
import inspect
def get_request():
"""Walk up the stack, return the nearest first argument named "request"."""
frame = None
try:
for f in inspect.stack()[1:]:
frame = f[0]
code = frame.f_code
if code.co_varnames[:1] == ("request",):
@Brick85
Brick85 / gist:7883799
Last active December 30, 2015 20:49
kohctpyktop
http://www.zachtronics.com/kohctpyktop/kohctpyktop.htm
KT229:
eNrtmVsOgyAQRYHhxzV0C/3vWrr/jTQ8tLYylo7hpRdjTLyOcxjjBdTe7W166umh
rZJsCDxT4Bys/ws01u1qOZbPqJZMgoyiQOM3tRxFfdS5/dxWVUurqqXFqRH4WdUa
fURVUVVU9RRVfW/ZpnyJodxP5wzfvEpEyf246ppVbOJ2MsXGqLEbslgfyMaGW5eI
BTOY+2RO3D3kne3i+4IKtpS2wyy/hLpS3XOjBrFgBjOYG6qwyitYNJjBPCIzwSoH
fohuRZFeVZQdo3kRzGA+HXN0SoJVDjzeHVLjFxqJmsNMJdTwRUmk7s8NwAxmGscZ
YJV/qryflV0oZeRlbbZj5hHrDOZKzDTeArzMH6VuzXD3v57hJ3+//wk2UsEM5g6Z
DTOzDFTx9MaNmzlSplWm9+Nqn/NGYtYNhcf3jK83RWLBDOYWzP6CxJu2ypt4FVs5
0gsHIMls