Skip to content

Instantly share code, notes, and snippets.

View muzhig's full-sized avatar
👨‍💻
working

Arseniy Potapov muzhig

👨‍💻
working
View GitHub Profile
#pragma once
template < typename T > class SP
{
private:
T* pData; // pointer
int* refcnt; // Reference count
public:
SmartPointer() : pData(0), refcnt(0)
{
@muzhig
muzhig / gist:5346671
Created April 9, 2013 15:30
Bluetooth Com port
me@hardy:~$ sudo hcitool scan
Scanning ...
00:02:C7:7D:F5:17 BlueGPS 7DF517
me@hardy:~$ sudo rfcomm bind /dev/rfcomm0 00:02:C7:7D:F5:17 1
me@hardy:~$ ls -l /dev/rfcomm0
crw-rw---- 1 root dialout 216, 0 2008-12-14 23:15 /dev/rfcomm0
@muzhig
muzhig / gist:4707541
Created February 4, 2013 15:46
POSTGRES
generate drop all tables statement
select 'drop table if exists "' || tablename || '" cascade;' from pg_tables where schemaname = 'public';
class backtrace
{
boost::shared_array<void*> m_backtrace;
size_t m_trace_size;
public:
static const int DEFAULT_STACK_DEPTH = 100;
static const int DEFAULT_EXCLUDE_FIRST_FRAMES_COUNT = 1;
typedef std::vector<std::string> stack_type;
@muzhig
muzhig / gist:4474079
Created January 7, 2013 10:46
OPENSSL
tar -cvpj /path/to/directory | openssl aes-256-cbc -kfile /path/to/enc.key | split -d -b 4000m - backup.tar.bz2.enc.
cat backup.tar.bz2.enc.* | openssl aes-256-cbc -d -kfile /path/to/enc.key | tar xvjf -
@muzhig
muzhig / gist:4473717
Created January 7, 2013 09:38
Django-admin-like configurable search view
from django.db.models import Q
from django.views.generic import ListView
import itertools
class BaseSearchView(ListView):
search_fields = []
def get_search_fields(self):
return self.search_fields
query_key = 'q'
git remote set-url origin ssh://newhost.com/usr/local/gitroot/myproject.git # change remote url
@muzhig
muzhig / gist:4460471
Created January 5, 2013 08:12
GITOLITE
gitolite admin repo – this is where you add new repos, users, and access.
git clone ssh://gitolite@hostname_or_ip:ssh_port/gitolite-admin
You now have a gitolite-admin directory with conf/ and keydir/ inside. Conf directory contains gitolite.conf file and you will add users, privileges and projects/repos here. Keydir is where you save the ssh key files. Note: Make sure the filename of ssh key matches the user on gitolite.conf without the .pub. As example, you will have your ssh key file in keydir/user.pub and in gitolite.conf you have the following:
repo gitolite-admin
RW+ = user
To add users, upload the ssh key file inside keydir/ and add his access inside gitolite.conf.
vi keydir/user2.pub
To create new repository, just add the following lines in conf/gitolite.conf:
repo drupal_dev
RW+ = user user2
@muzhig
muzhig / gist:4451452
Last active December 10, 2015 14:58
TAR
tar -c "$srcdir" | tar -C "$destdir" -xv
tar -cf archive.tar foo bar
tar -xf archive.tar # Extract all files from archive.tar.
tar -tvf archive.tar # List all files in archive.tar verbosely.
sudo su - <username>
sudo -u username <cmd>