Skip to content

Commit 9651e56

Browse files
committed
fun plugin
0 parents  commit 9651e56

File tree

7 files changed

+256
-0
lines changed

7 files changed

+256
-0
lines changed

FaceCode.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import sublime, sublime_plugin, os,time, commands
2+
from datetime import datetime, timedelta
3+
4+
class FaceCodeCommand(sublime_plugin.EventListener):
5+
6+
def __init__(self):
7+
self.cnt = 0
8+
self.settings = sublime.load_settings("FaceCode.sublime-settings")
9+
self.facecode = self.settings.get("facecode")
10+
self.time_format = self.settings.get("time_format")
11+
self.img_format = self.settings.get("img_format")
12+
self.path_photo = self.settings.get("path_save_photo")
13+
self.path_screen = self.settings.get("path_save_screen")
14+
self.device = self.settings.get("device")
15+
self.count_save = self.settings.get("count_save")
16+
self.filename = self.get_file_name()
17+
self.check_folder()
18+
19+
def on_pre_save(self, view):
20+
if self.facecode:
21+
if self.cnt % self.count_save == 0:
22+
self.save_photo()
23+
self.save_screen()
24+
self.cnt += 1
25+
26+
def check_folder(self):
27+
if not os.path.exists(self.path_photo) and self.path_photo:
28+
os.mkdir(self.path_photo, 0777)
29+
if not os.path.exists(self.path_screen) and self.path_screen:
30+
os.mkdir(self.path_screen, 0777)
31+
return
32+
33+
def get_file_name(self):
34+
dt = datetime.now()
35+
ds = str(dt.strftime(self.time_format))
36+
return ds+"."+self.img_format
37+
38+
def save_photo(self):
39+
os.system("streamer -c "+self.device+" -o "+self.path_photo+self.filename)
40+
return
41+
42+
def save_screen(self):
43+
win_id = commands.getoutput('xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | awk \'{print $5}\'')
44+
os.system("import -window "+win_id+" "+self.path_screen+self.filename)
45+
return

FaceCode.pyc

2.34 KB
Binary file not shown.

FaceCode.py~

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import sublime, sublime_plugin, os,time, string, re
2+
from datetime import datetime, timedelta
3+
4+
class FaceCodeCommand(sublime_plugin.EventListener):
5+
def __init__(self):
6+
self.cnt = 0
7+
self.settings = sublime.load_settings("FaceCode.sublime-settings")
8+
self.facecode = self.settings.get("facecode")
9+
self.time_format = self.settings.get("time_format")
10+
self.path = self.settings.get("path_save_photo")
11+
self.device = self.settings.get("device")
12+
self.count_save = self.settings.get("count_save")
13+
exit()
14+
15+
def on_pre_save(self, view):
16+
print self.count_save
17+
# if countSave % 10 == 0:
18+
# dt = datetime.now()
19+
# ds = str(dt.strftime("%d_%m_%y_%H_%M_%S"))
20+
# os.system("streamer -c /dev/video0 -o /home/alex/webcam/"+ds+".jpeg")
21+
# # os.system("cp /home/alex/webcam/"+ds+".jpeg /home/alex/Dropbox/all_ppl/Shcoder/webmorda/")
22+
self.count_save += 1

FaceCode.sublime-settings

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
//Включаем плагин
3+
"facecode": true,
4+
//Путь для сохранения снимков
5+
//Если не надо делать фото либо скрин сублайма то просто установите false
6+
"path_save_photo": "/home/alex/webcam/photo/",
7+
"path_save_screen": "/home/alex/webcam/screenshot/",
8+
//Формат сохранения
9+
// %d - день
10+
// %m - месяц
11+
// %y - год
12+
// %H - час
13+
// %M - минуты
14+
// %S - секунда
15+
//01_02_13_12_23_18.jpeg
16+
"time_format": "%d_%m_%y_%H_%M_%S",
17+
//Формат картинок на выходе (jpeg|jpg|png|gif)
18+
"img_format": "jpeg",
19+
//само устройство
20+
"device": "/dev/video0",
21+
//при каком по счёту сохранению будут делатся снимки
22+
//1 - при каждом, 100 - при каждом сотом
23+
"count_save": 100
24+
}

Main.sublime-menu

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[
2+
{
3+
"caption": "Preferences",
4+
"mnemonic": "n",
5+
"id": "preferences",
6+
"children":
7+
[
8+
{
9+
"caption": "Package Settings",
10+
"mnemonic": "P",
11+
"id": "package-settings",
12+
"children":
13+
[
14+
{
15+
"caption": "FaceCode",
16+
"children":
17+
[
18+
{
19+
"command": "open_file",
20+
"args": {"file": "${packages}/FaceCode/FaceCode.sublime-settings"},
21+
"caption": "Settings – Default"
22+
},
23+
{
24+
"command": "open_file",
25+
"args": {"file": "${packages}/User/FaceCode.sublime-settings"},
26+
"caption": "Settings – User"
27+
}
28+
]
29+
}
30+
]
31+
}
32+
]
33+
}
34+
]

package-metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"url": "https://github.com/phillipkoebbe/DetectSyntax", "version": "2013.01.11.23.54.49", "description": "Syntax detector for Sublime Text 2"}

