Posts

Showing posts from August, 2018

Error If condition not working for 29 February in php , when i set date 29 feb it show first conditon true1

Image
Clash Royale CLAN TAG #URR8PPP Error If condition not working for 29 February in php , when i set date 29 feb it show first conditon true1 problem between 28 and 29 February, please change date and see result $cmncdate = '2019-02-29'; $time=strtotime($cmncdate); $day=date("d",$time); $mnth=date("m",$time); if ($day>=1 AND $day<11) $nday = '10'; $newDate = date("Y-m-$nday", strtotime($cmncdate)); echo $newDate; elseif ($day>10 AND $day<21) $nday = '20'; $newDate = date("Y-m-$nday", strtotime($cmncdate)); echo $newDate; elseif ($day>20 AND $day<31 AND $mnth!=2) $nday = '30'; $newDate = date("Y-m-$nday", strtotime($cmncdate)); echo $newDate; elseif ($day>20 AND $day<29 AND $mnth=2) $nday = '28'; $newDate = date("Y-m-$nday", strtotime($cmncdate)); echo $newDate; elseif ($day=29 AND $mnth=2) $nday = '29'; $newDate = date("Y-m-$nday", strto

Filtering records city and state

Image
Clash Royale CLAN TAG #URR8PPP Filtering records city and state I have 2 tables with name = city and state city id_city | name_city 1 | JED 2 | RUD 3 | DMM state id_state | id_for_city | name_state 1 | 1 | JED1 2 | 1 | JED2 3 | 2 | RUH1 4 | 2 | RUH2 I used ComboBox and i have 2 first combobox1 select name_city (it's ok ) second combobox2 i want select name_state through id_for_city but it left join id_city (here it,s not okay ) how i can write query by using left join in java ? my code : frst comboBox1 i think it,s ok public void Filecombo() try String sql = "select name_city from city"; pstmt = conn.prepareStatement(sql); rs = pstmt.executeQuery(); while (rs.next()) options.add(rs.getString("name_city")); comboCity.setItems(options); pstmt.close(); rs.close(); catch (SQLException e) e.printStackTrace(); second comboBox2 (here probloem) public void Filecombo2() try String sq2 = " select name_state from state left join city on

How detect modified repeater item in Laravel?

Image
Clash Royale CLAN TAG #URR8PPP How detect modified repeater item in Laravel? I'm using this jquery plugin in my Laravel website and this is a repeater field plugin. I'm wondering how can I detect a edited or removed repeater item field in my edit post page so I can update or destroy that specific item in the database?! I'm asking this because names get reindexed dynamically by plugin if an item is removed. Now that I think more, maybe I can do this by adding a hidden input with the value of item id for each repeater items. – Ehsan Mousavi Aug 12 at 7:18 1 Answer 1 I solved my problem by adding a hidden input with the value of item id for each repeater items. By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Which is faster between a list comprehension and using the list()

Image
Clash Royale CLAN TAG #URR8PPP Which is faster between a list comprehension and using the list() Trying to create a list of items using one of these methods: from pathlib import Path list_comprehension = [item for item in Path('.').iterdir()] list_method = list(Path('.').iterdir()) Which is faster and how do I check for speed. try it like import time; start = time.time();list_comprehension = [item for item in Path('.').iterdir()];end=time.time()-start;print(end) – Saeed Aug 12 at 6:56 Use timeit to answer your own question... – Reut Sharabani Aug 12 at 7:01 timeit 2 Answers 2 you can use timeit module to achieve it. timeit import timeit first = """ from pathlib import Path list_comprehension = [item for item in Path('.').iterdir()] """ second = """ from pathlib import Path list_method = list(Path('.').iterdir()) """ print(timeit.timeit(stmt=first, number=10000)) #

Extern “C” error expected '=', ',', ';', 'asm' or '__attribute__' before 'int'

Image
Clash Royale CLAN TAG #URR8PPP Extern “C” error expected '=', ',', ';', 'asm' or '__attribute__' before 'int' I am trying to include a compiled library into a C project on a Nordic nrf52840. Below (as far as I understand) is a way to link to some of the methods foo and bar within the .lib file for the rest of the project. When Trying to compile this with Segger Embedded Studio I get the following expected '=', ',', ';', 'asm' or '__attribute__' before 'int' error with the following code snippet: foo bar .lib expected '=', ',', ';', 'asm' or '__attribute__' before 'int' #ifndef _FOOBAR_SERVICE_H_ #define _FOOBAR_SERVICE_H_ #if (defined(__linux__) || defined(__APPLE__) || defined(ARDUINO) || defined(__MSP430FR5969__)) #define IMPORT __attribute__ ((visibility ("default"))) #define EXPORT __attribute__ ((visibility ("default&q

SQL selection based on a particular field value

