Posts

Showing posts from September, 2022

Authzforce condition evaluation of matchAny in multi-valued string

I'm looking for a way to define a condition in a policy rule, so that when we pass a multiple string value in our certificate and try to authenticate authzforce against that rule, assuming the string value in the condition is equal to one of the string values we passed in the certificate, I want the rule to evaluate to 'true'. For example if the attribute value of the condition is "DNS:google.com" and the multiple value string we receive from the certificate are: ["DNS:google.nl" ,"DNS:google.com"], I would expect to get the rule evaluated to 'true' as one of those values are equal to the value of the condition ("DNS:google.com"). I tried to achieve this defining a rule with this condition: <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-is-in"> <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">DNS:google.com</AttributeValue> <AttributeDesignator C...

REGEX expression for finding ship to address of different countries

I am trying to extract the shipping address from a commercial invoice. One commercial invoice has ship to destination as Singapore. The other invoice has ship to destination as Hong Kong How do I write a regex to extract the destination address, which ends either with Singapore or Hong Kong ? I wrote a regex to extract the shipping address from a Commercial Invoice. see below: shipto = re.findall("Shipped To/FRT Forwarder\n[a-zA-Z0-9\s\#\-\,]*SINGAPORE", text). My problem is the shipping address could be SINGAPORE or HONG KONG or another location. How can I make the regex more generic? for example: my shipping address could be XXXX Singapore or YYYY Hong Kong How do I implement a "either OR" logic in REGEX in the address extraction ?

Why do I get MIME type error on Django/React app when loading css/js from Aws?

So I deployed a Django-Rest/React app on Heroku where I serve my static and media files on AWS S3 buckets. After pushing to Heroku and accessing the API URL or admin URL everything works fine but when I try to access my React URLs I get a MIME type error. On the network tab of developer tools, I get status 301 on my JS and CSS file. And in the console I get: Refused to apply style from 'https://app.herokuapp.com/static/css/main.9d3ee958.css/' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. app.herokuapp.com/:1 Refused to apply style from 'https://app.herokuapp.com/static/css/main.9d3ee958.css/' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. app.herokuapp.com/:1 Refused to execute script from 'https://app.herokuapp.com/static/js/main.3b833115.js/' because its MIME type ('text/html') is not executable,...

my application deploys on netlify when i build it locally but it doesnt work when i deploy it from github

Okay so i recently finished my portfolio and i wanted to host it on netlify through github but it failed. Their docs and build log are so confusing that i do not know how to trouble shoot the problem. However, when i ran npm run build locally on my system and then i dragged it onto netlify, it worked . I'm not saying i cant just keep doing this for all my websites but i would like to know any potential reason as to why it didn't work when i tried it from github. For context, the current node version is 16 and the one i am using on my system is version 14 . I'm not sure whether that is enough to affect the build from github but i just thought i would mention it. if However, that is a reason as to why it isn't deploying from github then how do i fix it?

How to release Java ReentrantLock after sometime no matter what

