Automating syncing of image names across a website?

Hi, really new to this so please bear with me.

I have a website with about 1000 images which over the years have been badly named.

  1. Is there software, plugins, methods etc to somehow automatically update all instances of an images file name in the html across multiple pages when the file name is changed in the root folder?
  2. Also is there a way to automate the process if the images folder structure is changed?

Automating removal of legacy entries in /etc/group

I’m removing entries in /etc/group programmatically.

Because I cannot use grep, cat, or cut for this exercise, I wrote my own program that can produce stdout and stdout data to essentially read a file. If you can write your solution in grep, awk, sed, cat, echo, etc. I can use it.

I have root access and can remove groups manually, but since n groups will contain a ‘+’ character, I need a script that checks for this.

After first I assumed I could append any line including ‘+’ with a #, but I’m now feeling confident that this isn’t how you programmatically manage /etc/groups. I haven’t found great documentation yet and was wondering if someone here might have a better idea on how to disable groups deemed ‘legacy’ via the use of ‘+’ character.

Automating the solution of pairs of polynomial inequalities as a bound

Let’s consider the following pair of quadratic inequalities:

$ $ x^2+x \geq a$ $


$ $ x^2-x < a$ $

The solution of the first inequality is $ $ x \geq \frac{-1+ \sqrt{1+4a}}{2}$ $ or $ $ x \geq \frac{-1- \sqrt{1+4a}}{2}$ $ .

Now, the first one is always going to be larger than the second one, as $ $ \sqrt{1+4a}>0$ $ . So, $ $ x \geq \frac{-1+ \sqrt{1+4a}}{2}$ $ is the “true” lower bound. Therefore, we will consider the solution as:

$ $ x \geq \frac{-1+ \sqrt{1+4a}}{2}$ $ ——> (1)

For the second inequality, the solution is $ $ x < \frac{1+ \sqrt{1+4a}}{2}$ $ or $ $ x < \frac{1- \sqrt{1+4a}}{2}$ $ .

Again, since $ $ \sqrt{1+4a}>0$ $ , the second solution is always going to be smaller than the first solution. So, $ $ x < \frac{1- \sqrt{1+4a}}{2}$ $ is the “true” upper bound.

However, because $ $ \frac{1- \sqrt{1+4a}}{2}$ $ is negative of the solution of the first inequality from (1), we encounter some issues. For example, if the solution in (1) is negative (<0), then its fine. For example, if, say, (1) evaluates to $ $ x \geq -5$ $ , then our solution to the second inequality implies $ $ x<5$ $ , which is fine. But, if the solution in (1) is positive (>0), then the pair of solutions taken together doesn’t make sense. For example, if (1) evaluates to $ $ x \geq 5$ $ , then our solution to the second inequality implies $ $ x<-5$ $ , which is nonsensical.

Therefore, we need to reject this solution for the second inequality and accept the other solution as the true solution:

$ $ x < \frac{1+ \sqrt{1+4a}}{2}$ $ ——> (2)

Thus, from (1) and (2), we can say that the solution of these 2 inequalities given as a bound is:

$ $ x \in [\frac{-1+ \sqrt{1+4a}}{2}, \frac{1+ \sqrt{1+4a}}{2})$ $

As demonstrated, the process of rejecting 2 of the possible solutions can be a bit involved. Also, the process can be different for other sets of inequalities, where the same lines of thinking might not disqualify 2 of the candidate solutions.

I want to be able to automate this process for any pair of inequalities. I have written the following code to solve a set of quadratic polynomial inequalities and return the solution as a bounded set:

from sympy import simplify, degree import math  def extract_terms(LHS, operator, var):     expression = simplify(LHS)     variable  = simplify(var)     poly_degree  = degree(expression, gen=variable)      term_coeffs = []     for x in range(poly_degree,-1,-1):         if x>0:             term = simplify(str(variable)+"**"+str(x))             term_coeffs.append(expression.coeff(term))             expression = simplify(str(expression)+"-"+str(simplify("("+str(term)+")*("+str(expression.coeff(term))+")")))         else:             const_value =  expression             term_coeffs.append(const_value)     return term_coeffs  def solve_quad_inequality(LHS, operator, var):     c, d, e = extract_terms(LHS, operator, var)     try:         s1 = -(d/(2.0*c))+math.sqrt(-(e/c)+(d/(2.0*c))**2)         s2 = -(d/(2.0*c))-math.sqrt(-(e/c)+(d/(2.0*c))**2)         return s1, s2     except:         print('The given inequality does not have a real solution.')         return 0  def give_soln_bounds(LHS_1, operator_1, var, LHS_2, operator_2):     s1a, s2a = solve_quad_inequality(LHS_1, operator_1, var)     print("The candidate solutions for {}{}0 are: {}{}{} or {}{}{}".format(LHS_1, operator_1, var, operator_1, s1a, var, operator_1, s2a))      s1b, s2b = solve_quad_inequality(LHS_2, operator_2, var)     print("The candidate solutions for {}{}0 are: {}{}{} or {}{}{}".format(LHS_2, operator_2, var, operator_2, s1b, var, operator_2, s2b))      a = s1a if s1a>=s2a else s2a     if s1b<s2b:         if s1b>a:             b = s1b         else:             b = s2b     else:         if s2b>a:             b=s2b         else:             b=s1b      print('The bounded solution for the given pair of inequalities is: x ∈ ['+str(a)+', '+str(b)+')')  give_soln_bounds("x**2-5*x+6", ">=", "x", "x**2-5*x+4", "<") 

