design – how to architect a cli based program to: 1, grep through files, 2 show report of grep’d instance, 3 open file from that report in vim?

I’ve got a couple handy little scripts that I use with VimWiki (my digital diary/journal system is deeply envied by non-geek active journal’ers) …and I want to integrate these separate functions into a sleek workflow.

One of the features of the VimWiki is to be able to insert :tags: throughout the wiki pages (including diary pages).

The object here is to integrate a couple tag-related scripts:

  • Script 1 gives prints to the console (piped to less, actually) an alphabetized list of all the tags in my diary.
  • Script 2 gives me a report of one specific tag: each time the tag is mentioned in a diary page the report will include the date of that daily entry, the tag, and the notes/text that follow the tag.

The desired functionality is to be able to invoke script1 and scroll through the list, and then hit on a selected tag to be able to invoke script2 while providing the selected tag as an argument for script2.

Script1 is very simple, it generates a list of all the :tags: used throughout my daily diary entries:

grep -rh -e '^:S*:$' ~/Documents/wiki/diary/*.mkd  |
while read -r line
do
  for word in ${line//:/ }
  do
    printf "${word}n"
  done
done | sort -u | less

The grep produces content like:

:tech:
:therapy:babylon:
:trauma:
:triggered:
:truama:leadership:business:toxicity:
:unfurling:
:tagOne:tagTwo:etcTag:

and then in the while & for loops we render that as a simple list

babylon
business
etcTag
leadership
tagOne
tagTwo
tech
therapy
toxicity
trauma
triggered
truama
unfurling

But less doesn’t have the ability to “select” a line(the line contains the name of a tag), let alone the ability to magically supply the highlighted text as an argument to the next script.

The next script is still pretty simple, it shows me all the contents related to a given tag:

#!/usr/bin/python3
import things
tagname = ':' + sys.argv(1) + ':'
directory = '/home/alec/Documents/wiki/diary/'
for filename in sorted(os.listdir(directory)):
  if filename.startswith("20") and filename.endswith(".mkd"): 
    with open(directory + filename) as file:
      # find all the contents related to the "tagname" argument supplied to the script
      # this is truncated because that specific code isn't particularly relevant
      if len(tagcontent) != 0:
        print(date + ' ' + tagline.rstrip())
        print(tagcontent)

This script will show me content from my diary pages related to the tag, so diarytags.py culture will give some content like:

# Tuesday 03 November 2020 :culture:business:leadership:toxicity:
stuff that I wrote that day related to the toxic culture that sometimes exists among leadership of organizations and businesses
# Thursday 26 November 2020 :politics:culture:empathy:love:
something I wrote that day about the lack of or need for more empathy and love in the culture of our politics and governance

…and so forth, pretty slick as far as journals/diaries go 🙂

So how to use the first script sort of like a gui/browser (solely inside the terminal of course) for supplying an argument to the second script? And, optimally, which may(?) be significantly harder(?), to be able to navigate back to the results of the first script to select a different tag and view its report.

The final step would be to then open a journal entry from the report which, something like Tuesday 03 November 2020 would open the file in vim: vi ~/Documents/wiki/diary/2020-11-03.mkd.

How would you go about designing a program like this?


edit:

About the simplest architecture that could work in a hack-like fashion would be using vim as the pager (probably supplying a special vimrc file for it) and vimscript functions so that <Enter> keybinding could use the keyword as an argument for script2. <Backspace> could be used to delete the current buffer and thus arrive back at the list of tags (produced by script1). And from the report (script2) a another vimscript function could be used to load the diary page for the section beneath the mouse cursor.

That might be good enough for my purposes.

I’m interested in other simple solutions. I’m interested in learning what options exist for designing a program that moves beyond the simple scripts as I’ve described here.

least squares – Quadratic Programming: Can a linear constraint convert a convex, quadratic program to a non-convex one?

I consider a quadratic program of the form

$$ minimize,||Ax – b||^2_2, x in mathbb{R}^n$$ (least-squares) in cvxpy and add linear constraints of the form $Bx le c$ consecutively.

The problem is solvable without constraints and with the first constraint, but fails after adding the second constraint with the message that the problem is non-convex.

Now I’m trying to imagine and visualise how a convex problem can be converted to a non-convex one by adding a linear constraint. At least for the 2D case I cannot find an example (visually) where this happens, because constraining a convex solution space by linear constraints keeps the solution space convex in my mind.

Could anyone give me a visual counterexample where this happens?

windows – I can’t reinstall the program after I remove it

I have a program called Gaussian 09 for quantum computation. I tried once to remove and reinstall it again but the installation window doesn’t show up. I tried a lot of things but no benefit so I format my pc and install it. now the same problem happens again and I don’t want to format my computer. is there any other way?

the issue details: when I run the setup.exe file it asks me for permission and then doesn’t do anything but it is shown in task manager enter image description here

enter image description here

Earn Lucrative Lifetime Commissions with Affiliate Program for 23 Year Old Digital Marketing Agency

About Us
SEMrush

Azam Marketing™ is a full-service digital marketing and design agency which unleashes the potential of the internet to grow our clients’ businesses. Our focus is one thing and one thing only: results.

Founded in 1997 as one of the world’s first digital agencies, we have unparalleled experience and know-how in search, social media, performance and email marketing. We also specialise in public relations, domain name acquisition and management, website design and development, online business consulting, and corporate training. Find out more about our suite of award-winning services here.

Affiliate Program

DigitalPoint friends, do you know of any individuals or businesses that might benefit from marketing or design services? If so, we would encourage you to take advantage of Azam Marketing’s generous affiliate program!
(​IMG)

Our Affiliate Program pays you for bringing new advertisers to our award-winning agency and allows you to expand the services you offer to clients.

We have referrers/affiliates who are earning hundreds or thousands of Dollars/Euros/Pounds every month for referring clients to us three and four years ago.

You can generate a lucrative recurring revenue stream for yourself with minimal effort.

Why does Azam Marketing have a client referral program?

It’s an acknowledged fact that businesses grow much faster through referrals and word of mouth recommendations than through advertising alone. We know the online industry flourishes through close-knit networks and many of the most successful partnerships are initiated via one-to-one introductions.

What kind of new clients are you looking for?

Our agency is looking to recruit new clients across all of our divisions in 2021 and beyond, which include affiliate, email, search and social media marketing, public relations, and web design and development. We also offer web hosting, domain name acquisition and management, and business consultancy services.

How will the scheme work?

A referral lead is made by delivering the lead to Azam by any means – social media, email, telephone or in person.

All potential clients will then be contacted by Azam to qualify the lead and fully understand what services the client requires. Our experienced sales team will then submit a comprehensive proposal to the client in order to secure the business.

(​IMG)​

We promise to handle all client referrals in a professional and efficient manner and will communicate with referrers at all times to ensure that you are kept informed. We encourage referrers to contribute as much as possible to warm up and convert leads.

What can I expect to earn?

To qualify for compensation, a referral lead must close within six months of the initial referral, and Azam must not already be engaged with or have knowledge of the opportunity.

Remuneration will be paid on the amount of work required by Azam Marketing up to the point of the client returning a signed contract. Thereafter, commissions of up to 15% of gross earnings will be paid to the referrer on the service(s) recommended to the client.

Commissions will not only be paid every month for the first year, but on a lifetime basis subject to certain terms. Referrers who remain proactively involved in the ongoing management of client partnerships will receive bigger payments.

How to join affiliate program

Further details here.

Thank you for reading this post.

 

Heartbid.net is the best XML RTB affiliate program | Proxies-free

Heartbid is a very old and reliable affiliate program. We work with XML RTB formats.

– more than 30K websites, over 50M daily advertising impressions
– control every bit of your campaign – bids, budgets, schedule and targeting
– choose between CPM/CPC/CPA bidding
– Stable payments
– desktop and mobile traffic
– all countries, operating systems and devices
– traffic quality system filters bots and fraud
– working with direct advertisers
Register now and get a welcome bonus!

concurrency – Does server farm change the design of the server program?

In The Linux Programming Interface Sec 60.4, it talks about design a server that handles multiple requests using multiple processes or threads, or pools of processes or threads. Then it discusses another approach “server farm”:

Other approaches to handling high client loads involve the use of multiple server
systems—a server farm.

One of the simplest approaches to building a server farm (employed by some
web servers) is DNS round-robin load sharing (or load distribution), where the authori-
tative name server for a zone maps the same domain name to several IP addresses
(i.e., several servers share the same domain name). Successive requests to the DNS
server to resolve the domain name return these IP addresses in a different order, in
a round-robin fashion. Further information about DNS round-robin load sharing
can be found in (Albitz & Liu, 2006).

Round-robin DNS has the advantage of being inexpensive and easy to set up.
However, it does present some problems. One of these is the caching performed by
remote DNS servers, which means that future requests from clients on a particular
host (or set of hosts) bypass the round-robin DNS server and are always handled by
the same server. Also, round-robin DNS doesn’t have any built-in mechanisms for
ensuring good load balancing (different clients may place different loads on a
server) or ensuring high availability (what if one of the servers dies or the server
application that it is running crashes?). Another issue that we may need to consider—
one that is faced by many designs that employ multiple server machines—is ensuring
server affinity; that is, ensuring that a sequence of requests from the same client are
all directed to the same server, so that any state information maintained by the
server about the client remains accurate.

A more flexible, but also more complex, solution is server load balancing. In this
scenario, a single load-balancing server routes incoming client requests to one of
the members of the server farm. (To ensure high availability, there may be a
backup server that takes over if the primary load-balancing server crashes.) This
eliminates the problems associated with remote DNS caching, since the server farm
presents a single IP address (that of the load-balancing server) to the outside world.
The load-balancing server incorporates algorithms to measure or estimate server
load (perhaps based on metrics supplied by the members of the server farm) and
intelligently distribute the load across the members of the server farm. The load-bal-
ancing server also automatically detects failures in members of the server farm (and
the addition of new servers, if demand requires it). Finally, a load-balancing server
may also provide support for server affinity. Further information about server load
balancing can be found in (Kopparapu, 2002).

When using a server farm (built on either DNS round-robin load sharing or server load-balancing),

  • is it correct that all machines in the farm run the same server program?

  • is the server program still designed in the same way as a standalone server program: handle multiple requests concurrently (using methods such as multiple processes/threads or pools of processes/threads)?

  • or does server farm change the design of the server program in some way, e.g. only handle just one request?

Thanks.