-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit eccb987
Showing
21 changed files
with
6,483 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
*pyc |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Fede Calendino | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### [Alfred Workflow](https://www.alfredapp.com/workflows/) to generate random values for different data types 🎲️ | ||
|
||
|
||
![Randomer example](/img/example_all.png) | ||
|
||
![Randomer example](/img/example_imei.png) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from uuid import uuid4 | ||
from string import ascii_lowercase, ascii_uppercase | ||
from random import choice, randint | ||
|
||
LETTER_VALUES = dict(zip(ascii_uppercase, filter(lambda i: i % 11, range(10, 39)))) | ||
|
||
|
||
def random_string(size=10): | ||
return "".join(choice(ascii_lowercase + ascii_uppercase) for _ in range(size)) | ||
|
||
|
||
def random_email(): | ||
return "".join([random_string(10), "@", random_string(7), ".com"]).lower() | ||
|
||
|
||
def random_imei(): | ||
imei = [randint(0, 9) for _ in range(14)] | ||
|
||
tmp = [] | ||
|
||
for index, digit in enumerate(imei): | ||
if index % 2: | ||
digit = digit * 2 | ||
|
||
tmp.extend(divmod(digit, 10)) | ||
|
||
imei.append((sum(tmp) * 9) % 10) | ||
return "".join(map(str, imei)) | ||
|
||
|
||
def random_unit_number(): | ||
number = [ | ||
choice(ascii_uppercase), | ||
choice(ascii_uppercase), | ||
choice(ascii_uppercase), | ||
choice("UJZ"), | ||
randint(0, 9), | ||
randint(0, 9), | ||
randint(0, 9), | ||
randint(0, 9), | ||
randint(0, 9), | ||
randint(0, 9), | ||
] | ||
|
||
values = list(map(lambda d: int(LETTER_VALUES.get(d, d)), number)) | ||
checksum = sum(d * 2 ** i for i, d in enumerate(values)) % 11 | ||
|
||
if checksum > 9: | ||
return random_unit_number() | ||
|
||
number.append(checksum) | ||
return "".join(map(str, number)) | ||
|
||
|
||
def random_uuid(): | ||
return str(uuid4()) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?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>bundleid</key> | ||
<string>com.github.fedecalendino.alfred-randomer</string> | ||
<key>category</key> | ||
<string>Tools</string> | ||
<key>connections</key> | ||
<dict> | ||
<key>EC765E5B-D5EC-4893-B319-32CDD2BC7C5C</key> | ||
<array> | ||
<dict> | ||
<key>destinationuid</key> | ||
<string>8C2A867D-8342-47CC-B605-C5A3D7740379</string> | ||
<key>modifiers</key> | ||
<integer>0</integer> | ||
<key>modifiersubtext</key> | ||
<string></string> | ||
<key>vitoclose</key> | ||
<false/> | ||
</dict> | ||
</array> | ||
</dict> | ||
<key>createdby</key> | ||
<string>Fede Calendino</string> | ||
<key>description</key> | ||
<string>Generate random values for different data types 🎲️</string> | ||
<key>disabled</key> | ||
<false/> | ||
<key>name</key> | ||
<string>Randomer</string> | ||
<key>objects</key> | ||
<array> | ||
<dict> | ||
<key>config</key> | ||
<dict> | ||
<key>autopaste</key> | ||
<false/> | ||
<key>clipboardtext</key> | ||
<string>{query}</string> | ||
<key>ignoredynamicplaceholders</key> | ||
<false/> | ||
<key>transient</key> | ||
<false/> | ||
</dict> | ||
<key>type</key> | ||
<string>alfred.workflow.output.clipboard</string> | ||
<key>uid</key> | ||
<string>8C2A867D-8342-47CC-B605-C5A3D7740379</string> | ||
<key>version</key> | ||
<integer>3</integer> | ||
</dict> | ||
<dict> | ||
<key>config</key> | ||
<dict> | ||
<key>alfredfiltersresults</key> | ||
<false/> | ||
<key>alfredfiltersresultsmatchmode</key> | ||
<integer>0</integer> | ||
<key>argumenttreatemptyqueryasnil</key> | ||
<false/> | ||
<key>argumenttrimmode</key> | ||
<integer>0</integer> | ||
<key>argumenttype</key> | ||
<integer>1</integer> | ||
<key>escaping</key> | ||
<integer>102</integer> | ||
<key>keyword</key> | ||
<string>!</string> | ||
<key>queuedelaycustom</key> | ||
<integer>3</integer> | ||
<key>queuedelayimmediatelyinitially</key> | ||
<true/> | ||
<key>queuedelaymode</key> | ||
<integer>0</integer> | ||
<key>queuemode</key> | ||
<integer>1</integer> | ||
<key>runningsubtext</key> | ||
<string>...</string> | ||
<key>script</key> | ||
<string>python ./main.py $@</string> | ||
<key>scriptargtype</key> | ||
<integer>1</integer> | ||
<key>scriptfile</key> | ||
<string></string> | ||
<key>subtext</key> | ||
<string></string> | ||
<key>title</key> | ||
<string></string> | ||
<key>type</key> | ||
<integer>0</integer> | ||
<key>withspace</key> | ||
<false/> | ||
</dict> | ||
<key>type</key> | ||
<string>alfred.workflow.input.scriptfilter</string> | ||
<key>uid</key> | ||
<string>EC765E5B-D5EC-4893-B319-32CDD2BC7C5C</string> | ||
<key>version</key> | ||
<integer>3</integer> | ||
</dict> | ||
</array> | ||
<key>readme</key> | ||
<string>Generate random values for different data types 🎲️</string> | ||
<key>uidata</key> | ||
<dict> | ||
<key>8C2A867D-8342-47CC-B605-C5A3D7740379</key> | ||
<dict> | ||
<key>xpos</key> | ||
<integer>305</integer> | ||
<key>ypos</key> | ||
<integer>40</integer> | ||
</dict> | ||
<key>EC765E5B-D5EC-4893-B319-32CDD2BC7C5C</key> | ||
<dict> | ||
<key>xpos</key> | ||
<integer>55</integer> | ||
<key>ypos</key> | ||
<integer>40</integer> | ||
</dict> | ||
</dict> | ||
<key>version</key> | ||
<string>v1.0</string> | ||
<key>webaddress</key> | ||
<string>https://github.com/fedecalendino/alfred-randomer</string> | ||
</dict> | ||
</plist> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# coding=utf-8 | ||
import sys | ||
|
||
from workflow import Workflow | ||
|
||
import generators | ||
|
||
|
||
GENERATORS = { | ||
"email": generators.random_email, | ||
"imei": generators.random_imei, | ||
"unit": generators.random_unit_number, | ||
"uuid": generators.random_uuid, | ||
} | ||
|
||
|
||
def main(workflow): | ||
param = " ".join(workflow.args).lower() | ||
|
||
if param in GENERATORS: | ||
items = [param] * 5 | ||
else: | ||
items = sorted(GENERATORS.keys()) | ||
|
||
for name in items: | ||
value = GENERATORS[name]() | ||
|
||
workflow.add_item( | ||
title=value, | ||
subtitle=name, | ||
arg=value, | ||
valid=True, | ||
) | ||
|
||
|
||
if __name__ == u"__main__": | ||
wf = Workflow() | ||
wf.run(main) | ||
wf.send_feedback() | ||
sys.exit() |
Empty file.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
# | ||
# Copyright (c) 2014 Dean Jackson <deanishe@deanishe.net> | ||
# | ||
# MIT Licence. See http://opensource.org/licenses/MIT | ||
# | ||
# Created on 2014-02-15 | ||
# | ||
|
||
"""A helper library for `Alfred <http://www.alfredapp.com/>`_ workflows.""" | ||
|
||
import os | ||
|
||
# Workflow objects | ||
from .workflow import Workflow, manager | ||
from .workflow3 import Variables, Workflow3 | ||
|
||
# Exceptions | ||
from .workflow import PasswordNotFound, KeychainError | ||
|
||
# Icons | ||
from .workflow import ( | ||
ICON_ACCOUNT, | ||
ICON_BURN, | ||
ICON_CLOCK, | ||
ICON_COLOR, | ||
ICON_COLOUR, | ||
ICON_EJECT, | ||
ICON_ERROR, | ||
ICON_FAVORITE, | ||
ICON_FAVOURITE, | ||
ICON_GROUP, | ||
ICON_HELP, | ||
ICON_HOME, | ||
ICON_INFO, | ||
ICON_NETWORK, | ||
ICON_NOTE, | ||
ICON_SETTINGS, | ||
ICON_SWIRL, | ||
ICON_SWITCH, | ||
ICON_SYNC, | ||
ICON_TRASH, | ||
ICON_USER, | ||
ICON_WARNING, | ||
ICON_WEB, | ||
) | ||
|
||
# Filter matching rules | ||
from .workflow import ( | ||
MATCH_ALL, | ||
MATCH_ALLCHARS, | ||
MATCH_ATOM, | ||
MATCH_CAPITALS, | ||
MATCH_INITIALS, | ||
MATCH_INITIALS_CONTAIN, | ||
MATCH_INITIALS_STARTSWITH, | ||
MATCH_STARTSWITH, | ||
MATCH_SUBSTRING, | ||
) | ||
|
||
|
||
__title__ = 'Alfred-Workflow' | ||
__version__ = open(os.path.join(os.path.dirname(__file__), 'version')).read() | ||
__author__ = 'Dean Jackson' | ||
__licence__ = 'MIT' | ||
__copyright__ = 'Copyright 2014-2019 Dean Jackson' | ||
|
||
__all__ = [ | ||
'Variables', | ||
'Workflow', | ||
'Workflow3', | ||
'manager', | ||
'PasswordNotFound', | ||
'KeychainError', | ||
'ICON_ACCOUNT', | ||
'ICON_BURN', | ||
'ICON_CLOCK', | ||
'ICON_COLOR', | ||
'ICON_COLOUR', | ||
'ICON_EJECT', | ||
'ICON_ERROR', | ||
'ICON_FAVORITE', | ||
'ICON_FAVOURITE', | ||
'ICON_GROUP', | ||
'ICON_HELP', | ||
'ICON_HOME', | ||
'ICON_INFO', | ||
'ICON_NETWORK', | ||
'ICON_NOTE', | ||
'ICON_SETTINGS', | ||
'ICON_SWIRL', | ||
'ICON_SWITCH', | ||
'ICON_SYNC', | ||
'ICON_TRASH', | ||
'ICON_USER', | ||
'ICON_WARNING', | ||
'ICON_WEB', | ||
'MATCH_ALL', | ||
'MATCH_ALLCHARS', | ||
'MATCH_ATOM', | ||
'MATCH_CAPITALS', | ||
'MATCH_INITIALS', | ||
'MATCH_INITIALS_CONTAIN', | ||
'MATCH_INITIALS_STARTSWITH', | ||
'MATCH_STARTSWITH', | ||
'MATCH_SUBSTRING', | ||
] |
Oops, something went wrong.