Skip to content

Instantly share code, notes, and snippets.

@fcrespo82
fcrespo82 / remove.md
Last active May 20, 2016 21:44
Remove all files from a make install that do not provide a make uninstall

You can use make install and DESTDIR to get a clean tree of the files in the kit. The following (untested script) should delete all the files of the SVN source kit.

BE CAREFUL WITH THIS COMMAND SINCE IT USES sudo rm AND COULD DAMAGE YOUR SYSTEM.

YOU HAVE BEEN WARNED!

make install DESTDIR=/tmp/qqq
cd /tmp/qqq
@fcrespo82
fcrespo82 / count_quotation_mark.py
Created February 9, 2015 20:14
Script to count quotation marks in jsp
import os
import re
with open("/home/fxcrespo/workspaces/workspace_siga/count.log", "w") as thelog:
for path, dirs, files in os.walk("/home/fxcrespo/workspaces/workspace_siga"):
for thefile in files:
thepath = os.path.join(path, thefile)
if thepath.endswith("jsp"):
thecount = len(re.findall("\"", "".join(open(thepath).readlines())))
if thecount > 0 and (thecount % 2 != 0):
@fcrespo82
fcrespo82 / clockface
Last active August 29, 2015 14:04 — forked from drdrang/clockface
I don't know why I did it, but this version shows the minutes past the represented in the emoji
#!/usr/bin/python
# -*- coding: utf-8 -*-
from sys import argv
from time import strftime
from math import floor
clocks = {'12:00': '🕛', '12:30': '🕧', '1:00': '🕐', '1:30': '🕜',
'2:00': '🕑', '2:30': '🕝', '3:00': '🕒', '3:30': '🕞',
'4:00': '🕓', '4:30': '🕟', '5:00': '🕔', '5:30': '🕠',
#!/usr/bin/env python
# wol.py
import socket
import struct
def wake_on_lan(macaddress):
""" Switches on remote computers using WOL. """
# Check macaddress format and try to compensate.
@fcrespo82
fcrespo82 / new_gist_file.py
Created March 22, 2014 01:09
Pure anonymous lambda recursive function in python
import urllib
a=['<','<','<','<']
[ (lambda a:lambda t,v:a(t,a,v))(lambda t,s,x:t if x==0 else s(urllib.quote(t),s,x-1))(x,idx+1) for idx,x in enumerate(a) ]
@fcrespo82
fcrespo82 / .bash_completion
Last active August 29, 2015 13:57
A shell completion for Brett Terpstra's doing command line utility http://brettterpstra.com/projects/doing/
_doing()
{
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "$(doing help -c)" -- $cur) )
}
complete -F _doing doing
import contacts
import webbrowser, urllib
from seamless_dropbox import open
import console
DRAFTS_ACTION = "Backup Contacts"
VCARD = ""
people = contacts.get_all_people()
i = 0
@fcrespo82
fcrespo82 / progressbar.py
Last active January 3, 2016 08:49
Progress bar module for python. Super simple to use.Any questions find me @fcrespo82 on twitter and app.net
#!/usr/bin/env python
def progressbar(total, value, size=70, fill_char="#", empty_char="-"):
if value > total:
raise Exception("'value' must be <= 'total'")
multiplier = (size*1.0)/total
fill=int(round(value*multiplier))
empty=int(round((total-value)*multiplier))
print("[{}{}]".format(fill_char*fill, empty_char*empty))
#!/usr/bin/python
import sys
import os, shutil
import subprocess
import os.path
from datetime import datetime
######################## Functions #########################
@fcrespo82
fcrespo82 / due.py
Created December 18, 2013 21:22
Send Due tasks from any computer with Python
#! /usr/bin/env python
import pushover
import sys
import datetime
import dateutil.parser
import urllib
DUE_URL = "due://x-callback-url/add?title={0}&duedate={1}&timezone=GMT"