Skip to content

Instantly share code, notes, and snippets.

@bevesce
bevesce / alexa_ask_write.py
Created June 4, 2017 16:09
Alexa skill that creates time stamped plain text note in dropbox
# to set it up you can follow this guide http://alexamods.com/guide-install-ask-google-alexa-skill/
# but in step 12 paste this code instead of uploading zip file
# you also need to enable encryption helpers and set up
# dropbox access token as env variable named "dropbox_token"
# of course you can use different name than "google"
# I'm using "write"
from base64 import b64decode
from datetime import datetime
from urllib import request, parse, error
import boto3
@bevesce
bevesce / alexa_ask_dropbox_notes.py
Created June 4, 2017 16:05
Alexa skill that reads plain text notes from dropbox
# to set it up you can follow this guide http://alexamods.com/guide-install-ask-google-alexa-skill/
# but in step 12 paste this code instead of uploading zip file
# you also need to enable encryption helpers and set up
# dropbox access token as env variable named "dropbox_token"
# of course you can use different name than "google"
# I'm using "notes"
from base64 import b64decode
from urllib import request
import difflib
import json
@bevesce
bevesce / spelling_with_google.py
Created September 24, 2016 10:12
check spelling using google search API
from urllib.request import urlopen
from urllib.parse import urlencode
import json
url_base = """https://www.googleapis.com/customsearch/v1?num=1&"""
# provide google api key from https://code.google.com/apis/console/
# project needs to have custom search api enabled
key =
pl_cse = '009341357436794688484:bi6ngbl4mvk'
@bevesce
bevesce / mini.dark.tmTheme
Created March 13, 2016 15:23
Sublime Text color theme with very few highlights
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Piotrek Wilczyński (procrastinationlog.com)</string>
<key>name</key>
<string>Mini Dark</string>
<key>semanticClass</key>
<string>mini.dark</string>
@bevesce
bevesce / qgo.py
Created March 13, 2016 13:23
make bash profile aliases from command line
import os
import re
import colors
PROFILE_PATH = os.path.expanduser('~/.profile')
def show_aliases():
for alias, command in find_aliases().items():
prefix = ''
@bevesce
bevesce / named_enum.py
Last active November 19, 2015 22:45
Enums for states and types for django SmallIntegerField
"""
Example:
class State(NamedEnum):
SUCCESS = En()
ERROR = En(u'co poszlo nie tak')
FU = En(u'FFFFUUUUUUUU-')
print State.SUCCESS
print State.ERROR
@bevesce
bevesce / colors.py
Last active August 29, 2015 14:08
Add colors to text in terminal
"""
Module contains:
1. Constants like RED, BLUE, ON_RED, RED_ON_BLUE, GREEN_ON_BLUE
that are ANSI codes in text that can be used to make terminal output
colorful.
>>> print colors.RED + 'this will be red'
2. Functions like red(text), blue(text), on_red(text), red_on_blue(text), green_on_blue(text).