Automate set color cell based on html color code in other column in Excel Posted: 16 Dec 2021 03:39 AM PST I have a column in excel with color codes like: #98BF64 #D9B300 #FF6347 #118DFF #D9B300 #DEEFFF #FF7F48 #000000 #00334E #B3B0AD And I want each color code to be the fill color of the next column in my spread sheet. I am doing this by hand formatting the fill cell with each custom color code in hex option. I have a loooong list so I wonder, is there a way to automate this? |
why number and string values are not a true condition for Rust Posted: 16 Dec 2021 03:39 AM PST As we know in some languages like javascript we can control our flow of instructions like this: // This could be something like `-2` or `9` const number = calc(); // This may be `undefined` or empty const name = getName(); if(number && name) { // do staff for truly conditions (number is bigger than `0`) } Why in Rust-lang can't we use these conditions(always we should be explicit)? fn main() { let number = calc() let name = getName() if(name && number) {} // Error -> mismatched types } |
Using a CSV file as input for searchbar function Posted: 16 Dec 2021 03:39 AM PST Good day, I am struggling to figure out how to use a CSV file as input for a search bar function. The search bar was initially created to search within a certain list. Now I can scrap that list and that same search bar needs to search within a list of products in a CSV file. I don't know where to even begin. Here is a code I have to use to display the list of products from a CSV file, from here I do not know how to use this displayed list and have it behave like data that can be searched in the search bar created previously. '''<?php class Item { public $itemNumber; public $name; public $type; public $make; public $model; public $brand; public $description; } echo "<html><body><center><table>\n\n"; $file = fopen("input.csv", "r"); while (($data = fgetcsv($file)) !== false) { echo "<tr>"; foreach ($data as $i) { echo "<td>" . htmlspecialchars($i) . "</td>"; } echo "</tr> \n"; } fclose($file); echo "\n</table></center></body></html>"; ?>''' This is the PHP code I was provided for the assignment that I need to use. |
Adding numbers on a string with condition R Posted: 16 Dec 2021 03:39 AM PST I have the following data where e_in is exogenous giving. Ann then is an equal distribution of e_in, however, e_in can only be distributed downwards, i.e. a string (this is why 7 and 8 has ann=9 while 1 to 6 have ann=8.5) e_in<-c(13,10,4,9,14,1,11,7) ann<-c(8.5,8.5,8.5,8.5,8.5,8.5,9,9) Dat_1<-data.frame(e_in,ann) >Dat_1 e_in ann 1 13 8.5 2 10 8.5 3 4 8.5 4 9 8.5 5 14 8.5 6 1 8.5 7 11 9.0 8 7 9.0 I would now like to calculate how much e_in is available at each point down the string (shown as smn). So for 1 there is 13 e_in avabile, where 1 will take 8.5. Number 2 will then have own e_in + whatever is send downwards form 1 (here 10 + (13-8.5) = 14.5) and so on. As the following: smn<-c(13,14.5,10,10.5,16,8.5,11,9) Dat_2<-data.frame(e_in,ann,smn) >Dat_2 e_in ann smn 1 13 8.5 13.0 2 10 8.5 14.5 3 4 8.5 10.0 4 9 8.5 10.5 5 14 8.5 16.0 6 1 8.5 8.5 7 11 9.0 11.0 8 7 9.0 9.0 Is there any easy way/package for this sort of calculation (I have done it 'by hand' for this example but it becomes significantly more time consuming with bigger strings.) |
Limit the length of serialized json strings Posted: 16 Dec 2021 03:39 AM PST When serializing an object as a json string, how to limit the length of the result, the result can be an incomplete json string, I don't want to serialize the whole object first and then go to truncate it with a subString |
Cypress: Should I perform tests on components which uses api data Posted: 16 Dec 2021 03:38 AM PST I am used to writing tests with react-testing-library and I can always pass mock data to components in order to test them. Let's say that I am rendering components with graphql data should my tests include those components as well? (e.g Blog post coming from graphql etc.) |
Why does this exception about deleting shared_ptr happen? Posted: 16 Dec 2021 03:38 AM PST I'm trying to write a simple text query program in C++. In this program I exploit shared_ptr to make class QueryResult to visit class TextQuery member. At the end of the function void runQueries(ifstream &infile), it jump into the function virtual void _M_dispose() noexcept { delete _M_ptr;} in the head file shared_ptr_base.h and throw out an exception as follow. Exception has occurred. Unknown signal. Here is the function runQueries void runQueries(ifstream &infile){ TextQuery tq(infile); shared_ptr<TextQuery> sp(&tq); QueryResult qe(sp); while(true){ cout << "enter word to look for, or q to quit:"; string s; if(!(cin>>s)||s=="q") break; qe.print(cout,tq.query(s)) <<endl; } cout <<sp.use_count()<<endl; } While in the class QueryResult , it has member variable shared_ptr sp which is initialized at constructor. I conjecture that the cause of the exception might be releasing problem of smart pointers. Could anyone tell me the actual reason? Thanks in advance. |
Click make Argument mutex Posted: 16 Dec 2021 03:38 AM PST I'm writing a CLI using the beautiful click library the use case i want to implement is something like this: cmd <arg> <option --list> arg: required --list: optional rationale But... the --list show only the available arg so my purpose is to make all arguments optional in this use case. I'm started from this request on the official repo, and a previous similar question very similar but it works only on Options. I've not found an elegant solution because Arguments works differently, In my real case I have a lot of arguments and options, so is not possible to reduce all Arguments into Options. |
Problem converting epoch to datetime - python Posted: 16 Dec 2021 03:38 AM PST I have a pandas data frame showing timestamp in epoch. I need to convert it to datetime format. The code looks like this: import pandas as pd import numpy as np import datetime import time data_all = pd.ExcelFile('testData_02.xls') data = pd.read_excel(data_all, 'TestData') GPSTime = data.loc[:,'GpsUtcTime'].astype(int) # In epochs #GPSTime = pd.to_numeric(GPSTime,errors='coerce') print(type(GPSTime)) datetime_time = datetime.datetime.fromtimestamp(GPSTime).strftime('%c') Time_str = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(GPSTime)) The data type comes out as pandas.core.series.Series. I've tried converting it to int using .astype(int) and pd.to_numeric, but neither seems to work. The code returns the following error: In [8]: %run NKS_combmorc <class 'pandas.core.series.Series'> --------------------------------------------------------------------------- TypeError Traceback (most recent call last) ~\Documents\Data\NKS_combmorc\NKS_combmorc.py in <module> 35 #datetime_time = datetime.datetime.fromtimestamp(GPSTime).strftime('%c') 36 #datetime_time = dates.num2date(GPSTime, tz='UTC') ---> 37 Time_str = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(GPSTime)) 38 39 ~\Anaconda3\envs\py3\lib\site-packages\pandas\core\series.py in wrapper(self) 139 if len(self) == 1: 140 return converter(self.iloc[0]) --> 141 raise TypeError(f"cannot convert the series to {converter}") 142 143 wrapper.__name__ = f"__{converter.__name__}__" TypeError: cannot convert the series to <class 'int'> [error message][1] [1]: https://i.stack.imgur.com/z6DsF.png I've been staring myself blind at this for hours. I'm sure I'm missing something simple. Can anyone see what I´m doing wrong? Thanks! |
Encrypt a file with password by powershell [closed] Posted: 16 Dec 2021 03:39 AM PST I am trying to encrypt and decrypt a complete file with a password but not able to get the solution. $script = Get-Content $path | Out-String $secure = ConvertTo-SecureString $script -asPlainText -force $export = $secure | ConvertFrom-SecureString Set-Content $destination $export "Script '$path' has been encrypted as '$destination'" |
Call PHP code on <input type='submit'> press with <form method="post"> Posted: 16 Dec 2021 03:39 AM PST Title. When i run the code, it runs echo "Twoje BMI wynosi: ". $bmi . "Jest to: ". $stopien; on page load, instead of when i press the submit button, how to fix it so it runs when i submit? <html> <body> <form method="post"> <b>Waga:</b><br> <input type="text" name="waga"></input><br><br> <b>Wzrost:</b><br> <input type="text" name="wzrost"></input><br> <input type="submit" name="submit" value="Submit"></button><br><br></form> <?php $waga=$_POST['waga']; $wzrost=$_POST['wzrost']; $bmi= $waga/$wzrost*$wzrost; if (isset( $_POST['submit'])) { if (isset($_POST['waga']) && isset($_POST['wzrost'])) { if ( is_numeric($_POST['wzrost']) && is_numeric($_POST['waga'])) { if ($bmi>40){ echo '<img src="kotek.png">'; } echo "Twoje BMI wynosi: ". $bmi ; ?> </body> </html> |
How to concatenate number of rows to one in pandas DataFrame Posted: 16 Dec 2021 03:38 AM PST How to concatenate ,for example ,every 3 rows to one with pandas as the input is csv file ? df = (pd.read_csv('sample.csv')) from ''' 10 ,11 ,12 13 ,14 ,15 16, 17 ,18 19 ,20, 21 22 ,23, 24 25 ,26, 27 ... ''' to ''' 10 ,11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 19 ,20 ,21 ,22 ,23 ,24 ,25 ,26 ,27 ... ''' Thanks in advance |
Dynamic method name in PHP8 Posted: 16 Dec 2021 03:38 AM PST In a loop I want a trait to populate the member variables. Problem: My IDE tells me: Array and String Offset access syntax with curly braces is no longer supported. My code use CustomTrait; private function mapUserData($mapping, $userData){ foreach($mapping as $owerKey => $theirKey) { $this->set{$owerKey} = $userData[$theirKey]; } } |
I have problem getting info from all $Users to mail only get info from 1 machine Posted: 16 Dec 2021 03:39 AM PST My problem is I get the list in console showing all machines "Name" , LastLogonDate Description.. But when I run full script only 1 machines info is sent by mail.. What am I missing? Sorry im kinda new to PS. ##Contains my list of computers that I need data from $Users = 'PCName1', 'PCName2', 'PCName3' ##Gets AdComputer info $Computers = Get-ADComputer -Filter * -Properties LastLogOnDate, Description $Users | foreach { $User = $_ $selectedMachine = $Computers | where Name -eq $User if ($selectedMachine) { $selectedMachine | select Name, LastLogOnDate, Description } # if it does not exist... } [string[]]$recipients = mymail@asds.com $fromEmail = from@email.com $server = "IP" [string]$emailBody = "$Computer" + "Mail Rapport sendt fra task scheduler $computer $time " send-mailmessage -from $fromEmail -to $recipients -subject "Machines INFO " -body $emailBody -priority High -smtpServer $server |
Partial itertools.product in python Posted: 16 Dec 2021 03:39 AM PST I would like to create the following list of tuples in Python, based on a list of possible values [0, 1, 2, 3] : (0, 0, 0), # all set to first value: 0 (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 1, 0), (0, 2, 0), (0, 3, 0), (1, 0, 0), (2, 0, 0), (3, 0, 0), (3, 3, 3), # all set to last value: 3 To summarize: - first value (
0 ) for all elements of the tuples - each value of the list of values (
[0, 1, 2, 3] ) for a given element of the tuple and other elements set to 0 - last value (
3 ) for all elements of the tuples What would be an efficient way to do it? ... maybe there is a magic function to do it? I was first thinking of using itertools.product and then filtering: list(product([0, 1, 2, 3], repeat=3)) ... or maybe by using pandas (which looks a bit overkill though). Thanks |
What does function with a go routine not return values? Posted: 16 Dec 2021 03:38 AM PST I am trying to load mail attachments from an email server using emersion/go-imap. When loading the emails with by search criteria, the function does not return the messages or the go routine does not finish. When I enable the debug messages with 's.mailClient.SetDebug(os.Stdout)', I see that the sequence IDs are all loaded correctly. In my service I have two functions: - FetchMailsByAddresses: Does the login/logout at the server, selects the inbox and loads the mails since the last search for a mail addresses.
func (s *ServiceLogic) FetchMailsByAddresses(inbox string, lastSearch time.Time, addresses []string) error { // Login and logout defer s.mailClient.Logout() if err := s.mailClient.Login(s.userName, s.pass); err != nil { return wrpErrLogin(err) } // Select INBOX mbox, err := s.mailClient.Select(inbox, false) if err != nil { return wrpErrSelectInbox(err) } if mbox.Messages == 0 { return nil } // Loop threw addresses for _, address := range addresses { fromSearch := "FROM " + address criteria := imap.NewSearchCriteria() criteria.Since = lastSearch criteria.WithFlags = []string{fromSearch} // Get the whole message body section := &imap.BodySectionName{} mails, err := s.FetchMailsByCriteria(criteria, section) if err != nil { return wrpErrFetchEmailID(err) } for msg := range mails { err := s.StoreMessageAttachments(msg, section) if err != nil { return wrpErrStoreMessageAttachment(err) } } } return nil } - FetchMailsByCriteria: Should return all messages that match my search criteria.
func (s *ServiceLogic) FetchMailsByCriteria(criteria *imap.SearchCriteria, section *imap.BodySectionName) (chan *imap.Message, error) { identifiers, err := s.mailClient.Search(criteria) if err != nil { return nil, wrpErrFetchEmailID(err) } seqSet := new(imap.SeqSet) seqSet.AddNum(identifiers...) items := []imap.FetchItem{section.FetchItem()} messages := make(chan *imap.Message) done := make(chan error, 1) go func() { done <- s.mailClient.Fetch(seqSet, items, messages) }() if err := <-done; err != nil { return nil, wrpErrFetchEmailContent(err) } return messages, nil } |
Why is the method of the Spring controller executing twice? [closed] Posted: 16 Dec 2021 03:38 AM PST Does anyone knows where comes the problem of controller method executing twice instead of once, when I run a SpringBoot with MVC application? It is like it's being executed by two different threads, and I don't know why... I tried to declare it with @Transactional, in order to lock a mutex for threads, it worked at the beginning but still came back to duplicates... |
Measure the time in sikuli Posted: 16 Dec 2021 03:39 AM PST I am trying to automate and measure the performance of an application and some use cases .The application launches the remote server through the VNC and do some user actions on the remote server. We are planning to use sikuli with python for this testing. I am very new to sikuli. How can I measure the time of the user actions in sikuli? For example, Im clicking on a button in the screen of the remote server and another screen launches. How to measure this? |
Standard Deviation Per Group With Condition Posted: 16 Dec 2021 03:39 AM PST I have a dataset that looks as follows: id year value 1 2000 1 1 2002 3 2 1999 10 2 2000 8 2 2001 9 3 2000 12 3 2001 5 3 2003 6 3 2004 7 3 2005 13 3 2006 2 3 2007 1 4 2005 5 4 2006 5 4 2007 5 4 2008 4 4 2009 7 I now want to add a column that indicates the recursively calculated standard deviation per ID, including at least 5 prior years of data (including the respective current year; the fact that years might be missing is ignored), i.e.: id year value SD 1 2000 1 NA 1 2002 3 NA 2 1999 10 NA 2 2000 8 NA 2 2001 9 NA 3 2000 12 NA 3 2001 5 NA 3 2003 6 NA 3 2004 7 NA 3 2005 13 3.26 3 2006 2 3.86 3 2007 1 4.24 4 2005 5 NA 4 2006 5 NA 4 2007 5 NA 4 2008 4 NA 4 2009 7 0.98 The solution to this can rely on the fact that the data is ordered by id and year. However I also appreciate solutions that do not explicity rely on ordering. Any help is appreciated, thanks. |
How to combine these multiple queries in laravel eloquent Posted: 16 Dec 2021 03:39 AM PST I have the following query, where the final result I want is the $rate // get latest effective date $effectiveDate = CpfEffectiveDate::where('effective_from', '<=', $currentDate) ->orderBy("effective_from", 'DESC') ->first(); // get scheme related to the effective date and citizenship type $scheme = CpfScheme::where("cpf_citizenship_id", $request->cpf_citizenship_id) ->where('cpf_effective_date_id', $effectiveDate->id) ->first(); // get rate based on scheme and other data $rate = CpfRate::where("cpf_scheme_id", $scheme->id) ->where("minimum_wage", '<', ceil($totalWage)) // query does not accept floats. should be acceptable as wage tiers should be integers ->where("minimum_age", '<', $request->employee_age) ->orderBy('minimum_wage', 'DESC') ->orderBy('minimum_age', 'DESC') ->first(); How can I combine all 3 queries into a single one? First I get the correct effective date from the first table, after which I use it to find the correct scheme (together with a citizenship_id) which I use to find the correct rate. Here are the following models: CpfRate class CpfRate extends Model { protected $table = "cpf_rates"; protected $primaryKey = "id"; protected $hidden = ["created_at", "updated_at"]; public function scheme() { return $this->belongsTo(CpfScheme::class, "cpf_scheme_id"); } protected $fillable = [ "minimum_age", "minimum_wage", "employer_percentage", "employee_percentage", "employee_offset_amount", // used for special cases, such as -500 for percentage = 0.15 * (TW - 500) "ordinary_wage_cap", // ordinary wage cap ]; } CpfScheme class CpfScheme extends Model { protected $table = "cpf_schemes"; protected $primaryKey = "id"; protected $hidden = ["created_at", "updated_at"]; public function citizenship() { return $this->belongsTo(CpfCitizenship::class, "cpf_citizenship_id"); } public function effectiveDate() { return $this->belongsTo(CpfEffectiveDate::class, "cpf_effective_date_id"); } } CpfEffectiveDate class CpfEffectiveDate extends Model { protected $table = "cpf_effective_dates"; protected $primaryKey = "id"; protected $hidden = ["created_at", "updated_at"]; // mutated to dates protected $dates = ['effective_from']; public function schemes() { return $this->hasMany(CpfScheme::class, "cpf_effective_date_id"); } } CpfCitizenship class CpfCitizenship extends Model { protected $table = "cpf_citizenships"; protected $primaryKey = "id"; protected $hidden = ["created_at", "updated_at"]; // fields protected $fillable = ['description']; public function schemes() { return $this->hasMany(CpfScheme::class, "cpf_citizenship_id"); } } |
How to validate or restrict user from inputting alphabet or numbers Posted: 16 Dec 2021 03:39 AM PST I've been trying to figure the problem in my code for hours is there any way to solve this? If so please help me fix this problem. It runs but the code inside while doesn't work the way it is intended to even though the condition make sense or I just don't know how while works??? Anyways, thank you for the people that will help. That's all the details import java.text.DecimalFormat; import javax.swing.JOptionPane; //imported JoptionPane for a basic UI //Don't mind the comments public class Calculator { public static void main(String[] args) { DecimalFormat format = new DecimalFormat("0.#####"); //Used this class to trim the zeroes in whole numbers and in the numbers with a trailing zero String[] response = {"CANCEL", "Addition", "Subtraction", "Multiplication", "Division", "Modulo"}; //Used array to assign reponses in the response variable(will be used in the showOptionDialog()) //CANCEL is 0, Addition is 1, Subtraction is 2 and so on. Will be used later in switch statement int selectCalculation = JOptionPane.showOptionDialog(null, "SELECT CALCULATION THAT YOU WANT TO PERFORM:", "SELECT CALCULATION", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, response, null); String numberInput1 = JOptionPane.showInputDialog(null, "ENTER THE FIRST NUMBER:"); //Used the class String instead of the data type double because I will be using a String method in while condition while (numberInput1.matches("[a-zA-Z]")) //Used regex here basically saying if numberInput1 does contain letter then start the loop until user inputs number { JOptionPane.showMessageDialog(null, "Make sure to enter numbers ONLY", "INVALID", JOptionPane.WARNING_MESSAGE); //Shows warning message so user will know what the accepted input is numberInput1 = JOptionPane.showInputDialog(null, "ENTER THE FIRST NUMBER:"); } String numberInput2 = JOptionPane.showInputDialog(null, "ENTER THE SECOND NUMBER:"); //Same reason as stated previously while (numberInput2.matches("[a-zA-Z]")) { JOptionPane.showMessageDialog(null, "Make sure to enter numbers ONLY", "INVALID", JOptionPane.WARNING_MESSAGE); numberInput2 = JOptionPane.showInputDialog(null, "ENTER THE SECOND NUMBER:"); } double firstNumber = Double.parseDouble(numberInput1); double secondNumber = Double.parseDouble(numberInput2); //Converts the numberInputs to double so Java will add numbers instead of String later switch (selectCalculation) //Used switches instead of if else because it will be a longer process if I used if else { case 1: double sum = firstNumber + secondNumber; JOptionPane.showMessageDialog(null, format.format(firstNumber) + " and " + format.format(secondNumber) + " is equals to " + format.format(sum), "The sum of:", JOptionPane.INFORMATION_MESSAGE); break; case 2: double difference = firstNumber - secondNumber; JOptionPane.showMessageDialog(null, format.format(firstNumber) + " and " + format.format(secondNumber) + " is equals to " + format.format(difference), "The difference of:", JOptionPane.INFORMATION_MESSAGE); break; case 3: double product = firstNumber * secondNumber; JOptionPane.showMessageDialog(null, format.format(firstNumber) + " and " + format.format(secondNumber) + " is equals to " + format.format(product), "The product of:", JOptionPane.INFORMATION_MESSAGE); break; case 4: double quotient = firstNumber / secondNumber; JOptionPane.showMessageDialog(null, format.format(firstNumber) + " and " + format.format(secondNumber) + " is equals to " + format.format(quotient), "The quotient of:", JOptionPane.INFORMATION_MESSAGE); break; case 5: double remainder = firstNumber % secondNumber; JOptionPane.showMessageDialog(null, format.format(firstNumber) + " and " + format.format(secondNumber) + " is equals to " + format.format(remainder), "The remainder of:", JOptionPane.INFORMATION_MESSAGE); break; default: JOptionPane.showMessageDialog(null, "MADE BY: GABRIEL POTAZO", "CALCULATION CANCELLED",JOptionPane.ERROR_MESSAGE); break; } } } |
vaadin 8 styles.scss not working with setStyleName Posted: 16 Dec 2021 03:39 AM PST I am working on styles.scss. This is working : .v-Notification-notif { background: #FFFFFF; border: 10px solid rgb(245, 121, 0); } but this is not : .v-Notification-notif.warning .v-Notification-caption { color: rgb(0, 0, 0); font-size: 30px; } when I say notif.setStyleName("notif"); notif is a Notification. Thank you for help. I also tried : .notif { .v-Notification { background: #FFFFFF; border: 10px solid rgb(245, 121, 0); } .v-Notification.warning .v-Notification-caption { color: rgb(0, 0, 0); font-size: 30px; } } but it still does not work. |
Issues creating custom column in Power BI Posted: 16 Dec 2021 03:38 AM PST I am currently working with a data set that has similar to the below fields: user | activity | date of activity | Jason | Activity A | 12/1/2022 | Jason | Activity B | 12/1/2022 | Jason | Activity C | 12/1/2022 | Each user will have multiple(different types) of activities on the same day. I am trying create a column that shows if a user has had activity on any given day but I don't want it to count all the activities just show 1 if he has activity on that day regardless of type or number of activities per day. So for Jason I would need it to show count of 1 for 12/01/2022 even though he has had 3 activities that day. |
implementation of ffmpeg complex_filter to ffmpeg-python Posted: 16 Dec 2021 03:39 AM PST I am trying to learn to convert ffmpeg command line of multiple audio merge to ffmpeg-python format. 'ffmpeg -i first.mka -i second.mka -i third.mka -i fourth.mka -filter_complex "[1]adelay=104000|104000[b]; [2]adelay=260000|260000[c]; [3]adelay=362000|362000[d]; [0][b][c][d]amix=4" merged.mka Can anyone help me learn full transformation syntax? Specifically i want to know how to represent filter complex in ffmpeg-python This is what i have tried lk = [60,120] audios = [] for k, i in enumerate(audio_file): audio = ffmpeg.input(i['src'], select_streams='a') if audio['streams'] and i['muted'] == False: a = (audio.filter('adelay', f"{i[lk] * 1000}| {i[lk] * 1000}")) audios.append(a) mix_audios = ffmpeg.filter_(audios, 'amix') if len(audios) > 1 else audios[0] |
AttributeError: 'numpy.ndarray' object has no attribute 'y' [closed] Posted: 16 Dec 2021 03:38 AM PST **i am working on project and i got an error AttributeError: 'numpy.ndarray' object has no attribute 'y' ** import tkinter as tk import control as co import numpy as np import matplotlib.pyplot as plt window= tk.Tk() window.title('project 2') window.geometry('300x200') a0= tk.IntVar(window, value='only numbers') a1= tk.IntVar(window, value='onlt numbers') a2= tk.IntVar(window, value='only numbers') a3= tk.IntVar(window, value='only numbers') def function(): b0=a0.get() b1=a1.get() b2=a2.get() b3=a3.get() sys=co.TransferFunction([b0],[b1,b2,b3]) print(sys) print(sys.pole()) t= np.linspace(0,5,100) _, y= co.step_response(sys,t) plt.plot(t.y) plt.xlabel('time (s)') plt.ylabel('amplitude') plt.titale('step response') plt.show() aa=tk.Label(window, text='num').pack() a= tk.Entry(window, width=30, textvariable= a0).pack() bb=tk.Label(window, text='S^2').pack() b= tk.Entry(window, width=30, textvariable= a1).pack() cc=tk.Label(window, text='S^1').pack() c= tk.Entry(window, width=30, textvariable= a2).pack() dd=tk.Label(window, text='S^0').pack() d= tk.Entry(window, width=30, textvariable= a3).pack() button= tk.Button(window, text='start', command=function).pack() window.mainloop AttributeError: 'numpy.ndarray' object has no attribute 'y'' |
Odoo 14 : psycopg2.OperationalError: FATAL: role "admin" does not exist Posted: 16 Dec 2021 03:39 AM PST my installation of odoo 14 isn't working. its debags like : psycopg2.OperationalError: FATAL: role "admin" does not exist whats my config file: db_host = localhost db_maxconn = 64 db_name = False db_password = paroli321 db_port = 5432 db_sslmode = prefer db_template = template0 db_user = admin |
how to access browser %variables% (enclosed in percent % signs) Posted: 16 Dec 2021 03:38 AM PST In various browsers you can find these type of variables %VAR% In firefox about:config you can find: %LOCALE% %VERSION% %OS% %GOOGLE_LOCATION_SERVICE_API_KEY% etc.. Where are those variables stored or set, and how to console log their value? |
Nodejs module.parent condition not working on ubuntu server Posted: 16 Dec 2021 03:39 AM PST I am working on an existing project and found this piece of code in my app.js //if (!module.parent) { // Server listen app.listen(mysettings.port, function () { console.log(`Server ready at ${ENV}:${mysettings.port}`); }); //} When I run locally, app.listen hits and my project runs, when I upload my project on a ubuntu server, the project does not run, but times out. When I comment out the condition on ubuntu the project runs perfectly. I know on my localhost, module.parent is null. Any help would be apperciated. |
Yarn packages out of date when running Rails app in Docker Posted: 16 Dec 2021 03:38 AM PST I start my Rails 6 app as Docker containers, but when it starts the Rails server, it keeps giving the error: warning Integrity check: System parameters don't match website_1 | error Integrity check failed website_1 | error Found 1 errors. website_1 | website_1 | website_1 | ======================================== website_1 | Your Yarn packages are out of date! website_1 | Please run `yarn install --check-files` to update. website_1 | ======================================== website_1 | website_1 | website_1 | To disable this check, please change `check_yarn_integrity` website_1 | to `false` in your webpacker config file (config/webpacker.yml). So why is this not working? I have that command in the Dockerfile and also that check is disabled in webpacker.yml . I build it with docker-compose up --build and then it doesn't seem to give errors. When I start it with docker-compose up , it will return the erorr when the Rails server is started. Here are the relevant files: Dockerfile: FROM ruby:2.6.5-slim LABEL maintainer="John van Arkelen <johnvanarkelen@fastmail.com>" RUN apt-get update -qq && apt-get install -y curl build-essential libpq-dev postgresql postgresql-contrib RUN mkdir /app RUN mkdir -p /usr/local/nvm WORKDIR /app RUN curl -sL https://deb.nodesource.com/setup_11.x | bash - RUN apt-get install -y nodejs RUN node -v RUN npm -v ENV BUNDLE_PATH /gems RUN gem install bundler -v 2.0.2 COPY Gemfile Gemfile.lock package.json yarn.lock ./ RUN bundle install RUN npm install -g yarn COPY . /app RUN yarn install --check-files webpacker.yml: default: &default source_path: app/javascript source_entry_path: packs public_root_path: public public_output_path: packs cache_path: tmp/cache/webpacker check_yarn_integrity: false webpack_compile_output: false docker-compose.yml: version: '2' services: postgres: image: 'postgres:10.3-alpine' volumes: - 'postgres:/var/lib/postgresql/data' environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: password123 POSTGRES_DB: qd_development env_file: - '.env' redis: image: 'redis:4.0-alpine' command: redis-server --requirepass password123 volumes: - 'redis:/data' website: depends_on: - 'postgres' - 'redis' build: . command: bundle exec rails s -p 3000 -b '0.0.0.0' ports: - '3000:3000' volumes: - '.:/app' - gem_cache:/gems environment: DATABASE_HOST: postgres POSTGRES_USER: postgres POSTGRES_PASSWORD: password123 POSTGRES_DB: qd_development env_file: - '.env' volumes: redis: postgres: gem_cache: |
Heap Analytics for react native app Posted: 16 Dec 2021 03:38 AM PST Heap Analytics automatically tracks all events so you can analyze data in hindsight without having to manually define all events upfront. Unfortunately, Heap does not seem to work in this way when used with a react native app. Does anybody know an analytics solution for React Native iOS, where all events are tracked automatically or how to get Heap working in that way without having to define all events manually? Thanks in advance. |
No comments:
Post a Comment