Jump to content

Bhishan

Member
  • Content count

    44
  • Joined

  • Last visited

About Bhishan

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. @deanishe Thanks for the suggestion, it worked now.
  2. **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.
  3. 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.
  4. @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
  5. @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
  6. @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.
  7. @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!
  8. @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!
  9. 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.
  10. @deanishe Thanks for clarification and apologies for wording.
  11. Can we create an Alfred workflow so that it will send an email if the battery is less than 15 %?
  12. 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 ?
  13. 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!
  14. Is it possible to write an Alfred workflow to turn off wifi after the certain time?
  15. @vitor Solved today, idk what was the problem, but the good news is it works fine now in any text fields.
×