This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#unindent selection | |
import editor | |
text = editor.get_text() | |
selection = editor.get_line_selection() | |
selected_text = text[selection[0]:selection[1]] | |
replacement = '' | |
for line in selected_text.splitlines(): | |
replacement += line[line.find('\t') + 1:] + '\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#indent selection | |
import editor | |
text = editor.get_text() | |
selection = editor.get_line_selection() | |
selected_text = text[selection[0]:selection[1]] | |
replacement = '' | |
for line in selected_text.splitlines(): | |
replacement += '\t' + line + '\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Comment/Uncomment selected lines. | |
import editor | |
text = editor.get_text() | |
selection = editor.get_line_selection() | |
selected_text = text[selection[0]:selection[1]] | |
is_comment = selected_text.strip().startswith('#') | |
replacement = '' | |
for line in selected_text.splitlines(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Pythonista | |
#For use with the rc tank in https://gist.github.com/4141545 | |
#I run this on my iPhone to control the tank on my iPad. | |
from scene import * | |
from sound import * | |
from socket import * | |
from struct import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Pythonista | |
# remote controlled tank without a game. Haven't figured out the gameplay yet. | |
# Use remote app https://gist.github.com/959c9fba8e1e0c04f898 to control the tank. | |
# Work in progress. | |
from time import clock | |
from scene import * | |
from sound import * | |
from struct import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#covert an image in the clipboard to a 57x57 rgb icon and store base64 version of it into the clipboard. | |
#if an image is not in the clipboard the base64 string 'b64str' will be loaded and displayed. | |
#after running the 1st time replace the contents of b64str with the clipboard. | |
from PIL import Image | |
import clipboard | |
from StringIO import * | |
import base64 | |
b64str=""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#---------------------------------------------------------------------- | |
# Copyright (c) 2012, Guy Carver | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without modification, | |
# are permitted provided that the following conditions are met: | |
# | |
# * Redistributions of source code must retain the above copyright notice, | |
# this list of conditions and the following disclaimer. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#---------------------------------------------------------------------- | |
# Copyright (c) 2012, Guy Carver | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without modification, | |
# are permitted provided that the following conditions are met: | |
# | |
# * Redistributions of source code must retain the above copyright notice, | |
# this list of conditions and the following disclaimer. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#---------------------------------------------------------------------- | |
# Copyright (c) 2012, Guy Carver | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without modification, | |
# are permitted provided that the following conditions are met: | |
# | |
# * Redistributions of source code must retain the above copyright notice, | |
# this list of conditions and the following disclaimer. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scene import * | |
import random | |
import console | |
from functools import partial | |
from sound import load_effect, play_effect | |
rows = 24 | |
cols = 20 | |
fsize = 20 | |
plot_size = 32 |
NewerOlder