Image
Clash Royale CLAN TAG #URR8PPP SQL selection based on a particular field value I have a table of people and a table of their addresses. A person can have multiple addresses, but there is an effective date attached to each address. I want to link people and address to their greatest effective date and I am stuck, with my query attached below I am getting just the maximum effective date in the entire table. Please note that this is RPG so the dates are stored like numbers, for instance today would be 20,180,831 (2018-08-31). SELECT PERSON.ID, PERSON.NAME, ADDRESS.ID, ADDRESS.ADD1, ADDRESS.ADD2, ADDRESS.CITY FROM PERSON LEFT JOIN ( SELECT * FROM ADDRESS WHERE EFF_DATE IN (SELECT MAX(EFF_DATE) FROM ADDRESS) ) AS A ON PERSON.ID = A.ID I know the problem is in the WHERE clause but I'm drawing a blank. 1 Answer 1 You need to use a LEFT OUTER JOIN between the table person and the table address , adding that the address must match the last eff_date. LEFT OUTER JOIN person add

How to catch the Collection sortBy keyword to variable on laravel blade?

Image
Clash Royale CLAN TAG #URR8PPP How to catch the Collection sortBy keyword to variable on laravel blade? On blade view .I resort my collection from controller like below $search_alls=$search_alls->sortByDesc('id'); or $search_alls=$search_alls->sortBy('id'); The above is work fine on my blade. I want to make a dynamic javascript button to change the keywork in the sortby clause,or change sortBy to sobyByDesc. How can I catch the ->sortBy($keywordvariable) or catch the ->$sortclausevariable($keywordvariable)? and how to reload the new sequence $serch_alls? Can by reload page javascript function? You can't run php code from javascript unless you either use AJAX or reload the page. – Alex van Vliet Aug 12 at 7:01 As @AlexvanVliet stated, you cannot modify the PHP code in your blade files. Those are rendered on the server before ever getting to the client (browser). XHR requests are your friend. – DigitalDrifter Aug 12 at 7:15 By cli

error when connecting database to the form , and give me the below error

Image
Clash Royale CLAN TAG #URR8PPP error when connecting database to the form , and give me the below error I am try to fill the form and I got this error. Please someone tell me why? I have attached all the code and the images: what I want is when I fill this form, it gets automatically saved in database. And please, if you can provide me how to upload images from the same form to the same database at phpmyadmin . phpmyadmin Error Message: This is the model : class Clinic_Model extends CI_Model function insert_into_db() $pfn = $_POST['pfn']; $pe = $_POST['pe']; $pmn = $_POST['pmn']; $pa = $_POST['pa']; $pw = $_POST['pw']; $ph = $_POST['ph']; $pgt = $_POST['pgt']; $pbp = $_POST['pbp']; $pec = $_POST['pec']; $this->db->query("INSERT INTO add_clinic VALUES($pfn','$pe','$pmn','$pa','$pw','$ph','$pgt','$pbp','$pec')");

Formal name for this optimization algorithm?

Image
Clash Royale CLAN TAG #URR8PPP Formal name for this optimization algorithm? I have the following problem in one of my coding project which I will simplify here: I am ordering groceries online and want very specific things in very specific quantities. I would like to order the following: There are many stores equidistant from me which I will have food delivered from. Not all stores have what I need. I want to obtain what I need with the fewest number of orders made. For example, ordering from Store #2 below is a wasted order, since I can complete my items in less orders by ordering from different stores. What is the name of the optimization algorithm that solves this? Store #1 Supply Store #2 Supply 1 Orange Juice 2 Steaks 1 Soup Store #3 Supply 25 Soup 50 Orange Juices Store #4 Supply 25 Steaks 10 Yams The lowest possible orders is 3 in this case. 8 Apples from Store #1. 2 Soup and 20 Orange Juice from Store #3. 1 Yam and 3 Steaks from Store #4. 3 Traveling apple?

SQL Server : Breaking Comma Delimited String and matching values in a table

Image
Clash Royale CLAN TAG #URR8PPP SQL Server : Breaking Comma Delimited String and matching values in a table I am using SQL Server and have a "tags" column that has a string of of comma-separated tags. Is there a way to break the string up and place in another table and have them match to be able to easily see liked tags? Row 1: 3years_andmore,access_ccc,access_sdl,associate_iii,ccc_tickets,desoto_counter,phone_call__property_tax,ticketing,trainer Row 2: 3years_andmore,access_ccc,access_sdl,associate_iii,ccc_tickets,desoto_counter,phone_call__dmv,ticketing,trainer Row 3: 5_minutes,access_ccc,access_sdl,associate_ii,ccc_tickets,desoto_counter,lessthan_3years,phone_call__operations___title_by_mail_inquiry,trainer Row4: access_ccc,access_sdl,associate_ii,ccc_customer_request_manager_other,ccc_tickets,desoto_counter,lessthan_3years,phone_call__associate_requesting_manager__customer_requesting_mr_brierton,trainer There is no real order and not the same tags in field but is t

how to loop over multiple registers in linux device tree node?