This gives the following output:

The candidate solutions for x**2-5*x+6>=0 are: x>=3.00000000000000 or x>=2.00000000000000 The candidate solutions for x**2-5*x+4<0 are: x<4.00000000000000 or x<1.00000000000000 The bounded solution for the given pair of inequalities is: x ∈ [3.00000000000000, 4.00000000000000) 

Another example test:

give_soln_bounds("x**2+x-1", ">=", "x", "x**2-x-1", "<") >>>  The candidate solutions for x**2+x-1>=0 are: x>=0.618033988749895 or x>=-1.61803398874989 The candidate solutions for x**2-x-1<0 are: x<1.61803398874989 or x<-0.618033988749895 The bounded solution for the given pair of inequalities is: x ∈ [0.618033988749895, 1.61803398874989) 

It seems to work fine for the examples I have thrown at it so far, but is there any way to know if its truly correct? Any counterexample would be great too!

Also, it can’t handle equations where I give symbolic inputs. For example, $ $ x^2-x-k<0$ $ , where the solution is expected in terms of k. Is there any way to do that?

Another issue is, if I want to this for cubic inequalities, I can foresee a problem with comparing all the 9 possibilities arising from the 3 candidate solutions for each inequality. Is there any way to cut down on the number of comparisons to be made to search for the valid solutions?

And finally, if you see any possible improvement in the code (be it style-wise or performance-wise), please do let me know.

Automating nodetool repair for cassandra on kubernetes

We are running cassandra on kubernetes using the yaml below. It’s working fine except for nodetool. We would like to have a kubernetes cronjob that executes nodetool repair periodically but accessing the jmx port (7199) from outside of the cassandra pods is not working. I’m fairly sure the problem is that the jmx port is listening on and I need it to listen on the pod ip or even better would be the node ip.

Has anyone setup something similar?

Inside the pod

root@cassandra-0:/# nc -vz localhost 9042 localhost [] 9042 (?) open root@cassandra-0:/# nc -vz localhost 7199 localhost [] 7199 (?) open 

Outside the pod

