Skip to content

Instantly share code, notes, and snippets.

View tlatsas's full-sized avatar

Tasos Latsas tlatsas

View GitHub Profile
@tlatsas
tlatsas / freepbx.spec
Last active December 22, 2015 19:59
freepbx spec file
###################################################################
#
# freepbx.spec - used to generate freepbx rpm
# For more info: http://www.rpm.org/max-rpm/ch-rpm-basics.html
#
# This spec file uses default directories:
# /usr/src/redhat/SOURCES - orig source, patches, icons, etc.
# /usr/src/redhat/SPECS - spec files
# /usr/src/redhat/BUILD - sources unpacked & built here
# /usr/src/redhat/RPMS - binary package files
@tlatsas
tlatsas / test-exception-inheritance.py
Created September 5, 2013 07:47
test exception inheritance in python woot
class HttpError(Exception):
pass
class UnauthorizedError(HttpError):
code = 401
def __str__(self):
return "You shall not pass!"
@tlatsas
tlatsas / do-not-rely-on-posix-php.patch
Last active December 22, 2015 03:49
freepbx 2.11.0 patch
diff --git a/install_amp.orig b/install_amp
index 492e19e..5d48e30 100755
--- a/install_amp.orig
+++ b/install_amp
@@ -994,9 +994,9 @@ if($installamp_clean || $uninstallamp) {
// TODO: if we bootstrap, do this first before even trying. Also, is their a problem boostraping as user root???
//
outn("Checking user..");
-//$current_user=(isset($_ENV["USER"]) ? $_ENV["USER"] : exec('whoami',$output));
-$euid = (posix_getpwuid(posix_geteuid()));
@tlatsas
tlatsas / extract.sh
Created September 2, 2013 10:54
extract rpm files on current folder from debian-based systems
rpm2cpio $1 | cpio -i --make-directories
#!/usr/bin/env python
import functools
import warnings
warnings.simplefilter("once", category=(PendingDeprecationWarning, DeprecationWarning))
def deprecate(msg, klass=PendingDeprecationWarning):
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
@tlatsas
tlatsas / vim.md
Last active December 21, 2015 14:08
vim tips

replacing

spaces -> tabs (w range)

:183,200:retab!

remove trailing space

:%s/\s\+$//
@tlatsas
tlatsas / epoch.js
Last active December 20, 2015 01:49
// sec
Math.round(new Date().getTime()/1000);
@tlatsas
tlatsas / office-mimes.txt
Created July 19, 2013 10:59
typical document mime types of files supported by libre/open office
application/vnd.oasis.opendocument.text
application/x-vnd.oasis.opendocument.text
application/vnd.oasis.opendocument.spreadsheet
application/x-vnd.oasis.opendocument.spreadsheet
application/vnd.oasis.opendocument.presentation
application/x-vnd.oasis.opendocument.presentation
application/msword
application/vnd.ms-excel
application/vnd.ms-excel.addin.macroEnabled.12
application/vnd.ms-excel.sheet.binary.macroEnabled.12

Tmux

Reload settings from within TMUX

:source-file ~/.tmux.conf
@tlatsas
tlatsas / read_plain_configs.py
Created July 11, 2013 15:18
read plain configuration files (without ini sections) using ConfigParser into dictionaries (so we can easily change valies), then built a string to write to file
import ConfigParser
from collections import OrderedDict
class NoSectionConfig(object):
section = "dummy"
def __init__(self, fp):
self.fp = fp
self.section_head = "[{0}]\n".format(self.section)
def readline(self):