python – use regex to separate a list of serial numbers into multiple lists with matched prefix

The question comes from How to separate a list of serial numbers into multiple lists with matched prefix? on Stack Overflow.

Input:

sn = ('bike-001', 'bike-002', 'car/001', 'bus/for/001', 'car/002', 'bus/for/002')

Intended output:

# string with same prefix will be in the same list, e.g.:

sn1 = ('bike-001', 'bike-002')
sn2 = ('car/001', 'car/002')
sn3 = ('bus/for/001', 'bus/for/002') 

The original thread already had a brilliant answer using .startswith(<sub_str>), however I still want to use regex to solve the question.

Here’s what I’ve tried: I use re.sub() to get the prefix and re.search() to get the 3-digits serial number. I’d like to know if there is a better way (like using one-time regex function) to get the solution.

import re

sn = ('bike-001', 'bike-002', 'car/001', 'bus/for/001', 'car/002', 'bus/for/002')
sn_dict = {}
for item in sn:
    category = re.sub(r'd{3}', "", item)
    number = re.search(r'd{3}', item).group()
    if category not in sn_dict.keys():
        sn_dict(category) = ()
    sn_dict(category).append(category + number)

After running the script we will have the following sn_dict:

{
    'bike-': ('bike-001', 'bike-002'), 
    'car/': ('car/001', 'car/002'), 
    'bus/for/': ('bus/for/001', 'bus/for/002')
}

Can I use a separate hosting company for a subdomain?

I own a .me domain (bought with GoDaddy), where I have my web hosted using Github pages. Now, I would like to create a sub-domain or sub-page (such that subdomain.example.me or example.me/subdomain) and fill it with an external template that I want to buy using a web-provided such as Squarespace. Is is possible to do that?

Pull data from separate Google sheet into a Google forms response sheet and update dynamically

Stack Exchange Network


Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Are there any privacy benefits in using a separate wallet in Bitcoin Core to “separate” myself from my service?

I currently run Bitcoin Core with the following wallets loaded in:

  1. hot.dat. Contains the smallest possible sum of Bitcoin. Unencrypted and used by myself for various personal Bitcoin purchases, and I intend to have it double as the wallet for my Bitcoin-based website. (Unless you tell me a good reason not to.)
  2. lukewarm.dat. Contains more than the “hot” wallet, but still not much compared to cold.dat. Encrypted with a long passphrase, but which is located on the same computer in a text document. I recon that it will stop at least automated malware which simply checks for wallet.dats and merely “sends them home”. It of course won’t stop somebody from manually finding the text document on my machine and figuring out that it’s the passphrase to use.
  3. cold.dat. Contains the vast majority of my satoshis. Encrypted with a long passphrase (partially stored on the same computer) with a bunch of additional parts with “hints” to myself rather than explicitly spelled out. This passphrase has never been entered to unlock the wallet outside of the dedicated Linux computer where it was created. (Not this machine.)

I’m aware that many would not consider my cold.dat to be a “cold wallet”, but I thought the naming scheme fit well enough. The reason I don’t use a truly “cold” wallet (where it’s not stored on a “live” computer even encrypted) has to do with me fearing losing the file or having a fire or getting it seized more than I fear somebody first hacking into my machine and then somehow figuring out my complicated passphrase scheme. I consider that so unlikely that it is far more likely that I would lose access to it in other ways.

Now I wonder if I should be having a separate “service.dat” wallet dedicated to my new service, or if I can just generate new receive addresses for my existing hot.dat and use those. Is there any privacy benefit in me doing that? Or would I just be wasting yet another transaction fee to send over some satoshis from my hot.dat to my potential “service.dat”?

What if somebody who I do private business with knows who I am (because I have to give them my home address) and when I’ve paid them using hot.dat, those “inputs”/”outputs” are reused for my service, and suddenly they can associate me, the individual, with my service? And would that change at all if I used a separate “service.dat” wallet for the service? Won’t it be the same “track” either way?

PS: No, it’s not something illegal or immoral. I’m simply trying to avoid any association between myself and the service, plus I’m also curious about this on an academic level.