Image
Clash Royale CLAN TAG #URR8PPP how to loop over multiple registers in linux device tree node? I implemented a generic driver, in the driver I just want to go over each registered device and do something. my driver is generic so I don't want to know anything in advance about the devices. I have some device tree nodes: uart0: uart@1000000 compatible = "generic-driver"; reg = <0x1000000 0x1000>,<0x1001000 0x1000>,<0x1002000 0x1000>; ; uart1: uart@2000000 compatible = "generic-driver"; reg = <0x2000000 0x1000>,<0x2001000 0x1000>,<0x2002000 0x1000>; ; in the driver I know how to get first offset and size with platform_get_resource, but what if I have multiple ranges? I saw an option to get it by add reg-names: reg = <0x2000000 0x1000>,<0x2001000 0x1000>,<0x2002000 0x1000>; reg-names = "uart0_0","urat0_1","uart0_2"; so in the driver I can use platform_get_resource_byname, but

prefix to infix in C

Image
Clash Royale CLAN TAG #URR8PPP prefix to infix in C #include<stdio.h> #include <stdlib.h> #include <string.h> struct Node char* data; struct Node* next; ; typedef struct Node NODE; NODE* push(NODE* top, char* item) NODE* newNode; newNode=(NODE*)malloc(sizeof(NODE)); newNode->next=NULL; newNode->data=item; if(top==NULL) top=newNode; else newNode->next=top; top=newNode; return top; char pop(NODE* top) NODE* temp=top; int i, returnValue; if(top==NULL) return top; returnValue=''; else top=top->next; returnValue=temp->data; free(temp); return returnValue; void display(NODE* top) NODE* temp=top; while(temp->next!=NULL) printf("%c",temp->data); temp=temp->next; printf("n"); int isOperator(char c) switch(c) case '*': case '/': case '+': case '-': return 1; return 0; char* prefix_to_infix(char* expression) NODE* top; top=(NODE*)malloc(sizeof(NODE));

getting current logged in user - symfony 4

Image
Clash Royale CLAN TAG #URR8PPP getting current logged in user - symfony 4 public function agencyHome(EntityManagerInterface $em) $repository = $em->getRepository(Ships::class); // $ships = $repository->findByOwner($own); $ships = $repository->findAll(); return $this->render('agency/index.html.twig', [ 'ships' => $ships, ]); on the code above i need to pass current logged in user to a repository, so i can find all related "ships" i tried with $u = $this->getUser()->getId(); with no succes :( thank you in advance :) In what context are you trying to get the current user - is this on the controller layer or the service layer? – Jason Ilicic Aug 12 at 6:48 in this controller which extends AbstractController – Alexander Br. Aug 12 at 6:52 In general. when using the Doctrine ORM you will never access or use the id. Might need to review the basics. – Cerad Aug 12 at 13:54 let's say i want to post a comment by

Postgres query issue with price matching with two tables

Image
Clash Royale CLAN TAG #URR8PPP Postgres query issue with price matching with two tables I have two tables, one is buy table and second is sell table. Buy Table id price qty in_status dt_added_at 1 10 15 1 2018-08-10 12:00:00+05:30 2 10 20 1 2018-08-10 13:00:00+05:30 3 12 15 1 2018-08-10 14:00:00+05:30 4 15 20 1 2018-08-10 15:00:00+05:30 Sell Table id price qty in_status dt_added_at 1 15 20 1 2018-08-10 12:00:00+05:30 2 12 15 1 2018-08-10 13:00:00+05:30 3 10 15 1 2018-08-10 14:00:00+05:30 4 10 20 1 2018-08-10 15:00:00+05:30 5 10 15 1 2018-08-10 16:00:00+05:30 Applied query of price matching table SELECT buy.*, sell.* FROM buy LEFT JOIN sell ON buy.price = sell.price AND buy.qty = sell.qty WHERE buy.price = 10 AND buy.in_status = 1 AND sell.price = 10 AND sell.in_status = 1 GROUP BY buy.id, sell.id, buy.dt_added_at, sell.dt_added_at ORDER BY buy.id, sell.id Actual Output id price qty in_status dt_added_at id price qty in_status dt_added_at 1 10 15 1 2018-08-10 12:00:00+05:30 3 10 1

How to use pretrained models in tensorflow estimator api?

Image
Clash Royale CLAN TAG #URR8PPP How to use pretrained models in tensorflow estimator api? There are many pretrained models available online, how to include those model in the tensorflow estimator api with other layers? I want to specifically use the estimator api as it distributes the the execution of the graph in different devices automatically. How to include the pretrained model for end to end training ? By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

submit input text into table as

Image
Clash Royale CLAN TAG #URR8PPP submit input text into table as <td> Ive been looking online for super long and I haven't been able to find an answer to something that seems super common. Basically what I want to do is submit input text and maybe also if a radio button or something like that is checked to popup as text in a table as here are some photos of the inputs and the table. I want to be able to press the "+" or "add" button and have all the text from the inputs added into the table and if the radio is checked (checked= true(something like that)) for it all to show up in the table when I press the add button. Here is my HTML for the example photo: <div class="bg"> <button id="droplist-btn" class="droplist-btn">Add By Droplist</button> <form> <input type="text" id="item-code-input" class="item-code-input" placeholder=""></input> <butto