can not draw line using UIBezierPath iOS Swift Posted: 23 Jan 2022 07:57 AM PST I am trying draw line using UIBezierPath but it is not working when i tried directly from view didload. override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. let freeform = UIBezierPath() freeform.move(to: .zero) freeform.addLine(to: CGPoint(x: 50, y: 50)) freeform.addLine(to: CGPoint(x: 50, y: 150)) freeform.addLine(to: CGPoint(x: 150, y: 50)) freeform.addLine(to: .zero) } |
How do I get the HWND of a window made with tkinter? Posted: 23 Jan 2022 07:56 AM PST How to get the HWND of a window made with tkinter? I have already tried this: print(root.winfo_id()) print(getAllWindows()) However, there is no root.winfo_id() in the list of getAllWindows() Why so? |
Unexpected errors when trying to download Homebrew on Apple M1 Mac Posted: 23 Jan 2022 07:56 AM PST Code error: ==> Downloading and installing Homebrew... HEAD is now at 768b17239 Merge pull request #12774 from milas/fix-bump-formula-pr error: Not a valid ref: refs/remotes/origin/master fatal: ambiguous argument 'refs/remotes/origin/master': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' error: 4348 bytes of body are still expected fetch-pack: unexpected disconnect while reading sideband packet fatal: early EOF fatal: index-pack failed Error: Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-core failed! fatal: invalid upstream 'origin/master' Failed during: /opt/homebrew/bin/brew update --force --quiet I tried doing git config --global http.postBuffer 524288000 as suggested here Github - unexpected disconnect while reading sideband packet but did not work. |
How to do SQL Insert in pure JSP/JSTl Posted: 23 Jan 2022 07:56 AM PST I'm trying to do a jsp page that inserts element into a SQL table that doesn't have any hardcoded naming. I've got how to get all columns name so I can access some parameters with the same name that I set in another page. But I want to control how to write that last ",": <sql:update var="tabla" dataSource="jdbc/subjetDB"> INSERT INTO <%=origen%> VALUES ( <c:forEach items="${tabla.rows[0]}" var="column"> <c:out value="${column.key},"/> </c:forEach> ) </sql:update> This produces the following: INSERT INTO producto VALUES ( CANTIDAD_MIN, CODIGO_PRODUCTO, NOMBRE_PRODUCTO, PRECIO, ) As you can see I must control where to add , so it creates a proper SQL transaction. |
How to get a class member of a grandparent class without using get-set? Posted: 23 Jan 2022 07:55 AM PST Can you access and change a class member of a grandparent class without using get-set and Reflect.set? I tried this code but it doesn't seem to work: class Grandparent{ this.classMember = null;//Define the class member constructor{ this.classMember = true; } } class Parent extends Grandparent{ constructor(){ super(); } } class Child extends Parent{ constructor(){ super().classMember = false; } } Is there any way you can do this without tampering with the parent class or grandparent class, or i.e, access and set the class member(s) inside the child class? |
DAX Rolling Average without date Posted: 23 Jan 2022 07:55 AM PST I have data in power bi containing fields for widget making devices (4), the widget serial numbers made, the dates (not time) the widgets were made and dimension A. Each device can make a widget on the same date (not necessarily everyday, other times multiple widgets per day) Trying to calculate 20 widget moving/rolling average of dimension A, filtered by device. Power BI rolling average is date based which doesn't work for this data with multiple points on same date. Tried rankx then calculating a rolling average but the resultant rolling average is incorrect:- Widgetrank = rankX( ALLSELECTED(widgettable), calculate(LASTDATE(widgettable[Date])), ,desc, Dense ) Moving Average:- DimensionA MovingAverage = var index = widgettable[widgetrank] var result = averagex( filter( widgettable, widgettable[widgetrank] < index+14 && widgettable[widgetrank] >= index ), widgettable[dimensionA] ) return fixed(result, 4) Can anyone please advise where it is wrong or how to achieve this? |
Firefox can't open tradingview chart, but Chrome can. on the same network environment Posted: 23 Jan 2022 07:55 AM PST From the console it keeps loading some resources: 2022-01-23T15:53:26.686Z:Alerts.Screener.Dispatcher:Error: Receive screener alerts snapshot timeout: 4 main_chart.3a34030d94c5f1691fc6.js:792:2438 Firefox can't establish a connection to the server at wss://prodata.tradingview.com/socket.io/websocket?from=chart%2FbRlnkhT8%2F&date=2022_01_21-11_27. bRlnkhT8:18:1051 Firefox can't establish a connection to the server at wss://prodata.tradingview.com/socket.io/websocket?from=chart%2FbRlnkhT8%2F&date=2022_01_21-11_27. bRlnkhT8:18:1051 Firefox can't establish a connection to the server at wss://pushstream.tradingview.com/message-pipe-ws/private_fzrUpGntAl3EC9SLyKFu9IgriCd-LHOlDBDcaLQrEaM. main_chart.3a34030d94c5f1691fc6.js:795:237 The connection to https://charts-storage-notifications.tradingview.com/charts-storage/layout/bRlnkhT8/subscribe?jwt=eyJhbGciOiJSUzUxMiIsImtpZCI6IkFod2IiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJ0dl9jaGFydCIsImlhdCI6MTY0Mjk1MDAwMCwiZXhwIjoxNjQzODE3NjAwLCJ0eXBlIjoib3duZXIiLCJsYXlvdXRJZCI6ImJSbG5raFQ4Iiwib3duZXJJZCI6OTkyNTg3Niwic2hhcmVkIjpmYWxzZX0.f0rT-t4YKZqSRJ0TY3_kjz0dkmO-hQyvg97MqrgnyOHiRezyM32-ESOmtsX8XsjmUF53bFcZKGW6NAgBWCoueMi8dN3_N4eohGLxfUIJxv_nIMkDWPbVXYNHJgNEVq8H8GmaAzSQVhjNurVbo-NB1ObVhMw8BmOSk_PrIk4yA8Dqf3Icr5f-Yas0btyBmu6M8g1pwAK_tChr6SUb6kZV0WyUivEgxulM5TuYQTK4Pwp9TyQPuVFQh1P0Uv1_aq0oWC_Iwf9PyPn4vKZdvNsFuWWknp1xxAHk69P0ck-feLO4Giay5TR1q5xvYLYXx9dTRsmy1nj_3DXKF6EaJpRPIw was interrupted while the page was loading. The version is : 96.0.2 Chrome is working well on the same device. |
Used a string array, got no errors, opened the app and it crashes Posted: 23 Jan 2022 07:55 AM PST I am trying to make an app in Android Studio that would "memorize" my grades and subjects. Currently, I am working on a system that would allow me to make subjects. Compiled it, got no errors, I open the app, the app crashes and I receive an error: "Attempt to invoke virtual method on a null object reference" I think the string array has something to do with it. This is my code: //these are declared in "public class MainActivity extends AppCompatActivity" LinearLayout linearLayout = findViewById(R.id.linearLayout); String[] subjectNames; int arrayCounter=-1; String name; //addSubject() gets called when a button is pressed public void addSubject (View view) { EditText editSubjectName = new EditText(this); editSubjectName.setHint("Unesi ime predmeta"); editSubjectName.setSingleLine(true); linearLayout.addView(editSubjectName); TextView subjectName = new TextView(this); subjectName.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); linearLayout.addView(subjectName); editSubjectName.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { name = editSubjectName.getText().toString(); arrayCounter++; return true; } return false; } }); subjectNames[arrayCounter] = name; } Thanks in advance! |
sudo asking for password Posted: 23 Jan 2022 07:57 AM PST I want to run /usr/bin/bash using sudo without a password Here is my sudo -l User user1 may run the following commands on ip-10-10-x-xxx: (ALL) NOPASSWD: /usr/bin/bash from this i am assuming i can run /usr/bin/bash with sudo without password, however password is still prompted. I have read other posts: - I do not have permission to view any sudoer file so IDK if the order in the sudoer file is messed up.
- I have tried using sudo -U root /user/bin/bash, still prompted me for a password
|
How do conditional operators in Python work for sets and tuples? [duplicate] Posted: 23 Jan 2022 07:57 AM PST I have written these lines in python: print({1, 2, 3} < {1, 3, 2}) print((1, 2, 3) < (1, 3, 2)) These gives output: False True I could not understand the working of < operator for two sets and two tuples. Please explain. |
How to display all the columns after applying group by function in pandas Posted: 23 Jan 2022 07:57 AM PST import pandas as pd df = pd.read_csv('filename.csv') df this is my data datafile this is the code i have used got this result how to get column 'price' after applying group by function result i expect please help me out..!! Thank you. |
AssertJ: How to assert on a map value object member? Posted: 23 Jan 2022 07:57 AM PST Given are a map like this: Map<String, BestClass> myMap = new HashMap<>(); and a class BestClass like this: class BestClass{ int a; int b; } Now, this map is being populated during the program process. Is there a clean way, not including looping over the map keys, to assert that, for example, none of the b values of the map object values are 0? |
how to pass data from one page to another page in react native using hook (useState)? Posted: 23 Jan 2022 07:56 AM PST -------------------- first page ------------------------- const [getName, setName] = useState("") <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Text>Home Screen</Text> <TextInput placeholder="enter your name" onChange={bob} /> <Button title="Next page" onPress={() => { navigation.navigate('Details', { myItem: getName, }); }} /> </View> function bob(input){ setName(input) } ----------------------Second screen ------------------------ <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> <Text>itemId:{route.params.myItem}</Text> I am facing this error::: Objects are not valid as a React child (found: object with keys {dispatchConfig, _targetInst, nativeEvent, _dispatchListeners, _dispatchInstances, type, target, currentTarget, eventPhase, bubbles, cancelable, timeStamp, defaultPrevented, isTrusted, isDefaultPrevented, isPropagationStopped}). If you meant to render a collection of children, use an array instead. |
How to use ifelse with str_detect across multiple columns Posted: 23 Jan 2022 07:55 AM PST I have a dataframe that shows ICD-10 codes for people who have died (decedents). Each row in the data frame corresponds to a decedent, each of whom can have up to twenty conditions listed as contributing factors to his or her death. I want to create a new column that shows if a decedent had any ICD-10 code for diabetes (1 for yes, 0 for no). The codes for diabetes fall within E10-E14 i.e., codes for diabetes must start with any of the strings in the following vector, but the fourth position can take on different values: diabetes <- c("E10","E11","E12","E13","E14") This is a small, made-up example of what the data looks like: original <- structure(list(acond1 = c("E112", "I250", "A419", "E149"), acond2 = c("I255", "B341", "F179", "F101"), acond3 = c("I258", "B348", "I10", "I10" ), acond4 = c("I500", "E669", "I694", "R092")), row.names = c(NA, -4L), class = c("tbl_df", "tbl", "data.frame")) acond1 | acond2 | acond3 | acond4 | E112 | I255 | I258 | I500 | I250 | B341 | B348 | E669 | A419 | F179 | I10 | I694 | E149 | F101 | I10 | R092 | This is my desired result: acond1 | acond2 | acond3 | acond4 | diabetes | E112 | I255 | I258 | I500 | 1 | I250 | B341 | B348 | E669 | 0 | A419 | F179 | I10 | I694 | 0 | E149 | F101 | I10 | R092 | 1 | There have been a couple other posts (e.g., Using if else on a dataframe across multiple columns, Str_detect multiple columns using across) on this type of question, but I can't seem to put it all together. Here is what I have unsuccessfully tried so far: library(tidyverse) library(stringr) #attempt 1 original %>% mutate_at(vars(contains("acond")), ifelse(str_detect(.,paste0("^(", paste(diabetes, collapse = "|"), ")")), 1, 0)) #attempt 2 original %>% unite(col = "all_conditions", starts_with("acond"), sep = ", ", remove = FALSE) %>% mutate(diabetes = if_else(str_detect(.,paste0("^(", paste(diabetes, collapse = "|"), ")")), 1, 0)) Any help would be appreciated. |
How to plot multiline for each ID starting at t=0 in Python Posted: 23 Jan 2022 07:57 AM PST So, I have a panel-time series dataset, but since for each ID the starting date is different, i created an additional variable t that is a count variable, t=0, 1, 2, 3, .... and the end date is all different. Using the data, I want to plot: - a multiline graph where x-axis is "t" =0,1,2,3... and y-axis is "growth" for all IDs
- additionally, if i want to have x-axis start from t=1 instead of t=0?
thank you! Current table: ID date growth t x1a 1/1/2018 1.2 0 x1a 2/1/2018 1 1 x1a 3/1/2018 3 2 x1a 4/1/2018 2 3 x1a 5/1/2018 0.9 4 z8d 3/1/2018 0.7 0 z8d 3/2/2018 1 1 z8d 3/3/2018 0.8 2 z8d 3/4/2018 0.6 3 z8d 3/5/2018 2.3 4 z8d 3/6/2018 1.7 5 z8d 3/7/2018 1 6 z8d 3/8/2018 2.1 7 j2u 1/1/2020 0.9 0 j2u 1/2/2020 0.8 1 j2u 1/3/2020 1.3 2 j2u 1/4/2020 1.4 3 j2u 1/5/2020 2 4 j2u 1/6/2020 1.4 5 .. .. .. .. |
Is GraphQL a different implementation of Rest? Posted: 23 Jan 2022 07:57 AM PST Rest definition says that Rest is not a standard or a protocol, it just a guiding principals how to design API and open its implementation to developers. With that definition, I think it's not correct to compare Rest and GraphQL. Can I say GraphQL is another implementation of Rest? |
powershell datetime subtraction Posted: 23 Jan 2022 07:56 AM PST I set up variables. $script:current = [datetime]::Today $r = 120 $global:eastern = [System.TimeZoneInfo]::convertTimeBySystemTimeZoneId([datetime]::Now, 'Eastern Standard Time') How would I go abouts subtracting seconds from this oneliner? $variable = (($script:current.DayOfWeek -match 'Monday|Tuesday|Wednesday|Thursday|Friday') -and $global:eastern.hour -eq 09 -and $global:eastern.Minute -eq 30 -and ([datetime]::Now.Second -eq 0)) This works, but trying to do so without an 'overload parsexact' error $culture = [cultureinfo]::InvariantCulture $format = 'HH:mm:ss' $east = [datetime]::ParseExact('09:30:00',$culture,'AssumeUniversal, AdjustToUniversal').Addseconds(-$r) [System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId($east, 'Eastern Standard Time') |
how to make SQL statements in same value Posted: 23 Jan 2022 07:57 AM PST Table: A | B | C | QW | 1 | 42 | QW | 2 | | QW | 3 | 12 | EW | 3 | | EW | 2 | | R | 1 | 52 | T | 2 | | Y | 3 | | UY | 1 | 1 | IO | 2 | | PO | 3 | | PP | 4 | 1 | IU | 12 | | PP | 5 | 55 | expected output: A | B | C | QW1 | | 42 | QW2 | | | QW3 | | 12 | EW3 | | | EW2 | | | R | 1 | 52 | T | 2 | | Y | 3 | | UY | 1 | 1 | IO | 2 | | PO | 3 | | PP4 | | 1 | IU | 12 | | PP5 | | 55 | In the table col[A] have repeating some same values throughout the rows. For those rows, need to make them concatenated with col[B] such as col[A]+col[B] as column A , and undisplay column B But I don't know how to make the SQL statements.Please help~ |
how to clear console in Java on Windows Posted: 23 Jan 2022 07:56 AM PST in curios to know how to clear console in windows i try few command but no thing works Runtime.getRuntime().exec("cls"); but it didnt work for me i like to know is there any method to clear terminal in Java or at is there any external library to this |
How to get clients ipaddress while they are signing up in java Posted: 23 Jan 2022 07:57 AM PST I just started learning about spring-boot and was trying to make an application where I want to get the client's IP address and store it in the MySQL database with all the other information like username, password, etc. I don`t understand what is going wrong here If you could please let me know what should my approach be user.java package net.codejava; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; @Entity @Table(name = "users") public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long idUser; @Column(nullable = false,unique=true,length = 45) private String email; @Column(nullable = false,unique=true,length = 45) private String firstname; @Column(nullable = false,unique=true,length = 45) private String lastname; @Column(nullable = false,unique=true,length = 45) private String username; @Column(nullable = true) private String IPaddress; @Column(nullable = false,length = 64) private String password; public Long getIdUser() { return idUser; } public void setIdUser(Long idUser) { this.idUser = idUser; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getFirstname() { return firstname; } public void setFirstname(String firstname) { this.firstname = firstname; } public String getLastname() { return lastname; } public void setLastname(String lastname) { this.lastname = lastname; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getIPaddress() { return IPaddress; } public void setIPaddress(String iPaddress) { IPaddress = iPaddress; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } user repository package net.codejava; import org.springframework.data.jpa.repository.JpaRepository; public interface UserRepository extends JpaRepository<User, Long> { } controller package net.codejava; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @Controller public class AppController { @Autowired private UserRepository repo; @GetMapping("") public String viewHomePage() { return "index"; } @GetMapping("/register") public String showSignUpForm(Model model) { model.addAttribute("user", new User()); return "signup_form"; } @PostMapping("/process_register") public String processRegistration(User user) { repo.save(user); return "register_success"; } } In the test repository, I tried this but didn't work package net.codejava; import static org.assertj.core.api.Assertions.assertThat; import javax.servlet.http.HttpServletRequest; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; import org.springframework.test.annotation.Rollback; @DataJpaTest @AutoConfigureTestDatabase(replace = Replace.NONE) @Rollback(false) public class UserRepositoryTests { @Autowired private UserRepository repo; @Autowired private TestEntityManager entityManager; // // @Autowired // private HttpServletRequest request; @Test public void testCreateUser() { User user = new User(); user.setEmail("Tarun@gmail.com"); user.setPassword("Ray*&^"); user.setFirstname("Tarun"); user.setLastname("Jai"); user.setUsername("TJai"); // user.setIPaddress(request.getRemoteHost()); User savedUser = repo.save(user); User existUser = entityManager.find(User.class, savedUser.getIdUser()); assertThat(user.getEmail()).isEqualTo(existUser.getEmail()); } } |
C Basic Sorting Algorithm through Command Arguments Posted: 23 Jan 2022 07:57 AM PST I'm having some problems with the code below. My goal with it is to sort an array created from the int value of command arguments ex using the argument Hello 125 17 -6 should give: Unsorted: 0 125 17 -6 Sorted: -6 0 17 125 The problem is an extra value is included and is printed out as: Unsorted: -858993460 0 125 17 -6 Sorted: -6 0 17 125 I dont know what this value represents and why my data[] array registers it. Basic Sorting code: void mySort(int d[], unsigned int n) { int i, j, key; for (i = 0; i < n; i++) { key = d[i]; j = i - 1; while (j >= 0 && d[j] > key) { d[j + 1] = d[j]; j = j - 1; } d[j + 1] = key; } } Main code: int main(int argc, char* argv[]) { int data[1000]; int nDataItems; int i; if (argc > 1) { nDataItems = argc; fprintf(stderr, "The command line arguments are:\n"); for (i = 1; i < argc; i++) { /* Prints each arg as a string, int and hex */ fprintf(stderr, " argv[%d] (as string): %s\n" " (as int): %d\n" " (as int in hex): %X\n\n", i, argv[i], atoi(argv[i]), atoi(argv[i])); data[i] = atoi(argv[i]);/* stores integer of each argument value */ } }else { fprintf(stderr, "There were no command line arguments.\n"); /* Default Test data */ nDataItems = 4; data[0] = 10; data[1] = 20; data[2] = 30; data[3] = 40; } printf("Unsorted Array: "); for (i = 0; i < nDataItems; i++) { printf(" %d ", data[i]); } mySort(data, nDataItems); /* Check that the data array is sorted. */ for (i = 0; i < nDataItems - 1; i++) { if (data[i] > data[i + 1]) { fprintf(stderr, "Sort error: data[%d] (= %d)" " should be <= data[%d] (= %d)- -aborting\n", i, data[i], i + 1, data[i + 1]); exit(1); /* exit(1) = exit failure*/ } } /* Print sorted array to stdout */ printf("\nSorted Array: "); if (argc > 1) { for (i = 1; i < nDataItems; i++) { printf(" %d ", data[i]); } } else { for (i = 0; i < nDataItems; i++) { printf(" %d ", data[i]); } } exit(0); /* exit(0) = exit success*/ } Help would be greately apreciated |
'Section mismatch in reference from a function to another function during linux kernel build after adding #pragma GCC Posted: 23 Jan 2022 07:57 AM PST In Linux 5.4.21 source code, I put #pragma GCC push_options #pragma GCC optimize ("O0") and #pragma GCC pop_options around the function static int __init gic_init_bases in the file /drivers/irqchip/irq-gic-v3.c . When I build it, I get this warning message (section mismatch). I later found it is actually the #pragma GCC optimize ("O0") line that is causing it. CALL scripts/atomic/check-atomics.sh CALL scripts/checksyscalls.sh CHK include/generated/compile.h CC arch/arm64/kernel/irq.o CC arch/arm64/kernel/setup.o CC drivers/irqchip/irq-gic-v3.o AS arch/arm64/kernel/head.o AR arch/arm64/kernel/built-in.a AR arch/arm64/built-in.a AR drivers/irqchip/built-in.a AR drivers/built-in.a GEN .version CHK include/generated/compile.h UPD include/generated/compile.h CC init/version.o AR init/built-in.a LD vmlinux.o MODPOST vmlinux.o WARNING: vmlinux.o(.text+0x227cc0): Section mismatch in reference from the function gic_smp_init() to the function .init.text:set_smp_cross_call() The function gic_smp_init() references the function __init set_smp_cross_call(). This is often because gic_smp_init lacks a __init annotation or the annotation of set_smp_cross_call is wrong. MODINFO modules.builtin.modinfo LD .tmp_vmlinux1 KSYM .tmp_kallsyms1.o LD .tmp_vmlinux2 KSYM .tmp_kallsyms2.o LD vmlinux SORTEX vmlinux SYSMAP System.map OBJCOPY arch/arm64/boot/Image Function call chain is like this: gic_init_bases -> gic_smp_init() -> set_smp_cross_call (currently CONFIG_SMP=y ). The message seems to say set_smp_cross_call is annotated with __init (meaning it is placed in .init.text ), but gic_smp_init is not. Without the #pragma debug setting, there was not warning of this kind. I'm not sure if I can just add add __init to gic_smp_init() (or remove _init from set_smp_cross_call ). What is the correct method to fix it? If I add __init to gic_smp_init , this warning goes away, but I think this will make the function be removed after initialization (which is ok maybe?). |
Why is my hamburger menu on mobile menus going under my hero image instead of pushing it down Posted: 23 Jan 2022 07:55 AM PST I have a responsive nav everything is fine but this, my hamburger menu when opened, is going under my hero image under the menu like the backgroud image of the hero image is covering it, I want it to push down the hero image and display it on mobile screens. You can see it on my Website or Here is my code for it HTML <nav class="navbar"> <!-- LOGO --> <div class="logo">EzcoderZ</div> <!-- NAVIGATION MENU --> <ul class="nav-links"> <!-- USING CHECKBOX HACK --> <input type="checkbox" id="checkbox_toggle" /> <label for="checkbox_toggle" class="hamburger">☰</label> <!-- NAVIGATION MENUS --> <div class="menu"> <li><a href="index.html">Home</a></li> <li><a href="about.html">About</a></li> <li><a href="contact.html">contact</a></li> <li><a href="pricing.html">Pricing</a></li> </div> </ul> </nav> <div class="hero-image"> <div class="hero-text"> <h1 style="font-size:50px">EzcoderZ</h1> <p>I am a coder</p> <button>Hire me</button> </div> </div> CSS /* UTILITIES */ * { margin: 0; padding: 0; box-sizing: border-box; } a { text-decoration: none; } li { list-style: none; } /* NAVBAR STYLING STARTS */ .navbar { display: flex; align-items: center; justify-content: space-between; padding: 20px; background-color: black; color: #fff; } .nav-links a { margin: none; color: #fff; } .nav-links a:hover { text-decoration: none; background: none; } /* LOGO */ .logo { font-size: 32px; } /* NAVBAR MENU */ .menu { display: flex; gap: 1em; font-size: 18px; } .menu li:hover { background-color: red; border-radius: 5px; transition: 0.3s ease; } .menu li { padding: 5px 14px; } /*RESPONSIVE NAVBAR MENU STARTS*/ /* CHECKBOX HACK */ input[type=checkbox]{ display: none; } /*HAMBURGER MENU*/ .hamburger { display: none; font-size: 24px; user-select: none; } /* APPLYING MEDIA QUERIES */ @media (max-width: 768px) { .menu { display:none; position: absolute; background-color:teal; right: 0; left: 0; text-align: center; padding: 16px 0; } .menu li:hover { display: inline-block; background-color:#4c9e9e; transition: 0.3s ease; } .menu li + li { margin-top: 12px; } input[type=checkbox]:checked ~ .menu{ display: block; } .hamburger { display: block; } .dropdown { left: 50%; top: 30px; transform: translateX(35%); } .dropdown li:hover { background-color: #4c9e9e; } } .hero-image { background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("img/herobg.jpg"); height: 90%; background-position: center; background-repeat: no-repeat; background-size: cover; position: relative; } .hero-text { text-align: center; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: white; } .hero-text button { border: none; outline: 0; display: inline-block; padding: 10px 25px; color: black; background-color: #ddd; text-align: center; cursor: pointer; } .hero-text button:hover { background-color: #555; color: white; } |
url generated for Streamlit not working properly. ngrok tells me to register again even though I have already registered or gives me an error Posted: 23 Jan 2022 07:56 AM PST Below is my code for deploying my ml model on streamlit. I am using Google Collab !pip install streamlit --quiet !pip install pyngrok==4.1.1 from pyngrok import ngrok %%writefile app.py import streamlit as st import joblib st.title('Spam Ham Deployment') test_model=joblib.load('spam_ham') ip=st.text_input('Enter your message') op=test_model.predict([ip]) if st.button('Predict') st.title(op) !nohup streamlit run app.py & url=ngrok.connect(port='8501') url Note: Initially I did not have ngrok on my PC After running the last code block I got the url but ngrok wanted me to create an account. I created an account, extracted ngrok on Windows, authenticated my ngrok agent and restarted my computer. I ran the last block again and got an error "Your account may not run more than 2 tunnels over a single ngrok client session." So I killed the process and ran all code blocks. However, after gettiing the URl and running it in the browser it tells to to register again. Note: There is a warning when the URL is generated 't=2022-01-22T22:40:55+0000 lvl=warn msg="can't bind default web address, trying alternatives" obj=web addr=127.0.0.1:4040' Why is this hapenning? Can someone tell me what I should to do in order to solve the situation? Edit: I tried to change port to 5040 that has listening state but then it shows a different error 'The connection to http://9039-35-186-177-6.ngrok.io was successfully tunneled to your ngrok client, but the client failed to establish a connection to the local address localhost:5040.' |
Mixes (traits, mixins) as an intermediate link between interfaces and inheritance Posted: 23 Jan 2022 07:57 AM PST Help I don't know how to solve the problem Mixes (traits, mixins) as an intermediate link between interfaces and inheritance. |
How to import subset from MS Access based on condition criteria Posted: 23 Jan 2022 07:57 AM PST Hoping you can help please. EDIT 23 Jan I'm trying to use python to create a dataframe which consists of certain rows (based on condition criteria) extracted from an MS Access table. I can't seem to get the condition to work. The MS Access table has column names such as Date, Course, Horse etc. I want to, for example, get all the rows with Date = "01-Dec-2021" and Course = "Kempton". I have managed to get the following code working with one criteria: import pyodbc connStr = (r"DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};" r"DBQ=C:\Users\chris\Documents\UKHR\SFF_Cum\SFFCum_py.accdb;") conn = pyodbc.connect(connStr) cursor = conn.cursor() sql = "select * FROM SFF_cumQ_O where Course = ?" cursor.execute(sql, ["Kempton"]) #print(cursor.fetchone()) print(cursor.fetchall()) cursor.close() conn.close() However, when I try to import the rows based on Date = "01-Dec-2021" and Course = "Kempton" I get an error - "Exception has occurred: Error ('07002', '[07002] [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. (-3010) (SQLExecDirectW)')" import pyodbc connStr = (r"DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};" r"DBQ=C:\Users\chris\Documents\UKHR\SFF_Cum\SFFCum_py.accdb;") conn = pyodbc.connect(connStr) cursor = conn.cursor() sql = "select * FROM SFF_cumQ_O WHERE Date = '01-Dec-2021' and Course = 'Kempton'" cursor.execute(sql) print(cursor.fetchall()) |
Cucumber step not binding with step definitions when using Example block Posted: 23 Jan 2022 07:58 AM PST I am using cucumber with java. When i am trying to pass value from Example block steps are not binding with the step definitions. Throwing steps undefined step reference error on feature file. Feature File code: Scenario Outline: Verify "Create your account" button on the Profile screen for Guest user Given I launched the app When I skip the On-boarding flow And I tap on continue with free lessons button And I tap on Profile tab Then the output should be <output> Then I should be able to see <text> on profile screen And I enter Username as <username> and Password as <username> And I tap create your account button on profile screen Then I should redirected to Create your account screen Examples: | text | output | username | pwd | |Register now| 5000 | sam | willis | Step Definition code that i tried: @Then("I should be able to see {string} on profile screen") public void i_should_be_able_to_see_register_now_to_save_your_xp_and_access_your_full_profile_on_profile_screen(String text) { profile = new Profile(); Assert.assertTrue(profile.verifyLevelTagForGuestUser(text)); } @Then("I should be able to see <text> on profile screen") public void iShouldBeAbleToSeeTextOnProfileScreen(String output) { profile = new Profile(); Assert.assertTrue(profile.verifyLevelTagForGuestUser(output)); } @When("^I enter Username as \"([^\"]*)\" and Password as \"([^\"]*)\"$") public void I_enter_Username_as_and_Password_as(String arg1, String arg2) { } @And("I enter Username as <username> and Password as <username>") public void iEnterUsernameAsUsernameAndPasswordAsUsername() { } Any help would be appreciated. [Step definition image][1] |
prevent first input focus in ionic Posted: 23 Jan 2022 07:56 AM PST i have a login screen to application and when launching,the 'username' input gets the focus automatically and pops out the keyboard. when the keyboard pops out contents of my login screen pushes up resulting in wrong dimensions. How can i prevent this auto focusing of the first input ? And also a point to note is this only happens in iOS. In android it works just fine. This is how it is displayed when the application is launched(Blocking the fields and pushing the contents up) Here's my code <ion-view title="*************" hide-back-button="false" > <ion-content class="has-header" scroll="false" > <center style="position:relative;"> <div id="logo"> <img src="img/lof_logo.png" style="margin-top:40px;" class="img-responsive" width="270"/> </div> <div class="box on fadein fadeout " ng-show="toggle" ng-animate="'box'" style="z-index:1" > <div class="container" ng-controller="LoginController"> <form id="ftForm" name="form" autocomplete="off" novalidate shake-that ng-submit="login(credentials)" novalidate> <div class="panel-body"> <div class="form-group box-shadow" ng-class="{'has-error': form.name.$invalid && submitted}"> <input style="padding-left:5px;" type="text" class="form-control" id="username" name="username" placeholder="User Name" ng-model="credentials.username" ng-model-options="{updateOn: 'blur'}" required> </div> <div class="form-group box-shadow" ng-class="{'has-error': form.password.$invalid && submitted}"> <input style="padding-left:5px;" type="password" class="form-control" id="password" name="password" placeholder="Password" ng-model="credentials.password" required> </div> </div> <div class="box-shadow" > <button type="submit" class="btn btn-primary btn-block" >Login</button> </div> </form> <div class="alert alert-success message" ng-show="showMessage">Well done!</div> </div> </div> <a href="#"> <img src="img/online_banking_bg.png" class="img-responsive" style="margin-top:40px; z-index: 1; margin-bottom:40px; " ng-click="toggle = !toggle" /> </a> <ion-scroll zooming="false" direction="y" style="height:250px;"> <div class="row" style="text-align: center;"> <div class="col"> <a style="font-size: 20px; color:" href="#/app/services/product"> <i class="icon ion-arrow-graph-up-right" style="font-size: 50px;"></i> <h5>Products and Services</h5> </a> </div> <div class="col"> <a style="font-size: 20px; color:" href="#/app/services/locations"> <i class="icon ion-android-location" style="font-size: 50px;"></i> <h5>Locate a Branch / ATM</h5> </a> </div> </div> <div class="row" style="text-align: center;"> <div class="col"> <a style="font-size: 20px; color:" href="#/app/services/calc"> <i class="icon ion-ios7-calculator" style="font-size: 50px;"></i> <h5>Financial Calculator</h5> </a> </div> <div class="col"> <a style="font-size: 20px; color:" href="#/app/services/news"> <i class="icon ion-ios7-world-outline" style="font-size: 50px;"></i> <h5>News and CSR</h5> </a> </div> </div> <div class="row" style="text-align: center;"> <div class="col"> <a style="font-size: 20px; color:" href="#/app/services/promotion"> <i class="icon ion-android-promotion" style="font-size: 50px;"></i> <h5>Promotions and Offers</h5> </a> </div> <div class="col"> <a style="font-size: 20px; color:" href="#/app/services/contact"> <i class="icon ion-ios7-telephone" style="font-size: 50px;"></i> <h5>Contact and Feedback</h5> </a> </div> </div> <br/><br/> </ion-scroll> <!-- <div class="item item-text-wrap"> <div class="button-bar"> <a class="button" href="#/app/services/product">Small</a> <a class="button" href="#/app/account/balance">Medium</a> <a class="button" ng-click="showImage(3)">Very large</a> </div> </div> --> </center> <script id="image-modal.html" type="text/ng-template"> <div class="modal image-modal transparent"> <ion-pane class="transparent"> <img ng-src="{{imageSrc}}" class="fullscreen-image"/> </ion-pane> </div> </script> </ion-content> </ion-view> |
How can I "mouse swipe" with plain Javascript? Posted: 23 Jan 2022 07:56 AM PST I'm new to Javascript and I'm trying to "master" it somehow and in order for me to do so I don't want to use any library [like jQuery] yet. That being said, I have found several ways to implement a "mouse swipe" with just Javascript like: Simulate swipe with mouse in javascript. But the answers are always very shallow in the posts that I have found. Even tho, all of the solutions point to: mousedown -> mousemove -> mouseup events. Which is what I'm doing. I set up an exercise for my self to "master" the bases of Javascript: I would have to create a flat and cross-browser-compatible interface that would allow me to save notes (in local storage) using only Javascript, css3 and html5 (the hard part is the cross browser compatibility). So I thought of a simple table with 2 columns: to save the title of the note (first column) and the note (second column). i.e. What matters is the table at the end. I want to be able to "mouse-swipe" the rows of the table. This is what I have come up to (I'm not going to put all the code, just the basics of what I got): First: the table is a set of classes through CSS; /*CSS*/ div.table { display: table; } div.table .row{ display: table-row; } div.table .row .col, div.table .row .col-2{ display: table-cell; } Second: the html; <div id="savedNotesTable" class="table"> <div class="row"> <div class="col">Testing</div> <div class="col-2">This is a test</div> </div> <div class="row"> <div class="col">Testing</div> <div class="col-2">This is a test</div> </div> <div class="row"> <div class="col">Testing</div> <div class="col-2">This is a test</div> </div> </div> Last but not least: the Javascript function addEvent(element, type, fn){ // custom add event function that cares about compatibility // returns fn } function removeEvent(element, type, fn){ /*custom remove event function that cares about compatibility and removes only the specific handler*/ } function addSwipe(element, parent){ addEvent(element, "mousedown", function(e){ var mouseupHandler = addEvent(document, "mouseup", mouseUpHandler); var mousemoveHandler = addEvent(document, "mousemove", function(e){ // element.style.position = "static"; // parent.style.left = e.pageX + 'px'; // add transition and blur to the element // mouseSwipe = absolute value of(originalPosition of mouse - e.pageX) }); function mouseUpHandler(e){ // pseudocode: // if mouseSwipe >= 50%(div size) = delete from the parent which is the "table" // transition and blur OUT to 100% and delete // if mouseSwipe < 50%(div size) = don't delete // transition back to 0% and unblur. removeEvent(document, "mousemove", mousemoveHandler); removeEvent(document, "mouseup", mouseupHandler); }; }); }; // this is just to add them to the test notes on the html // The real thing is going to add the swipe when I save the new element var table = document.getElementById("savedNotesTable"); var notes = table ? table.childNodes : undefined; for(var prop in notes){ if(prop != "length" && notes.hasOwnProperty(prop)){ if(notes[prop].nodeName != "#text"){ addSwipe(notes[prop], table); }; }; }; Am I doing it right? Or is there another way I'm not seeing? I was able to get somewhere messing with the position of the divs like position="absolute" inside the onmousedown event but that messed with the width and length of the table row. I'm looking for best practices also. |
Getting the Redirected URL from the Original URL Posted: 23 Jan 2022 07:56 AM PST I have a table in my database which contains the URLs of some websites. I have to open those URLs and verify some links on those pages. The problem is that some URLs get redirected to other URLs. My logic is failing for such URLs. Is there some way through which I can pass my original URL string and get the redirected URL back? Example: I am trying with this URL: http://individual.troweprice.com/public/Retail/xStaticFiles/FormsAndLiterature/CollegeSavings/trp529Disclosure.pdf It gets redirected to this one: http://individual.troweprice.com/staticFiles/Retail/Shared/PDFs/trp529Disclosure.pdf I tried to use following code: HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Uris); req.Proxy = proxy; req.Method = "HEAD"; req.AllowAutoRedirect = false; HttpWebResponse myResp = (HttpWebResponse)req.GetResponse(); if (myResp.StatusCode == HttpStatusCode.Redirect) { MessageBox.Show("redirected to:" + myResp.GetResponseHeader("Location")); } When I execute the code above it gives me HttpStatusCodeOk . I am surprised why it is not considering it a redirection. If I open the link in Internet Explorer then it will redirect to another URL and open the PDF file. Can someone help me understand why it is not working properly for the example URL? By the way, I checked with Hotmail's URL (http://www.hotmail.com) and it correctly returns the redirected URL. Thanks, |
No comments:
Post a Comment