Cedric
Member-
Posts
37 -
Joined
-
Last visited
-
Days Won
2
Cedric last won the day on June 22 2016
Cedric had the most liked content!
Profile Information
-
Location
France
Recent Profile Visitors
Cedric's Achievements
Member (4/5)
2
Reputation
-
solved send csv filter to list filter within the workflow
Cedric replied to Cedric's topic in Discussion & Help
Perfect, that's exactly what I needed! Thanks. -
Cedric reacted to a post in a topic: send csv filter to list filter within the workflow
-
Cedric started following send csv filter to list filter within the workflow
-
solved send csv filter to list filter within the workflow
Cedric posted a topic in Discussion & Help
Context I am trying to create a simple workflow which outputs a list of common git commands with a basic explainer in the subtext. To import my list I created the following csv file "git config","Set configuration options such as user name and email. It's done once at the setup of git.","git config --global user.name USERNAME" "git init","Create an empty Git repository in the specified directory. Initial step to start a new project.","git init REPO_NAME" "git clone","Create a local copy of a remote repository. Necessary to start working locally on the project.","git clone REPO_URL" "git add","Add files to the staging area in preparation for a commit. Done after making changes to the working directory.","git add FILE_NAME" "git status","Display the state of the working directory and the staging area. It helps to see what changes are staged for commit.","git status" "git commit","Record changes to the repository with a message. This comes before making a pull request.","git commit -m COMMIT_MESSAGE" "git branch","List, create, or delete branches in the repository. Used to work on features or fixes in isolation.","git branch BRANCH_NAME" "git checkout","Switch between branches or restore files to the working directory. Used to switch the context.","git checkout BRANCH_NAME" "git merge","Combine changes from one branch into another. Used to integrate changes made in a branch.","git merge SOURCE_BRANCH" "git pull","Fetch from and integrate with another repository or a local branch. Keep your branch up-to-date with the remote repository.","git pull REMOTE_NAME BRANCH_NAME" "git push","Update remote references along with associated objects. Send your commits to the remote repository.","git push REMOTE_NAME BRANCH_NAME" "git log","Show the commit logs. View the history of the repository.","git log" "git stash","Temporarily save changes that you don’t want to commit immediately. Useful to clean working directory.","git stash save STASH_NAME" "git remote","Manage the set of remotes. Useful for adding remote repositories.","git remote add REMOTE_NAME REMOTE_URL" "git diff","Show changes between the working directory and the index or between two branches. Useful for reviewing code changes.","git diff SOURCE_BRANCH TARGET_BRANCH" The main output is a Copy to Clipboard action. An alternative action is a search to the https://git-scm.com website Problem My problem is that the subtext is too long, so the explanation is truncated. I was then thinking of passing the CSV to the list filter as a series of a series of arguments separated by a newline, allowing me to recapture them on output and sending them to a large type output. Is that possible somehow or do I need to switch to a script filter? -
RecentlyAdded — List directory contents by added date
Cedric replied to vitor's topic in Share your Workflows
Thanks it worked! -
RecentlyAdded — List directory contents by added date
Cedric replied to vitor's topic in Share your Workflows
Hello, I have been an avid user of your workflow for years. But I recently upgrated to MacOs 13, and the workflow stopped working. Here is what I get in the debugger: [12:38:09.440] ERROR: RecentlyAdded[Script Filter] Code 126: /Users/cedric/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/9E2D9F43-89B8-461E-ACAD-0AF96EE4D44E: line 1: ./recentlyadded: Permission denied I use the 2022.2 version. Any idea? Thanks! -
deanishe reacted to a post in a topic: SmartFolders: Browse and search the contents of your Saved Searches
-
[Help] calling dependencies in a Python workflow
Cedric replied to Cedric's topic in Workflow Help & Questions
Thanks so much for the response, it's so much clearer now. A lot of things weren't obvious to me, like the part about "modelled on the requests library" meaning that it worked exactly the same way. Because I didn't understand how Alfred worked, the part of the code about grabbing the query went over my head, as I didn't understand what the code was doing. Here is why I'm using the print function: my goal with the v0.1 of the workflow was to be able to display (print) very simply the answer to the question "male or female?" I naively thought that I could write a v0.1 my Python script and easily integrate it into Alfred, and iterate from there. Obviously, there are too many hurdles in doing that, so I will: - finalise the script (by making sure my code works when the API returns errors or the like). - integrate it into Alfred by using your library Thanks for the clarification, really. I'm going to post again here when I'm done rewriting the code. -
[Help] calling dependencies in a Python workflow
Cedric replied to Cedric's topic in Workflow Help & Questions
I've already read it twice before posting (along with Alfred-workflow documentation and the bundler code comments and documentation, and other forum posts), I do try to do my homework before asking for help! The tutorial does not do exactly what I'm trying to do, as I'm not trying to show a list of posts. It might be why the answer didn't seem so obvious to me. But I guess I'll take a small break and re-read it again, maybe taking a step back will help seeing the answers there. Thanks a lot for your help, sorry if it seemed like I was trying to make your write the tutorial again. -
[Help] calling dependencies in a Python workflow
Cedric replied to Cedric's topic in Workflow Help & Questions
Thanks for the quick reply! About the error in the code I'm not sure I understand what's happening: I tested the code in iPython, and it works. I then tested the worfklow while using fixed values ('Alice Nicolas' instead of '{query}') and it works. When I'm using it with {query} it doesn't work. Here is the error message, for reference: [ERROR: alfred.workflow.action.script] Traceback (most recent call last): File "genderize.py", line 36, in <module> proba = [float(r.json()[p]['probability']) for p in range(len(values))] KeyError: 0 About passing the query I'm not sure I understand exactly how do I pass the query. In the other workflow that I wrote in bash, I knew that scrip.sh word makes 'word' a positional parameter that I can grab in the code. For python, I don't know how to tell Alfred "replace the {query} in the code with my input". I thought it was managed automatically. About the problems with the code I know that my code doesn't work if the API returns errors, I went for a first version that would allow me to test creating a working workflow in Alfred. Once i can do that, I will focus on making the code stronger. I'm a beginner at Python, so I don't have the best practices yet in regards to querying API. About alfred-wofklow It's included in the folder at the moment, but not used. I plan to review the tutorials later to see how I can adapt the code to my needs if I want to complexify the workflow. Working with requests first was a good way to learn a popular Python module that I will probably use in other projects. -
[Help] calling dependencies in a Python workflow
Cedric replied to Cedric's topic in Workflow Help & Questions
Thanks a lot for the tips, and especially for the aliases. pip now works as it should and I successfully installed Requests in the worfklow. I do have a message about pip not being up to date, should I try to update it? It seems to be in the system folder. That said, my workflow still does not work. I tried using the script filter, but Alfred would display fallback options (Google...) before I'm able to finish typing the names. I then tried with the other script object, but nothing happens. If you could give it a look and tell me what's wrong, that would be really helpful. Here is the link. Thanks! -
I'm trying to create a Python workflow that would work with the API of https://genderize.io In my Python code I use the "requests" and "collections" modules. The code works as intended when ran through the Python interpreter, but now I don't know how to actually finalize the worfklow and include the dependencies. I tried using the Python dependency bundler, but it didn't seem to work. I tried to pip install inside the workflow folder, but I have the Homebrew related bug with the pip install --target=url. I used a technique which did install requests in the workflow, but I'm not sure how to point to it now. I'm very confused despite my best efforts, and the workflow folders reflect that. Hopefully someone can walk me though the correct steps to do once the code is written and working. Thanks! Here is the workflow: link And the code: #!/usr/bin/env python # encoding: utf-8 #Code under MIT lience, modified from Stack Overflow answers, as listed below: #orlp http://stackoverflow.com/a/19560097 #Aaron Hall http://stackoverflow.com/a/33737067 #metatoaster http://stackoverflow.com/a/25480206 #Ultimate Zero http://stackoverflow.com/a/13224079 import requests from collections import OrderedDict import bundler bundler.init() #1.PREPARING THE QUERY #import Alfred's query query = '{query}' #transform query into a list values = query.split() #format the keys as expect by genderize.io keys = ['name' + '[' + str(i) + ']' for i in range(len(values))] #create the parameters as an ordered dictionary of keys and values, as expected by requests.get() names = OrderedDict([(k, v) for k, v in zip(keys, values)]) #2. SENDING THE QUERY AND FORMATTING THE RESULTS #query the API with the GET request r = requests.get('https://api.genderize.io/', params=names) #define a function to easily access probability. proba = [float(r.json()[p]['probability']) for p in range(len(values))] #define a function to easily access count. count = [int(r.json()[c]['count']) for c in range(len(values))] #define a function to easily access gender. gender = [str(r.json()[g]['gender']) for g in range(len(values))] #3. PROCESSING THE RESULTS #print the results of the query, with some variations linked to the strenght of the guess for r in range(len(values)): if proba[r] >= 0.9: print values[r], 'is most likely', gender[r] elif 0.7 <= proba[r] < 0.9: print values[r], 'is probably', gender[r] elif 0.5 < probar[r] < 0.7: print values[r], 'is maybe', gender[r] else: 'the gender of', values[r], 'is unknown'
-
Hello, Thanks for this amazing worfklow. I'm a big pocket user (top 1% reader according to their stats) but both the mac app and the firefox extension were failing me (the firefox extension doesn't work when you don't save your history). I'm not sure how the "save link from clipboard" works though. I activated the global shortcut, but nothing much happens. How is it supposed to work? Should the link appear in alfred with the option to "save to pocket"? or does it work in the background with no feedback to the user? By the way, you should mention in the description that users have to set the global hotkey themselves; this is the normal behaviour of Alfred to avoid conflicts with other system hotkeys. Cheers
-
[Request] Excel functions worfklow (csv provided)
Cedric replied to Cedric's topic in Workflow Help & Questions
Could you give me some pointer about how to set the language? I'm not sure where to start to make this happen. Thanks! -
deanishe reacted to a post in a topic: Help with Alfred + Automator/AppleScript
-
Help with Alfred + Automator/AppleScript
Cedric replied to Cedric's topic in Workflow Help & Questions
I have completely rewritten my workflow to make it work even if the project name contains one or more space. The code doesn't care, and simply checks that a section number is correctly entered. I did as you said as well, and got the .sh script on a dedicated file, using /bin myscript.sh {query} to set the positional parameters. This workflow now works exactly as intended, thank you for your help! #!/bin/bash #code under MIT licence, modified from Stack Overflow, Unix.com and Ask Ubuntu answers, from the users below: #bashist http://stackoverflow.com/a/6968547 #Ignacio Vazquez-Abrams http://stackoverflow.com/a/2210386 #robotronic http://www.unix.com/shell-programming-and-scripting/42417-what-does-mean-double-pipe.html #geirha http://askubuntu.com/a/29596 #the positional parameters are set from Alfred's script filter #test if the last parameter is a valid integer. if [[ ${@: -1} =~ ^[0-9]+$ ]]; then #run the automator workflow. ${@:1:($#-1)} = All parameters but the last; {@: -1} = last parameter automator -D project_name="${@:1:($#-1)}" -D section_number="${@: -1}" folder_cleanup.workflow #If the last parameter was not a valid integer, send a notification else echo 'Incorrect section number? Try again' fi -
Help with Alfred + Automator/AppleScript
Cedric replied to Cedric's topic in Workflow Help & Questions
You're right, my workflow was confused. I now edited the automator workflow and here is the script that Alfred runs. #!/bin/bash arr="{query}" set -- $arr automator -D project_name="$1" -D section_number="$2" /Users/.../Alfred.alfredpreferences/workflows/.../folder_cleanup.workflow And it's working beautifully! This is great, and all the files are in the worfklow so it will work on my other computers. This shows that with even with my limited coding knowledge, I can create interesting workflows, at least for my personal use. I'll definitly think about doing more of them in the future. The mistake that kept me blocked was silly, and I accidentally closed the page while writing about it, which is sillier. So I'll edit this response when I have the time to add the full explanation. A question: is it possible to give the automator function a relative path to the workflow, rather than the absolute one? Second question: My workflow requires two arguments separated by a space (that Alfred recognizes as a single argument with a space inside). How could I modify the script so it tells me if I forgot to put 2 arguments? Maybe counting the number of array items, and using an IF? IF array != 2, echo {error_message}. I understand that the echo becomes another {query} than can be passed to a notification that would show warn the user? Thanks for your help! -
[Request] Excel functions worfklow (csv provided)
Cedric replied to Cedric's topic in Workflow Help & Questions
This is great, thanks a lot! This is an example I will be able to tweak in the future for similar needs, which is awesome. What I wanted to do was: Be able to find an English function name, with the subtitle showing the description From there, be able to display the French translation of the function, and copy it in the clipboard Additionnaly I would have been able to open the English description webpage of the function using a modifier like ALT+ENTER What I tried to do was: Display the list of functions in Alfred (with their description as subtitle), so I could filter them Display the French translation using a modifier, like CMD Copy the translation using CMD+ENTER This is why I added these to my xml <subtitle mod="cmd">Translation in user selected language</subtitle> <text type="copy">Translation copied in clipboard</text> But it clearly didn't work. What I wish I could do, ideally, would be To be able to set the second language with which I want the worfklow to work (e.g. with a XLANG [language] command) Then be able to search for an English function, with the subtitle showing the description (e.g. with an XL command) From there, be able to show the translation of the function in the user-defined language (via XLANG) and copy it in the clipboard Additionally, the workflow would At step 2, allow me to open a webpage with the English description of the function using a modifier like ALT+ENTERI took into consideration the fact that a 2-step process is hard to do currenly. I saw several worflows (Lastpass, Date Calculator, TimeZones) which allow a specific command to set user-defined parameters that affect other commands, so maybe it's easier that way? Thanks so much for your help.