readme.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
DetectSyntax
2+
============
3+
4+
Support
5+
-------
6+
7+
If you find DetectSyntax helpful, please consider making a donation.
8+
9+
<a href='http://www.pledgie.com/campaigns/16864'><img alt='Click here to lend your support to: DetectSyntax and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/16864.png?skin_name=chrome' border='0' /></a>
10+
11+
Description
12+
-----------
13+
14+
DetectSyntax is a plugin for Sublime Text 2 that allows you to detect the syntax of files that might not otherwise be detected properly. For example, files with the `.rb` extension are usually Ruby files, but when they are found in a Rails project, they could be RSpec spec files, Cucumber step files, Ruby on Rails files (controllers, models, etc), or just plain Ruby files. This is actually the problem I was trying to solve when I started working on this plugin.
15+
16+
Installation
17+
------------
18+
19+
DetectSyntax can be installed in a variety of ways:
20+
21+
* Through Package Control [http://wbond.net/sublime_packages/package_control] (http://wbond.net/sublime_packages/package_control)
22+
23+
Open Package Control
24+
Select 'Install Package'
25+
Find and select 'DetectSyntax'
26+
27+
* By cloning this repository in Packages
28+
29+
cd into your Packages folder
30+
git clone git://github.com/phillipkoebbe/DetectSyntax.git .
31+
32+
* By downloading the files and placing them in a directory under Packages, such as DetectSyntax or User
33+
34+
If you don't put the files in Packages/User (you *can*, but probably shouldn't), make sure they live in Packages/DetectSyntax. If you download and extract a compressed archive from GitHub, the directory will be `phillipkoebbe-DetectSyntax`. Remove `phillipkoebbe-`.
35+
36+
Usage
37+
-----
38+
39+
DetectSyntax is based on the idea that there are rules for selecting a certain syntax. You define the rules, the plugin checks them. The first one to pass wins. If you have need of multiple conditions that must be met, you should use the function rule. See the default settings file for more on function rules.
40+
41+
Create your own rules in `Packages/User/DetectSyntax.sublime-settings`. The easiest way to get started is to just copy the default settings file found in `Packages/DetectSyntax/DetectSyntax.sublime-settings` to your user directory and modify it to meet your needs. Make sure you rename the `default_syntaxes` key to just `syntaxes`. If you don't, you will overwrite the default syntaxes and they will not work.
42+
43+
See the default settings file for examples and comments related to creating rules.
44+
45+
Credits
46+
-------
47+
48+
It all started by forking the plugin created by JeanMertz (1). I modified it quite extensively until I ended up with something entirely my own (2). @maxim and @omarramos commented on the gist and suggested it should be part of Package Control. As I had created it solely for my own consumption, it seemed a bit "hard-coded" to be valuable as a package, but then I took a look at SetSyntax (3) and saw how using settings would make it very flexible. That set me on the path that led to DetectSyntax.
49+
50+
(1) [https://gist.github.com/925008] (https://gist.github.com/925008)
51+
(2) [https://gist.github.com/1497794] (https://gist.github.com/1497794)
52+
(3) [https://github.com/aparajita/SetSyntax] (https://github.com/aparajita/SetSyntax)
53+
54+
Contributing
55+
------------
56+
57+
* Fork the project.
58+
* Use topic branch.
59+
* Make pull request.
60+
61+
History
62+
-------
63+
64+
2013-01-11
65+
66+
* Corrected location of Blade PHP files.
67+
68+
2013-01-05
69+
70+
* Added support for Blade PHP files.
71+
72+
2012-11-18
73+
74+
* Added support for zsh config files. [Thanks Benjamin Smith]
75+
76+
2012-10-25
77+
78+
* Added ability to match all rules. [Thanks for the idea Kirk Strauser]
79+
80+
2012-10-20
81+
82+
* Added jbuilder to the Ruby rule. [Thanks Aaron Crespo]
83+
* Expanded Vagrantfile rule to catch extensions (like Vagrantfile.local).
84+
85+
2012-09-01
86+
87+
* Removed Puppet files from Ruby syntax. See https://github.com/phillipkoebbe/DetectSyntax/issues/11 for details.
88+
* Added some more files to YAML, PHP, XML, INI, and ShellScript. [Thanks Chris Jones]
89+
90+
2012-08-13
91+
92+
* User-defined syntax rules get processed first now. [Closes #11]
93+
94+
2012-08-07
95+
96+
* Added rule to Ruby syntax for Puppet (pp) files.
97+
98+
2012-07-12
99+
100+
* Added support for .simplecov (https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config) [Closes #9, thanks Andrey Botalov]
101+
* Added Preferences menu [Closes #8, thanks Kirk Strauser]
102+
* Create a bare-bones user settings file if one doesn't exist
103+
104+
2012-07-02
105+
106+
* Fixed improper handling of directories with non-ascii characters [Closes #5, thanks Andrew Dryga]
107+
108+
2012-06-28
109+
110+
* Better handling of file defining a function potentially not existing.
111+
112+
2012-06-26
113+
114+
* Added new_file_syntax so new files can have a syntax applied immediately.
115+
116+
2012-06-20
117+
118+
* Added rule for *.thor (thanks Magnus Rex).
119+
120+
2012-04-13
121+
122+
* Renamed the `syntaxes` key to `default_syntaxes` so it is no longer necessary to duplicate default rules in User/DetectSyntax.sublime-settings.
123+
124+
2012-03-23
125+
126+
* Added rule type of 'binary' which builds a shebang regexp for the user.
127+
128+
2012-03-22
129+
130+
* Check to make sure the syntax file exists before trying to set it. [Closes #3, thanks tito]

0 commit comments

Comments
 (0)