architecture – What is the benefit of having separate web servers and application servers?

Most of the web applications that I have seen developed in my organisation , have the following components :

JS App (from browser) -> Web server -> Service(s)/Application server(s) -> Database

Each of these components typically does the following:

JS App – The interface (UI) for users to interact with the application from their browsers, typically a single page app.
Web server – Listens to HTTP requests and constructs the response by calling various services (application servers).
Application server – Fetches data by calling a database, and other services and processes the data based on some business logic and returns a response.
Database – Stores data.

Let’s say my organization runs a hotel booking website, and is planning to provide a new functionality of travel packages, think of a package as consisting of multiple bookings at multiple hotels, travel (trains, flights etc) bookings, etc., this new ‘Packages’ application would be made up of the following components :

PackagesFrontEnd – JS App
PackagesWebApp – Web server
PackagesService – Application server/service
PackagesDB – Database

The PackagesWebApp would communicate with the PackagesService, and various services that handle bookings for hotels, travel etc., to serve its requests. The PackagesService is pretty much a wrapper on top of the PackagesDB, containing some business logic.

My question is, why do the web and application servers need to be separate here ? in my example, what is the problem with having PackagesWebApp and PackagesService as a single thing ? I have tried asking co workers, and searching online, but could not find a convincing answer for this, heard and read the following reasons:

Separation of concerns: Separating presentation logic and business logic (Why can’t this be done at a module level ? with interfaces in between the classes for the layers ? Also, a side effect of this is that people duplicate some business logic like validation for example, in both the components to ‘fail fast’ but this sometimes comes back to bite when a change was done in one but missed in the other)

Availability: If one component has a bug and it misbehaves, it might bring down both the components (The web app wouldn’t be useable anyways if either of the servers is down, even when they are separated, so what is the additional benefit here ? And, even if there is a benefit to this, then, by extension the same thing might happen, where, a bug in the code for feature ‘X’ thats unrelated to features ‘Y’ and ‘Z’ brings down all of them, so why not separate them also ? where do you draw a line for this ?)

On the other hand, there are definitely some overheads that come with having multiple components, like maintaining codebases, integrating components, maintaining infrastructure resources, debugging/finding root cause for issues is more complicated. In such a situation, doesn’t separation only make sense if it solves some problem thats worth taking on these additional things ?

Can someone please help me in understanding the reason why this is needed ?

plotting – How can I make 3 separate tables of parameters instead of only one table like this?

In the code below, how can I make 3 separate parameter tables for tup1, tup2, tup3 and plot each function fi of corresponding tupi?
Like:

  • f1 with tup1
  • f2 with tup2
  • f3 with tup3

Currently there is one one tup table.

f1(a_, b_, c_) := (a x^2 + b x + c)/3;
f2(a_, b_, c_) := (a x^2 + b x + c)^2;
f3(a_, b_, c_) := 3 (a x^2 + b x + c);
tup1 := RandomInteger(5, {6, 3});
tup2 := RandomInteger(5, {8, 3});
tup3 := RandomInteger(5, {10, 3});
tup = Join(tup1, tup2, tup3);
functions1 = f1 @@@ tup1;
functions2 = f2 @@@ tup2;
functions3 = f3 @@@ tup3;
functions = Join(functions1, functions2, functions3);
colors = ColorData(97) /@ Range(Length@functions);
functionswithtooltips = MapThread(Tooltip, {functions, tup});
plot1 = Plot(Evaluate(functionswithtooltips), {x, 0, 5}, 
   GridLines -> Automatic, ImageSize -> Large, 
   PlotStyle -> Thread(Directive(colors, Opacity(.3), Thin)));
