Skip to content

Instantly share code, notes, and snippets.

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 / .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
@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) ]
#!/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 / 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': '🕠',
@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 / gist:4137305
Created November 23, 2012 21:01
Script to sync Pythonista App to Dropbox
import webbrowser, os, pprint
# Include the Dropbox SDK libraries
#from dropbox import client, rest, session
import dropbox
# Configuration
TOKEN_FILENAME = 'PythonistaDropbox.token'
# Get your app key and secret from the Dropbox developer website
APP_KEY = '<your dropbox app_key>'
APP_SECRET = '<your dropbox app_secret>'
@fcrespo82
fcrespo82 / gist:5033378
Created February 25, 2013 21:14
Open SMS compose window with prepopulated number and body
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.recipients = [NSArray arrayWithObject:@"48151623"];
picker.body = @"Body text.";
[self presentModalViewController:picker animated:YES];
[picker release];
@fcrespo82
fcrespo82 / RodarComoAdmin.txt
Last active December 15, 2015 06:19
This gist shows how to run an app as admin in OS X
on run {input, parameters}
using terms from application "Finder"
set filepath to POSIX path of input
do shell script "open '" & filepath & "'" with administrator privileges
end using terms from
end run
@fcrespo82
fcrespo82 / pushover.py
Created March 21, 2013 21:39
This gist describes how to send messages via push to your phone using pushover API
import requests
USER_TOKEN = u'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' #replace with your user key
APP_TOKEN = u'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' #replace with your APP token/key
HEADERS = { "Content-type": "application/x-www-form-urlencoded" }
def sendPush(message, title, url, url_title):
parameters = { u'token': APP_TOKEN,
u'user': USER_TOKEN,