$   nc -vz localhost 9042 nc: connect to localhost port 9042 (tcp) failed: Connection refused Connection to localhost 9042 port [tcp/*] succeeded! $   nc -vz localhost 7199 nc: connect to localhost port 7199 (tcp) failed: Connection refused nc: connect to localhost port 7199 (tcp) failed: Connection refused 

Outside the pod using the pod ip

$   nc -vz 7199 nc: connect to port 7199 (tcp) failed: Connection refused $   nc -vz 9042 Connection to 9042 port [tcp/*] succeeded! 

apiVersion: v1 kind: Service metadata:   labels:     app: cassandra   name: cassandra spec:   clusterIP: None   ports:   - port: 9042   selector:     app: cassandra --- apiVersion: apps/v1beta1 kind: StatefulSet metadata:   name: cassandra   labels:     app: cassandra spec:   serviceName: cassandra   replicas: {{ }}   selector:     matchLabels:       app: cassandra   template:     metadata:       labels:         app: cassandra     spec:       terminationGracePeriodSeconds: 1800       containers:       - name: cassandra         image: cassandra:3.11.3         imagePullPolicy: Always         ports:         - containerPort: 7000           name: intra-node         - containerPort: 7001           name: tls-intra-node         - containerPort: 7199           name: jmx           hostPort: 7199         - containerPort: 9042           hostPort: 9042           name: cql         resources:           limits:             cpu: "500m"             memory: 1Gi           requests:             cpu: "500m"             memory: 1Gi         securityContext:           capabilities:             add:               - IPC_LOCK         lifecycle:           preStop:             exec:               command:                - /bin/sh               - -c               - nodetool drain         env:           - name: MAX_HEAP_SIZE             value: 512M           - name: HEAP_NEWSIZE             value: 100M           - name: CASSANDRA_SEEDS             value: "cassandra-0.cassandra.default.svc.cluster.local"           - name: CASSANDRA_CLUSTER_NAME             value: "K8Demo"           - name: CASSANDRA_DC             value: "DC1-K8Demo"           - name: CASSANDRA_RACK             value: "Rack1-K8Demo"           - name: POD_IP             valueFrom:               fieldRef:                 fieldPath: status.podIP         volumeMounts:         - name: cassandra-data           mountPath: /var/lib/cassandra/data       volumes:       - name: cassandra-data         hostPath:           path: /data/cassandra 

Automating using spreadsheet for calculations [on hold]

Okay so, I have spreadsheet: Which i would like to use for calculations. This spreadsheet is used for calculating Damage per second on an online rpg. In spreadsheet you can change “gear” or items which your charecter has.

I would like to do calculations quickly for example 20 characters with different items on changing only one specific for all of them. I was thinking i could just make object called character with strings for gear and just use openpyxl to modify string values on spreadsheet but that brought out errors because openpyxl doesn’t do calculations and for some reason even though values (attributes like strength and Attackpower) changed like i wanted all formulas went for DIV/0! error.

Do i need to implement all formulas in some programming language for myself or is there somekind of way to use existing spreadsheet with calculations for my advantage?

I would like to use C/C++, java or python for this project.

Automating Site Usage Reporting: Top queries by month, abandoned queries etc

My question is almost identical to one raised 5 years ago:

Pragmatically download export search usage reports

Again, being able to access, download and schedule the distribution of reports with the dynamic links located on a site page: 

The key requirement as @Petter has stated is to allow business users to access the reports without needing to bother SharePoint or Site collection admins.

automating to push changes to github for multiple repos using python

This Python script does following activities:

  • clone repo, as provided from the list

  • creating a new branch “jenkinsMigrate”

  • rename Jenkinsfile to Jenkinsfile.migrate

  • push code to GitHub in a new branch.

NOTE: credentials were configured already.

    import git     import os     import subprocess      gitUrl = "https://*****"     cwd = "*****"      with open("migrateList.txt", "r") as file:         for line in file:             #configure gitUri for each repository             gitUri = gitUrl + line.strip() + ".git"             try:                 global repo                 repo = git.Repo.clone_from(gitUri, cwd + line.strip())             except:                 print(" directory already available")             os.chdir(cwd + line.strip())              #checkout new branch for migration             repo.git.checkout('-b', "jenkinsMigrate")    ["git", "mv", "Jenkinsfile", "Jenkinsfile.migrate"])             repo.git.add(update=True)             repo.index.commit("jenkins migration")             origin = repo.remote(name='origin')              #push new branch to github   ["git","push", "--set-upstream", "origin", "jenkinsMigrate"])   ["cd", ".."]) 

Sample text file:

$   cat migrateList.txt  repo1 repo2 repo3 repo4 

This is a working code, but all I am looking for is to maintain consistency in the commands that I use. eg: For some of the git commands that I have used are from gitpython module where as others are invoked with shell commands. Apart from these any other suggestions are welcome.


Help automating Wi-Fi Calling or Airplane mode toggle with Tasker

I am absolutely 100% new to Tasker. I have bought and install this app to automate a few things which IFTTT simply can’t.

Here is the situation :

My bedroom is in a basement apartment and so I do not get good cell service reception at all while I’m down there, and since it doubles as my office space (on days I work from home) and my gaming area, I tend to spend a decent amount of my time in my room. This being said, I have an LG V30 ThinQ with android 8.x Oreo and my current service provider offers a Wi-Fi Calling service. Naturally, I turned it on and bingo… Calls are now crisp and text messages send without a hitch! Well… that’s at home at least. You see, at my work the opposite is true : The Wi-Fi is shit, but the cell service reception is always super strong. Yes, my phone does have a setting to use Wi-Fi calling as a second priority to my cell service (meaning that it will use my cell service before using the Wi-Fi Calling) but instead of switching intelligently based on the strength of the cell service reception strength, it only switches to Wi-Fi Calling once I stop having cell service reception period! Which doesn’t work well in the basement, since sometime I get just enough signal to toggle it back to the shitty cell service for calling!

So, I would like to create a task with Tasker that, once connected to/disconnected from my home network, would allow either the Wi-Fi Calling to be toggled ; or for the airplane mode to be toggled. That way, as long as I’m connected to my home network, my phone will be using the Wi-Fi calling capabilities, without having to toggle them on and off again manually.

Problem is, since I’m new to this, I don’t know the first thing about programming a task in this version of Tasker. All tutorials I came across were very little helpful.

Could somebody work me though setting up something along those lines?


Nikolas Desforges