My objective is to avoid thread deadlock or starvation. I have the following sample code for using ReentranLocks: class X { private final ReentrantLock lock = new ReentrantLock(); // ... public void m1() { lock.lock(); // block until condition holds try { // ... method body // ... start doing the calculations here ... } finally { //Do not release the lock here, instead, release it in m2() } } public void m2() { try { // ... method body // ... continue doing the calculations here } finally { lock.unlock() } } } I know I can use tryLock() with a timeout, but I am thinking also to ensure it will be unlocked no matter what as the lock will start in m1() and will be unlocked in m2() . How to ensure it will be unlocked say after 3 seconds no matter what, as soon as I start the lock in m1() ? For the above to be successful, ie. without sending unlock request after 3 seconds, the caller o...

Fetching multiple values serial wise, if data is repeated

Image
i need help in understanding on which lookup function can i use, that fetches values from another sheet in serial order. In the attached image you would see that a product has multiple order id's. I want the lookup to fetch values in serial number(ignoring the value fetched earlier) when product name is entered twice in the lookup sheet. Is there a vba function or a formula for such search. I am a novice and help will be appriciated. Original Sheet Lookup sheet

DryIoc: register decorator with two interfaces, retrieve the decorator instance when resolving the other interface

Here is a somewhat simplified description of the problem I'm trying to solve: I have a service (e.g. a repository) implementing an interface that I need to inject as a dependency: public class Service : IService { ... } I'd like to add a decorator, for example one that add caching that also implements another interface: public class CachingService: IService, IFlushable { public CachingService(IService decoratee) { ... } public void Flush() { ... } } public interface IFlushable { public void Flush(); } Normally, I'd just register the CachingService as an implementation of IService as as decorator, using Setup.Decorator or Setup.DecoratorWith . But in this case I have an extra requirement related to the IFlushable interface. There will be several different services with their own decorators, all of them implementing the both the decorated service interface and IFlushable. I need to inject all the IFlushable decorators as a dependency to be able to flush all the c...

restoring the exception environment

Can anyone explain the concept of restoring the exception environment simply and smoothly. It is said that when we use the exception handler in the try...endtry statement،When the program reaches the endtry, it restores the exception environment, but if it suddenly encounters a break command, for example, this recovery does not take place. And the program even after exiting the try.......endtry command thinks that it is in the previous exception environment, and if another error occurs, it returns to the previous try......endtry command. Like the following code snippet: program testBadInput3; #include( "stdlib.hhf" ) static input: int32; begin testBadInput3; // This forever loop repeats //until the user enters // a good integer and the break //statement below // exits the loop. forever try stdout.put( "Enter an integer value: " ); stdin.get( input ); stdout.put( "The first input value was: ", input, nl ); break; exception( ex.ValueOutOfRange ...

How to add up more data in an existing plotly graph?

Image
I have successfully plotted the below data using plotly from an Excel file. Here is my code: file_loc1 = "AgeGroupData_time_to_treatment.xlsx" df_centroid_CoordNew = pd.read_excel(file_loc1, index_col=None, na_values=['NA'], usecols="C:D,AB") df_centroid_CoordNew.head() df_centroid_Coord['Ambulance_Treatment_Time'] = df_centroid_Coord ['Base_TT'] fig = px.scatter(df_centroid_Coord, x="x", y="y", title="Southern Region Centroids", color='Ambulance_Treatment_Time', hover_name="KnNamn", hover_data= ['Ambulance_Treatment_Time', "TotPop"], log_x=True, size_max=60, color_continuous_scale='Reds', range_color=(0.5,2), width=1250, height=1000) fig.update_traces(marker={'size': 8, 'symbol': 1}) #fig.update_traces(marker={'symbol': 1}) fig.update...

How do you maintain on Python the value of the last row in a column, like on excel?

I have looked around and haven't found an 'elegant' solution. It can't be that it is not doable. What I need is to have a column ('col A') on a dataframe that it is always 0, if the adjacent ('col B') column hits 1, then change the value to 1, and all further rows should be 1 (no matter what else happens on 'col B'), until another column ('col C') hits 1, then 'col A' returns to 0, until this repeats. The data has thousands of rows, and it gets updated regularly. any ideas? I have tried shift, iloc and loops, but can't make it work. the result should look something like this: [sample data][1] date col A col B col C ... 0 0 0 ... 0 0 0 ... 1 1 0 ... 1 1 0 ... 1 0 1 ... 0 0 0 ... 0 0 0 ... 1 1 0 ... 1 1 0 ... 1 0 0 ... 1 0 0 ... 1 1 0 ... 1 0 0 ... 1 1 0 ... 1 0 1 ... 0 0 ...

Cannot Browse to specific Type in Settings designer for WPF/.net Core application

Image
When I've used Settings Designer before, I've been able to browse to find non-standard Types (e.g. uncommon enums etc) to use in my Settings via a "Browse" button at the bottom of the drop down under the "Type" column. I'm developing a WPF desktop application for .net Core and there is no Browse option as pictured below: I did go into the code behind ( Settings.Designer.cs. ) and edit the code manually, but on saving, this just reverted to string. I'm guessing this may have something to do with settings also having an element in App.config and I notice it has a "serialiseAs" tag - didn't know what to put here. Exmaple of the code behind settings and App.config: [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.DefaultSettingValueAttribute("")] public string UiTheme { get { return ((string)(this["UiTheme"...

type guards for optional parameters

I have the following fixture file that i have type guarded below. it has few optional properties fixture file- { "profiles": [ { "name": "Laakea", "phoneNumber": "2033719225", "authGroupName": "Drivers" }, { "name": "Lkhagvasuren", "phoneNumber": "2033719225", "authGroupName": "Drivers" }, { "name": "Joaquin", "phoneNumber": "2033719225" } ] } type interface- export interface Profile { name: string; authGroupName?: string; phoneNumber?: string; email?: string; } type guard function- export function isValidProfiles(profiles: unknown): profiles is Profile[] { if (!Array.isArray(profiles)) { return false; } for (let index = 0; index ...

Little Endian in Instruction

I'm learning about RISC-V instructions in Computer Architecture. What i wonder is, because of little endian, any number in RISC-V's instruction's little digit is on little bit. I know that RISC-V use little endian to express data in memory. but I'm not sure it is same to express number in instructions. for example, add instruction has that form, [funct7][rs2][rs1][funct3][rd][opcode], MSB is in funct7, LSB is in opcode. and rs1, rs2, rd is some number with 5bits. if [rd] is 0b00001, position of 1 is LSB in rd's 5 bits. this point is my question. is reason that 1's position is LSB, RISC-V use little endian? if that is right, is (0b00001's) position of 1, MSB in big endian?

Regex matching mixed string segments containing operator, string designator, and curly-brace group

I am looking for a C# regex solution to match/capture some small but complex chunks of data. I have thousands of unstructured chunks of data in my database (comes from a third-party data store) that look similar to this: not BATTCOMPAR{275} and FORKCARRIA{ForkSpreader} and SIDESHIFT{WithSSPassAttachCenterLine} and TILTANGLE{4up_2down} and not AUTOMATSS{true} and not FORKLASGUI{true} and not FORKCAMSYS{true} and OKED{true} I want to be able to split that up into discrete pieces (regex match/capture) like the following: not BATTCOMPAR{275} and FORKCARRIA{ForkSpreader} and SIDESHIFT{WithSSPassAttachCenterLine} and TILTANGLE{4up_2down} and not AUTOMATSS{true} and not FORKLASGUI{true} and not FORKCAMSYS{true} and OKED{true} The data will always conform to the following rules: At the end of each chunk of data there will be a string enclosed by curly braces, like this: {275} The "curly brace grouping" will always come at the end of a string beginning with not or and ...

Use at inference a multi-task learning model shared in Huggingface hub

I train with success a multi-task bert model. My Bert model works by having a shared BERT-style encoder transformer, and two different task heads for each task. The two heads are a binary classification head (num_label =2) and a sentiment classification head (num_label = 5) I try to share it on the hub and reload it after for inference. But i failed. Here is the code : class SequenceClassificationHead(nn.Module): def __init__(self, hidden_size, num_labels, dropout_p=0.1): super().__init__() self.num_labels = num_labels self.dropout = nn.Dropout(dropout_p) self.classifier = nn.Linear(hidden_size, num_labels) self._init_weights() def _init_weights(self): self.classifier.weight.data.normal_(mean=0.0, std=0.02) if self.classifier.bias is not None: self.classifier.bias.data.zero_() def forward(self, sequence_output, pooled_output, labels=None, **kwargs): pooled_output = self.dropout(pooled_output)...

Maple: Dividing polynomials

I am trying to simplify or approximate the following so that it's not in fraction form: [1]: https://i.stack.imgur.com/HH3wR.png I've tried simplify, factor, expand... they all stay in fraction form. I found this: https://www.maplesoft.com/support/help/Maple/view.aspx?path=PolynomialTools/Approximate/Divide&cid=185 which I thought would be perfect but it's not working. Basically, I have 253704*q^(7/2)-475136*q^4+825264*q^(9/2)-1284096*q^5+1938336*q^(11/2)-2973696*q ^6+4437312*q^(13/2)-6107136*q^7+8118024*q^(15/2)-11354112*q^8+15653352*q^(17/2) -19802112*q^9+24832944*q^(19/2) as the numerator and 836*q^9+594*q^8-648*q^7-418*q^6+540*q^5-99*q^4-88*q^3+54*q^2-12*q+1 as the denominator. I am trying to get an answer in polynomial form - but instead I get (1/q^(1/2)+264*q^(1/2)-2048*q+7944*q^(3/2)-24576*q^2+64416*q^(5/2)-135168*q^3+ 253704*q^(7/2)-475136*q^4+825264*q^(9/2)-1284096*q^5+1938336*q^(11/2)-2973696*q ^6+4437312*q^(13/2)-6107136*q^7+8118024*q^(15/2)-11354112*...

Is there a way to skip a step in Specflow with NUnit?

I have a test case where I included a step that applies to all markets I run this against but one. I would like to skip this step in this scenario. This is what I am currently doing, but I am wondering if there is a built in function. I have searched and I am not having much luck, thanks. [Then(@"Verify Yearly AutoOrder was created from enrollment")] public void ThenVerifyYearlyAutoOrderWasCreatedFromEnrollment() { if (!Market.Equals("in")) { this.srEnrollPage.VerifyYearlyAutoOrderWasCreatedFromEnrollment(this.dataCarriers.orderNumber, this.dataCarriers.userEmail); } else { return; // India does not have yearly autoOrders as of now. } }

bad_function_call thrown and segmentation fault caused when passing avx variables to std::function

This problem is found when writing some code related to computer graphics, a simplified version of the code is shown below: #include <bits/stdc++.h> #define __AVX__ 1 #define __AVX2__ 1 #pragma GCC target("avx,avx2,popcnt,tune=native") #include <immintrin.h> namespace with_avx { class vec { public: vec(double x = 0, double y = 0, double z = 0, double t = 0) { vec_data = _mm256_set_pd(t, z, y, x); } __m256d vec_data; }; } // namespace with_avx namespace without_avx { class vec { public: vec(double x = 0, double y = 0, double z = 0, double t = 0) { vec_data[0] = x, vec_data[1] = y, vec_data[2] = z, vec_data[3] = t; } double vec_data[4]; }; } // namespace without_avx #ifdef USE_AVX using namespace with_avx; #else using namespace without_avx; #endif vec same(vec x) { return x; } std::function<vec(vec)> stdfunc = same; int main() { vec rand_vec(rand(), rand(), rand()); vec ret = stdfunc(rand_vec); ...

Plotly: how to change the position of the display

Image
I'm very new to Dash. Just trying to move around. from dash import Dash,html,dcc,Input, Output import plotly.express as px import plotly.graph_objects as go import dash_daq as daq app.layout = html.Div([ html.H1('Billboard'), dcc.Interval(id='input_place'), html.Div([daq.LEDDisplay( label="Distance", labelPosition='top', value=55.99 )],style={'width': '25%', 'display': 'inline-block', 'padding': '0 0'}) ]) if __name__ == '__main__': app.run_server(debug=False) Output of this is above I just want to move to the center ? how to do that. thank you in advance!!!

Windows Auto Complete Icon List

Image
Hi does anyone knows where is the list of Icons for Windows Auto-Complete? Notice when you are typing in notepad, browser or anywhere in Windows OS. There is some icons to select when you are typing a text. I would like to know if where can we find this list. for example i type bear, i can select a bear icon from the auto-complete. or when i type pizza, there is a pizza icon that i can select. anyway, just like to see the list of icons available for the auto-complete feature. Thank you in advance btw this icons can also be used in git commit and will show in pull request in bitbucket

Terraform & GCP : Error 403 when attempting to introduce impersonation on project-level

I am quite lost when it comes to applying principles that enable service account impersonation ... My terraform project structure has a root module per environment, base for basic infrastructure, dev for the dev environment and prod for the production environment. terraform-infra-genesis ┣ base ┃ ┣ ... ┃ ┣ impersonators_x_users.tf <- user email me@domain.com is granted iam.serviceAccounts.getAccessToken role on 'super-admin' here (On all the organization) ┃ ┣ ... ┃ ┣ providers_x_access_tokens.tf ┃ ┣ service_accounts_x_roles.tf <- 'dev-admin' service account declared here ┃ ┣ terraform.tfstate ┃ ┗ terraform.tfstate.backup ┣ dev <- Everything here belongs to the dev environment ┃ ┣ backend.tf ┃ ┣ data_products.tf <- Usage of the module 'marketing-hub' here ┃ ┣ ... ┃ ┣ impersonators_x_providers_x_access_tokens.tf <- Declaration of as_dev_admin provider to 'delegate' ressource creation (such as folders) to the dev envir...

SQL Update table from one database from other table from another database

I am trying to perform an update from a table in one database from another table in another database. One table has a number of lat/lon and I want to update the other one with those based on the matching address. I have tried this: UPDATE WENS_IMPORT.dbo.new_import SET WENS_IMPORT.dbo.new_import.lat = WENS.dbo.SUBSCRIPTION.lat, WENS_IMPORT.dbo.new_import.lon = WENS.dbo.SUBSCRIPTION.lon FROM WENS.dbo.SUBSCRIPTION AS Table_A INNER JOIN WENS_IMPORT.dbo.new_import AS Table_B ON Table_A.streetAddress = Table_B.Address WHERE Table_A.account_id = '388' AND Table_A.active = '1' I thought this was the best route but I keep getting this error returned: ERROR: The multi-part identifier "WENS.dbo.SUBSCRIPTION.lat" could not be bound. Error Code: 4104 Is this because it is seeing a number of records that match the address? Any help would be greatly appreciated! Thanks so much!

Open Refine: Exporting nested XML with templating

I have a question regarding the templating option for XML in Open Refine. Is it possible to export data from two columns in a nested XML-structure, if both columns contain multiple values, that need to be split first? Here's an example to illustrate better what I mean. My columns look like this: Column1 Column2 https://d-nb.info/gnd/119119110;https://d-nb.info/gnd/118529889 Grützner, Eduard von;Elisabeth II., Großbritannien, Königin Each value separated by semicolon in Column1 has a corresponding value in Column2 in the right order and my desired output would look like this: <edm:Agent rdf:about="https://d-nb.info/gnd/119119110"> <skos:prefLabel xml:lang="zxx">Grützner, Eduard von</skos:prefLabel> </edm:Agent> <edm:Agent rdf:about="https://d-nb.info/gnd/118529889"> <skos:prefLabel xml:lang="zxx">Elisabeth II., Großbritannien, Königin</skos:prefLabel> </edm:Agent> I managed to...

Hi, can someone tell me how to replace texts in a pdf file without creating a new pdf file? Or can I overwrite a text file like other editors do? [closed]

I was working with iText7 in Java, and want to know how this can be done today in 2022. Did not find much ways for the same.If not this, can someone explain how vs code or other editors overwrite existing files ie the save option and not the save as option.

Drop certain rows based on quantity of rows with specific values

I am newer data science and am working on a project to analyze sports statistics. I have a dataset of hockey statistics for a group of players over multiple seasons. Players have anywhere between 1 row to 12 rows representing their season statistics over however many seasons they've played. Example: Player Season Pos GP G A P +/- PIM P/GP ... PPG PPP SHG SHP OTG GWG S S% TOI/GP FOW% 0 Nathan MacKinnon 2022 1 65 32 56 88 22 42 1.35 ... 7 27 0 0 1 5 299 10.7 21.07 45.4 1 Nathan MacKinnon 2021 1 48 20 45 65 22 37 1.35 ... 8 25 0 0 0 2 206 9.7 20.37 48.5 2 Nathan MacKinnon 2020 1 69 35 58 93 13 12 1.35 ... 12 31 0 0 2 4 318 11.0 21.22 43.1 3 Nathan MacKinnon 2019 1 82 41 58 99 20 34 1.21 ... 12 37 0 0 1 6 365 11.2 22.08 43.7 4 Nathan MacKinnon 2018 1 74 39 58 97 11 55 1.31 ... 12 32 0 1 3 12 284 13.7 ...

Convert a 3D spectrogram to object file format (.OFF)

Most deformed 3d shapes ever so far without one single correct. ; i.e., this should look like a 3d graph While the html is fine.. I tried most definitely close to everything except the answer.. I'm surprised I didn't come across the answer after so many attempts. 3d arrays in space, much spectrogram graph. Is it disconnected from go.graph obj/y/n-therefore grayscale?3, or, should we "go." in the face/vert structure? I'm happy with the shape/yet.. I'm not sure if I triangulated the stacked faces of f. Let alone np.columnstack the np.ones to get the len and tuple(map(int of the face. Totally confused. BTW can you convert from html? I will use the format mutual frequently so might come in handy. Code: import numpy as np import warnings warnings.filterwarnings('ignore') import os from scipy import signal from scipy.io import wavfile import matplotlib.pyplot as plt import librosa.display import plotly.graph_objs as go filename=[] for filename in os.li...

memory leak in view struct

I'm at my wit's end here. For some reason the following code causes a memory leak and I can't figure out why. If I comment out the contents of the onEditingChanged callback in TableElement there is no leak, if I remove the data binding altogether there is no leak, and if I remove the viewModel and instead just declare mapData as a state in ContentView there is no leak, but that isn't a viable solution for my actual code. Does anyone know what's causing this memory leak? Thanks in advance Here's my model: class EditFuelLevelViewModel: ObservableObject { @Published var mapData: [[Float]] = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]] } And here's my view: struct ContentView: View { private struct TableElement: View { @Binding var data: Float @State private var text: String init(data: Binding<Float>) { self._data = data self.text = String(data.wrappedValu...

rspec: test array of instances

I'm trying to create rspec tests to test an array of instances. Specifically, I want to verify certain attributes of each instance within the array. Is there a way to use rspec to test this scenario? For example, suppose I have the following array that I want to verify: [#<Car id:1, buy_date: "2022-10-10", model: "Ford">, #<Car id:2, buy_date: "2021-01-10", model: "Ferrari">, #<Car id:3, buy_date: "2022-03-12", model: "Toyota">] As my test, I want to check that the buy_date is correct. I tried the following expect statement but I don't think it's meant for arrays of instances so the tests failed when I expected them to pass. expect(cars).to include([ have_attributes( buy_date: "2022-10-10" ), have_attributes( buy_date: "2021-01-10" ), ...

Execution failed for task ':app:mapDebugSourceSetPaths

Execution failed for task ':app:mapDebugSourceSetPaths'. Error while evaluating property 'extraGeneratedResDir' of task ':app:mapDebugSourceSetPaths' Failed to calculate the value of task ':app:mapDebugSourceSetPaths' property 'extraGeneratedResDir'. > Querying the mapped value of provider(interface java.util.Set) before task ':app:processDebugGoogleServices' has completed is not supported Try: Run with --info or --debug option to get more log output. Run with --scan to get full insights. Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:mapDebugSourceSetPaths'. at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:38) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77) at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExe...