Skip to content

Instantly share code, notes, and snippets.

@xr09
xr09 / synergy.conf
Created May 3, 2013 12:18
my synergy config, put this in .synergy.conf in your home
section: screens
# two hosts named: desktop and laptop
# These are the nice names of the hosts to make it easy to write the config file
# The aliases section below contain the "actual" names of the hosts (their hostnames)
laptop:
desktop:
end
section: links
desktop:
@xr09
xr09 / gist:5662502
Created May 28, 2013 12:42
A Doctrine entity
<?php
namespace Cid\FrontBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Solicitud
*
@xr09
xr09 / composer.json
Created June 28, 2013 14:12
requirements.txt vs composer.json
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
@xr09
xr09 / gist:7758982
Created December 2, 2013 21:06
synergy.conf
section: screens
laptop:
desktop:
end
section: links
desktop:
right = laptop
# Desktop1 is to the right of Laptop
@xr09
xr09 / ubackup.sh
Last active January 4, 2016 20:29
Minimal rotating backup system
#!/usr/bin/bash
backup_number=8
base_name="backup.gz"
backup_path="/opt/somebackup/"
cd $backup_path
# clean any old temp backup
@xr09
xr09 / gist:8677086
Created January 28, 2014 21:40
bitwise
>>> map(lambda n: 1 << n, xrange(10))
[1, 2, 4, 8, 16, 32, 64, 128, 256, 512]
>>> from math import pow
>>> map(lambda n: pow(n, 2), xrange(10))
[0.0, 1.0, 4.0, 9.0, 16.0, 25.0, 36.0, 49.0, 64.0, 81.0]
@xr09
xr09 / home_nuker.py
Last active August 29, 2015 14:02
the home nuker
import os
import stat
import shutil
import subprocess
# protected folders in /home
DONT_DELETE = 'Department lost+found someguy'.split()
def chmod_writable(func, path, excinfo):
@xr09
xr09 / gist:912044868b954685de2b
Created August 4, 2014 13:56
mkalias on-the-fly
# mkalias name "command param1 param2 etc.."
# Example: mkalias srvfolder "python -m SimpleHTTPServer"
mkalias () {
echo "alias $1=\"$2\"" >> ~/.bashrc
}
import subprocess
command = subprocess.Popen( ["-c", "who | cut -d' ' -f1 | sort | uniq | grep -v root" ], stdout=subprocess.PIPE, shell=True )
users, err = command.communicate()
@xr09
xr09 / rd
Last active August 29, 2015 14:16
rdesktop like a pro
DOMAIN_NAME="domain-name"
DOMAIN_USER='domain-user'
DOMAIN_PASS='...pass..'
# USAGE:
# rd ( hostname | ip )
# rd winserver
# rd 10.0.0.4
rd()