Jump to content

Bhishan

Member
  • Posts

    146
  • Joined

  • Last visited

Everything posted by Bhishan

  1. It would be nice for Alfred to custom keybindings like : `ctrl-k ctrl-a` instead of only `ctrl-k`. That is two set of commands should be supported.
  2. Your link is broken. Probably you may want to share it on github or just share the code in this thread.
  3. @deanishe Thanks for the suggestion, it worked now.
  4. **Question** How to plot column0 vs column2 of a data file using Alfred and Python? Shared Workflow =============== https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/python_plots/aa python plots.alfredworkflow?raw=true Sample datafile: https://raw.githubusercontent.com/bhishanpdl/Shared/master/Alfred_questions/python_plots/data.txt The given workflow reads the column0 vs column1 of the given data file and plots it. Is it possible to make plot column0 vs column2 using arguments? Required Method: ============= 1. selet the given file in Finder 2. double tap shift (open alfred3) 3. plot 0 2 # This should plot column0 vs column2 The python script used: ================= import sys import numpy as np import matplotlib.pyplot as plt ifile = sys.argv[1] x,y = np.genfromtxt(ifile,delimiter='',usecols=(0,1),\ comments='#',unpack=True,dtype=None).astype(np.float64) plt.plot(x,y,'ro') plt.xlabel('x') plt.ylabel('y') plt.xlim(min(x)*0.9, max(x)*1.1) plt.ylim(min(y)*0.9, max(y)*1.1) plt.show() Problem: ======== I could not figure out how to pass the arguments to the python workflow when we select the file from the Finder. Help will be appreciated.
  5. Oh my goodness! I only looked at the source code (Run Script ) not at the "Copy to Clipboard" part! It was really silly, sorry for that. The good thing is it worked now and I will tackle similar problems easily in the future. You made my day, thanks.
  6. @deanishe Nearly perfect, It is a very simple issue, I can always delete backticks easily, but just to complete the question, it also pastes backticks. This time I used: I also tried this, but did not work: ans = extract_code_from_repl(query.strip("`")) # try1 ans = extract_code_from_repl(query.strip(r"`")) # try2 ans = extract_code_from_repl(query.strip("\`")) # try3
  7. @deanishe It also pastes only two backticks. Tested: https://docs.python.org/2/library/collections.html Here is my workflow: https://github.com/bhishanpdl/Shared/blob/master/Alfred_questions/text_manipulation/z Text Manipulation_new_python.alfredworkflow?raw=true
  8. @vitor, Sorry This time it only prints only two backticks: ``. I am unfamiliar with perl and ruby and learning regex in python. I could not fix the problem in ruby and again seek for the help. As long as the workflow works, It is immaterial which language I use: whether perl, ruby, or the mighty python. P.S. I appreciate your effort and help and apologize for asking XY-problem since I thought If it was in python I would have figure out myself after learning one simple example.
  9. @deanishe Dr. deanishe, Today I learned little bit "sed" thanks to admin "vitor" and trying to fix my problem. In the mean time, I saw a comment with python, where I feel more comfortable working in. Yes I was trying to copy the python REPL documentation and pasting it without ">>>" sign probably created using "reST" and "Sphinx". I am familiar with python and extremely unfamiliar with "perl" and "ruby". If only I get one example in python for this problem next similar problems I would solve easily using python and regex module. Thanks for the concern, and I would again appreciate if this problem can be solved using also python in Alfred? (Without using Alfred I can definitely do this.) I hope it is possible in Alfred!
  10. @vitor Thanks, it worked, but partially. The workflow I tested: I also tried to put ` inside the bracket [`>.\s] but it did not work. Many many python tutorials are given in the following format: For example:, https://docs.python.org/2/library/collections.html Original text to copy: >>> # Tally occurrences of words in a list >>> cnt = Counter() >>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']: ... cnt[word] += 1 >>> cnt Counter({'blue': 3, 'red': 2, 'green': 1}) >>> # Find the ten most common words in Hamlet >>> import re >>> words = re.findall(r'\w+', open('hamlet.txt').read().lower()) >>> Counter(words).most_common(10) [('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631), ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)] The output I got is: `$>>> # Tally occurrences of words in a list cnt = Counter() for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']: cnt[word] += 1 cnt Counter({'blue': 3, 'red': 2, 'green': 1}) # Find the ten most common words in Hamlet import re words = re.findall(r'\w+', open('hamlet.txt').read().lower()) Counter(words).most_common(10) [('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631), ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)] ` I would like to remove backticks and copy the line only if it stars with ">>>". Preferred output: # Tally occurrences of words in a list cnt = Counter() for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']: cnt[word] += 1 cnt # Find the ten most common words in Hamlet import re words = re.findall(r'\w+', open('hamlet.txt').read().lower()) Counter(words).most_common(10) **Changes** 1. Initial <<<oneSpace is removed. 2. Initial 3dotsOnespace is removed. 3. If the line does not start with <<< it will not be copied. 4. For some reason there is a hidden backtick ` it should not be copied. This would be highly helpful. In python documentation, many tutorials are in above format and copying them with without unwanted angles will be much helpful. I hope I would get further help. Thanks a lot!
  11. Basically, I wanted to remove the initial string ">>> " from all the lines of selected text. The current workflow does not strip the string ">>> " and paste the original string. I have shared the workflow in github . How the problem can be fixed.
  12. @deanishe Thanks for clarification and apologies for wording.
  13. Can we create an Alfred workflow so that it will send an email if the battery is less than 15 %?
  14. I liked the workflow, but, sadly it did not work in my machine. Info: Macos 10.13.4 (mac os high sierra) date: May 21, 2018 Usage: selected some text, go to alfred and type editwith Then type Notes.app Then nothing happens, it DOES NOT open notes.app with the selected text. similarly, it does not work with any app. Has anybody used this workflow on High Sierra ?
  15. I have created top 20 most anticipated Hollywood movies of 2018. Scroll down to see the movies other than first 9 movies. We can see how many days until the movies. Also, we can click the SHIFT button to see the QuickView of Wikipedia. The workflow is shared on github. We can add and edit the workflow easily. Enjoy the movies and enjoy the workflow!
  16. Is it possible to write an Alfred workflow to turn off wifi after the certain time?
  17. @vitor Solved today, idk what was the problem, but the good news is it works fine now in any text fields.
  18. There is an excellent tutorial about Alfred Script Filter creation explained in this link. Its so easy to create args in that workflow, but how can we use the arguments passed into the script filter in other actions in the same workflow? In the shared workflow, how can we use the variable "Alfred" ? The workflow is shared in github.
  19. The top parts, works but it gives me two outputs of the same thing. Example: 1. text selected: This is practice 2. select the text with mouse 3.hit the keyboard combination, it gives: `This is practice``This is practice` 4. it should give: `This is practice`
  20. Thanks, it works now. I was using var_show previously, forgot to remove var_.
  21. The last bash script in the workflow has following code: query=$1 if [ $query = "hide" ]; then defaults write com.apple.Dock autohide -bool TRUE; killall Dock fi if [ $query = "show" ]; then defaults write com.apple.Dock autohide -bool FALSE; killall Dock fi Can we refactor this code so that it would look nicer, and still works on Alfred? My attempt was this, but it did not work: [[ "${1}" == 'var_show' ]] && defaults write com.apple.Dock autohide -bool FALSE; killall Dock [[ "${1}" == 'var_hide' ]] && defaults write com.apple.Dock autohide -bool TRUE; killall Dock
  22. Is there a simple way of replacing the text in any text editor like this: original text: print('hello') markdown code formatted replace text: `print('hello')` keyboard shortcut: ctrl-opt-c My attempted workflow is shared on github.
  23. @vitor Thanks a lot. It works now. But, can we change the bash script like this: # Wanted version [[ "${1}" == 'var_show' ]] && defaults write com.apple.Dock autohide -bool FALSE; killall Dock [[ "${1}" == 'var_hide' ]] && defaults write com.apple.Dock autohide -bool TRUE; killall Dock # Ugly but working version: query=$1 if [ $query = "hide" ]; then defaults write com.apple.Dock autohide -bool TRUE; killall Dock fi if [ $query = "show" ]; then defaults write com.apple.Dock autohide -bool FALSE; killall Dock fi
  24. @vitor I deleted the redundant python script, but this still does not work. The List Filter is giving problem, If I delete LIST FILTER the script works, but I want to keep it. Is there any way I keep the list filter and when we click on "Hide" on list filter, it will hide the dock ? The updated link is shared here.
×
×
  • Create New...