ttlist = Cases(plot1, _Tooltip, All);
t = Deploy@
  DynamicModule({n = {1}, hidden = ConstantArray(1, Length@ttlist)}, 
   hidden((n)) = 2;
   Dynamic(
    Legended(
     Graphics(
      Table(With({i = i, ind = hidden((i))}, 
        Tooltip({ttlist((i, 1, 1)), 
          
          DynamicModule({boxes = {ttlist((i, 1, 2)), 
              Style(ttlist((i, 1, 2)), Opacity(1), Thickness(Large))},
             index = ind, length = 2}, 
           EventHandler(
            Dynamic(
             boxes((index))), {"MouseClicked" :> (index = 
                index /. {1 -> 2, 2 -> 1};
               hidden((i)) = index; 
               n = Flatten(Position(hidden, 2));), 
             Method -> "Preemptive", PassEventsDown -> True, 
             PassEventsUp -> True}), DynamicModuleValues :> {})}, 
         ttlist((i, 2)))), {i, 1, Length@ttlist}), ImageSize -> 700, 
      AspectRatio -> 1/GoldenRatio, PlotRange -> {{0, 5}, {0, 50}}, 
      Frame -> True, GridLines -> Automatic), 
     TogglerBar(
      Dynamic(n, (n = #; hidden((All)) = 1; hidden((n)) = 2) &), 
      MapIndexed(#2((1)) -> 
         Style(#, 16, Bold, Opacity(1), colors((#2((1))))) &, tup), 
      Appearance -> "Vertical" -> {Automatic, 4}))))

load balancing – How does DNS work across two separate networks using NAT?

Apologies for sounding naive in advance, I am a newbie in servers/networking and have a generic question around Load Balancers, DNS and NATting.

We have an app deployed on our private data center. The DNS/endpoint points to our load balancer (HAProxy). We have a new client who want to access our endpoint but it is not possible to establish direct connectivity from their hosts to our endpoint (as they are outside our network). So, we thought of implementing NATting. Now the client has established some sort of NATting where they connect to the NAT host and it routes traffic to our load balancer.

However, this is not enough as traffic is served over https on our load balancer and the dns has to resolve along with the certificates (SSL). Their network does not have direct access to our network and thus their hosts do not understand what our endpoint is.

So, how do we make this to work? How can we make our DNS accessible to them securely so that the requests flow from their network into NAT servers and then onto our load balancer?

VPS cPanel & Management combo at NameCheap vs Platinum Server Management & cPanel with separate VPS

I guess a VPS is like having a rare sportscar. Great performance but lots of maintenance needed compared to managed shared hosting. Anyway, … | Read the rest of https://www.webhostingtalk.com/showthread.php?t=1837284&goto=newpost

Split rows into separate coiumns in Google Sheets

I have data in one column as follows:

website.com/US/x=abc
website.com/US/x=pqr
website.com/BO/x=avgdf
website.com/BO/x=jeid
website.com/RO/x=klhg
website.com/RO/x=dfg
website.com/CA/x=rfd
website.com/CA/x=jde
website.com/AU/x=ggr
website.com/AU/x=gff

I need this separated into different columns separating as follows:

website.com/US/x=abc   website.com/BO/x=avgdf   website.com/RO/x=klhg   website.com/CA/x=rfd
website.com/US/x=pqr   website.com/BO/x=jeid   website.com/RO/x=dfg   website.com/CA/x=jde

Please help!

Does Google Consider a Subdomain as a Separate Domain?

If you think about it, the answer is quite simple. EVERY subdomain is considered a SEPARATE domain.

For example EVERYONE on tripod.com has his OWN subdomain. Mine is “mmerlinn.tripod.com” but yours could be “vitaliykolos.tripod.com” and so on. If Google did not treat them as separate domains all of your statistics would be the same as mine and vice versa. Since tripod.com has THOUSANDS of subdomains, ONE for each user, if Google considered them all the same domain, any statistics, links, and so on that Google collected would be WORTHLESS.

Further, even “www.mmerlinn.com” is a subdomain of “mmerlinn.com” and Google treats them both as separate domains unless they are specifically linked together via the control panel on the server. I have mine linked so that no matter which is used, the same page is served up and all Google statistics, links, etc. are common to both.

And, yes, I resurrected an OLD thread simply because NOBODY really answered the question. Now, if anyone is searching for an answer in the future, he can get a clear answer with examples.