qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
892,262
I am facing problem in loading data. I have to copy 800,000 rows from one table to another in Oracle database. I tried for 10,000 rows first but the time it took is not satisfactory. I tried using the "BULK COLLECT" and "INSERT INTO SELECT" clause but for both the cases response time is around 35 minutes. This is not the desired response I'm looking for. Does anyone have any suggestions?
2009/05/21
[ "https://Stackoverflow.com/questions/892262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Anirban, Using an "INSERT INTO SELECT" is the fastest way to populate your table. You may want to extend it with one or two of these hints: * APPEND: to use direct path loading, circumventing the buffer cache * PARALLEL: to use parallel processing if your system has multiple cpu's and this is a one-time operation or an operation that takes place at a time when it doesn't matter that one "selfish" process consumes more resources. Just using the append hint on my laptop copies 800,000 very small rows below 5 seconds: ``` SQL> create table one_table (id,name) 2 as 3 select level, 'name' || to_char(level) 4 from dual 5 connect by level <= 800000 6 / Tabel is aangemaakt. SQL> create table another_table as select * from one_table where 1=0 2 / Tabel is aangemaakt. SQL> select count(*) from another_table 2 / COUNT(*) ---------- 0 1 rij is geselecteerd. SQL> set timing on SQL> insert /*+ append */ into another_table select * from one_table 2 / 800000 rijen zijn aangemaakt. Verstreken: 00:00:04.76 ``` You mention that this operation takes 35 minutes in your case. Can you post some more details, so we can see what exactly is taking 35 minutes? Regards, Rob.
I would agree with Rob. Insert into () select is the fastest way to do this. What exactly do you need to do? If you're trying to do a table rename by copying to a new table and then deleting the old, you might be better off doing a table rename: ``` alter table table rename to someothertable; ```
892,262
I am facing problem in loading data. I have to copy 800,000 rows from one table to another in Oracle database. I tried for 10,000 rows first but the time it took is not satisfactory. I tried using the "BULK COLLECT" and "INSERT INTO SELECT" clause but for both the cases response time is around 35 minutes. This is not the desired response I'm looking for. Does anyone have any suggestions?
2009/05/21
[ "https://Stackoverflow.com/questions/892262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Anirban, Using an "INSERT INTO SELECT" is the fastest way to populate your table. You may want to extend it with one or two of these hints: * APPEND: to use direct path loading, circumventing the buffer cache * PARALLEL: to use parallel processing if your system has multiple cpu's and this is a one-time operation or an operation that takes place at a time when it doesn't matter that one "selfish" process consumes more resources. Just using the append hint on my laptop copies 800,000 very small rows below 5 seconds: ``` SQL> create table one_table (id,name) 2 as 3 select level, 'name' || to_char(level) 4 from dual 5 connect by level <= 800000 6 / Tabel is aangemaakt. SQL> create table another_table as select * from one_table where 1=0 2 / Tabel is aangemaakt. SQL> select count(*) from another_table 2 / COUNT(*) ---------- 0 1 rij is geselecteerd. SQL> set timing on SQL> insert /*+ append */ into another_table select * from one_table 2 / 800000 rijen zijn aangemaakt. Verstreken: 00:00:04.76 ``` You mention that this operation takes 35 minutes in your case. Can you post some more details, so we can see what exactly is taking 35 minutes? Regards, Rob.
try to drop all indexes/constraints on your destination table and then re-create them after data load. use `/*+NOLOGGING*/` hint in case you use NOARCHIVELOG mode, or consider to do the backup right after the operation.
892,262
I am facing problem in loading data. I have to copy 800,000 rows from one table to another in Oracle database. I tried for 10,000 rows first but the time it took is not satisfactory. I tried using the "BULK COLLECT" and "INSERT INTO SELECT" clause but for both the cases response time is around 35 minutes. This is not the desired response I'm looking for. Does anyone have any suggestions?
2009/05/21
[ "https://Stackoverflow.com/questions/892262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
INSERT INTO SELECT is the fastest way to do it. If possible/necessary, disable all indexes on the target table first. If you have no existing data in the target table, you can also try CREATE AS SELECT.
try to drop all indexes/constraints on your destination table and then re-create them after data load. use `/*+NOLOGGING*/` hint in case you use NOARCHIVELOG mode, or consider to do the backup right after the operation.
892,262
I am facing problem in loading data. I have to copy 800,000 rows from one table to another in Oracle database. I tried for 10,000 rows first but the time it took is not satisfactory. I tried using the "BULK COLLECT" and "INSERT INTO SELECT" clause but for both the cases response time is around 35 minutes. This is not the desired response I'm looking for. Does anyone have any suggestions?
2009/05/21
[ "https://Stackoverflow.com/questions/892262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
INSERT INTO SELECT is the fastest way to do it. If possible/necessary, disable all indexes on the target table first. If you have no existing data in the target table, you can also try CREATE AS SELECT.
As with the above, I would recommend the `Insert INTO ... AS select ....` or `CREATE TABLE ... AS SELECT ...` as the fastest way to copy a large volume of data between two tables. You want to look up the direct-load insert in your oracle documentation. This adds two items to your statements: parallel and nologging. Repeat the tests but do the following: ``` CREATE TABLE Table2 AS SELECT * FROM Table1 where 1=2; ALTER TABLE Table2 NOLOGGING; ALTER TABLE TABLE2 PARALLEL (10); ALTER TABLE TABLE1 PARALLEL (10); ALTER SESSION ENABLE PARALLEL DML; INSERT INTO TABLE2 SELECT * FROM Table 1; COMMIT; ALTER TABLE 2 LOGGING: ``` This turns off the rollback logging for inserts into the table. If the system crashes, there's not recovery and you can't do a rollback on the transaction. The PARALLEL uses N worker thread to copy the data in blocks. You'll have to experiment with the number of parallel worker threads to get best results on your system.
892,262
I am facing problem in loading data. I have to copy 800,000 rows from one table to another in Oracle database. I tried for 10,000 rows first but the time it took is not satisfactory. I tried using the "BULK COLLECT" and "INSERT INTO SELECT" clause but for both the cases response time is around 35 minutes. This is not the desired response I'm looking for. Does anyone have any suggestions?
2009/05/21
[ "https://Stackoverflow.com/questions/892262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would agree with Rob. Insert into () select is the fastest way to do this. What exactly do you need to do? If you're trying to do a table rename by copying to a new table and then deleting the old, you might be better off doing a table rename: ``` alter table table rename to someothertable; ```
Is the table you are copying to the same structure as the other table? Does it have data or are you creating a new one? Can you use exp/imp? Exp can be give a query to limit what it exports and then imported into the db. What is the total size of the table you are copying from? If you are copying most of the data from one table to a second, can you instead copy the full table using exp/imp and then remove the unwanted rows which would be less than copying.
892,262
I am facing problem in loading data. I have to copy 800,000 rows from one table to another in Oracle database. I tried for 10,000 rows first but the time it took is not satisfactory. I tried using the "BULK COLLECT" and "INSERT INTO SELECT" clause but for both the cases response time is around 35 minutes. This is not the desired response I'm looking for. Does anyone have any suggestions?
2009/05/21
[ "https://Stackoverflow.com/questions/892262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Anirban, Using an "INSERT INTO SELECT" is the fastest way to populate your table. You may want to extend it with one or two of these hints: * APPEND: to use direct path loading, circumventing the buffer cache * PARALLEL: to use parallel processing if your system has multiple cpu's and this is a one-time operation or an operation that takes place at a time when it doesn't matter that one "selfish" process consumes more resources. Just using the append hint on my laptop copies 800,000 very small rows below 5 seconds: ``` SQL> create table one_table (id,name) 2 as 3 select level, 'name' || to_char(level) 4 from dual 5 connect by level <= 800000 6 / Tabel is aangemaakt. SQL> create table another_table as select * from one_table where 1=0 2 / Tabel is aangemaakt. SQL> select count(*) from another_table 2 / COUNT(*) ---------- 0 1 rij is geselecteerd. SQL> set timing on SQL> insert /*+ append */ into another_table select * from one_table 2 / 800000 rijen zijn aangemaakt. Verstreken: 00:00:04.76 ``` You mention that this operation takes 35 minutes in your case. Can you post some more details, so we can see what exactly is taking 35 minutes? Regards, Rob.
INSERT INTO SELECT is the fastest way to do it. If possible/necessary, disable all indexes on the target table first. If you have no existing data in the target table, you can also try CREATE AS SELECT.
892,262
I am facing problem in loading data. I have to copy 800,000 rows from one table to another in Oracle database. I tried for 10,000 rows first but the time it took is not satisfactory. I tried using the "BULK COLLECT" and "INSERT INTO SELECT" clause but for both the cases response time is around 35 minutes. This is not the desired response I'm looking for. Does anyone have any suggestions?
2009/05/21
[ "https://Stackoverflow.com/questions/892262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would agree with Rob. Insert into () select is the fastest way to do this. What exactly do you need to do? If you're trying to do a table rename by copying to a new table and then deleting the old, you might be better off doing a table rename: ``` alter table table rename to someothertable; ```
As with the above, I would recommend the `Insert INTO ... AS select ....` or `CREATE TABLE ... AS SELECT ...` as the fastest way to copy a large volume of data between two tables. You want to look up the direct-load insert in your oracle documentation. This adds two items to your statements: parallel and nologging. Repeat the tests but do the following: ``` CREATE TABLE Table2 AS SELECT * FROM Table1 where 1=2; ALTER TABLE Table2 NOLOGGING; ALTER TABLE TABLE2 PARALLEL (10); ALTER TABLE TABLE1 PARALLEL (10); ALTER SESSION ENABLE PARALLEL DML; INSERT INTO TABLE2 SELECT * FROM Table 1; COMMIT; ALTER TABLE 2 LOGGING: ``` This turns off the rollback logging for inserts into the table. If the system crashes, there's not recovery and you can't do a rollback on the transaction. The PARALLEL uses N worker thread to copy the data in blocks. You'll have to experiment with the number of parallel worker threads to get best results on your system.
892,262
I am facing problem in loading data. I have to copy 800,000 rows from one table to another in Oracle database. I tried for 10,000 rows first but the time it took is not satisfactory. I tried using the "BULK COLLECT" and "INSERT INTO SELECT" clause but for both the cases response time is around 35 minutes. This is not the desired response I'm looking for. Does anyone have any suggestions?
2009/05/21
[ "https://Stackoverflow.com/questions/892262", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
INSERT INTO SELECT is the fastest way to do it. If possible/necessary, disable all indexes on the target table first. If you have no existing data in the target table, you can also try CREATE AS SELECT.
Is the table you are copying to the same structure as the other table? Does it have data or are you creating a new one? Can you use exp/imp? Exp can be give a query to limit what it exports and then imported into the db. What is the total size of the table you are copying from? If you are copying most of the data from one table to a second, can you instead copy the full table using exp/imp and then remove the unwanted rows which would be less than copying.
9,046,596
I have admin user with following five roles[ROLE\_ADMIN,ROLESWITCHUSER,ROLE\_DOCTOR,ROLE\_USER] and some **normal users** with only one role i.e ROLE\_USER ,now my question is how can i get only normal users from my secuser table i tried with somne iterations ``` def roleId=SecRole.findByAuthority("ROLE_USER") userInstance = SecUserSecRole.findAllBySecRole(roleId).secUser ``` here i got userInstance with all users along with adminuser now i tried to elminate adminuser from my userInstance and saved it in selectUserMap but am getting result for sometime and sometimes its giving all users. I think the sort() function not sorting the userinstansce roles please help me ``` for(int i=0;i<userInstance.size();i++) { println( "am in loop "+i+userInstance[i].username+"roles"+userInstance[i].getAuthorities()) def x=(userInstance[i].getAuthorities().sort()) for(a in x ) { //println(a.getAuthority()) if((a.getAuthority() == use)) abc=true else abc=false if((a.getAuthority() == adm)) { println("break") break; } abc=(abc && (a.getAuthority() == use)) if(abc) { println("am in true if ") selectUserMap.add(j,userInstance[i]) j=j+1 } else { println("am in else") } } } println("==============all users "+selectUserMap) ```
2012/01/28
[ "https://Stackoverflow.com/questions/9046596", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1170646/" ]
One thing that would help is to use hierarchical roles - see section "14 Hierarchical Roles" at <http://grails-plugins.github.com/grails-spring-security-core/docs/manual/> - and then you wouldn't grant `ROLE_USER` to anyone but "real" users. If you define your hierarchy like this: ``` grails.plugins.springsecurity.roleHierarchy = ''' ROLE_ADMIN > ROLE_USER ROLE_DOCTOR > ROLE_USER ROLE_ADMIN > ROLE_DOCTOR ''' ``` then you don't need to explicitly grant `ROLE_USER` in the database to either a doctor or an admin, but the role will be inferred as granted. Then your original query will work: ``` def userRole = SecRole.findByAuthority("ROLE_USER") def usersWithUserRole = SecUserSecRole.findAllBySecRole(userRole).secUser ``` If you can't or don't want to do this, then you should use a proper database query. It's extremely and unnecessarily expensive to load every user and every user's roles from the database and filter them out in your application. Use this HQL query: ``` def userRole = SecRole.findByAuthority("ROLE_USER") def users = SecUserSecRole.executeQuery( 'select u from SecUser u where ' + '(select count(ur.user) from SecUserSecRole ur where ur.user=u)=1 and ' + '(:r in (select ur.role from SecUserSecRole ur where ur.user=u))', [r: userRole]) ```
Oh, you've choosen really complicated way, can understand your algorhitm :( Maybe this is enough: ``` List selectUserList = userInstance.findAll { List roles = it.authorities*.authority return roles.contains('ROLE_USER') && !roles.contains('ROLE_ADMIN') } ``` I guess you can build `selectUserMap` from this `selectUserList` list (can't understand where you get `j`) PS maybe it's better to rename `userInstance` to `userInstances`, because it's a list actually, not one instance?
42,437,889
I am unable to read checkbox value in ionic 2 i tried following code ``` <div class="form-group"> <label ></label> <div *ngFor="let mydata of activity" > <label> <input type="checkbox" name="activity" value="{{mydata.activity_id}}" [checked]="activity.includes(mydata)" (change)="changeSchedules(mydata)" /> {{mydata.activity_name}} </label> </div> </div> ``` script file ``` this.subscriptionForm = new FormGroup({ activity: new FormArray(this.subscription.schedules.map(schedule => new FormControl(schedule)), Validators.minLength(1)) }); changeSchedules(mydata: any) { var currentScheduleControls: FormArray = this.subscriptionForm.get('activity') as FormArray; var index = currentScheduleControls.value.indexOf(mydata); if(index > -1) {currentScheduleControls.removeAt(index) } else { currentScheduleControls.push(new FormControl(mydata)); } } ``` i searche so many things but i did not get proper solution can somebody help to figure out this
2017/02/24
[ "https://Stackoverflow.com/questions/42437889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7477025/" ]
All you need to do is to use `.map` and fetch products ``` var product = json.OrderLine.map(function(el){ return {"Product": el.Product, "TotalValue":el.TotalValue, "Quantity":el.Quantity}; }); var rebuild = { "Message": "string", "Balance": 0, "OrderId": 10, "SiteId": 1234, "OrderLine": product, "CustomData": {} } ``` Try this [fiddle](https://jsfiddle.net/Lz3v9psp/5/)
You can access object using key.. Try this ``` var product = $.map(oldJson, function (data, key) { if (key == "OrderLine") return data; }); ```
42,437,889
I am unable to read checkbox value in ionic 2 i tried following code ``` <div class="form-group"> <label ></label> <div *ngFor="let mydata of activity" > <label> <input type="checkbox" name="activity" value="{{mydata.activity_id}}" [checked]="activity.includes(mydata)" (change)="changeSchedules(mydata)" /> {{mydata.activity_name}} </label> </div> </div> ``` script file ``` this.subscriptionForm = new FormGroup({ activity: new FormArray(this.subscription.schedules.map(schedule => new FormControl(schedule)), Validators.minLength(1)) }); changeSchedules(mydata: any) { var currentScheduleControls: FormArray = this.subscriptionForm.get('activity') as FormArray; var index = currentScheduleControls.value.indexOf(mydata); if(index > -1) {currentScheduleControls.removeAt(index) } else { currentScheduleControls.push(new FormControl(mydata)); } } ``` i searche so many things but i did not get proper solution can somebody help to figure out this
2017/02/24
[ "https://Stackoverflow.com/questions/42437889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7477025/" ]
You can try the following each loop: ```js var json = { "Message": "string", "Balance": 0, "OrderId": 94, "SiteId": 1234, "OrderLine": [{ "Id": "e672f84e-4b97-4cd7-826a-d0e57247ffe3", "Product": { "Id": 21, "Codes": [ "1112" ], "Sku": "CS1112" }, "Description": "testing 123", "QuantityRequired": 1, "QuantityPicked": 0, "SourceSite": { "Id": 1, "PropertyCode": "", "StoreCode": "1" }, "Status": "Preparing", "TotalOriginalValue": 0, "TotalAdjustedValue": 0, "AdjustmentReference": null, "Note": null, "PromotionLines": [ ], "Taxes": [ ], "CancellationReason": null, "QuantityIssued": 0, "TotalPaidAmount": null, "CustomData": { } }, { "Id": "c9f18678-11f0-4fbb-afe4-db926ae97d04", "Product": { "Id": 9, "Codes": [ "1113" ], "Sku": "CS1113" }, "Description": "testing 123", "QuantityRequired": 1, "QuantityPicked": 0, "SourceSite": { "Id": 1, "PropertyCode": "", "StoreCode": "1" }, "Status": "Preparing", "TotalOriginalValue": 0, "TotalAdjustedValue": 0, "AdjustmentReference": null, "Note": null, "PromotionLines": [ ], "Taxes": [ ], "CancellationReason": null, "QuantityIssued": 0, "TotalPaidAmount": null, "CustomData": { } } ], "CustomData": { } } $.each(json.OrderLine, function(i, v) { json.OrderLine[i] = {"product":v.Product,"TotalValue": v.TotalOriginalValue, "Quantity": v.QuantityRequired} }); console.log(json) ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> ``` or using for loop: ```js var json = { "Message": "string", "Balance": 0, "OrderId": 94, "SiteId": 1234, "OrderLine": [{ "Id": "e672f84e-4b97-4cd7-826a-d0e57247ffe3", "Product": { "Id": 21, "Codes": [ "1112" ], "Sku": "CS1112" }, "Description": "testing 123", "QuantityRequired": 1, "QuantityPicked": 0, "SourceSite": { "Id": 1, "PropertyCode": "", "StoreCode": "1" }, "Status": "Preparing", "TotalOriginalValue": 0, "TotalAdjustedValue": 0, "AdjustmentReference": null, "Note": null, "PromotionLines": [ ], "Taxes": [ ], "CancellationReason": null, "QuantityIssued": 0, "TotalPaidAmount": null, "CustomData": { } }, { "Id": "c9f18678-11f0-4fbb-afe4-db926ae97d04", "Product": { "Id": 9, "Codes": [ "1113" ], "Sku": "CS1113" }, "Description": "testing 123", "QuantityRequired": 1, "QuantityPicked": 0, "SourceSite": { "Id": 1, "PropertyCode": "", "StoreCode": "1" }, "Status": "Preparing", "TotalOriginalValue": 0, "TotalAdjustedValue": 0, "AdjustmentReference": null, "Note": null, "PromotionLines": [ ], "Taxes": [ ], "CancellationReason": null, "QuantityIssued": 0, "TotalPaidAmount": null, "CustomData": { } } ], "CustomData": { } } for (var i = 0; i < json.OrderLine.length; i++) { json.OrderLine[i] = { "product": json.OrderLine[i].Product, "TotalValue": json.OrderLine[i].TotalOriginalValue, "Quantity": json.OrderLine[i].QuantityRequired } } console.log(json) ```
You can access object using key.. Try this ``` var product = $.map(oldJson, function (data, key) { if (key == "OrderLine") return data; }); ```
39,971,264
Good Day! I have a dropdown menu which select employee number and shows table data on basis of that particular selection. I have save as pdf code which saves table data in pdf. It is working fine but my table column headers are only shown not the values. I have dropdown in one file having javascript which is sent to another file where my table is shown. Below is the code for my all files and what I have tried for this so far. **For Dropdown:** ``` <?php include("connect-db.php"); ?> <html> <head> <title>PHP insertion</title> <link rel="stylesheet" href="css/insert.css" /> <link rel="stylesheet" href="css/navcss.css" /> <script> function showUser(str) { if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } else { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("txtHint").innerHTML = xmlhttp.responseText; } }; xmlhttp.open("GET","search_empnumber.php?emp_id="+str,true); xmlhttp.send(); } } /*function showAssessories(acc) { if (acc == "") { document.getElementById("txtHint2").innerHTML = ""; return; } else { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("txtHint2").innerHTML = xmlhttp.responseText; } }; xmlhttp.open("GET","getassessories.php?emp_id="+acc,true); xmlhttp.send(); } }*/ </script> </head> <body> <div class="maindiv"> <?php include("includes/head.php");?> <?php include("menu.php");?> <div class="form_div"> <form> <div class="forscreen"> <h1>Search Records:</h1> <p>You may search by Employee Number</p> <select name="employeenumber" class="input" onchange="showUser(this.value)"> <option value="">Please Select Employee Number:</option> </div> <?php $select_emp="SELECT distinct(emp_number) FROM employees"; $run_emp=mysql_query($select_emp); while($row=mysql_fetch_array($run_emp)){ $emp_id=$row['emp_id']; $first_name=$row['first_name']; $last_name=$row['last_name']; $emp_number=$row['emp_number']; $total_printers=$row['total_printers']; $total_scanners=$row['total_scanners']; $total_pc=$row['total_pc']; $total_phones=$row['total_phones']; $other_equips=$row['other_equips']; ?> <option value="<?php echo $emp_number;?>"><?php echo $emp_number;?></option> <?php } ?> </select> <html> </form> </div> <br> <div id="txtHint"></div> <br> <div id="txtHint2"></div> </div> <?php include 'includes/foot.php';?> </body> </html> ``` **The function for dropdown: onchange="showUser(this.value)"** ``` function showUser(str) { if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } else { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("txtHint").innerHTML = xmlhttp.responseText; } }; xmlhttp.open("GET","search_empnumber.php?emp_id="+str,true); xmlhttp.send(); } } ``` **search\_empnumber.php File:** ``` <!DOCTYPE html> <html> <form action="search_empnumber.php" method="POST"> <input type="submit" value="SAVE AS PDF" class="btnPDF" name="submit" /> </form> <head> <style> table { width: 100%; border-collapse: collapse; } table, td, th { border: 1px solid black; padding: 5px; } th {text-align: left;} .link{ color:#00F; cursor:pointer;} </style> </head> <body> <?php //$emp_id =($_REQUEST['emp_id']); $emp_id =($_REQUEST['emp_id']); $count=1; include("connect-db.php"); //$sql = "SELECT * from employees where department='".$department."'"; //$sql = "select * from employees as pg inner join accessories as pd on pg.emp_number= pd.emp_number "; //$result = mysql_query($sql) or die(mysql_error()); //$result = mysql_query($query) or die(mysql_error()); //$emp_id =($_POST['employeenumber']); $sql="SELECT * FROM employees WHERE emp_number = '".$emp_id."'"; $result = mysql_query($sql) or die(mysql_error()); $count=1; echo "<table> <tr> <th>S.No</th> <th>First Name</th> <th>Last Name</th> <th>Employee Number</th> <th>Department</th> <th>Email</th> <th>Total Printers</th> <th>Total Scanners</th> <th>Total Pc</th> <th>Total Phones</th> <th>Other Equipments</th> </tr>"; while($row = mysql_fetch_array($result)){ echo "<tr>"; echo "<td>" . $count . "</td>"; echo "<td>" . $row['first_name'] . "</td>"; echo "<td>" . $row['last_name'] . "</td>"; echo "<td>" . $row['emp_number'] . "</td>"; echo "<td>" . $row['department'] . "</td>"; echo "<td>" . $row['email'] . "</td>"; echo "<td>" . $row['total_printers'] . "</td>"; echo "<td>" . $row['total_scanners'] . "</td>"; echo "<td>" . $row['total_pc'] . "</td>"; echo "<td>" . $row['total_phones'] . "</td>"; echo "<td>" . $row['other_equips'] . "</td>"; echo "</tr>"; $count++; } echo "</table>"; echo '<div class="forscreen">'; // echo '<br />';echo '<button class="btnPrint" type="submit" value="Submit" onclick="window.print()">Print</button>'; //echo '<input type="submit" value="SAVE AS PDF" class="btnPDFsearch" name="submit"/>'; // echo '<input type="submit" value="SAVE AS PDF" class="btnPDF" name="submit" />'; echo '</div>'; echo '<div class="forscreen">'; //echo '<br />';echo '<button class="btnPrevious" type="submit" value="Submit" onclick="history.back(); return false;">Previous Page</button>'; echo '</div>'; ?> </body> </html> ``` **PDF code (I tried) in same file of search\_empnumber:** ``` <?php error_reporting(E_ALL ^ E_DEPRECATED); include('connect-db.php'); ?> <?php //if($_POST['submit']){ if (isset($_POST['submit'])){ require_once 'includes/practice.php'; $pdf->SetFont('times', '', 11); $tb1 = '</br></br> <table cellspacing="0" cellpadding="5" border="1"> <tr style="background-color:#f7f7f7;color:#333; "> <td width="60">First Name</td> <td width="60">Last Name</td> <td width="80">Employee Number</td> <td width="80">Department</td> <td width="60">Email</td> <td width="80">Total Printers</td> <td width="80">Total Scanners</td> <td width="60">Total PCs</td> <td width="60">Total Phones</td> <td width="60">Other Equipments</td> </tr> </table>'; include('connect-db.php'); //$emp_id =($_POST['emp_id']); $emp_id =($_POST['employeenumber']); $result1= mysql_query("SELECT * FROM employees where emp_number = '".$emp_id."'"); while($row = mysql_fetch_assoc($result1)){ $tb2 = '<table cellspacing="0" cellpadding="5" border="1"> <tr> <td width="60">' . $row['first_name'] . '</td> <td width="60">' . $row['last_name'] . '</td> <td width="80">'. $row['emp_number'] .'</td> <td width="80">'.$row['department'].'</td> <td width="60">'.$row['email'].'</td> <td width="80">'.$row['total_printers'].'</td> <td width="80">'.$row['total_scanners'].'</td> <td width="60">'.$row['total_pc'].'</td> <td width="60">'.$row['total_phones'].'</td> <td width="60">'.$row['other_equips'].'</td> </tr> </table>'; $tb1 = $tb1.$tb2; } $pdf->writeHTML($tb1, true, false, false, false, ''); ob_end_clean(); $pdf->Output('Report.pdf', 'D'); } ?> ``` The files i.e. practoce.php and pdf libraries are not added becuase they are just creating tables in defined formats
2016/10/11
[ "https://Stackoverflow.com/questions/39971264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3478450/" ]
You can disable the csrf check on the login uri by editing the `VerifyCsrfToken` class of your Laravel app: ``` class VerifyCsrfToken extends BaseVerifier { /** * The URIs that should be excluded from CSRF verification. * * @var array */ protected $except = [ 'login/*', // Your route url here ]; } ``` This will make the ajax call to the login route vulnerable to csrf-attacks, but will solve your problem. See it as a workaround / quick fix. What you **really** want to do, is to provide the login via an api-call. Since you are using another app to access the laravel app. This is what API's are meant to be used for. Laravel routes are default handled by the `web` middleware group, which includes the `VerifyCsrfToken` class. What you want to do is specify a new middleware group for you api-calls, which does not include any csrf-checks. I would consider using a package for this, e.g. <https://github.com/tymondesigns/jwt-auth>
If you need to send more information with javascript try this ``` jQuery.support.cors = true; $.ajax({ url: 'http://192.168.1.78/myproject/login', type: 'POST', dataType: dataType, data: data, crossDomain: true, cotentType: YOUR_CONTENT_TYPE, success: successCallback, error: errorCallback, beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', SOMETHING.val()); } }); ``` To make this script right for your needs, you should read about **CORS**, **crossDomain** and **xhr.setRequestHeader** You can also use Postman (Chrome extension) [xhr.setRequestHeader](https://msdn.microsoft.com/fr-fr/library/ms536752(v=vs.85).aspx) [Postman sample](http://www.java-success.com/chrome-postman-to-test-and-debug-restful-web-services/) ***EDIT***: Did you read this? [Token Mismatch Exception on Login (Laravel)](https://stackoverflow.com/questions/22066241/token-mismatch-exception-on-login-laravel) Regards,
2,185,188
Here is my query: ``` select * from (select *, 3956 * 2 * ASIN(SQRT(POWER(SIN(RADIANS(45.5200077 - lat)/ 2), 2) + COS(RADIANS(45.5200077)) * COS(RADIANS(lat)) * POWER(SIN(RADIANS(-122.6942014 - lng)/2),2))) AS distance from stops order by distance, route asc) as p group by route, dir order by distance asc limit 10 ``` This works fine at the command line and in PHPMyAdmin. I'm using [Dbslayer](http://code.nytimes.com/projects/dbslayer/wiki) to connect to MySQL via my JavaScript backend, and the request is returning a 1064 error. Here is the encoded DBSlayer request string: > > <http://localhost:9090/db>?{%22SQL%22:%22select%20\*%20from%20%28select%20\*,%203956%20\*%202%20\*%20ASIN%28SQRT%28POWER%28SIN%28RADIANS%2845.5200077%20-%20lat%29/%202%29,%202%29%20+%20COS%28RADIANS%2845.5200077%29%29%20\*%20COS%28RADIANS%28lat%29%29%20\*%20POWER%28SIN%28RADIANS%28-122.6942014%20-%20lng%29/2%29,2%29%29%29%20AS%20distance%20from%20%60stops%60%20order%20by%20%60distance%60,%20%60route%60%20asc%29%20as%20p%20group%20by%20%60route%60,%20%60dir%60%20order%20by%20%60distance%60%20asc%20limit%2010%22} > > > And the response: > > {"MYSQL\_ERRNO" : 1064 , "MYSQL\_ERROR" : "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(RADIANS(45.5200077)) \* COS(RADIANS(lat)) \* POWER(SIN(RADIANS(-122.6942014 - lng' at line 1" , "SERVER" : "trimet"} > > > Thanks!
2010/02/02
[ "https://Stackoverflow.com/questions/2185188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would suggest that you take a look at Vanilla Forums: <http://vanillaforums.org/>
I'm biased but I'd recommend looking at Drupal - you seem to want to build a customized system out of existing components and Drupal's module architecture lets you do this quite easily. There are lots of resources on the web for learning how to build community sites with Drupal that a quick Google search will bring up. You can then use modules like the [User Karma](http://drupal.org/project/user_karma) module to create a reputation system
2,185,188
Here is my query: ``` select * from (select *, 3956 * 2 * ASIN(SQRT(POWER(SIN(RADIANS(45.5200077 - lat)/ 2), 2) + COS(RADIANS(45.5200077)) * COS(RADIANS(lat)) * POWER(SIN(RADIANS(-122.6942014 - lng)/2),2))) AS distance from stops order by distance, route asc) as p group by route, dir order by distance asc limit 10 ``` This works fine at the command line and in PHPMyAdmin. I'm using [Dbslayer](http://code.nytimes.com/projects/dbslayer/wiki) to connect to MySQL via my JavaScript backend, and the request is returning a 1064 error. Here is the encoded DBSlayer request string: > > <http://localhost:9090/db>?{%22SQL%22:%22select%20\*%20from%20%28select%20\*,%203956%20\*%202%20\*%20ASIN%28SQRT%28POWER%28SIN%28RADIANS%2845.5200077%20-%20lat%29/%202%29,%202%29%20+%20COS%28RADIANS%2845.5200077%29%29%20\*%20COS%28RADIANS%28lat%29%29%20\*%20POWER%28SIN%28RADIANS%28-122.6942014%20-%20lng%29/2%29,2%29%29%29%20AS%20distance%20from%20%60stops%60%20order%20by%20%60distance%60,%20%60route%60%20asc%29%20as%20p%20group%20by%20%60route%60,%20%60dir%60%20order%20by%20%60distance%60%20asc%20limit%2010%22} > > > And the response: > > {"MYSQL\_ERRNO" : 1064 , "MYSQL\_ERROR" : "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(RADIANS(45.5200077)) \* COS(RADIANS(lat)) \* POWER(SIN(RADIANS(-122.6942014 - lng' at line 1" , "SERVER" : "trimet"} > > > Thanks!
2010/02/02
[ "https://Stackoverflow.com/questions/2185188", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I would suggest that you take a look at Vanilla Forums: <http://vanillaforums.org/>
Pligg, open source, seems pretty useful for features such as voting up and down posts <http://www.pligg.com/about.php> . BBpress <http://bbpress.org/> , integrates with Wordpress and allows for plug ins. Also, <https://stackexchange.com/> looks interesting!
28,207,101
How to make ListView Item Selection remain stable ? ``` <ListView android:id="@+id/list_slidermenu" android:layout_height="0dp" android:layout_width="match_parent" android:layout_weight="8" android:layout_gravity="start" android:scrollbars="none" android:fastScrollEnabled="true" android:choiceMode="singleChoice" /> ```
2015/01/29
[ "https://Stackoverflow.com/questions/28207101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1859489/" ]
You've to make `getSelectedIndex()` and `setSelectedIndex()` method in your adapter. ``` private int selectedIndex; public int getSelectedIndex() { return selectedIndex; } public void setSelectedIndex(int index) { this.selectedIndex = index; // Re-draw the list by informing the view of the changes notifyDataSetChanged(); } ``` and then ``` @Override public View getView(int position, View convertView, ViewGroup parent) { ....... // Highlight the selected item in the list if (selectedIndex != -1 && selectedIndex == position) { v.setBackgroundResource(R.color.yourColor); } return v; } ``` and used from `onListItemClick(....)` ``` adapter.setSelectedIndex(position); ``` Another way as @Sun said ------------------------ Used gradient to make list selection remain stable **gradient\_bg.xml:-** ``` <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#7ecce8" android:centerColor="#7ecce8" android:endColor="#7ecce8" /> </shape> ``` **gradient\_bg\_hover.xml:-** ``` <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#7ecce8" android:centerColor="#7ecce8" android:endColor="#7ecce8" /> </shape> ``` **list\_selector.xml:-** ``` <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/gradient_bg" /> <item android:state_pressed="true" android:drawable="@drawable/gradient_bg_hover" /> <item android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/gradient_bg_hover" /> </selector> ``` finally in `ListView`, use `listSelector` property like below: ``` android:listSelector="@drawable/list_selector" ```
> > You need to keep track of selected item and accordingly change the background of the list row. > > > 1.Change the selected item's position in item click : ``` @Override public void onItemSelected(AdapterView<?> arg0, View arg1,int position, long arg3) { adapter.setSelectedItem(position); } ``` 2.Get selected item and set background : ``` public class AudioAdapter extends ArrayAdapter<Audio> { Integer selected_position = -1; @Override public View getView(int position, View convertView, ViewGroup parent) { // Your Code if (position == selected_position) { // set selected color v.setBackgroundResource(R.color.yourSelectedColor); } else { // set default color v.setBackgroundResource(R.color.yourDefaultColor); } } public int getSelectedItem() { return selected_position; } public void setSelectedItem(int index) { this.selected_position = index; } } ``` Hope it helps ツ
28,207,101
How to make ListView Item Selection remain stable ? ``` <ListView android:id="@+id/list_slidermenu" android:layout_height="0dp" android:layout_width="match_parent" android:layout_weight="8" android:layout_gravity="start" android:scrollbars="none" android:fastScrollEnabled="true" android:choiceMode="singleChoice" /> ```
2015/01/29
[ "https://Stackoverflow.com/questions/28207101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1859489/" ]
You've to make `getSelectedIndex()` and `setSelectedIndex()` method in your adapter. ``` private int selectedIndex; public int getSelectedIndex() { return selectedIndex; } public void setSelectedIndex(int index) { this.selectedIndex = index; // Re-draw the list by informing the view of the changes notifyDataSetChanged(); } ``` and then ``` @Override public View getView(int position, View convertView, ViewGroup parent) { ....... // Highlight the selected item in the list if (selectedIndex != -1 && selectedIndex == position) { v.setBackgroundResource(R.color.yourColor); } return v; } ``` and used from `onListItemClick(....)` ``` adapter.setSelectedIndex(position); ``` Another way as @Sun said ------------------------ Used gradient to make list selection remain stable **gradient\_bg.xml:-** ``` <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#7ecce8" android:centerColor="#7ecce8" android:endColor="#7ecce8" /> </shape> ``` **gradient\_bg\_hover.xml:-** ``` <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#7ecce8" android:centerColor="#7ecce8" android:endColor="#7ecce8" /> </shape> ``` **list\_selector.xml:-** ``` <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/gradient_bg" /> <item android:state_pressed="true" android:drawable="@drawable/gradient_bg_hover" /> <item android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/gradient_bg_hover" /> </selector> ``` finally in `ListView`, use `listSelector` property like below: ``` android:listSelector="@drawable/list_selector" ```
I have used gradient to make list selection remain stable gradient\_bg.xml:- ``` <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#7ecce8" android:centerColor="#7ecce8" android:endColor="#7ecce8" /> </shape> ``` gradient\_bg\_hover.xml:- ``` <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#7ecce8" android:centerColor="#7ecce8" android:endColor="#7ecce8" /> </shape> ``` list\_selector.xml:- ``` <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/gradient_bg" /> <item android:state_pressed="true" android:drawable="@drawable/gradient_bg_hover" /> <item android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/gradient_bg_hover" /> </selector> ``` finally in ListView, use listSelector property like below: ``` android:listSelector="@drawable/list_selector" ```
28,207,101
How to make ListView Item Selection remain stable ? ``` <ListView android:id="@+id/list_slidermenu" android:layout_height="0dp" android:layout_width="match_parent" android:layout_weight="8" android:layout_gravity="start" android:scrollbars="none" android:fastScrollEnabled="true" android:choiceMode="singleChoice" /> ```
2015/01/29
[ "https://Stackoverflow.com/questions/28207101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1859489/" ]
I have used gradient to make list selection remain stable gradient\_bg.xml:- ``` <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#7ecce8" android:centerColor="#7ecce8" android:endColor="#7ecce8" /> </shape> ``` gradient\_bg\_hover.xml:- ``` <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:startColor="#7ecce8" android:centerColor="#7ecce8" android:endColor="#7ecce8" /> </shape> ``` list\_selector.xml:- ``` <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/gradient_bg" /> <item android:state_pressed="true" android:drawable="@drawable/gradient_bg_hover" /> <item android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/gradient_bg_hover" /> </selector> ``` finally in ListView, use listSelector property like below: ``` android:listSelector="@drawable/list_selector" ```
> > You need to keep track of selected item and accordingly change the background of the list row. > > > 1.Change the selected item's position in item click : ``` @Override public void onItemSelected(AdapterView<?> arg0, View arg1,int position, long arg3) { adapter.setSelectedItem(position); } ``` 2.Get selected item and set background : ``` public class AudioAdapter extends ArrayAdapter<Audio> { Integer selected_position = -1; @Override public View getView(int position, View convertView, ViewGroup parent) { // Your Code if (position == selected_position) { // set selected color v.setBackgroundResource(R.color.yourSelectedColor); } else { // set default color v.setBackgroundResource(R.color.yourDefaultColor); } } public int getSelectedItem() { return selected_position; } public void setSelectedItem(int index) { this.selected_position = index; } } ``` Hope it helps ツ
24,624,098
In Eclipse, I just imported an external `JAR`. Viewing any of the classes in the Package Explorer will instead of showing a source code open a Class File Editor with saying "Source not found". The folder of the JAR I have downloaded, however, has only `JAR`, no `lib`, no `src`, no `docs`. Is there still a way how to view/generate a view the source code so then I can view it in Eclipse properly?
2014/07/08
[ "https://Stackoverflow.com/questions/24624098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1079484/" ]
Try this : * Download java decompiler from <http://jd.benow.ca/> and now double click on *jd-gui* and click on open file. * Then open .jar file from that folder. * Now you get class files and save all these class files (click on file then click "save all sources" in jd-gui) by src name.
.jar files don't contain source code but are more like binary files for Java. You can either get the source code from the projects page (if it is an OpenSource project of course) An other possible way to view the source code of a .jar file is by using a decompiler (<http://jd.benow.ca/>; Also has a Eclipse plugin I think). This method can be very painful though when an obfuscator has been used by the developer who generated the .jar file.
24,624,098
In Eclipse, I just imported an external `JAR`. Viewing any of the classes in the Package Explorer will instead of showing a source code open a Class File Editor with saying "Source not found". The folder of the JAR I have downloaded, however, has only `JAR`, no `lib`, no `src`, no `docs`. Is there still a way how to view/generate a view the source code so then I can view it in Eclipse properly?
2014/07/08
[ "https://Stackoverflow.com/questions/24624098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1079484/" ]
.jar files don't contain source code but are more like binary files for Java. You can either get the source code from the projects page (if it is an OpenSource project of course) An other possible way to view the source code of a .jar file is by using a decompiler (<http://jd.benow.ca/>; Also has a Eclipse plugin I think). This method can be very painful though when an obfuscator has been used by the developer who generated the .jar file.
If possible I suggest you to use Maven for manage dependencies of your project, in most cases it did the trick for you. See: [Get source JARs from Maven repository](https://stackoverflow.com/questions/2059431/get-source-jars-from-maven-repository)
24,624,098
In Eclipse, I just imported an external `JAR`. Viewing any of the classes in the Package Explorer will instead of showing a source code open a Class File Editor with saying "Source not found". The folder of the JAR I have downloaded, however, has only `JAR`, no `lib`, no `src`, no `docs`. Is there still a way how to view/generate a view the source code so then I can view it in Eclipse properly?
2014/07/08
[ "https://Stackoverflow.com/questions/24624098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1079484/" ]
Try this : * Download java decompiler from <http://jd.benow.ca/> and now double click on *jd-gui* and click on open file. * Then open .jar file from that folder. * Now you get class files and save all these class files (click on file then click "save all sources" in jd-gui) by src name.
You cannot view the source form a .jar files as it contains binaries.Use a java decompiler instead to decompile the .class files and view their sources.
24,624,098
In Eclipse, I just imported an external `JAR`. Viewing any of the classes in the Package Explorer will instead of showing a source code open a Class File Editor with saying "Source not found". The folder of the JAR I have downloaded, however, has only `JAR`, no `lib`, no `src`, no `docs`. Is there still a way how to view/generate a view the source code so then I can view it in Eclipse properly?
2014/07/08
[ "https://Stackoverflow.com/questions/24624098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1079484/" ]
Try this : * Download java decompiler from <http://jd.benow.ca/> and now double click on *jd-gui* and click on open file. * Then open .jar file from that folder. * Now you get class files and save all these class files (click on file then click "save all sources" in jd-gui) by src name.
If possible I suggest you to use Maven for manage dependencies of your project, in most cases it did the trick for you. See: [Get source JARs from Maven repository](https://stackoverflow.com/questions/2059431/get-source-jars-from-maven-repository)
24,624,098
In Eclipse, I just imported an external `JAR`. Viewing any of the classes in the Package Explorer will instead of showing a source code open a Class File Editor with saying "Source not found". The folder of the JAR I have downloaded, however, has only `JAR`, no `lib`, no `src`, no `docs`. Is there still a way how to view/generate a view the source code so then I can view it in Eclipse properly?
2014/07/08
[ "https://Stackoverflow.com/questions/24624098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1079484/" ]
You cannot view the source form a .jar files as it contains binaries.Use a java decompiler instead to decompile the .class files and view their sources.
If possible I suggest you to use Maven for manage dependencies of your project, in most cases it did the trick for you. See: [Get source JARs from Maven repository](https://stackoverflow.com/questions/2059431/get-source-jars-from-maven-repository)
32,792,299
I have following route explicitly defined in my routes.rb ``` map.book_preview_v2 '/books/v2/:id', :controller => 'books', :action => 'show_v2' ``` But, in the logs, I see following message: ``` 2015-09-25 16:49:04 INFO (session: f561ebeab121cd1c8af38e0482f176b8) method /books/v2/519869.json (user: xxx:669052) params: {"controller"=>"books", "action"=>"v2", "id"=>"519869", "format"=>"json"} ActionController::UnknownAction (No action responded to v2. Actions: some_method_1, some_method_2, some_method_3, some_method_4, some_method_5, **show_v2**, some_method_6, and some_method_7): ``` Am I missing some convention over configuration thing? Why in the logs I see action as "v2" instead of "show\_v2"?
2015/09/26
[ "https://Stackoverflow.com/questions/32792299", "https://Stackoverflow.com", "https://Stackoverflow.com/users/929701/" ]
> > ActionController::UnknownAction (No action responded to v2. Actions: > some\_method\_1, some\_method\_2, some\_method\_3, some\_method\_4, > some\_method\_5, **show\_v2**, some\_method\_6, and some\_method\_7): > > > Why in the logs I see action as "v2" instead of "show\_v2"? > > > As per the [***Rails 2***](http://guides.rubyonrails.org/v2.3.11/routing.html) default route ``` map.connect ':controller/:action/:id' ``` it expects `v2` as `action` but you defined `show_v2` as `action` in the route. Changing your `route` to below should work ``` map.connect '/books/show_v2/:id', :controller => 'books', :action => 'show_v2' ```
**UPDATE** This is how to create [routes](http://guides.rubyonrails.org/v2.3.11/routing.html#regular-routes) for rails v2.3.8 Please revised the routes into. ``` map.connect '/books/v2/:id', :controller => 'books', :action => 'show_v2' ``` I hope It can help you.
111,729
In John Carpenter's [*They Live*](https://en.wikipedia.org/wiki/They_Live) we hear the famous line > > I have come here to chew bubble gum and kick ass, and I'm all outta bubble gum. > > > It obviously made it into the general vernacular, but was it ad-libbed by Mr. Piper as some suggest, or did it originate elsewhere?
2015/12/22
[ "https://scifi.stackexchange.com/questions/111729", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/55937/" ]
When asked this directly, Roddy Piper said that he ad-libbed it. From a 2013 [interview](https://web.archive.org/web/20190831133511/https://my.xfinity.com/blogs/movies/2013/07/17/%E2%80%98rowdy%E2%80%99-roddy-piper-stocked-up-on-bubble-gum-reflects-on-%E2%80%98they-live%E2%80%99/): > > Onda: Did you really ad-lib that line? > > > Piper: Yeah. I couldn’t tell you what it really means either. It was one of those – “Roddy, you’ve got bullets on you, you’ve got a shotgun, you’ve got sunglasses, you go into a bank, you’re not gonna rob it, say something … action!” I’m all out of bubblegum. Lunch! That was it. No more than that. I know, it’s crazy. > > >
*Five on the Black Hand Side* (1973), 15 years before *They Live* (1988). Timestamp 1:49 in this clip. > > I ain’t giving up nothing for bubblegum and hard time, and I’m fresh out of bubblegum. > > > Not saying this is the original, or that Piper actually had a line. All I'm saying is that this was a saying before *They Live*.
9,019,846
At the moment I have a MasterPage in an ASP.NET MVC3 project with a animesearch function ``` function AnimeSearch() { alert(document.getElementById('anime').value); window.location = "Paging/AnimeBySearch?searchstring=" + (document.getElementById('anime').value); } ``` What I do , I type in an anime movie in an html input tag and it returns the correct values accordingly. As one can see , is that my JavaScript function is calling my controller and then the function with the correct parameters(from the input). However a couple of questions. ***First*** since this function is on my masterpage and the controller call is pretty static the following of course happens. When I get my result after for instance searching for "naruto" I am in the paging controller. If I want another anime movie then of course because of my static location the controller does not work anymore. This is my first question , what is the cleanest and proper way of handling this(no hacks please , did that , works but is not good coding )? ***Second*** Is my approach correct ( calling the controller and action like this from javascript )?
2012/01/26
[ "https://Stackoverflow.com/questions/9019846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/928867/" ]
``` function getBaseUrl() { return "@Url.Content("~/")"; } function AnimeSearch(baseUrl) { alert(document.getElementById('anime').value); window.location = getGetBaseUrl() + "/Paging/AnimeBySearch?searchstring=" + (document.getElementById('anime').value); } ```
i would suggest that you think about a rewrite of the implementation and setup a controller and view that queries the anime model. this controller would implement an action method that allowed for paging and would return a partialview that was emitted into a predefined div on your anime search view. i'm in transit on iphone at present, otherwise would leave code example. will update when on terra firma...
2,747,928
I am working on migrating the ASP.NET apllication to MVC Framework. I have implemented session timeout for InActiveUser using JQuery idleTimeout plugin. I have set idletime for 30 min as below in my Master Page. So that After the user session is timedout of 30 Min, an Auto Logout dialog shows for couple of seconds and says that "**You are about to be signed out due to Inactivity**" Now after this once the user is logged out and redirected to Home Page. Here i again want to show a Dialog and should stay there saying "**You are Logged out**" until the user clicks on it. Here is my code in Master page: ``` $(document).ready(function() { var SEC = 1000; var MIN = 60 * SEC; // http://philpalmieri.com/2009/09/jquery-session-auto-timeout-with-prompt/ <% if(HttpContext.Current.User.Identity.IsAuthenticated) {%> $(document).idleTimeout({ inactivity: 30 * MIN, noconfirm : 30 * SEC, redirect_url: '/Account/Logout', sessionAlive: 0, // 30000, //10 Minutes click_reset: true, alive_url: '', logout_url: '' }); <%} %> ``` } Logout() Method in Account Controller: ``` public virtual ActionResult Logout() { FormsAuthentication.SignOut(); return RedirectToAction(MVC.Home.Default()); } ``` Appreciate your responses.
2010/04/30
[ "https://Stackoverflow.com/questions/2747928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/254913/" ]
How about instead of redirecting to a url, you redirect to a javascript function which does whatever you want it to do first, then redirect to the url from within the javascript. ``` function logout() { alert('You are about to be signed out due to Inactivity'); window.location = '/Account/Logout'; } $(document).ready(function() { var SEC = 1000; var MIN = 60 * SEC; // http://philpalmieri.com/2009/09/jquery-session-auto-timeout-with-prompt/ <% if(HttpContext.Current.User.Identity.IsAuthenticated) {%> $(document).idleTimeout({ inactivity: 30 * MIN, noconfirm : 30 * SEC, redirect_url: 'javascript:logout()', sessionAlive: 0, // 30000, //10 Minutes click_reset: true, alive_url: '', logout_url: '' }); <%} %> ``` p/s: Though I do wonder what's the difference between the `redirect_url` and the `logout_url` parameters.
Try This [Seesion Alert Using Jquery](http://sumeshparakkat.blogspot.in/2010/11/session-timeout-with-warning-and-jquery.html) from my blog: * Session set to time out (e.g. 30 minutes). * When session times out, the user is logged out. * Display a countdown so the user knows how long is left. * Inform the user when they are approaching the limit (e.g. 5 minutes left). * Let the user know that they’ve been automatically timed out due to inactivity.
3,043,418
How to handle multiple event in web control using javascript for ex handling onpaste and on keyup event in textarea
2010/06/15
[ "https://Stackoverflow.com/questions/3043418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/400962/" ]
There's no special trick to assigning different event handlers to an element, just define them as you would: ``` var tArea = document.getElementById("myTextArea"); // Define `onpaste` handler - note that Opera doesn't support `onpaste` tArea.onpaste = function (evt) { } // Define `onkeyup` handler tArea.onkeyup = function (evt) { } ``` If you want to assign multiple functions to the same event, you need to use [`attachEvent`](http://msdn.microsoft.com/en-us/library/ms536343(VS.85).aspx) for IE and [`addEventListener`](https://developer.mozilla.org/en/DOM/element.addEventListener) for other browsers.
You can add as many event handlers as you need to an element. ``` element.addEventListener('event-type', handler1, true); element.addEventListener('another-type', handler2, true); element.addEventListener('third-type', handler3, true); function handler1( e ){} function handler2( e ){} function handler3( e ){} ``` Of course this is different in ie. ``` element.attachEvent('onevent-type', handler1); element.attachEvent('onanother-type', handler2); element.attachEvent('onthird-type', handler3); ``` so you'll have to code around that or use a library
1,624,338
I have an android application with a LOT of activities, think of something like a book where every page is a new activity. The user can make changes in each activity, for example highlight certain texts with different colored markers etc. and it's crucial that I'll remember this information as long as the application stays alive (and I don't want/need to remember any of this when it's not). As I understand the best mechanism for storing this kind of information is via `onSaveInstanceState(Bundle outState)` and `onCreate(Bundle)`/`onRestoreInstanceState(Bundle)` rather than lets say, the Preferences mechanism. My only problem is that the user can navigate backwards to previous pages (Activities) and the only way i know of achieving this is by calling `finish()` which of course kills the current activity without calling `onSaveInstanceState(Bundle outState)` and even if it did call it, the next time I would launch an activity representing that page it would be an entirely new instance. So my question is: Is there a way to go back to the previous activity without calling `finish()`? or, is there a better way to save this information? maybe through static variables? Thanks! P.S. I know I could also implement my app differently so that not every page would have its own activity but this isn't the answer I'm looking for.
2009/10/26
[ "https://Stackoverflow.com/questions/1624338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/101334/" ]
Try to use startActivity() with flags such as Intent.FLAG\_ACTIVITY\_CLEAR\_TOP. You could read the full story here: <http://developer.android.com/reference/android/content/Intent.html#setFlags(int>)
I had exactly the same problem and after I thought and tried a lot, IMHO I found the most feasible solution. I inherited the Activity and adds a static method to kill if exists only. So, instead of killing the activity whenever it exits. I kill it whenever it is called again. For example, ``` MyActivity.killIfExists(); startActivity(new Intent(this, MyActivity.class)); ``` So that, the app will always be singleton and save its state with onSaveInstanceState.
319,488
I'm a software engineer. There are many times when I write a good chunk, or even the entirety of, a feature, but opt not to make it actually run in the program for some reason or another. This code is still there, and could theoretically work, but it never will because it's inaccessible. What's a good one-word term for such code? I want to use it, or a form of it, like this: > > "This is \_\_\_\_\_\_ code." > > > "I am going to \_\_\_\_\_\_ this code". > > > --- **Terms I considered** (but don't seem to fully-convey the purpose) include: * **frozen**/**freeze** (implies it causes the program to freeze?) * **isolated**/**isolate** (implies it can be run in some isolated environment) * **vitrified**/**vitrify** (implies it's changed to something else and can't change back) * **fossilized**/**fossilize** (implies it's old and broken and should only be observed. Same problems as *vitrified*)
2016/04/14
[ "https://english.stackexchange.com/questions/319488", "https://english.stackexchange.com", "https://english.stackexchange.com/users/51742/" ]
I'm rather thinking of the word **unused**. Edit: Unused should be understandable for non technical persons. Other possibilities include **unnecessary** (you often see this in change logs, as in *removed unnecessary lines*) or maybe **orphaned** (although I haven't seen this in a real coding situation. It's rather a translation of a term in my native tongue)
legacy code, used primarily for informal pseudocode
319,488
I'm a software engineer. There are many times when I write a good chunk, or even the entirety of, a feature, but opt not to make it actually run in the program for some reason or another. This code is still there, and could theoretically work, but it never will because it's inaccessible. What's a good one-word term for such code? I want to use it, or a form of it, like this: > > "This is \_\_\_\_\_\_ code." > > > "I am going to \_\_\_\_\_\_ this code". > > > --- **Terms I considered** (but don't seem to fully-convey the purpose) include: * **frozen**/**freeze** (implies it causes the program to freeze?) * **isolated**/**isolate** (implies it can be run in some isolated environment) * **vitrified**/**vitrify** (implies it's changed to something else and can't change back) * **fossilized**/**fossilize** (implies it's old and broken and should only be observed. Same problems as *vitrified*)
2016/04/14
[ "https://english.stackexchange.com/questions/319488", "https://english.stackexchange.com", "https://english.stackexchange.com/users/51742/" ]
When discussing code or functionality that is either in progress or completed but has not been approved or won't be used, we often use the term [shelved](http://www.oxforddictionaries.com/us/definition/american_english/shelve) ---------------------------------------------------------------------------------- > > decide not to proceed with (a project or plan), either temporarily or permanently. > > > This implies that it was not a failure (which would be "trashed") and that it could later be unsheleved and put to use. [example](https://msdn.microsoft.com/en-us/library/ms181404%28v=vs.100%29.aspx)
legacy code, used primarily for informal pseudocode
319,488
I'm a software engineer. There are many times when I write a good chunk, or even the entirety of, a feature, but opt not to make it actually run in the program for some reason or another. This code is still there, and could theoretically work, but it never will because it's inaccessible. What's a good one-word term for such code? I want to use it, or a form of it, like this: > > "This is \_\_\_\_\_\_ code." > > > "I am going to \_\_\_\_\_\_ this code". > > > --- **Terms I considered** (but don't seem to fully-convey the purpose) include: * **frozen**/**freeze** (implies it causes the program to freeze?) * **isolated**/**isolate** (implies it can be run in some isolated environment) * **vitrified**/**vitrify** (implies it's changed to something else and can't change back) * **fossilized**/**fossilize** (implies it's old and broken and should only be observed. Same problems as *vitrified*)
2016/04/14
[ "https://english.stackexchange.com/questions/319488", "https://english.stackexchange.com", "https://english.stackexchange.com/users/51742/" ]
It's called [**unreachable code**](https://en.wikipedia.org/wiki/Unreachable_code). "Unreachable code" is different from dead code, dead code is code that when executed will result in no change, for example: ``` x = 5; /* Dead Code Begin */ x = 6; x = 5; /* Dead Code End */ ``` Unreachable code however is code that e.g. in a function that is not referenced anywhere, or code that is after the `return` clause of a function, this code is present, and theoretically compiled, but can never be "reached" to be executed. **Edit:** Many are claiming that this is not the correct answer and it is not cited anywhere, even though I see wikipedia's distinction is enough, I will quote MISRA C 2012: > > Section 8.2 Rule 2.1: A project shall not contain *unreachable code* > > > **Rationale** > > > Provided that a program does not exhibit any undefined behaviour, *unreachable code* cannot be executed and cannot have any effect on the program's outputs. The presence of *unreachable code* may therefore indicate an error in the program's logic. > > > Then the rule directly after that: > > Section 8.2. Rule 2.2: There shall be no *dead code* > > > **Aplification** > > > Any operation that is executed but whose removal would not affect program behaviour constitutes dead code. > > > . > > > . > > > . > > > *Note: unreachable code* is not *dead code* as it cannot be executed. > > > And before someone comments that it is saying it is a mistake and not intentional, MISRA exists exactly so that when you break one of its rules you justify why you did that and that it is intentional, otherwise the violation should be removed, but it does not change the definition of what is unreachable and what is dead code.
[RTCA DO-178C](http://www.rtca.org/store_product.asp?prodid=803) - the standard for safety critical code in aircraft - uses the terms "*dead code*" for code that is never reached in any path through the code. The term "*deactivated code*" is for code that is deliberately never used in a particular configuration, but could be used in a different mode.
319,488
I'm a software engineer. There are many times when I write a good chunk, or even the entirety of, a feature, but opt not to make it actually run in the program for some reason or another. This code is still there, and could theoretically work, but it never will because it's inaccessible. What's a good one-word term for such code? I want to use it, or a form of it, like this: > > "This is \_\_\_\_\_\_ code." > > > "I am going to \_\_\_\_\_\_ this code". > > > --- **Terms I considered** (but don't seem to fully-convey the purpose) include: * **frozen**/**freeze** (implies it causes the program to freeze?) * **isolated**/**isolate** (implies it can be run in some isolated environment) * **vitrified**/**vitrify** (implies it's changed to something else and can't change back) * **fossilized**/**fossilize** (implies it's old and broken and should only be observed. Same problems as *vitrified*)
2016/04/14
[ "https://english.stackexchange.com/questions/319488", "https://english.stackexchange.com", "https://english.stackexchange.com/users/51742/" ]
It's called [**unreachable code**](https://en.wikipedia.org/wiki/Unreachable_code). "Unreachable code" is different from dead code, dead code is code that when executed will result in no change, for example: ``` x = 5; /* Dead Code Begin */ x = 6; x = 5; /* Dead Code End */ ``` Unreachable code however is code that e.g. in a function that is not referenced anywhere, or code that is after the `return` clause of a function, this code is present, and theoretically compiled, but can never be "reached" to be executed. **Edit:** Many are claiming that this is not the correct answer and it is not cited anywhere, even though I see wikipedia's distinction is enough, I will quote MISRA C 2012: > > Section 8.2 Rule 2.1: A project shall not contain *unreachable code* > > > **Rationale** > > > Provided that a program does not exhibit any undefined behaviour, *unreachable code* cannot be executed and cannot have any effect on the program's outputs. The presence of *unreachable code* may therefore indicate an error in the program's logic. > > > Then the rule directly after that: > > Section 8.2. Rule 2.2: There shall be no *dead code* > > > **Aplification** > > > Any operation that is executed but whose removal would not affect program behaviour constitutes dead code. > > > . > > > . > > > . > > > *Note: unreachable code* is not *dead code* as it cannot be executed. > > > And before someone comments that it is saying it is a mistake and not intentional, MISRA exists exactly so that when you break one of its rules you justify why you did that and that it is intentional, otherwise the violation should be removed, but it does not change the definition of what is unreachable and what is dead code.
I would use [inactive](http://www.merriam-webster.com/dictionary/inactive) to indicate that it is not being executed in any existing code path. From your example: > > "This is *inactive* code." > > > "I am going to *activate/deactivate* this code". > > >
319,488
I'm a software engineer. There are many times when I write a good chunk, or even the entirety of, a feature, but opt not to make it actually run in the program for some reason or another. This code is still there, and could theoretically work, but it never will because it's inaccessible. What's a good one-word term for such code? I want to use it, or a form of it, like this: > > "This is \_\_\_\_\_\_ code." > > > "I am going to \_\_\_\_\_\_ this code". > > > --- **Terms I considered** (but don't seem to fully-convey the purpose) include: * **frozen**/**freeze** (implies it causes the program to freeze?) * **isolated**/**isolate** (implies it can be run in some isolated environment) * **vitrified**/**vitrify** (implies it's changed to something else and can't change back) * **fossilized**/**fossilize** (implies it's old and broken and should only be observed. Same problems as *vitrified*)
2016/04/14
[ "https://english.stackexchange.com/questions/319488", "https://english.stackexchange.com", "https://english.stackexchange.com/users/51742/" ]
How about **auxiliary** code (**auxiliary**/**auxiliarize**): something that's useful but unused, held in reserve in case it's needed. (I also like **vestigial** code, but that's not as good an answer, since it might imply obsoleteness).
I do believe this is called **Dormant Code**, a variant term from **Unreachable code**, because **Unreachable code** is most of the times an error effect as stated above as programming errors in complex conditional branches; a consequence of the internal transformations performed by an optimizing compiler; incomplete testing of a new or modified program that failed to test the bypassed unreachable code; obsolete code that a programmer forgot to delete; and not a purposeful actual cause; I would term it **Dormant Code**, because it's functional code that you chose not to turn on but it's there whenever you need and if you trigger it; if you can't actually FIND the code although it's functional AND working, then the term is **Hidden code** not **Dormant code**. HOWEVER, if Kojiro's concept for the code fall in these:unused code that a programmer decided not to delete because it was intermingled with functional code;conditionally useful code that will never be reached, because current input data will never cause that code to be executed; then it can be placed inside the construct of **Unreachable Code**
319,488
I'm a software engineer. There are many times when I write a good chunk, or even the entirety of, a feature, but opt not to make it actually run in the program for some reason or another. This code is still there, and could theoretically work, but it never will because it's inaccessible. What's a good one-word term for such code? I want to use it, or a form of it, like this: > > "This is \_\_\_\_\_\_ code." > > > "I am going to \_\_\_\_\_\_ this code". > > > --- **Terms I considered** (but don't seem to fully-convey the purpose) include: * **frozen**/**freeze** (implies it causes the program to freeze?) * **isolated**/**isolate** (implies it can be run in some isolated environment) * **vitrified**/**vitrify** (implies it's changed to something else and can't change back) * **fossilized**/**fossilize** (implies it's old and broken and should only be observed. Same problems as *vitrified*)
2016/04/14
[ "https://english.stackexchange.com/questions/319488", "https://english.stackexchange.com", "https://english.stackexchange.com/users/51742/" ]
It's called [**unreachable code**](https://en.wikipedia.org/wiki/Unreachable_code). "Unreachable code" is different from dead code, dead code is code that when executed will result in no change, for example: ``` x = 5; /* Dead Code Begin */ x = 6; x = 5; /* Dead Code End */ ``` Unreachable code however is code that e.g. in a function that is not referenced anywhere, or code that is after the `return` clause of a function, this code is present, and theoretically compiled, but can never be "reached" to be executed. **Edit:** Many are claiming that this is not the correct answer and it is not cited anywhere, even though I see wikipedia's distinction is enough, I will quote MISRA C 2012: > > Section 8.2 Rule 2.1: A project shall not contain *unreachable code* > > > **Rationale** > > > Provided that a program does not exhibit any undefined behaviour, *unreachable code* cannot be executed and cannot have any effect on the program's outputs. The presence of *unreachable code* may therefore indicate an error in the program's logic. > > > Then the rule directly after that: > > Section 8.2. Rule 2.2: There shall be no *dead code* > > > **Aplification** > > > Any operation that is executed but whose removal would not affect program behaviour constitutes dead code. > > > . > > > . > > > . > > > *Note: unreachable code* is not *dead code* as it cannot be executed. > > > And before someone comments that it is saying it is a mistake and not intentional, MISRA exists exactly so that when you break one of its rules you justify why you did that and that it is intentional, otherwise the violation should be removed, but it does not change the definition of what is unreachable and what is dead code.
I would use the word [hidden](https://www.google.com/webhp?ion=1&espv=2&ie=UTF-8#q=define%3A%20hidden): > > kept out of sight; concealed. > > > synonyms: concealed, secret, undercover, invisible, unseen, out of sight, closeted, covert; secluded, tucked away; camouflaged, disguised, masked, cloaked > > > "This feature has been implemented, but it's currently **hidden** from users."
319,488
I'm a software engineer. There are many times when I write a good chunk, or even the entirety of, a feature, but opt not to make it actually run in the program for some reason or another. This code is still there, and could theoretically work, but it never will because it's inaccessible. What's a good one-word term for such code? I want to use it, or a form of it, like this: > > "This is \_\_\_\_\_\_ code." > > > "I am going to \_\_\_\_\_\_ this code". > > > --- **Terms I considered** (but don't seem to fully-convey the purpose) include: * **frozen**/**freeze** (implies it causes the program to freeze?) * **isolated**/**isolate** (implies it can be run in some isolated environment) * **vitrified**/**vitrify** (implies it's changed to something else and can't change back) * **fossilized**/**fossilize** (implies it's old and broken and should only be observed. Same problems as *vitrified*)
2016/04/14
[ "https://english.stackexchange.com/questions/319488", "https://english.stackexchange.com", "https://english.stackexchange.com/users/51742/" ]
You might consider ***disabled*** or ***deactivated***: > > **disable**: to cause (something) to be unable to work in the normal way > > **deactivate**: to make (something) no longer active or effective > > definitions from [merriam-](http://www.merriam-webster.com/dictionary/disable)[webster](http://www.merriam-webster.com/dictionary/deactivate).com > > >
Depends on *why* you disabled it. You could perhaps be more descriptive about why you disabled it rather than looking for a generic "\_\_\_\_ code". Here's a few generic words: * Disabled * Unused * Stashed And a few specific ones: * Uncontrolled * Untested * Deprecated * Obsolete * Non-production ready
319,488
I'm a software engineer. There are many times when I write a good chunk, or even the entirety of, a feature, but opt not to make it actually run in the program for some reason or another. This code is still there, and could theoretically work, but it never will because it's inaccessible. What's a good one-word term for such code? I want to use it, or a form of it, like this: > > "This is \_\_\_\_\_\_ code." > > > "I am going to \_\_\_\_\_\_ this code". > > > --- **Terms I considered** (but don't seem to fully-convey the purpose) include: * **frozen**/**freeze** (implies it causes the program to freeze?) * **isolated**/**isolate** (implies it can be run in some isolated environment) * **vitrified**/**vitrify** (implies it's changed to something else and can't change back) * **fossilized**/**fossilize** (implies it's old and broken and should only be observed. Same problems as *vitrified*)
2016/04/14
[ "https://english.stackexchange.com/questions/319488", "https://english.stackexchange.com", "https://english.stackexchange.com/users/51742/" ]
[RTCA DO-178C](http://www.rtca.org/store_product.asp?prodid=803) - the standard for safety critical code in aircraft - uses the terms "*dead code*" for code that is never reached in any path through the code. The term "*deactivated code*" is for code that is deliberately never used in a particular configuration, but could be used in a different mode.
My view is that such code should not exist in the code base and is a code or process smell. > > This is **cluttering** code. I am going to **clutter up the codebase with** this code. > > >
319,488
I'm a software engineer. There are many times when I write a good chunk, or even the entirety of, a feature, but opt not to make it actually run in the program for some reason or another. This code is still there, and could theoretically work, but it never will because it's inaccessible. What's a good one-word term for such code? I want to use it, or a form of it, like this: > > "This is \_\_\_\_\_\_ code." > > > "I am going to \_\_\_\_\_\_ this code". > > > --- **Terms I considered** (but don't seem to fully-convey the purpose) include: * **frozen**/**freeze** (implies it causes the program to freeze?) * **isolated**/**isolate** (implies it can be run in some isolated environment) * **vitrified**/**vitrify** (implies it's changed to something else and can't change back) * **fossilized**/**fossilize** (implies it's old and broken and should only be observed. Same problems as *vitrified*)
2016/04/14
[ "https://english.stackexchange.com/questions/319488", "https://english.stackexchange.com", "https://english.stackexchange.com/users/51742/" ]
Since the code is inaccessible, most compilers will eliminate it through *[Dead Code Elimination](http://www.compileroptimizations.com/category/dead_code_elimination.htm)*, or *DCE*. So you can refer to it as *dead code*, or simply *dead*. Nullstone's compendium of [compiler optimizations](http://www.compileroptimizations.com/index.html) defines *dead code* as > > Code that is unreachable or that does not affect the program (e.g. > dead stores) [and] can be eliminated. > > > Since the code is apparently not going to be run, you can also say it is *excluded* from the build. So, to complete your sentences: > > This is *excluded* code. > > > I'm going to *exclude* this code. > > >
How about **auxiliary** code (**auxiliary**/**auxiliarize**): something that's useful but unused, held in reserve in case it's needed. (I also like **vestigial** code, but that's not as good an answer, since it might imply obsoleteness).
319,488
I'm a software engineer. There are many times when I write a good chunk, or even the entirety of, a feature, but opt not to make it actually run in the program for some reason or another. This code is still there, and could theoretically work, but it never will because it's inaccessible. What's a good one-word term for such code? I want to use it, or a form of it, like this: > > "This is \_\_\_\_\_\_ code." > > > "I am going to \_\_\_\_\_\_ this code". > > > --- **Terms I considered** (but don't seem to fully-convey the purpose) include: * **frozen**/**freeze** (implies it causes the program to freeze?) * **isolated**/**isolate** (implies it can be run in some isolated environment) * **vitrified**/**vitrify** (implies it's changed to something else and can't change back) * **fossilized**/**fossilize** (implies it's old and broken and should only be observed. Same problems as *vitrified*)
2016/04/14
[ "https://english.stackexchange.com/questions/319488", "https://english.stackexchange.com", "https://english.stackexchange.com/users/51742/" ]
**moth-balled** verb (used with object) 2. to put into storage or reserve; inactivate. adjective 3. inactive; unused; stored away:
Depends on *why* you disabled it. You could perhaps be more descriptive about why you disabled it rather than looking for a generic "\_\_\_\_ code". Here's a few generic words: * Disabled * Unused * Stashed And a few specific ones: * Uncontrolled * Untested * Deprecated * Obsolete * Non-production ready
29,083,343
I'm trying to search in an database for records with a specific date. I've tried to search in the following ways: ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=01/01/2015 ``` and ``` SELECT * FROM TABLE_1 WHERE CAL_DATE='01/01/2015' ``` I'm working with an Access database, and in the table, the dates are showing in the same format (01/01/2015). Is there something I'm missing in the SQL statement?
2015/03/16
[ "https://Stackoverflow.com/questions/29083343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4344054/" ]
Try using CDATE function on your filter: ``` WHERE CAL_DATE = CDATE('01/01/2015') ``` This will ensure that your input is of date datatype, not a string.
SELECT \* from Table1 WHERE (CDATE(ColumnDate) BETWEEN #03/26/2015# AND #03/19/2015#) if this works .. vote for it.. we use above query for searching records from 26th march to 19 the march.. change the dates accordingly..
29,083,343
I'm trying to search in an database for records with a specific date. I've tried to search in the following ways: ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=01/01/2015 ``` and ``` SELECT * FROM TABLE_1 WHERE CAL_DATE='01/01/2015' ``` I'm working with an Access database, and in the table, the dates are showing in the same format (01/01/2015). Is there something I'm missing in the SQL statement?
2015/03/16
[ "https://Stackoverflow.com/questions/29083343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4344054/" ]
Any of the options below should work: Format the date directly in your query. ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=#01/01/2015#; ``` The DateValue function will convert a string to a date. ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=DateValue('01/01/2015'); ``` The CDate function will convert a value to a date. ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=CDate('01/01/2015'); ``` The DateSerial function will return a date given the year, month, and day. ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=DateSerial(2015, 1, 1); ``` See the following page for more information on the above functions: [techonthenet.com](http://www.techonthenet.com/access/functions/)
Try using CDATE function on your filter: ``` WHERE CAL_DATE = CDATE('01/01/2015') ``` This will ensure that your input is of date datatype, not a string.
29,083,343
I'm trying to search in an database for records with a specific date. I've tried to search in the following ways: ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=01/01/2015 ``` and ``` SELECT * FROM TABLE_1 WHERE CAL_DATE='01/01/2015' ``` I'm working with an Access database, and in the table, the dates are showing in the same format (01/01/2015). Is there something I'm missing in the SQL statement?
2015/03/16
[ "https://Stackoverflow.com/questions/29083343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4344054/" ]
SELECT \* from Table1 WHERE (CDATE(ColumnDate) BETWEEN #03/26/2015# AND #03/19/2015#) if this works .. vote for it.. we use above query for searching records from 26th march to 19 the march.. change the dates accordingly..
SELECT \* from Table1 WHERE (CDATE(ColumnDate) BETWEEN #03/26/2015# AND #03/19/2015#) if this works .. vote for it.. we use above query for searching records from 26th march to 19 the march.. change the dates accordingly..
29,083,343
I'm trying to search in an database for records with a specific date. I've tried to search in the following ways: ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=01/01/2015 ``` and ``` SELECT * FROM TABLE_1 WHERE CAL_DATE='01/01/2015' ``` I'm working with an Access database, and in the table, the dates are showing in the same format (01/01/2015). Is there something I'm missing in the SQL statement?
2015/03/16
[ "https://Stackoverflow.com/questions/29083343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4344054/" ]
Any of the options below should work: Format the date directly in your query. ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=#01/01/2015#; ``` The DateValue function will convert a string to a date. ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=DateValue('01/01/2015'); ``` The CDate function will convert a value to a date. ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=CDate('01/01/2015'); ``` The DateSerial function will return a date given the year, month, and day. ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=DateSerial(2015, 1, 1); ``` See the following page for more information on the above functions: [techonthenet.com](http://www.techonthenet.com/access/functions/)
SELECT \* from Table1 WHERE (CDATE(ColumnDate) BETWEEN #03/26/2015# AND #03/19/2015#) if this works .. vote for it.. we use above query for searching records from 26th march to 19 the march.. change the dates accordingly..
29,083,343
I'm trying to search in an database for records with a specific date. I've tried to search in the following ways: ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=01/01/2015 ``` and ``` SELECT * FROM TABLE_1 WHERE CAL_DATE='01/01/2015' ``` I'm working with an Access database, and in the table, the dates are showing in the same format (01/01/2015). Is there something I'm missing in the SQL statement?
2015/03/16
[ "https://Stackoverflow.com/questions/29083343", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4344054/" ]
Any of the options below should work: Format the date directly in your query. ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=#01/01/2015#; ``` The DateValue function will convert a string to a date. ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=DateValue('01/01/2015'); ``` The CDate function will convert a value to a date. ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=CDate('01/01/2015'); ``` The DateSerial function will return a date given the year, month, and day. ``` SELECT * FROM TABLE_1 WHERE CAL_DATE=DateSerial(2015, 1, 1); ``` See the following page for more information on the above functions: [techonthenet.com](http://www.techonthenet.com/access/functions/)
SELECT \* from Table1 WHERE (CDATE(ColumnDate) BETWEEN #03/26/2015# AND #03/19/2015#) if this works .. vote for it.. we use above query for searching records from 26th march to 19 the march.. change the dates accordingly..
70,932
i am an CS student and i got an job-offer as an Linux Administrator. I took this job to get deeper into Linux in order to understand and use Linux more wise. So : Do you have any suggestions (books,links) to Linux System Administration. For Example : installing software over ssh , creating a mailinglist, installing and maintaining lampp. etc?
2009/10/02
[ "https://serverfault.com/questions/70932", "https://serverfault.com", "https://serverfault.com/users/12792/" ]
I keep the following two books on my shelf. When new editions come out I buy them. Essential System Administration by Frisch; O'Reilly Running Linux by Dalheimer;et.al.; O'Reilly The Frisch book covers more than Linux. Multiple Unix variants are covered. --- Unix Shell Programming by Kochan; Sams Is adequate. Somebody may have a better candidate for shell scripting.
[Linux from Scratch](http://www.linuxfromscratch.org/) will teach you everything you wanted to know about Linux, and the stuff you were too afraid to ask about.
70,932
i am an CS student and i got an job-offer as an Linux Administrator. I took this job to get deeper into Linux in order to understand and use Linux more wise. So : Do you have any suggestions (books,links) to Linux System Administration. For Example : installing software over ssh , creating a mailinglist, installing and maintaining lampp. etc?
2009/10/02
[ "https://serverfault.com/questions/70932", "https://serverfault.com", "https://serverfault.com/users/12792/" ]
As well as linux nitty gritty,I think getting meta about system administration is not just useful, but needed. Technical knowledge is needed, but soft skills, organizational and operational context and processes place it in perspective. try Mark Burgess' ["Principles of System and Network Admnistration"](http://rads.stackoverflow.com/amzn/click/0471823031) and Tom Limoncelli's ["Practice of System and Network Administration, Second Edition"](http://rads.stackoverflow.com/amzn/click/0321492668)
I keep the following two books on my shelf. When new editions come out I buy them. Essential System Administration by Frisch; O'Reilly Running Linux by Dalheimer;et.al.; O'Reilly The Frisch book covers more than Linux. Multiple Unix variants are covered. --- Unix Shell Programming by Kochan; Sams Is adequate. Somebody may have a better candidate for shell scripting.
70,932
i am an CS student and i got an job-offer as an Linux Administrator. I took this job to get deeper into Linux in order to understand and use Linux more wise. So : Do you have any suggestions (books,links) to Linux System Administration. For Example : installing software over ssh , creating a mailinglist, installing and maintaining lampp. etc?
2009/10/02
[ "https://serverfault.com/questions/70932", "https://serverfault.com", "https://serverfault.com/users/12792/" ]
I can very highly recommend the [Linux Administration Handbook](http://rads.stackoverflow.com/amzn/click/0131480049). Also, see the answers to [this question](https://serverfault.com/questions/1046/what-is-the-single-most-influential-book-every-sysadmin-should-read). And commit the contents of [BashFAQ](http://mywiki.wooledge.org/EnglishFrontPage) to memory.
[Linux from Scratch](http://www.linuxfromscratch.org/) will teach you everything you wanted to know about Linux, and the stuff you were too afraid to ask about.
70,932
i am an CS student and i got an job-offer as an Linux Administrator. I took this job to get deeper into Linux in order to understand and use Linux more wise. So : Do you have any suggestions (books,links) to Linux System Administration. For Example : installing software over ssh , creating a mailinglist, installing and maintaining lampp. etc?
2009/10/02
[ "https://serverfault.com/questions/70932", "https://serverfault.com", "https://serverfault.com/users/12792/" ]
[How Linux Works](http://rads.stackoverflow.com/amzn/click/1593270356) on No Starch Press is a fantastic introduction to Linux administration.
[Linux from Scratch](http://www.linuxfromscratch.org/) will teach you everything you wanted to know about Linux, and the stuff you were too afraid to ask about.
70,932
i am an CS student and i got an job-offer as an Linux Administrator. I took this job to get deeper into Linux in order to understand and use Linux more wise. So : Do you have any suggestions (books,links) to Linux System Administration. For Example : installing software over ssh , creating a mailinglist, installing and maintaining lampp. etc?
2009/10/02
[ "https://serverfault.com/questions/70932", "https://serverfault.com", "https://serverfault.com/users/12792/" ]
I like [The linux Documentation Project](http://www.tldp.org) for basic information. Although the entry I go to most on that site is [The Advanced Bash Scripting Guide](http://www.tldp.org/LDP/abs/html/index.html). I've also found that google is your friend when it comes to man pages `man <command>` in google will generally give you a very well formatted man page which is useful in keeping the number of open terminals down.
I keep the following two books on my shelf. When new editions come out I buy them. Essential System Administration by Frisch; O'Reilly Running Linux by Dalheimer;et.al.; O'Reilly The Frisch book covers more than Linux. Multiple Unix variants are covered. --- Unix Shell Programming by Kochan; Sams Is adequate. Somebody may have a better candidate for shell scripting.
70,932
i am an CS student and i got an job-offer as an Linux Administrator. I took this job to get deeper into Linux in order to understand and use Linux more wise. So : Do you have any suggestions (books,links) to Linux System Administration. For Example : installing software over ssh , creating a mailinglist, installing and maintaining lampp. etc?
2009/10/02
[ "https://serverfault.com/questions/70932", "https://serverfault.com", "https://serverfault.com/users/12792/" ]
As well as linux nitty gritty,I think getting meta about system administration is not just useful, but needed. Technical knowledge is needed, but soft skills, organizational and operational context and processes place it in perspective. try Mark Burgess' ["Principles of System and Network Admnistration"](http://rads.stackoverflow.com/amzn/click/0471823031) and Tom Limoncelli's ["Practice of System and Network Administration, Second Edition"](http://rads.stackoverflow.com/amzn/click/0321492668)
[Linux from Scratch](http://www.linuxfromscratch.org/) will teach you everything you wanted to know about Linux, and the stuff you were too afraid to ask about.
70,932
i am an CS student and i got an job-offer as an Linux Administrator. I took this job to get deeper into Linux in order to understand and use Linux more wise. So : Do you have any suggestions (books,links) to Linux System Administration. For Example : installing software over ssh , creating a mailinglist, installing and maintaining lampp. etc?
2009/10/02
[ "https://serverfault.com/questions/70932", "https://serverfault.com", "https://serverfault.com/users/12792/" ]
I keep the following two books on my shelf. When new editions come out I buy them. Essential System Administration by Frisch; O'Reilly Running Linux by Dalheimer;et.al.; O'Reilly The Frisch book covers more than Linux. Multiple Unix variants are covered. --- Unix Shell Programming by Kochan; Sams Is adequate. Somebody may have a better candidate for shell scripting.
Have a look at the [how2forge](http://www.howtoforge.com/) for basic lamp functions or maybe if Redhat/Centos/fedora is your thing [RHCT/e](http://www.redhat.com/certification/rhce/) or maybe a Comptia [Linux+](http://www.comptia.org/certifications/listed/linux.aspx) don't really know what your background is so basically throwing certs at you (sorry I know you asked for books etc)
70,932
i am an CS student and i got an job-offer as an Linux Administrator. I took this job to get deeper into Linux in order to understand and use Linux more wise. So : Do you have any suggestions (books,links) to Linux System Administration. For Example : installing software over ssh , creating a mailinglist, installing and maintaining lampp. etc?
2009/10/02
[ "https://serverfault.com/questions/70932", "https://serverfault.com", "https://serverfault.com/users/12792/" ]
[How Linux Works](http://rads.stackoverflow.com/amzn/click/1593270356) on No Starch Press is a fantastic introduction to Linux administration.
I keep the following two books on my shelf. When new editions come out I buy them. Essential System Administration by Frisch; O'Reilly Running Linux by Dalheimer;et.al.; O'Reilly The Frisch book covers more than Linux. Multiple Unix variants are covered. --- Unix Shell Programming by Kochan; Sams Is adequate. Somebody may have a better candidate for shell scripting.
70,932
i am an CS student and i got an job-offer as an Linux Administrator. I took this job to get deeper into Linux in order to understand and use Linux more wise. So : Do you have any suggestions (books,links) to Linux System Administration. For Example : installing software over ssh , creating a mailinglist, installing and maintaining lampp. etc?
2009/10/02
[ "https://serverfault.com/questions/70932", "https://serverfault.com", "https://serverfault.com/users/12792/" ]
I know that you asked for books, but since you desire to learn... One of the best learning tools that you'll find is a good virtual machine manager, such as VMWare or VirtualBox. You can set up a complete virtual learning environment right on your pc, and experiment without the worry of making a mistake in a production environment. .
I can very highly recommend the [Linux Administration Handbook](http://rads.stackoverflow.com/amzn/click/0131480049). Also, see the answers to [this question](https://serverfault.com/questions/1046/what-is-the-single-most-influential-book-every-sysadmin-should-read). And commit the contents of [BashFAQ](http://mywiki.wooledge.org/EnglishFrontPage) to memory.
70,932
i am an CS student and i got an job-offer as an Linux Administrator. I took this job to get deeper into Linux in order to understand and use Linux more wise. So : Do you have any suggestions (books,links) to Linux System Administration. For Example : installing software over ssh , creating a mailinglist, installing and maintaining lampp. etc?
2009/10/02
[ "https://serverfault.com/questions/70932", "https://serverfault.com", "https://serverfault.com/users/12792/" ]
I like [The linux Documentation Project](http://www.tldp.org) for basic information. Although the entry I go to most on that site is [The Advanced Bash Scripting Guide](http://www.tldp.org/LDP/abs/html/index.html). I've also found that google is your friend when it comes to man pages `man <command>` in google will generally give you a very well formatted man page which is useful in keeping the number of open terminals down.
I know that you asked for books, but since you desire to learn... One of the best learning tools that you'll find is a good virtual machine manager, such as VMWare or VirtualBox. You can set up a complete virtual learning environment right on your pc, and experiment without the worry of making a mistake in a production environment. .
42,491,374
My problem is when I try to add margin bottom to all elements of columns:2 list, i've added margin-bottom:5px for spacing but for some reason it doubles the spacing. One in the third element bottom and the fourth element top (which gives me the problem) ![problem](https://i.imgur.com/ggTfTJp.png) Is there any solution for my problem?
2017/02/27
[ "https://Stackoverflow.com/questions/42491374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3157171/" ]
I have just hit this bug in Chrome. With a little investigation, it seems the bottom of the last `<li>` in the first column gets placed at the top of the 2nd column. [![CSS Column Bug](https://i.stack.imgur.com/BtN4T.jpg)](https://i.stack.imgur.com/BtN4T.jpg) The solution was to apply the follwing to the `<li>`'s: ``` display: inline-block; width: 100%; ``` Hope this helps, someone else.
Actually it was bug inside an old version of Chrome. I tried Firefox and Chrome current versions; neither of them had this problem.
42,491,374
My problem is when I try to add margin bottom to all elements of columns:2 list, i've added margin-bottom:5px for spacing but for some reason it doubles the spacing. One in the third element bottom and the fourth element top (which gives me the problem) ![problem](https://i.imgur.com/ggTfTJp.png) Is there any solution for my problem?
2017/02/27
[ "https://Stackoverflow.com/questions/42491374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3157171/" ]
I have just hit this bug in Chrome. With a little investigation, it seems the bottom of the last `<li>` in the first column gets placed at the top of the 2nd column. [![CSS Column Bug](https://i.stack.imgur.com/BtN4T.jpg)](https://i.stack.imgur.com/BtN4T.jpg) The solution was to apply the follwing to the `<li>`'s: ``` display: inline-block; width: 100%; ``` Hope this helps, someone else.
I recently had a similar issue too and the solution is in MDN [docs](https://developer.mozilla.org/en-US/docs/Web/CSS/break-inside). ``` .card { break-inside: avoid; page-break-inside: avoid; } ``` And an example from [MDN](https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Multiple-column_Layout).
26,350,212
I am trying to generate a random sequence from a fixed number of characters that contains at least one of each character. For example having the ensemble `m = letters[1:3]` I would like to create a sequence of N = 10 elements that contain at least one of each `m` characters, like ``` a a a a b c c c c a ``` I tried with `sample(n,N,replace=T)` but in this way also a sequence like ``` a a a a a c c c c a ``` can be generated that does not contain `b`.
2014/10/13
[ "https://Stackoverflow.com/questions/26350212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3036416/" ]
``` f <- function(x, n){ sample(c(x, sample(m, n-length(x), replace=TRUE))) } f(letters[1:3], 5) # [1] "a" "c" "a" "b" "a" f(letters[1:3], 5) # [1] "a" "a" "b" "b" "c" f(letters[1:3], 5) # [1] "a" "a" "b" "c" "a" f(letters[1:3], 5) # [1] "b" "c" "b" "c" "a" ```
Josh O'Briens answer is a good way to do it but doesn't provide much input checking. Since I already wrote it might as well present my answer. It's pretty much the same thing but takes care of checking things like only considering unique items and making sure there are enough unique items to guarantee you get at least one of each. ``` at_least_one_samp <- function(n, input){ # Only consider unique items. items <- unique(input) unique_items_count <- length(items) if(unique_items_count > n){ stop("Not enough unique items in input to give at least one of each") } # Get values for vector - force each item in at least once # then randomly select values to get the remaining. vals <- c(items, sample(items, n - unique_items_count, replace = TRUE)) # Now shuffle them sample(vals) } m <- c("a", "b", "c") at_least_one_samp(10, m) ```
4,981,526
For a project I'm working on, a stopwatch-like timer needs to be displayed to the form. If I remember correctly in VB, text could be outputted to a picture box, but I can't find a way to do it in c#. A label would work, if there is a way to prevent the resizing of the box. Thanks.
2011/02/13
[ "https://Stackoverflow.com/questions/4981526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/614479/" ]
A Label would probably be the simplest option. I'm not sure why you would need to prevent resizing of the picturebox (which is also simple to do). If you are worried about your picturebox being resized and your Label no longer being centered, or being the wrong size, you can just put code in the resize event which dynamically updates the size and location of the Label and its font, based on the current size of the picturebox. However, if you are determined to not use labels, you can always have your picturebox subscribe to the Paint event and then use e.Graphics to just draw your text whenever the picturebox is repainted. ``` private void pictureBox1_Paint(object sender, PaintEventArgs e) { using (Font myFont = new Font("Microsoft Sans Serif", 10)) { e.Graphics.DrawString("This time is...Hammertime", myFont, Brushes.Black, new Point(0,0)); } } ``` However, you would also have to redraw this for every iteration of your timer. Like I said, Label would be a better option than this. Calling e.Graphics wouldn't give you any real advantage over Label , but it would create more things for you to worry about.
Using a TextBox is probably the most appropriate thing for this; just set `ReadOnly` to true.
66,251,664
I am trying to make a stock bot that checks if something is in stock and when I try to use: `if ATC.isDisplayed():` I get the error: `AttributeError: 'list' object has no attribute 'isDisplayed'` My whole code: ``` import time import asyncio import colorama import subprocess from colorama import Fore, Back, Style from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.support.expected_conditions import presence_of_element_located driver = webdriver.Chrome( executable_path=r'C:\Users\Joe mama\Desktop\app\chromedriver.exe') colorama.init(autoreset=True) driver.get("https://www.currys.co.uk/gbuk/computing-accessories/components-upgrades/graphics-cards/msi-geforce-rtx-3060-ti-8-gb-gaming-x-trio-graphics-card-10219250-pdt.html") driver.maximize_window() Name = driver.find_elements_by_css_selector( "#content > div.product-page > section > div.to-print > h1 > span:nth-child(2)") Price = driver.find_elements_by_css_selector( "#product-actions > div.amounts > div > div > span.ProductPriceBlock__Price-kTVxGg.QWqil") Link = driver.find_elements_by_tag_name("a") OOS = driver.find_elements_by_css_selector( "#product-actions > div.oos.oos-no-alt.border.space-b > strong") ATC = driver.find_elements_by_css_selector( "#product-actions > div.channels.space-b > div.space-b.center > button") while True: try: if OOS.isDisplayed(): print(colorama.Fore.RED + f"|| {Name[0].text} || Out Of Stock || {Price[0].text} ||") driver.refresh() except: if ATC.isDisplayed(): print(colorama.Fore.GREEN + f'|| {Name[0].text} || IN STOCK || {Price[0].text} ||') ``` If anyone could help that would be very helpful, I've been trying to figure this out for ages.
2021/02/17
[ "https://Stackoverflow.com/questions/66251664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15231411/" ]
For solution, simple make this: On models ```py db = SQLAlchemy() #Remove the app here ``` On app ```py from models import db db.init_app(app) #Add this line Before migrate line migrate = Migrate(app, db) ```
I was able to find a workaround. In my models.py I substituted this line: ``` from app import app as app ``` for this: ``` try: from app import app as app except ImportError: from __main__ import app ``` It works but it's ugly. I thought there must be a prettier way to do this.
66,251,664
I am trying to make a stock bot that checks if something is in stock and when I try to use: `if ATC.isDisplayed():` I get the error: `AttributeError: 'list' object has no attribute 'isDisplayed'` My whole code: ``` import time import asyncio import colorama import subprocess from colorama import Fore, Back, Style from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.support.expected_conditions import presence_of_element_located driver = webdriver.Chrome( executable_path=r'C:\Users\Joe mama\Desktop\app\chromedriver.exe') colorama.init(autoreset=True) driver.get("https://www.currys.co.uk/gbuk/computing-accessories/components-upgrades/graphics-cards/msi-geforce-rtx-3060-ti-8-gb-gaming-x-trio-graphics-card-10219250-pdt.html") driver.maximize_window() Name = driver.find_elements_by_css_selector( "#content > div.product-page > section > div.to-print > h1 > span:nth-child(2)") Price = driver.find_elements_by_css_selector( "#product-actions > div.amounts > div > div > span.ProductPriceBlock__Price-kTVxGg.QWqil") Link = driver.find_elements_by_tag_name("a") OOS = driver.find_elements_by_css_selector( "#product-actions > div.oos.oos-no-alt.border.space-b > strong") ATC = driver.find_elements_by_css_selector( "#product-actions > div.channels.space-b > div.space-b.center > button") while True: try: if OOS.isDisplayed(): print(colorama.Fore.RED + f"|| {Name[0].text} || Out Of Stock || {Price[0].text} ||") driver.refresh() except: if ATC.isDisplayed(): print(colorama.Fore.GREEN + f'|| {Name[0].text} || IN STOCK || {Price[0].text} ||') ``` If anyone could help that would be very helpful, I've been trying to figure this out for ages.
2021/02/17
[ "https://Stackoverflow.com/questions/66251664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15231411/" ]
For solution, simple make this: On models ```py db = SQLAlchemy() #Remove the app here ``` On app ```py from models import db db.init_app(app) #Add this line Before migrate line migrate = Migrate(app, db) ```
Try to change app import in models.py to: ```py from flask import current_app as app ```
66,251,664
I am trying to make a stock bot that checks if something is in stock and when I try to use: `if ATC.isDisplayed():` I get the error: `AttributeError: 'list' object has no attribute 'isDisplayed'` My whole code: ``` import time import asyncio import colorama import subprocess from colorama import Fore, Back, Style from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.support.expected_conditions import presence_of_element_located driver = webdriver.Chrome( executable_path=r'C:\Users\Joe mama\Desktop\app\chromedriver.exe') colorama.init(autoreset=True) driver.get("https://www.currys.co.uk/gbuk/computing-accessories/components-upgrades/graphics-cards/msi-geforce-rtx-3060-ti-8-gb-gaming-x-trio-graphics-card-10219250-pdt.html") driver.maximize_window() Name = driver.find_elements_by_css_selector( "#content > div.product-page > section > div.to-print > h1 > span:nth-child(2)") Price = driver.find_elements_by_css_selector( "#product-actions > div.amounts > div > div > span.ProductPriceBlock__Price-kTVxGg.QWqil") Link = driver.find_elements_by_tag_name("a") OOS = driver.find_elements_by_css_selector( "#product-actions > div.oos.oos-no-alt.border.space-b > strong") ATC = driver.find_elements_by_css_selector( "#product-actions > div.channels.space-b > div.space-b.center > button") while True: try: if OOS.isDisplayed(): print(colorama.Fore.RED + f"|| {Name[0].text} || Out Of Stock || {Price[0].text} ||") driver.refresh() except: if ATC.isDisplayed(): print(colorama.Fore.GREEN + f'|| {Name[0].text} || IN STOCK || {Price[0].text} ||') ``` If anyone could help that would be very helpful, I've been trying to figure this out for ages.
2021/02/17
[ "https://Stackoverflow.com/questions/66251664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15231411/" ]
I was able to find a workaround. In my models.py I substituted this line: ``` from app import app as app ``` for this: ``` try: from app import app as app except ImportError: from __main__ import app ``` It works but it's ugly. I thought there must be a prettier way to do this.
Try to change app import in models.py to: ```py from flask import current_app as app ```
41,005,412
When using the pickle lib with some classes that i have created, the output is fairly easily readable to the user. For example, if i have a fill called saves, and save all my class data into a .save file inside it, when opening the file with a text editor, you can vaguely see all the variables and without too much struggle, change them to a desired result. Heres a snippet from a save file i created with pickle (it's a game): ``` S'Strength' p4 I5 sS'Health' p8 I100 ``` In this the value of 'Health' is 100 and the 'Strength' is 5, if the user was to edit the save file (as it will save locally), they could easily change any of the variables they'd like in order to cheat the game. Because i am creating a game where saving the game is one of the features i plan to implement this has become an issue. I did think about using encryption but using a second external lib is a last resort as it can be quite tedious, so i was wondering if there were any other ways i could go about doing this, or if pickle comes with a built in function for this (after researching i have not seen none).
2016/12/06
[ "https://Stackoverflow.com/questions/41005412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4440588/" ]
Instead of trying to make your data *unreadable*, you could simply sign the data and then authenticate it when read. ### Saving Here use [`hmac`](https://docs.python.org/3/library/hmac.html) to compute a hash. We then save the hash along with the data: ``` import hmac, pickle # pickle the data pickled = pickle.dumps(data) digest = hmac.new("some-shared-key", pickled, digestmod=<my choice of hasher> ).hexdigest() # now save the hashed digest and the pickled data with open("some-file", "wb") as f: # save these in some way you can distinguish them when you read them print(digest, file=f) print(pickled, file=f) ``` ### Loading To authenticate the data we recompute the digest of the pickled data and compare it against the digest saved alongside it. ``` import hmac, pickle with open("some-file", "rb") as f: digest = f.readline() pickled = f.read() # confirm integrity recomputed = hmac.new("some-shared-key", pickle, digestmod=<my choice of hasher> ).hexdigest() if not compare_digest(digest, recomputed): raise SomeOneIsCheatingOhNoException ```
One idea to obfuscate just a little bit is a simple hex conversion or an encoding of your choosing. For hex I'd do (+12 is random noise I guess) ``` mylist_obf = map(lambda item:int(item.encode('hex'))+12,mylist) ``` Get the original back by doing the reverse ``` my_original_list = map(lambda item: str(int(item)-12).decode('hex'),mylist_obf) ``` Mind you this is terribly insecure and will serve just to discourage players thinking it is actually encrypted.
22,322,038
I've a c application that uses a remote axis web service, when I connect to service using http protocol there is no problem, but when I want to use ssl, I can't call service operations & it just returns NULL. here is part of my axis2.xml for client application: ``` <transportReceiver name="http" class="axis2_http_receiver"> <parameter name="port" locked="false">6060</parameter> <parameter name="exposeHeaders" locked="true">false</parameter> </transportReceiver> <transportReceiver name="https" class="axis2_http_receiver"> <parameter name="port" locked="false">6060</parameter> <parameter name="exposeHeaders" locked="true">false</parameter> </transportReceiver> <transportSender name="http" class="axis2_http_sender"> <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter> <parameter name="xml-declaration" insert="false"/> <!--parameter name="Transfer-Encoding">chunked</parameter--> <!--parameter name="HTTP-Authentication" username="" password="" locked="true"/--> <!--parameter name="PROXY" proxy_host="127.0.0.1" proxy_port="8080" proxy_username="" proxy_password="" locked="true"/--> </transportSender> <transportSender name="https" class="axis2_http_sender"> <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter> <parameter name="xml-declaration" insert="false"/> </transportSender> ``` is it any error with this configurations? do I need something more? my server uses a self-signed certificate, can it cause the problem? Another question is that if I want to enable client authentication, How can I pass required parameters (SERVER\_CERT, KEY\_FILE, SSL\_PASSPHRASE) programmatically in my code (& not in axis2.xml)? **EDIT :** I succeed to connect to service via normal SSL (with no client authentication), but when I want to use client authentication, client fails with the following log: ``` [Sun Mar 16 12:49:10 2014] [info] Starting addressing out handler [Sun Mar 16 12:49:10 2014] [debug] ..\..\src\modules\mod_addr\addr_out_handler.c(133) No action present. Stop processing addressing [Sun Mar 16 12:49:10 2014] [debug] ..\..\src\core\transport\http\sender\http_transport_sender.c(246) ctx_epr:https://mysite.com/axis2/services/myService [Sun Mar 16 12:49:10 2014] [debug] ..\..\src\core\transport\http\sender\http_transport_sender.c(805) using axis2 native http sender. [Sun Mar 16 12:49:10 2014] [debug] ..\..\src\core\transport\http\sender\http_sender.c(416) msg_ctx_id:urn:uuid:fe18bf10-6611-4af9-85f6-b062bd7eb231 [Sun Mar 16 12:49:14 2014] [debug] ..\..\src\core\transport\http\sender\http_client.c(571) http client , response timed out [Sun Mar 16 12:49:14 2014] [error] ..\..\src\core\transport\http\sender\http_client.c(574) Response timed out [Sun Mar 16 12:49:14 2014] [error] ..\..\src\core\transport\http\sender\http_sender.c(1381) status_code < 0 [Sun Mar 16 12:49:14 2014] [error] ..\..\src\core\engine\engine.c(179) Transport sender invoke failed ```
2014/03/11
[ "https://Stackoverflow.com/questions/22322038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/183652/" ]
Delete the folder "D:\WORK\target\tomcat\" and try again, the tomcat-maven-plugin would re-create this folder and the file "tomcat-users.xml".
Create a file for Tomcat users in: ``` D:\WORK\target\tomcat\conf\tomcat-users.xml ``` and add the following: ``` <?xml version="1.0" encoding="UTF-8"?> <tomcat-users> <role rolename="tomcat"/> <role rolename="admin"/> <role rolename="manager"/> <user username="admin" password="admin" roles="tomcat,admin,manager"/> </tomcat-users> ```
22,322,038
I've a c application that uses a remote axis web service, when I connect to service using http protocol there is no problem, but when I want to use ssl, I can't call service operations & it just returns NULL. here is part of my axis2.xml for client application: ``` <transportReceiver name="http" class="axis2_http_receiver"> <parameter name="port" locked="false">6060</parameter> <parameter name="exposeHeaders" locked="true">false</parameter> </transportReceiver> <transportReceiver name="https" class="axis2_http_receiver"> <parameter name="port" locked="false">6060</parameter> <parameter name="exposeHeaders" locked="true">false</parameter> </transportReceiver> <transportSender name="http" class="axis2_http_sender"> <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter> <parameter name="xml-declaration" insert="false"/> <!--parameter name="Transfer-Encoding">chunked</parameter--> <!--parameter name="HTTP-Authentication" username="" password="" locked="true"/--> <!--parameter name="PROXY" proxy_host="127.0.0.1" proxy_port="8080" proxy_username="" proxy_password="" locked="true"/--> </transportSender> <transportSender name="https" class="axis2_http_sender"> <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter> <parameter name="xml-declaration" insert="false"/> </transportSender> ``` is it any error with this configurations? do I need something more? my server uses a self-signed certificate, can it cause the problem? Another question is that if I want to enable client authentication, How can I pass required parameters (SERVER\_CERT, KEY\_FILE, SSL\_PASSPHRASE) programmatically in my code (& not in axis2.xml)? **EDIT :** I succeed to connect to service via normal SSL (with no client authentication), but when I want to use client authentication, client fails with the following log: ``` [Sun Mar 16 12:49:10 2014] [info] Starting addressing out handler [Sun Mar 16 12:49:10 2014] [debug] ..\..\src\modules\mod_addr\addr_out_handler.c(133) No action present. Stop processing addressing [Sun Mar 16 12:49:10 2014] [debug] ..\..\src\core\transport\http\sender\http_transport_sender.c(246) ctx_epr:https://mysite.com/axis2/services/myService [Sun Mar 16 12:49:10 2014] [debug] ..\..\src\core\transport\http\sender\http_transport_sender.c(805) using axis2 native http sender. [Sun Mar 16 12:49:10 2014] [debug] ..\..\src\core\transport\http\sender\http_sender.c(416) msg_ctx_id:urn:uuid:fe18bf10-6611-4af9-85f6-b062bd7eb231 [Sun Mar 16 12:49:14 2014] [debug] ..\..\src\core\transport\http\sender\http_client.c(571) http client , response timed out [Sun Mar 16 12:49:14 2014] [error] ..\..\src\core\transport\http\sender\http_client.c(574) Response timed out [Sun Mar 16 12:49:14 2014] [error] ..\..\src\core\transport\http\sender\http_sender.c(1381) status_code < 0 [Sun Mar 16 12:49:14 2014] [error] ..\..\src\core\engine\engine.c(179) Transport sender invoke failed ```
2014/03/11
[ "https://Stackoverflow.com/questions/22322038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/183652/" ]
Create a file for Tomcat users in: ``` D:\WORK\target\tomcat\conf\tomcat-users.xml ``` and add the following: ``` <?xml version="1.0" encoding="UTF-8"?> <tomcat-users> <role rolename="tomcat"/> <role rolename="admin"/> <role rolename="manager"/> <user username="admin" password="admin" roles="tomcat,admin,manager"/> </tomcat-users> ```
1. Use tomcat maven plugin, start the web application 2. Rebuild the project 3. Restart tomcat maven plugin. 4. The error must occur **Solution:** Before rebuilding the project, you must stop tomcat maven plugin first.
22,322,038
I've a c application that uses a remote axis web service, when I connect to service using http protocol there is no problem, but when I want to use ssl, I can't call service operations & it just returns NULL. here is part of my axis2.xml for client application: ``` <transportReceiver name="http" class="axis2_http_receiver"> <parameter name="port" locked="false">6060</parameter> <parameter name="exposeHeaders" locked="true">false</parameter> </transportReceiver> <transportReceiver name="https" class="axis2_http_receiver"> <parameter name="port" locked="false">6060</parameter> <parameter name="exposeHeaders" locked="true">false</parameter> </transportReceiver> <transportSender name="http" class="axis2_http_sender"> <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter> <parameter name="xml-declaration" insert="false"/> <!--parameter name="Transfer-Encoding">chunked</parameter--> <!--parameter name="HTTP-Authentication" username="" password="" locked="true"/--> <!--parameter name="PROXY" proxy_host="127.0.0.1" proxy_port="8080" proxy_username="" proxy_password="" locked="true"/--> </transportSender> <transportSender name="https" class="axis2_http_sender"> <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter> <parameter name="xml-declaration" insert="false"/> </transportSender> ``` is it any error with this configurations? do I need something more? my server uses a self-signed certificate, can it cause the problem? Another question is that if I want to enable client authentication, How can I pass required parameters (SERVER\_CERT, KEY\_FILE, SSL\_PASSPHRASE) programmatically in my code (& not in axis2.xml)? **EDIT :** I succeed to connect to service via normal SSL (with no client authentication), but when I want to use client authentication, client fails with the following log: ``` [Sun Mar 16 12:49:10 2014] [info] Starting addressing out handler [Sun Mar 16 12:49:10 2014] [debug] ..\..\src\modules\mod_addr\addr_out_handler.c(133) No action present. Stop processing addressing [Sun Mar 16 12:49:10 2014] [debug] ..\..\src\core\transport\http\sender\http_transport_sender.c(246) ctx_epr:https://mysite.com/axis2/services/myService [Sun Mar 16 12:49:10 2014] [debug] ..\..\src\core\transport\http\sender\http_transport_sender.c(805) using axis2 native http sender. [Sun Mar 16 12:49:10 2014] [debug] ..\..\src\core\transport\http\sender\http_sender.c(416) msg_ctx_id:urn:uuid:fe18bf10-6611-4af9-85f6-b062bd7eb231 [Sun Mar 16 12:49:14 2014] [debug] ..\..\src\core\transport\http\sender\http_client.c(571) http client , response timed out [Sun Mar 16 12:49:14 2014] [error] ..\..\src\core\transport\http\sender\http_client.c(574) Response timed out [Sun Mar 16 12:49:14 2014] [error] ..\..\src\core\transport\http\sender\http_sender.c(1381) status_code < 0 [Sun Mar 16 12:49:14 2014] [error] ..\..\src\core\engine\engine.c(179) Transport sender invoke failed ```
2014/03/11
[ "https://Stackoverflow.com/questions/22322038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/183652/" ]
Delete the folder "D:\WORK\target\tomcat\" and try again, the tomcat-maven-plugin would re-create this folder and the file "tomcat-users.xml".
1. Use tomcat maven plugin, start the web application 2. Rebuild the project 3. Restart tomcat maven plugin. 4. The error must occur **Solution:** Before rebuilding the project, you must stop tomcat maven plugin first.
8,574,968
I am creating Google integrated asp.net Application. i want to retrieve all the information of a friend of logged in user in gmail. I got the list of contacts in gridview. But I am not able to get the profile pic of any contact. I am adding datacolumns dynamically in the gridview. Here is my code of retrieving photo: ``` RequestSettings rs = new RequestSettings(App_Name, Uname, Password_property); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> f = cr.GetContacts(); foreach (Contact t in f.Entries) { Stream photo = cr.Service.Query(t.PhotoUri); if (photo != null) { dr1["Profile Pic"] = System.Drawing.Image.FromStream(photo); } } ``` It crashes and says remote server returned an error. Then i tried another code: ``` Stream photo = cr.GetPhoto(t); if (photo != null) { dr1["Profile Pic"] = System.Drawing.Image.FromStream(photo); } ``` It also crashes and gives error of ``` Google.GData.Client.GDataNotModifiedException : Content not modified ``` I am not able to get the contact photo anyhow. Any help is appreciated. Thanks
2011/12/20
[ "https://Stackoverflow.com/questions/8574968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1099303/" ]
The following code works fine for me: ``` public static List<ContactDetail> GetAllContact(string username, string password) { List<ContactDetail> contactDetails = new List<ContactDetail>(); ContactsQuery query = new ContactsQuery(ContactsQuery.CreateContactsUri("default")); RequestSettings rs = new RequestSettings("W7CallerID", username, password); ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> feed = cr.GetContacts(); foreach (Contact entry in feed.Entries) { ContactDetail contact = new ContactDetail { Name = entry.Name.FullName, EmailAddress1 = entry.Emails.Count >= 1 ? entry.Emails[0].Address : "", EmailAddress2 = entry.Emails.Count >= 2 ? entry.Emails[1].Address : "", Phone = entry.Phonenumbers.Count >= 1 ? entry.Phonenumbers[0].Value : "", Details = entry.Content, Pic = System.Drawing.Image.FromStream(cr.Service.Query(entry.PhotoUri)) }; contactDetails.Add(contact); } return contactDetails; } ```
I Have managed to successfully retrieve photographs using the GData Library. Photographs are returned as a stream. The following code retrieves the stream ``` requestFactory = new GOAuthRequestFactory("c1", ApplicationName, parameters); service = new ContactsService(ApplicationName); service.RequestFactory = requestFactory; resultsStream = service.Query(new Uri(Uri)); ```
39,131,713
I'd like to know why ternary conditional-statements like these: `on_actu.boolean ? IMG1 = "on-actu.png" : IMG1 = "off-actu.png";` give me the following JSLint error : > > expected an assignment or function call and instead saw an expression > > >
2016/08/24
[ "https://Stackoverflow.com/questions/39131713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6524096/" ]
You're using the ternary operator wrong. ``` ValueToAssign = BooleanConditional ? valueOne : valueTwo; ``` More information here: <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator>
On the left you can specify variable to which you are setting value, and on the right the actual value; ``` IMG1 = on_actu.boolean ? "on-actu.png" : "off-actu.png"; ```
39,131,713
I'd like to know why ternary conditional-statements like these: `on_actu.boolean ? IMG1 = "on-actu.png" : IMG1 = "off-actu.png";` give me the following JSLint error : > > expected an assignment or function call and instead saw an expression > > >
2016/08/24
[ "https://Stackoverflow.com/questions/39131713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6524096/" ]
You're using the ternary operator wrong. ``` ValueToAssign = BooleanConditional ? valueOne : valueTwo; ``` More information here: <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator>
You should use this example ``` var IMG1 = on_actu.boolean ? "on-actu.png" : "off-actu.png"; ``` Regars
39,131,713
I'd like to know why ternary conditional-statements like these: `on_actu.boolean ? IMG1 = "on-actu.png" : IMG1 = "off-actu.png";` give me the following JSLint error : > > expected an assignment or function call and instead saw an expression > > >
2016/08/24
[ "https://Stackoverflow.com/questions/39131713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6524096/" ]
On the left you can specify variable to which you are setting value, and on the right the actual value; ``` IMG1 = on_actu.boolean ? "on-actu.png" : "off-actu.png"; ```
You should use this example ``` var IMG1 = on_actu.boolean ? "on-actu.png" : "off-actu.png"; ``` Regars
66,842,297
I have a function like so: ``` const x = y(callback); x(); ``` It may be called with a synchronous or asynchronous callback: ``` const a = y(() => 42); const b = y(async () => Promise.resolve(42)); ``` The function `y` should take a callback, that can be synchronous or asynchronous. Is it possible to catch a thrown error from either a synchronous or asynchronous callback? I can't simply wrap the callback in a `try/catch`: ``` const y = (callback) => function () { try { return callback(...arguments); } catch (callbackError) { throw callbackError; } }; ``` because that doesn't catch the errors thrown from promises. I can't just chain a `.catch` onto the callback as it might not be a promise. I've read that checking if a function is a promise before calling it [may not trivial/may not be possible](https://stackoverflow.com/questions/38508420/how-to-know-if-a-function-is-async). I can't call it to check if it returns a promise before chaining the `catch` onto it because if it throws, the `catch` would not have yet been chained onto the call Is there a way to catch an error from a callback that may or may not be a promise? --- Per the comments, I should have specified I don't want the function to return a promise. That is: ``` const a = y(() => { throw new Error(); })(); console.log(a instanceof Error); const b = y(async () => { throw new Error(); })(); console.log(b instanceof Error); const c = y(() => 42)(); console.log(c === 42); const d = y(async () => Promise.resolve(42))(); console.log(d instanceof Promise); ``` should all be true. Simply put, I want to return an error or the result
2021/03/28
[ "https://Stackoverflow.com/questions/66842297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2483271/" ]
An async function also emits a promise, you might consider to also wrap the async inside a promise, which on resolution emits the value
Well you can do something like this by making all your code async... If I get your problem right. UPD: understand the problem, here is my approach ```js (async () => { // Run fn const fn = callback => { return new Promise(async (resolve, reject) => { const res = await callback().catch(err => reject(err)); // Resolve resolve(res); }); }; const variousFNs = [ // Function 1 { fn: () => 2+2 }, // Function 2 with error { fn: () => { const x = 1; x = 2; return x; } }, // Promise Function 3 { fn: () => Promise.resolve(8) }, // Promise function 4 with error { fn: () => new Promise(async (resolve, reject) => reject('some promise error')) } ]; // // // Run all your fns for (let i = 0; i < variousFNs.length; i++) { try { const res = await variousFNs[i].fn(); console.log(res); } catch(err) { console.log(`Error catched: ${err}`); } } })(); ```
66,842,297
I have a function like so: ``` const x = y(callback); x(); ``` It may be called with a synchronous or asynchronous callback: ``` const a = y(() => 42); const b = y(async () => Promise.resolve(42)); ``` The function `y` should take a callback, that can be synchronous or asynchronous. Is it possible to catch a thrown error from either a synchronous or asynchronous callback? I can't simply wrap the callback in a `try/catch`: ``` const y = (callback) => function () { try { return callback(...arguments); } catch (callbackError) { throw callbackError; } }; ``` because that doesn't catch the errors thrown from promises. I can't just chain a `.catch` onto the callback as it might not be a promise. I've read that checking if a function is a promise before calling it [may not trivial/may not be possible](https://stackoverflow.com/questions/38508420/how-to-know-if-a-function-is-async). I can't call it to check if it returns a promise before chaining the `catch` onto it because if it throws, the `catch` would not have yet been chained onto the call Is there a way to catch an error from a callback that may or may not be a promise? --- Per the comments, I should have specified I don't want the function to return a promise. That is: ``` const a = y(() => { throw new Error(); })(); console.log(a instanceof Error); const b = y(async () => { throw new Error(); })(); console.log(b instanceof Error); const c = y(() => 42)(); console.log(c === 42); const d = y(async () => Promise.resolve(42))(); console.log(d instanceof Promise); ``` should all be true. Simply put, I want to return an error or the result
2021/03/28
[ "https://Stackoverflow.com/questions/66842297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2483271/" ]
Realised that it's not necessary to chain the `catch` immediately! So the following abomination allows me to determine if it is a promise and handle the error accordingly: ``` const y = (error, callback) => function () { try { const returnValue = callback(...arguments); if (returnValue instanceof Promise) { return returnValue.catch((callbackError) => { return callbackError; }); } else { return returnValue; } } catch (callbackError) { return callbackError; } }; ``` If you're wondering why this function is useful, here's an example of what I'm using it for. It modifies the error (chaining it with another error, see [`VError`](https://github.com/joyent/node-verror)) before returning it: ``` const y = (error, callback) => function () { try { const returnValue = callback(...arguments); if (returnValue instanceof Promise) { return returnValue.catch((callbackError) => { throw VError(error, callbackError); }); } else { return returnValue; } } catch (callbackError) { throw VError(error, callbackError); } }; ``` Note the return of the following as per the question: ``` const a = y(() => 42)(); // returns '42' const b = y(async () => Promise.resolve(42))(); // returns 'Promise {42}' const c = y(() => { throw new Error('Base'); })(); // throws VError const d = y(async () => { throw new Error('Base'); })(); // throws VError ```
An async function also emits a promise, you might consider to also wrap the async inside a promise, which on resolution emits the value
66,842,297
I have a function like so: ``` const x = y(callback); x(); ``` It may be called with a synchronous or asynchronous callback: ``` const a = y(() => 42); const b = y(async () => Promise.resolve(42)); ``` The function `y` should take a callback, that can be synchronous or asynchronous. Is it possible to catch a thrown error from either a synchronous or asynchronous callback? I can't simply wrap the callback in a `try/catch`: ``` const y = (callback) => function () { try { return callback(...arguments); } catch (callbackError) { throw callbackError; } }; ``` because that doesn't catch the errors thrown from promises. I can't just chain a `.catch` onto the callback as it might not be a promise. I've read that checking if a function is a promise before calling it [may not trivial/may not be possible](https://stackoverflow.com/questions/38508420/how-to-know-if-a-function-is-async). I can't call it to check if it returns a promise before chaining the `catch` onto it because if it throws, the `catch` would not have yet been chained onto the call Is there a way to catch an error from a callback that may or may not be a promise? --- Per the comments, I should have specified I don't want the function to return a promise. That is: ``` const a = y(() => { throw new Error(); })(); console.log(a instanceof Error); const b = y(async () => { throw new Error(); })(); console.log(b instanceof Error); const c = y(() => 42)(); console.log(c === 42); const d = y(async () => Promise.resolve(42))(); console.log(d instanceof Promise); ``` should all be true. Simply put, I want to return an error or the result
2021/03/28
[ "https://Stackoverflow.com/questions/66842297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2483271/" ]
Realised that it's not necessary to chain the `catch` immediately! So the following abomination allows me to determine if it is a promise and handle the error accordingly: ``` const y = (error, callback) => function () { try { const returnValue = callback(...arguments); if (returnValue instanceof Promise) { return returnValue.catch((callbackError) => { return callbackError; }); } else { return returnValue; } } catch (callbackError) { return callbackError; } }; ``` If you're wondering why this function is useful, here's an example of what I'm using it for. It modifies the error (chaining it with another error, see [`VError`](https://github.com/joyent/node-verror)) before returning it: ``` const y = (error, callback) => function () { try { const returnValue = callback(...arguments); if (returnValue instanceof Promise) { return returnValue.catch((callbackError) => { throw VError(error, callbackError); }); } else { return returnValue; } } catch (callbackError) { throw VError(error, callbackError); } }; ``` Note the return of the following as per the question: ``` const a = y(() => 42)(); // returns '42' const b = y(async () => Promise.resolve(42))(); // returns 'Promise {42}' const c = y(() => { throw new Error('Base'); })(); // throws VError const d = y(async () => { throw new Error('Base'); })(); // throws VError ```
Well you can do something like this by making all your code async... If I get your problem right. UPD: understand the problem, here is my approach ```js (async () => { // Run fn const fn = callback => { return new Promise(async (resolve, reject) => { const res = await callback().catch(err => reject(err)); // Resolve resolve(res); }); }; const variousFNs = [ // Function 1 { fn: () => 2+2 }, // Function 2 with error { fn: () => { const x = 1; x = 2; return x; } }, // Promise Function 3 { fn: () => Promise.resolve(8) }, // Promise function 4 with error { fn: () => new Promise(async (resolve, reject) => reject('some promise error')) } ]; // // // Run all your fns for (let i = 0; i < variousFNs.length; i++) { try { const res = await variousFNs[i].fn(); console.log(res); } catch(err) { console.log(`Error catched: ${err}`); } } })(); ```
66,842,297
I have a function like so: ``` const x = y(callback); x(); ``` It may be called with a synchronous or asynchronous callback: ``` const a = y(() => 42); const b = y(async () => Promise.resolve(42)); ``` The function `y` should take a callback, that can be synchronous or asynchronous. Is it possible to catch a thrown error from either a synchronous or asynchronous callback? I can't simply wrap the callback in a `try/catch`: ``` const y = (callback) => function () { try { return callback(...arguments); } catch (callbackError) { throw callbackError; } }; ``` because that doesn't catch the errors thrown from promises. I can't just chain a `.catch` onto the callback as it might not be a promise. I've read that checking if a function is a promise before calling it [may not trivial/may not be possible](https://stackoverflow.com/questions/38508420/how-to-know-if-a-function-is-async). I can't call it to check if it returns a promise before chaining the `catch` onto it because if it throws, the `catch` would not have yet been chained onto the call Is there a way to catch an error from a callback that may or may not be a promise? --- Per the comments, I should have specified I don't want the function to return a promise. That is: ``` const a = y(() => { throw new Error(); })(); console.log(a instanceof Error); const b = y(async () => { throw new Error(); })(); console.log(b instanceof Error); const c = y(() => 42)(); console.log(c === 42); const d = y(async () => Promise.resolve(42))(); console.log(d instanceof Promise); ``` should all be true. Simply put, I want to return an error or the result
2021/03/28
[ "https://Stackoverflow.com/questions/66842297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2483271/" ]
You can use `async/await` notation here. Await will work with both synchronous and asnychronous functions. Try to do: ```js async function init() { const x = y( async () => await callback() ); try { await x(); } catch(error) { /.../ } } ``` and your function can be simplified now to: ```js const y = (callback) => function (...argument) { return callback(...arguments); }; ```
Well you can do something like this by making all your code async... If I get your problem right. UPD: understand the problem, here is my approach ```js (async () => { // Run fn const fn = callback => { return new Promise(async (resolve, reject) => { const res = await callback().catch(err => reject(err)); // Resolve resolve(res); }); }; const variousFNs = [ // Function 1 { fn: () => 2+2 }, // Function 2 with error { fn: () => { const x = 1; x = 2; return x; } }, // Promise Function 3 { fn: () => Promise.resolve(8) }, // Promise function 4 with error { fn: () => new Promise(async (resolve, reject) => reject('some promise error')) } ]; // // // Run all your fns for (let i = 0; i < variousFNs.length; i++) { try { const res = await variousFNs[i].fn(); console.log(res); } catch(err) { console.log(`Error catched: ${err}`); } } })(); ```
66,842,297
I have a function like so: ``` const x = y(callback); x(); ``` It may be called with a synchronous or asynchronous callback: ``` const a = y(() => 42); const b = y(async () => Promise.resolve(42)); ``` The function `y` should take a callback, that can be synchronous or asynchronous. Is it possible to catch a thrown error from either a synchronous or asynchronous callback? I can't simply wrap the callback in a `try/catch`: ``` const y = (callback) => function () { try { return callback(...arguments); } catch (callbackError) { throw callbackError; } }; ``` because that doesn't catch the errors thrown from promises. I can't just chain a `.catch` onto the callback as it might not be a promise. I've read that checking if a function is a promise before calling it [may not trivial/may not be possible](https://stackoverflow.com/questions/38508420/how-to-know-if-a-function-is-async). I can't call it to check if it returns a promise before chaining the `catch` onto it because if it throws, the `catch` would not have yet been chained onto the call Is there a way to catch an error from a callback that may or may not be a promise? --- Per the comments, I should have specified I don't want the function to return a promise. That is: ``` const a = y(() => { throw new Error(); })(); console.log(a instanceof Error); const b = y(async () => { throw new Error(); })(); console.log(b instanceof Error); const c = y(() => 42)(); console.log(c === 42); const d = y(async () => Promise.resolve(42))(); console.log(d instanceof Promise); ``` should all be true. Simply put, I want to return an error or the result
2021/03/28
[ "https://Stackoverflow.com/questions/66842297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2483271/" ]
Realised that it's not necessary to chain the `catch` immediately! So the following abomination allows me to determine if it is a promise and handle the error accordingly: ``` const y = (error, callback) => function () { try { const returnValue = callback(...arguments); if (returnValue instanceof Promise) { return returnValue.catch((callbackError) => { return callbackError; }); } else { return returnValue; } } catch (callbackError) { return callbackError; } }; ``` If you're wondering why this function is useful, here's an example of what I'm using it for. It modifies the error (chaining it with another error, see [`VError`](https://github.com/joyent/node-verror)) before returning it: ``` const y = (error, callback) => function () { try { const returnValue = callback(...arguments); if (returnValue instanceof Promise) { return returnValue.catch((callbackError) => { throw VError(error, callbackError); }); } else { return returnValue; } } catch (callbackError) { throw VError(error, callbackError); } }; ``` Note the return of the following as per the question: ``` const a = y(() => 42)(); // returns '42' const b = y(async () => Promise.resolve(42))(); // returns 'Promise {42}' const c = y(() => { throw new Error('Base'); })(); // throws VError const d = y(async () => { throw new Error('Base'); })(); // throws VError ```
You can use `async/await` notation here. Await will work with both synchronous and asnychronous functions. Try to do: ```js async function init() { const x = y( async () => await callback() ); try { await x(); } catch(error) { /.../ } } ``` and your function can be simplified now to: ```js const y = (callback) => function (...argument) { return callback(...arguments); }; ```
28,862,708
i have a bunch of nested HTML elements, like ``` <div> <div> <div>A</div> </div> <div> <div><span>B</span></div> </div> </div> ``` Is there a way to only select the innermost divs, those that do not contain any other divs? Notice that div B does have descendants, but no other divs. **Clarification** i mean to select all those divs that do not contain another div, but maybe some other tags.
2015/03/04
[ "https://Stackoverflow.com/questions/28862708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/256361/" ]
> > Is there a way to only select the innermost divs, those that do not contain any other divs? > > > You could combine the [`:not()`](http://api.jquery.com/not-selector/)/[`:has()`](http://api.jquery.com/has-selector/) selectors in order to select the innermost `div` elements that don't contain other `div` elements: ``` $('div:not(:has(div))'); ``` Given the HTML you provided, if you don't want the `div` with the "A" text node to be selected, you could only select elements that contain other elements, in this case a `span`: [**Example Here**](http://jsfiddle.net/zx9breag/) ``` $('div:not(:has(div)):has(*)'); ```
Can do something like: ``` $('div').not(':has(div)').css('color','red') ``` explanation is ambiguous though so not 100% clear that this is expected result `**[DEMO](http://jsfiddle.net/m8t9Ljsp/)**`
58,569,543
This question is about my understanding of what kind of material design I should use so that I can implement something below in iOS. Please find a image of what we have in Android, <https://www.filemail.com/d/jezaeiintbbjihn> We call our location API every 10 secs which moves the icon. When the user clicks on the icon it opens a bottom drawer. It's refreshed every 10 seconds and shows data from the API until we close that drawer. In iOS, what kind of material design shall I consider for this? The example API out put we have: ``` {"user_id":"xxxxx-036e-45ea-abac-4d84511e1654","device_id":"xxxxx","timestamp":"2019-10-26 09:22:25","location":"23.736756666666665;90.41241999999998","lsb":0,"speed":"25.2","heading":108.36,"engine":1,"door":0,"fuel":"0.00","temperature":"0","ins_timestamp":"2019-10-26 09:22:31"} ```
2019/10/26
[ "https://Stackoverflow.com/questions/58569543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5738609/" ]
Google themselves has been open-sourcing the components they’ve used to build Material Design-powered apps on iOS. If you wish to have the almost same feel that you have in your android application you can try using the google's open sourced material components for iOS. You can refer the link to know more. <https://material.io/develop/ios/> For your need, you can use bottomsheet material component for iOS provided by material.io. <https://material.io/develop/ios/components/bottom-sheet/>
You can check the following also: <https://github.com/amr-abdelfattah/iOS-OptionMenu> I have built it based on: <https://material.io/develop/ios/components/bottom-sheet/> It’s for easily and flexible creation of Material Bottom Sheet.
26,770,307
I am trying to create an app that will play some audio files. I was hoping to stream the audio from a web server, but so far am placing an mp3 directly into the project as I don't know how to link to http urls. I have created a stop button and my understanding is that if you press stop and then play again, the mp3 file should resume from where it has stopped. That's not happening for me. Any clues as to what I have done wrong please? I have also tried using pause as well with no change. Many thanks in advance. The code from my .h file is below. Also, what do I need to do if I want to have multiple audio files? ``` #import "ViewController.h" @interface ViewController () @end @implementation ViewController AVAudioPlayer *player; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)play:(id)sender { NSURL *songURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"hustle" ofType:@"mp3"]]; player = [[AVAudioPlayer alloc] initWithContentsOfURL:songURL error:nil]; player.volume = 0.5; [player play]; } - (IBAction)pause:(id)sender { [player stop]; } - (IBAction)volumeChanged:(id)sender { player.volume = volumeSlider.value; } @end ``` Here is the edited .m file with the array: ``` #import "ViewController.h" @interface ViewController () @end @implementation ViewController AVAudioPlayer *player; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //NSURL *songURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"hustle" ofType:@"mp3"]]; //player = [[AVAudioPlayer alloc] initWithContentsOfURL:songURL error:nil]; //player.volume = 0.5; songsArray = [[NSMutableArray alloc] initWithObjects:@"hustle", @"hustle2", nil]; NSUInteger currentTrackNumber; currentTrackNumber=0; } - (IBAction)startPlaying { if (player) { [player stop]; player = nil; } player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[[NSString alloc] initWithString:[songsArray objectAtIndex:currentTrackNumber]] ofType:@"mp3"]] error:NULL]; player.delegate = self; [player play]; } - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player1 successfully:(BOOL)flag { if (flag) { if (currentTrackNumber < [songsArray count] - 1) { currentTrackNumber ++; if (player) { [player stop]; player = nil; } player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource:[[NSString alloc] initWithString:[songsArray objectAtIndex:currentTrackNumber]] ofType:@"mp3"]] error:NULL]; player.delegate = self; [player play]; } } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)play:(id)sender { [player play]; } - (IBAction)pause:(id)sender { [player stop]; } - (IBAction)volumeChanged:(id)sender { player.volume = volumeSlider.value; } @end ```
2014/11/06
[ "https://Stackoverflow.com/questions/26770307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3934210/" ]
``` Write the code like this, when you click on the pause button the audio stopped then click on the play button the audio will resumed where the audio stopped. - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. NSURL *songURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"hustle" ofType:@"mp3"]]; player = [[AVAudioPlayer alloc] initWithContentsOfURL:songURL error:nil]; player.volume = 0.5; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (IBAction)play:(id)sender { [player play]; } - (IBAction)pause:(id)sender { [player stop]; } ```
@user3934210 Take a array in .h file and write protocol delegate for Player "AVAudioPlayerDelegate>" ``` NSMutableArray *songsArray; ``` in .m files ``` Add all the .mp3 songs to the array in viewDidLoad songsArray = [[NSMutableArray alloc]initWithObjects:@“A”,@“B”,@“C”,nil]; //replace your files then take one Integer value to find the current song NSUInteger currentTrackNumber; and set the currentTrackNumber=0 in viewDidLoad, then copy the below code - (IBAction)startPlaying { if (player) { [player stop]; player = nil; } player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[[NSString alloc] initWithString:[songsArray objectAtIndex:currentTrackNumber]] ofType:@"mp3"]] error:NULL]; player.delegate = self; [player play]; } - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player1 successfully:(BOOL)flag { if (flag) { if (currentTrackNumber < [songsArray count] - 1) { currentTrackNumber ++; if (player) { [player stop]; player = nil; } player = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[[NSString alloc] initWithString:[songsArray objectAtIndex:currentTrackNumber]] ofType:@"mp3"]] error:NULL]; player.delegate = self; [player play]; } } } ```
18,343,955
I have noticed similar repetition and trying to work around using a single for loop for this if I can to minimize the code length: I wouldn't need to use a switch case if I can form a loop instead? 1. $returnNo variable starts at 5, each case multiplied by 2 then minus 1. 2. where it shows "$a<=", it starts at 5 and each case multiplied by 2 then plus 3. 3. the if() statement starting at if($matchno == 7), each case multiplied by 2 then plus 1. 4. the final if() statement starting at if($matchno == 8), each case multiplied by 2. 5. I have done up to case 64, it will actually go up to 512. As I know the code is repeating I am hoping someone can help me produce a single loop for this? Many thanks! ``` switch($max) { case 80 : $returnNO = 5; for($a = 1; $a<=5; $a++) { if($matchno == $a || $matchno == ($a+1)){ $matchinfo['matchno'] = $returnNO; $matchinfo['place'] = ($matchno == $a ? 'clan1' : 'clan2'); return $matchinfo; } $returnNO++; $a++; } if($matchno == 7){ $matchinfo['winner'] = true; return $matchinfo; }elseif($matchno == 8){ $matchinfo['third_winner'] = true; return $matchinfo; } break; case 160 : $returnNO = 9; for($a = 1; $a<=13; $a++) { if($matchno == $a || $matchno == ($a+1)){ $matchinfo['matchno'] = $returnNO; $matchinfo['place'] = ($matchno == $a ? 'clan1' : 'clan2'); return $matchinfo; } $returnNO++; $a++; } if($matchno == 15){ $matchinfo['winner'] = true; return $matchinfo; }elseif($matchno == 16){ $matchinfo['third_winner'] = true; return $matchinfo; } break; case 320 : $returnNO = 17; for($a = 1; $a<=29; $a++) { if($matchno == $a || $matchno == ($a+1)){ $matchinfo['matchno'] = $returnNO; $matchinfo['place'] = ($matchno == $a ? 'clan1' : 'clan2'); return $matchinfo; } $returnNO++; $a++; } if($matchno == 31){ $matchinfo['winner'] = true; return $matchinfo; } elseif($matchno == 32){ $matchinfo['third_winner'] = true; return $matchinfo; } break; case 640 : $returnNO = 33; for($a = 1; $a<=61; $a++) { if($matchno == $a || $matchno == ($a+1)){ $matchinfo['matchno'] = $returnNO; $matchinfo['place'] = ($matchno == $a ? 'clan1' : 'clan2'); return $matchinfo; } $returnNO++; $a++; } if($matchno == 63){ $matchinfo['winner'] = true; return $matchinfo; }elseif($matchno == 64){ $matchinfo['third_winner'] = true; return $matchinfo; } break; } } ```
2013/08/20
[ "https://Stackoverflow.com/questions/18343955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2447836/" ]
I'll use the first two cases as an example: ``` switch ($max) { case 80: $returnNO = 5; $loopCount = 5; $winner = 7; $thirdWinner = 8; break; case 160: $returnNO = 9; $loopCount = 13; $winner = 15; $thirdWinner = 16; break; ... } for ($a = 1; $a <= $loopCount; $a++) { if ($matchno == $a || $matchno == ($a + 1)) { $matchinfo['matchno'] = $returnNO; $matchinfo['place'] = ($matchno == $a ? 'clan1' : 'clan2'); return $matchinfo; } } if ($matchno == $winner) { $matchinfo['winner'] = true; return $matchinfo; } else if ($matchno == $thirdWinner) { $matchinfo['third_winner'] = true; return $matchinfo; } ``` Simply explained, remove the code that repeats all the time and try to parameterize it (either by creating a function or by putting all repeated code somewhere else... in this example, I put the repeating code after the switch statement and paremeterized it.
If I understood well, here is an alternative solution which I think would work for all cases you specified, with no use of switch case. ``` $div10 = $max / 10; $maxLoop = $div10 - 3; $returnNO = $div10 / 2 + 1; for($a = 1; $a<=$maxLoop; $a++) { if($matchno == $a || $matchno == ($a+1)){ $matchinfo['matchno'] = $returnNO; $matchinfo['place'] = ($matchno == $a ? 'clan1' : 'clan2'); return $matchinfo; } $returnNO++; $a++; } if($matchno == ($div10-1)){ $matchinfo['winner'] = true; return $matchinfo; }elseif($matchno == $div10){ $matchinfo['third_winner'] = true; return $matchinfo; } ```
597,875
I am following the experiment in the popular electronics book - "Make: Electronics third edition". However, when replicating one of the experiments mentioned in the book (specifically Experiment 3 "Applying pressure", the part under the subheading "It's the law!", Pg 28), I am stuck. I believe the experiment is trying to teach the effect of varying resistances in a circuit on the current reading (read using a multimeter). In my case I do not see a reading on my meter at all, it reads 0 Amps (see attached images). I have run the following diagnostics: 1. Check battery voltage (it reads about 9.5v), switched to a different battery, just in case. 2. Vary the resistance, instead of 1kohms I tried 470 ohms. 3. Continuity tests on circuit connections. 4. Check if the multimeter fuse is blown. The way I did this is by opening up the meter, using the meter's own probes to measure resistance across the glass fuse inside, which reads a value close to 0 ohms which means it offers little to no resistance, meaning it's not blown. I could have just done this wrong. 5. Create circuit connections using just alligator clips and wires to eliminate the possibility of a faulty breadboard. 6. Setting the meter dial to 2mA, 20mA, and 200mA to see if the 0 Amp reading changes. I am not sure what I am doing wrong, maybe it is a really stupid error that I have somehow overlooked. To address concerns regarding faulty wire connections, I took @TylerW 's advice to use an LED. when replacing the jumper between the resistor and LED with the meter, the LED turns off. Does this confirm that the meter's fuse is blown? Any recommendations for a good multimeter welcome in that case. ![new_circuit_2](https://i.stack.imgur.com/UOPYy.jpg) ![new_circuit_1](https://i.stack.imgur.com/8dgQq.jpg) ![breadboard_closeup](https://i.stack.imgur.com/slbDQ.jpg) ![circuit](https://i.stack.imgur.com/xgg5n.jpg) ![meter_closeup](https://i.stack.imgur.com/ekHlK.jpg)
2021/12/04
[ "https://electronics.stackexchange.com/questions/597875", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/301431/" ]
There is nothing wrong that I can see with your setup. I can think of two possibilities: 1. The fuse is blown. You cannot necessarily check it in-circuit because various parts are interconnected internally. If you don’t have another meter maybe try inspecting it visually to see if the element is intact. 2. You have a lot of potentially dodgy connections, from alligator clips to solderless breadboard. Maybe one of them is open. You can simplify things significantly to help rule that out.
Simplify. Get rid of the breadboard. Jumper between the battery + and one end of the resistor. Another jumper from the other end of the resistor to the DMM. Finally, from the other DMM input to the battery -.
597,875
I am following the experiment in the popular electronics book - "Make: Electronics third edition". However, when replicating one of the experiments mentioned in the book (specifically Experiment 3 "Applying pressure", the part under the subheading "It's the law!", Pg 28), I am stuck. I believe the experiment is trying to teach the effect of varying resistances in a circuit on the current reading (read using a multimeter). In my case I do not see a reading on my meter at all, it reads 0 Amps (see attached images). I have run the following diagnostics: 1. Check battery voltage (it reads about 9.5v), switched to a different battery, just in case. 2. Vary the resistance, instead of 1kohms I tried 470 ohms. 3. Continuity tests on circuit connections. 4. Check if the multimeter fuse is blown. The way I did this is by opening up the meter, using the meter's own probes to measure resistance across the glass fuse inside, which reads a value close to 0 ohms which means it offers little to no resistance, meaning it's not blown. I could have just done this wrong. 5. Create circuit connections using just alligator clips and wires to eliminate the possibility of a faulty breadboard. 6. Setting the meter dial to 2mA, 20mA, and 200mA to see if the 0 Amp reading changes. I am not sure what I am doing wrong, maybe it is a really stupid error that I have somehow overlooked. To address concerns regarding faulty wire connections, I took @TylerW 's advice to use an LED. when replacing the jumper between the resistor and LED with the meter, the LED turns off. Does this confirm that the meter's fuse is blown? Any recommendations for a good multimeter welcome in that case. ![new_circuit_2](https://i.stack.imgur.com/UOPYy.jpg) ![new_circuit_1](https://i.stack.imgur.com/8dgQq.jpg) ![breadboard_closeup](https://i.stack.imgur.com/slbDQ.jpg) ![circuit](https://i.stack.imgur.com/xgg5n.jpg) ![meter_closeup](https://i.stack.imgur.com/ekHlK.jpg)
2021/12/04
[ "https://electronics.stackexchange.com/questions/597875", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/301431/" ]
There is nothing wrong that I can see with your setup. I can think of two possibilities: 1. The fuse is blown. You cannot necessarily check it in-circuit because various parts are interconnected internally. If you don’t have another meter maybe try inspecting it visually to see if the element is intact. 2. You have a lot of potentially dodgy connections, from alligator clips to solderless breadboard. Maybe one of them is open. You can simplify things significantly to help rule that out.
Switch your multimeter to amps (not mA to protect the meter) and directly short a 9V alkaline through it. If the meter still shows nothing, and not even a teensy little spark is seen (internal resistance of the battery will limit current), it's the meter.
597,875
I am following the experiment in the popular electronics book - "Make: Electronics third edition". However, when replicating one of the experiments mentioned in the book (specifically Experiment 3 "Applying pressure", the part under the subheading "It's the law!", Pg 28), I am stuck. I believe the experiment is trying to teach the effect of varying resistances in a circuit on the current reading (read using a multimeter). In my case I do not see a reading on my meter at all, it reads 0 Amps (see attached images). I have run the following diagnostics: 1. Check battery voltage (it reads about 9.5v), switched to a different battery, just in case. 2. Vary the resistance, instead of 1kohms I tried 470 ohms. 3. Continuity tests on circuit connections. 4. Check if the multimeter fuse is blown. The way I did this is by opening up the meter, using the meter's own probes to measure resistance across the glass fuse inside, which reads a value close to 0 ohms which means it offers little to no resistance, meaning it's not blown. I could have just done this wrong. 5. Create circuit connections using just alligator clips and wires to eliminate the possibility of a faulty breadboard. 6. Setting the meter dial to 2mA, 20mA, and 200mA to see if the 0 Amp reading changes. I am not sure what I am doing wrong, maybe it is a really stupid error that I have somehow overlooked. To address concerns regarding faulty wire connections, I took @TylerW 's advice to use an LED. when replacing the jumper between the resistor and LED with the meter, the LED turns off. Does this confirm that the meter's fuse is blown? Any recommendations for a good multimeter welcome in that case. ![new_circuit_2](https://i.stack.imgur.com/UOPYy.jpg) ![new_circuit_1](https://i.stack.imgur.com/8dgQq.jpg) ![breadboard_closeup](https://i.stack.imgur.com/slbDQ.jpg) ![circuit](https://i.stack.imgur.com/xgg5n.jpg) ![meter_closeup](https://i.stack.imgur.com/ekHlK.jpg)
2021/12/04
[ "https://electronics.stackexchange.com/questions/597875", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/301431/" ]
There is nothing wrong that I can see with your setup. I can think of two possibilities: 1. The fuse is blown. You cannot necessarily check it in-circuit because various parts are interconnected internally. If you don’t have another meter maybe try inspecting it visually to see if the element is intact. 2. You have a lot of potentially dodgy connections, from alligator clips to solderless breadboard. Maybe one of them is open. You can simplify things significantly to help rule that out.
Try adding an LED in series to the circuit (I see some in the corner of your picture!) to help verify the connection isn't broken somewhere. I'd recommend using the 470 ohm resistor you mentioned with it instead of the 1k. The longer lead of the LED should be on the positive side of the circuit. If the bulb lights up and your meter still shows 0A while on the 200mA setting, something's wrong with your meter. If the bulb doesn't light up, use a jumper wire instead of your meter - if the bulb lights up after that, you have a blown fuse. If the bulb *still* doesn't light up, you've got a bad connection with one of your clips or on the breadboard, so fiddle around with those until you get a lit bulb.
597,875
I am following the experiment in the popular electronics book - "Make: Electronics third edition". However, when replicating one of the experiments mentioned in the book (specifically Experiment 3 "Applying pressure", the part under the subheading "It's the law!", Pg 28), I am stuck. I believe the experiment is trying to teach the effect of varying resistances in a circuit on the current reading (read using a multimeter). In my case I do not see a reading on my meter at all, it reads 0 Amps (see attached images). I have run the following diagnostics: 1. Check battery voltage (it reads about 9.5v), switched to a different battery, just in case. 2. Vary the resistance, instead of 1kohms I tried 470 ohms. 3. Continuity tests on circuit connections. 4. Check if the multimeter fuse is blown. The way I did this is by opening up the meter, using the meter's own probes to measure resistance across the glass fuse inside, which reads a value close to 0 ohms which means it offers little to no resistance, meaning it's not blown. I could have just done this wrong. 5. Create circuit connections using just alligator clips and wires to eliminate the possibility of a faulty breadboard. 6. Setting the meter dial to 2mA, 20mA, and 200mA to see if the 0 Amp reading changes. I am not sure what I am doing wrong, maybe it is a really stupid error that I have somehow overlooked. To address concerns regarding faulty wire connections, I took @TylerW 's advice to use an LED. when replacing the jumper between the resistor and LED with the meter, the LED turns off. Does this confirm that the meter's fuse is blown? Any recommendations for a good multimeter welcome in that case. ![new_circuit_2](https://i.stack.imgur.com/UOPYy.jpg) ![new_circuit_1](https://i.stack.imgur.com/8dgQq.jpg) ![breadboard_closeup](https://i.stack.imgur.com/slbDQ.jpg) ![circuit](https://i.stack.imgur.com/xgg5n.jpg) ![meter_closeup](https://i.stack.imgur.com/ekHlK.jpg)
2021/12/04
[ "https://electronics.stackexchange.com/questions/597875", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/301431/" ]
There is nothing wrong that I can see with your setup. I can think of two possibilities: 1. The fuse is blown. You cannot necessarily check it in-circuit because various parts are interconnected internally. If you don’t have another meter maybe try inspecting it visually to see if the element is intact. 2. You have a lot of potentially dodgy connections, from alligator clips to solderless breadboard. Maybe one of them is open. You can simplify things significantly to help rule that out.
Your multimeter is has a design that is prone to blowing fuses. The voltage and ohms input is also the mA input. This means any time in the history of your meter that you may connected to a voltage source and then rotated the switch past the current (amps) measurement selector, your fuse would have blown. You need to open your meter and do a continuity test on the fuse (or just replace the fuse). [![enter image description here](https://i.stack.imgur.com/iI6nn.jpg)](https://i.stack.imgur.com/iI6nn.jpg)
597,875
I am following the experiment in the popular electronics book - "Make: Electronics third edition". However, when replicating one of the experiments mentioned in the book (specifically Experiment 3 "Applying pressure", the part under the subheading "It's the law!", Pg 28), I am stuck. I believe the experiment is trying to teach the effect of varying resistances in a circuit on the current reading (read using a multimeter). In my case I do not see a reading on my meter at all, it reads 0 Amps (see attached images). I have run the following diagnostics: 1. Check battery voltage (it reads about 9.5v), switched to a different battery, just in case. 2. Vary the resistance, instead of 1kohms I tried 470 ohms. 3. Continuity tests on circuit connections. 4. Check if the multimeter fuse is blown. The way I did this is by opening up the meter, using the meter's own probes to measure resistance across the glass fuse inside, which reads a value close to 0 ohms which means it offers little to no resistance, meaning it's not blown. I could have just done this wrong. 5. Create circuit connections using just alligator clips and wires to eliminate the possibility of a faulty breadboard. 6. Setting the meter dial to 2mA, 20mA, and 200mA to see if the 0 Amp reading changes. I am not sure what I am doing wrong, maybe it is a really stupid error that I have somehow overlooked. To address concerns regarding faulty wire connections, I took @TylerW 's advice to use an LED. when replacing the jumper between the resistor and LED with the meter, the LED turns off. Does this confirm that the meter's fuse is blown? Any recommendations for a good multimeter welcome in that case. ![new_circuit_2](https://i.stack.imgur.com/UOPYy.jpg) ![new_circuit_1](https://i.stack.imgur.com/8dgQq.jpg) ![breadboard_closeup](https://i.stack.imgur.com/slbDQ.jpg) ![circuit](https://i.stack.imgur.com/xgg5n.jpg) ![meter_closeup](https://i.stack.imgur.com/ekHlK.jpg)
2021/12/04
[ "https://electronics.stackexchange.com/questions/597875", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/301431/" ]
There is nothing wrong that I can see with your setup. I can think of two possibilities: 1. The fuse is blown. You cannot necessarily check it in-circuit because various parts are interconnected internally. If you don’t have another meter maybe try inspecting it visually to see if the element is intact. 2. You have a lot of potentially dodgy connections, from alligator clips to solderless breadboard. Maybe one of them is open. You can simplify things significantly to help rule that out.
Everything points to a blown fuse, which can easily be replaced. However, if replacing the fuse it does not work, maybe, because the current measuring circuit in the meter is damaged, you can always use the voltmeter part of the meter to measure current (don’t throw it out). Use a one ohm resistor, or even the 1k you already have, in series with the circuit you want to measure the current and measure the voltage between the leads of the resistor instead. A simple math (current = voltage / resistance) will tell you the current value.
597,875
I am following the experiment in the popular electronics book - "Make: Electronics third edition". However, when replicating one of the experiments mentioned in the book (specifically Experiment 3 "Applying pressure", the part under the subheading "It's the law!", Pg 28), I am stuck. I believe the experiment is trying to teach the effect of varying resistances in a circuit on the current reading (read using a multimeter). In my case I do not see a reading on my meter at all, it reads 0 Amps (see attached images). I have run the following diagnostics: 1. Check battery voltage (it reads about 9.5v), switched to a different battery, just in case. 2. Vary the resistance, instead of 1kohms I tried 470 ohms. 3. Continuity tests on circuit connections. 4. Check if the multimeter fuse is blown. The way I did this is by opening up the meter, using the meter's own probes to measure resistance across the glass fuse inside, which reads a value close to 0 ohms which means it offers little to no resistance, meaning it's not blown. I could have just done this wrong. 5. Create circuit connections using just alligator clips and wires to eliminate the possibility of a faulty breadboard. 6. Setting the meter dial to 2mA, 20mA, and 200mA to see if the 0 Amp reading changes. I am not sure what I am doing wrong, maybe it is a really stupid error that I have somehow overlooked. To address concerns regarding faulty wire connections, I took @TylerW 's advice to use an LED. when replacing the jumper between the resistor and LED with the meter, the LED turns off. Does this confirm that the meter's fuse is blown? Any recommendations for a good multimeter welcome in that case. ![new_circuit_2](https://i.stack.imgur.com/UOPYy.jpg) ![new_circuit_1](https://i.stack.imgur.com/8dgQq.jpg) ![breadboard_closeup](https://i.stack.imgur.com/slbDQ.jpg) ![circuit](https://i.stack.imgur.com/xgg5n.jpg) ![meter_closeup](https://i.stack.imgur.com/ekHlK.jpg)
2021/12/04
[ "https://electronics.stackexchange.com/questions/597875", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/301431/" ]
Switch your multimeter to amps (not mA to protect the meter) and directly short a 9V alkaline through it. If the meter still shows nothing, and not even a teensy little spark is seen (internal resistance of the battery will limit current), it's the meter.
Simplify. Get rid of the breadboard. Jumper between the battery + and one end of the resistor. Another jumper from the other end of the resistor to the DMM. Finally, from the other DMM input to the battery -.
597,875
I am following the experiment in the popular electronics book - "Make: Electronics third edition". However, when replicating one of the experiments mentioned in the book (specifically Experiment 3 "Applying pressure", the part under the subheading "It's the law!", Pg 28), I am stuck. I believe the experiment is trying to teach the effect of varying resistances in a circuit on the current reading (read using a multimeter). In my case I do not see a reading on my meter at all, it reads 0 Amps (see attached images). I have run the following diagnostics: 1. Check battery voltage (it reads about 9.5v), switched to a different battery, just in case. 2. Vary the resistance, instead of 1kohms I tried 470 ohms. 3. Continuity tests on circuit connections. 4. Check if the multimeter fuse is blown. The way I did this is by opening up the meter, using the meter's own probes to measure resistance across the glass fuse inside, which reads a value close to 0 ohms which means it offers little to no resistance, meaning it's not blown. I could have just done this wrong. 5. Create circuit connections using just alligator clips and wires to eliminate the possibility of a faulty breadboard. 6. Setting the meter dial to 2mA, 20mA, and 200mA to see if the 0 Amp reading changes. I am not sure what I am doing wrong, maybe it is a really stupid error that I have somehow overlooked. To address concerns regarding faulty wire connections, I took @TylerW 's advice to use an LED. when replacing the jumper between the resistor and LED with the meter, the LED turns off. Does this confirm that the meter's fuse is blown? Any recommendations for a good multimeter welcome in that case. ![new_circuit_2](https://i.stack.imgur.com/UOPYy.jpg) ![new_circuit_1](https://i.stack.imgur.com/8dgQq.jpg) ![breadboard_closeup](https://i.stack.imgur.com/slbDQ.jpg) ![circuit](https://i.stack.imgur.com/xgg5n.jpg) ![meter_closeup](https://i.stack.imgur.com/ekHlK.jpg)
2021/12/04
[ "https://electronics.stackexchange.com/questions/597875", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/301431/" ]
Try adding an LED in series to the circuit (I see some in the corner of your picture!) to help verify the connection isn't broken somewhere. I'd recommend using the 470 ohm resistor you mentioned with it instead of the 1k. The longer lead of the LED should be on the positive side of the circuit. If the bulb lights up and your meter still shows 0A while on the 200mA setting, something's wrong with your meter. If the bulb doesn't light up, use a jumper wire instead of your meter - if the bulb lights up after that, you have a blown fuse. If the bulb *still* doesn't light up, you've got a bad connection with one of your clips or on the breadboard, so fiddle around with those until you get a lit bulb.
Simplify. Get rid of the breadboard. Jumper between the battery + and one end of the resistor. Another jumper from the other end of the resistor to the DMM. Finally, from the other DMM input to the battery -.
597,875
I am following the experiment in the popular electronics book - "Make: Electronics third edition". However, when replicating one of the experiments mentioned in the book (specifically Experiment 3 "Applying pressure", the part under the subheading "It's the law!", Pg 28), I am stuck. I believe the experiment is trying to teach the effect of varying resistances in a circuit on the current reading (read using a multimeter). In my case I do not see a reading on my meter at all, it reads 0 Amps (see attached images). I have run the following diagnostics: 1. Check battery voltage (it reads about 9.5v), switched to a different battery, just in case. 2. Vary the resistance, instead of 1kohms I tried 470 ohms. 3. Continuity tests on circuit connections. 4. Check if the multimeter fuse is blown. The way I did this is by opening up the meter, using the meter's own probes to measure resistance across the glass fuse inside, which reads a value close to 0 ohms which means it offers little to no resistance, meaning it's not blown. I could have just done this wrong. 5. Create circuit connections using just alligator clips and wires to eliminate the possibility of a faulty breadboard. 6. Setting the meter dial to 2mA, 20mA, and 200mA to see if the 0 Amp reading changes. I am not sure what I am doing wrong, maybe it is a really stupid error that I have somehow overlooked. To address concerns regarding faulty wire connections, I took @TylerW 's advice to use an LED. when replacing the jumper between the resistor and LED with the meter, the LED turns off. Does this confirm that the meter's fuse is blown? Any recommendations for a good multimeter welcome in that case. ![new_circuit_2](https://i.stack.imgur.com/UOPYy.jpg) ![new_circuit_1](https://i.stack.imgur.com/8dgQq.jpg) ![breadboard_closeup](https://i.stack.imgur.com/slbDQ.jpg) ![circuit](https://i.stack.imgur.com/xgg5n.jpg) ![meter_closeup](https://i.stack.imgur.com/ekHlK.jpg)
2021/12/04
[ "https://electronics.stackexchange.com/questions/597875", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/301431/" ]
Your multimeter is has a design that is prone to blowing fuses. The voltage and ohms input is also the mA input. This means any time in the history of your meter that you may connected to a voltage source and then rotated the switch past the current (amps) measurement selector, your fuse would have blown. You need to open your meter and do a continuity test on the fuse (or just replace the fuse). [![enter image description here](https://i.stack.imgur.com/iI6nn.jpg)](https://i.stack.imgur.com/iI6nn.jpg)
Simplify. Get rid of the breadboard. Jumper between the battery + and one end of the resistor. Another jumper from the other end of the resistor to the DMM. Finally, from the other DMM input to the battery -.
597,875
I am following the experiment in the popular electronics book - "Make: Electronics third edition". However, when replicating one of the experiments mentioned in the book (specifically Experiment 3 "Applying pressure", the part under the subheading "It's the law!", Pg 28), I am stuck. I believe the experiment is trying to teach the effect of varying resistances in a circuit on the current reading (read using a multimeter). In my case I do not see a reading on my meter at all, it reads 0 Amps (see attached images). I have run the following diagnostics: 1. Check battery voltage (it reads about 9.5v), switched to a different battery, just in case. 2. Vary the resistance, instead of 1kohms I tried 470 ohms. 3. Continuity tests on circuit connections. 4. Check if the multimeter fuse is blown. The way I did this is by opening up the meter, using the meter's own probes to measure resistance across the glass fuse inside, which reads a value close to 0 ohms which means it offers little to no resistance, meaning it's not blown. I could have just done this wrong. 5. Create circuit connections using just alligator clips and wires to eliminate the possibility of a faulty breadboard. 6. Setting the meter dial to 2mA, 20mA, and 200mA to see if the 0 Amp reading changes. I am not sure what I am doing wrong, maybe it is a really stupid error that I have somehow overlooked. To address concerns regarding faulty wire connections, I took @TylerW 's advice to use an LED. when replacing the jumper between the resistor and LED with the meter, the LED turns off. Does this confirm that the meter's fuse is blown? Any recommendations for a good multimeter welcome in that case. ![new_circuit_2](https://i.stack.imgur.com/UOPYy.jpg) ![new_circuit_1](https://i.stack.imgur.com/8dgQq.jpg) ![breadboard_closeup](https://i.stack.imgur.com/slbDQ.jpg) ![circuit](https://i.stack.imgur.com/xgg5n.jpg) ![meter_closeup](https://i.stack.imgur.com/ekHlK.jpg)
2021/12/04
[ "https://electronics.stackexchange.com/questions/597875", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/301431/" ]
Everything points to a blown fuse, which can easily be replaced. However, if replacing the fuse it does not work, maybe, because the current measuring circuit in the meter is damaged, you can always use the voltmeter part of the meter to measure current (don’t throw it out). Use a one ohm resistor, or even the 1k you already have, in series with the circuit you want to measure the current and measure the voltage between the leads of the resistor instead. A simple math (current = voltage / resistance) will tell you the current value.
Simplify. Get rid of the breadboard. Jumper between the battery + and one end of the resistor. Another jumper from the other end of the resistor to the DMM. Finally, from the other DMM input to the battery -.
72,658,664
Really wired problem. My routing had been configured well and has been checked enough times. However, page1, page3 and page5 works well. And page2, page4, page6 don't redirect to themselves. If I tap redirect button then instead of page2 go to the landing page. If I write <https://example.com/page2> -> the same: <https://example.com> and without some content. Check the routes here. ``` const routes: Routes = [ { path: '', component: LandingComponent}, { path: 'page1', component: Page1Component}, { path: 'page2', component: Page2Component}, { path: 'page3', component: Page3Component}, { path: 'page4', component: Page4Component}, { path: 'page5', component: Page5Component}, { path: 'page6', component: Page6Component}, { path: '**', component: NotFound404Component} ]; ``` And component that doesn't load. ``` @Component({ selector: 'app-page2', templateUrl: './page2.component.html', styleUrls: ['./page2.component.scss'], animations: [ trigger('animation1', [ transition('void => *', useAnimation(flip)) ]), trigger('animation2', [ transition('void => *', useAnimation(bounceInDown), { params: { timing: 3} }) ]) ] }) export class Page2Component implements OnInit { constructor(public some: SomeService) { } ngOnInit(): void { } } ``` The main point!! No problems with Chrome (MacOS) even with dimension 'iPhone'. All works well. But there are problems with Chrome (iOS), as I have described above. Any Idea?
2022/06/17
[ "https://Stackoverflow.com/questions/72658664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12623972/" ]
On android studio upper bar File->settings->tools->emulator-> then check or uncheck -launch in tool window
File -> Settings -> Tools -> Emulator And disable "Launch in a tool window"
52,284,067
Is there a way to authenticate a user with SAML token using firebase as a backend? The company I am working with requires that SAML is used within the authentication system and I am not sure if this is possible with firebase as a backend. Thanks
2018/09/11
[ "https://Stackoverflow.com/questions/52284067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2037909/" ]
Maybe new GCP service ["Cloud Identity for Customers and Partners"](https://cloud.google.com/identity-cp/) (in beta for now) could help you. > > Cloud Identity for Customers and Partners (CICP) provides an identity platform that allows users to authenticate to your applications and services, like multi-tenant SaaS applications, mobile/web apps, games, APIs and more. CICP is built on an enhanced Firebase Authentication infrastructure, so it's perfect if you're building a service on Firebase, Google Cloud Platform (GCP), or on another platform, and need secure, easy-to-use authentication. > > > You can check [SAML provider](https://cloud.google.com/identity-cp/docs/how-to-enable-application-for-saml), Firebase is behind the scene. > > This guide shows how to enable an existing web application for Security Assertion Markup Language (SAML) 2.0, with Cloud Identity for Customers and Partners (CICP). This will include accepting SAML assertions from identity providers (IdP) as a SAML service provider, verifying their contents, and producing a lightweight JWT that you can use in your application to verify authentication and perform authorization. > > > Hope it will help. **Updated on February 25th, 2020 :** [I published a tutorial](https://medium.com/@tfalvo/single-sign-on-sso-for-your-firebase-app-with-saml-f67c71e0b4d6) on how to integrate SAML authentication with Firebase and Angular app.
You can now use SAML provider with the new [Cloud Identity platform](https://cloud.google.com/identity-platform/). This platform works in combination with Firebase too. Check [Thierry's answer](https://stackoverflow.com/a/55322424/209103) for more details. --- **Old/outdated answer** below: At the moment there is no built-in SAML provider for Firebase Authentication. See this [discussion on the firebase-talk mailing list](https://groups.google.com/forum/#!topic/firebase-talk/tUYXF7GRTqQ). From that post: > > To support SAML authentication with Firebase Auth, you need to [use custom authentication](https://firebase.google.com/docs/auth/admin/create-custom-tokens). > > > When the SAML response is posted to your server, your convert the SAML assertion to a custom token (minted via Firebase Admin SDK) and then pass that token to the client where you signInWithCustomToken. You can add any additional SAML claims to the custom token claims and they will propagate to the Firebase ID token JWT. > > > It's a valid feature request though, so I highly recommend to [file a feature request](https://firebase.google.com/support/contact/bugs-features/).
10,247,870
I'm looking for a way to return an array from the database query, but only for the first row. I'd prefer not to use objects.. My current solution: ``` //Gather $data = $this->db->from('view')->where('alias', $alias)->get()->result_array(); //Collect the first row only $data = $data[0]; ``` Which is pretty ugly to be honest. As said, I'd prefer to not use objects.
2012/04/20
[ "https://Stackoverflow.com/questions/10247870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1113435/" ]
Use the `row()` method instead: ``` $data = $this->db->from('view')->where('alias', $alias)->get()->row(); ``` [Oh, you don't want to use objects. `row_array()` then. But consider objects.]
You can do this: ``` $data = $this->db->from('view')->where('alias', $alias)->get()->row_array(); ``` This does the same as minitech's answer, only it returns an array (like you want) instead of an object.
10,247,870
I'm looking for a way to return an array from the database query, but only for the first row. I'd prefer not to use objects.. My current solution: ``` //Gather $data = $this->db->from('view')->where('alias', $alias)->get()->result_array(); //Collect the first row only $data = $data[0]; ``` Which is pretty ugly to be honest. As said, I'd prefer to not use objects.
2012/04/20
[ "https://Stackoverflow.com/questions/10247870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1113435/" ]
Use the `row()` method instead: ``` $data = $this->db->from('view')->where('alias', $alias)->get()->row(); ``` [Oh, you don't want to use objects. `row_array()` then. But consider objects.]
You can use the row\_array() function to grab data from a single row. Specify that row as the parameter. For example, to get the first row of your result, do this: ``` $this->db->from('view')->where('alias', $alias)->get()->result_array(0); ```
10,247,870
I'm looking for a way to return an array from the database query, but only for the first row. I'd prefer not to use objects.. My current solution: ``` //Gather $data = $this->db->from('view')->where('alias', $alias)->get()->result_array(); //Collect the first row only $data = $data[0]; ``` Which is pretty ugly to be honest. As said, I'd prefer to not use objects.
2012/04/20
[ "https://Stackoverflow.com/questions/10247870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1113435/" ]
Use the `row()` method instead: ``` $data = $this->db->from('view')->where('alias', $alias)->get()->row(); ``` [Oh, you don't want to use objects. `row_array()` then. But consider objects.]
If you want to get only first row as an array you can use this code too: ``` $data = $this->db->from('view')->where('alias', $alias)->get()->first_row('array'); ``` But if you really want to get only 1 result, allways use select('TOP 1 ....') because this method improves your query returning time performance. When you use get() directly, it will try to return whole data and not only first row. And then it shows what you want (first row). But if you use TOP 1 method; it's the best.
10,247,870
I'm looking for a way to return an array from the database query, but only for the first row. I'd prefer not to use objects.. My current solution: ``` //Gather $data = $this->db->from('view')->where('alias', $alias)->get()->result_array(); //Collect the first row only $data = $data[0]; ``` Which is pretty ugly to be honest. As said, I'd prefer to not use objects.
2012/04/20
[ "https://Stackoverflow.com/questions/10247870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1113435/" ]
You can do this: ``` $data = $this->db->from('view')->where('alias', $alias)->get()->row_array(); ``` This does the same as minitech's answer, only it returns an array (like you want) instead of an object.
You can use the row\_array() function to grab data from a single row. Specify that row as the parameter. For example, to get the first row of your result, do this: ``` $this->db->from('view')->where('alias', $alias)->get()->result_array(0); ```
10,247,870
I'm looking for a way to return an array from the database query, but only for the first row. I'd prefer not to use objects.. My current solution: ``` //Gather $data = $this->db->from('view')->where('alias', $alias)->get()->result_array(); //Collect the first row only $data = $data[0]; ``` Which is pretty ugly to be honest. As said, I'd prefer to not use objects.
2012/04/20
[ "https://Stackoverflow.com/questions/10247870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1113435/" ]
You can do this: ``` $data = $this->db->from('view')->where('alias', $alias)->get()->row_array(); ``` This does the same as minitech's answer, only it returns an array (like you want) instead of an object.
If you want to get only first row as an array you can use this code too: ``` $data = $this->db->from('view')->where('alias', $alias)->get()->first_row('array'); ``` But if you really want to get only 1 result, allways use select('TOP 1 ....') because this method improves your query returning time performance. When you use get() directly, it will try to return whole data and not only first row. And then it shows what you want (first row). But if you use TOP 1 method; it's the best.
4,236,286
Peace to all. Studying and trying to get a handle on how to calculate like-minded questions, I came across this [question](https://www.thoughtco.com/speed-of-light-in-miles-per-hour-609319) from the web. I don't understand how exactly it was solved. How were the units canceled out and with what exactly? > > ***Solution***: > > To convert this measurement, we need to convert meters to > miles and seconds to hours. To do this, we need the following > relationships: > 1000 meter = 1 kilometer; 1 kilometers = 0.621 mile; 60 seconds = 1 minute; 60 minutes = 1 hour; We can now set up the equation using these relationships so the units cancel out leaving only the > desired miles/hour. > > > speedMPH = 2.998 x 10^8 m/sec x (1 km/1000 m) x (0.621 mi/1 km) x (60 sec/1 min) x (60 min/1 hr) > > > > > > Note all the units canceled out, leaving only miles/hr: > > > > > > speedMPH = (2.998 x 10^8 x 1/1000 x 0.621 x 60 x 60) miles/hr > > > > > > speedMPH = 6.702 x 10^8 miles/hr > > > > > > > > > ***Answer***: > > The speed of light in miles per hour is 6.702 x 10^8 miles/hr. > > >
2021/08/30
[ "https://math.stackexchange.com/questions/4236286", "https://math.stackexchange.com", "https://math.stackexchange.com/users/961761/" ]
Rather than tackling the problem at hand, here is a simpler example. Suppose we start with a speed of 60 mph and want to convert to miles per minute. Since 1 hour is 60 minutes, we have $$60\text{ mph} = \frac{60\text{ miles}}{1\text{ hour}} = \frac{60\text{ miles}}{60\text{ min}} = 1\text{ mile/min}.$$ Note that we have replaced 1 hour by 60 minutes 'by hand'. This is effective for a single unit conversion, but seems tedious if multiple conversions had to be done. To make things more practical, we instead rewrite the above computation as such: $$60\text{ mph} = \frac{60\text{ miles}}{1\text{ hour}}\times\frac{1 \text{ hour}}{60 \text{ minutes}} = 1\text{ mile/min}.$$ Note that we've exchanged "replace 1 hour by 60 minutes" with "multiply by 1 hour / 60 minutes." The reason this works is because 1 hour = 60 minutes, so (1 hour)/(60 minutes) is just equal to one. So we multiplied 60 mph by 1, leaving the quantity itself unchanged; however, the old units cancel out in the process and thereby carry out unit conversion. In this example, of course, the problem is simple enough that it doesn't make a difference. But suppose we wanted to convert 60 mph into units of feet per second. Since one mile is 5280 feet, one hour is 60 minutes, and one minute is 60 seconds, we can carry out all three unit conversions by the following multiplication: \begin{align} 60\text{ mph} &= \frac{60\text{ miles}}{1\text{ hour}} \times \frac{1\text{ hour}}{60\text{ minutes}} \times \frac{1\text{ minute}}{60\text{ seconds}} \times \frac{5280\text{ feet}}{1\text{ mile}} \\ &= \frac{60\times 5280}{60\times 60} \frac{\text{feet}}{\text{second}}\\ & = 88\text{ ft/sec}. \end{align} Note how the multiplications are arranged to cancel out hours, minutes, and miles. Can you see how to apply this idea to your problem?
Notice how some units cancel when the proper terms are multiplied. $$1\space \frac{m}{s}\approx 2.237\space mph \\ \implies 299792458 \space \frac{m}{s} \space \times\space 2.237\space \frac{mph}{m} \space\times\space 1\space h \space \times\space 3600\space \frac{s}{h}\\ = \,2,414,288,622,766\space mph$$
22,297,101
I am creating column charts using highchart its displaying 0 if all of the fields are 0. I want to display single 0 per category if all data in that particular category is 0 (i.e., total is 0) Please refer <http://jsfiddle.net/rutup/6hxPU/18/> ``` function createBarChart(source, title, placeHolderId, sideText, xColumnValue) { $('#' + placeHolderId).highcharts({ credits: { enabled: false }, chart: { type: 'column' }, exporting: { enabled: false }, title: { text: false }, xAxis: { categories: xColumnValue }, legend: { layout: 'vertical', align: 'right', verticalAlign: 'top', y: 20, borderWidth: 0, enabled: true }, yAxis: { min: 0, minRange: 0, lineWidth: 0, gridLineWidth: 0, title: { text: sideText }, labels: { enabled: false } }, stackLabels: { enabled: true, style: { fontWeight: 'bold', color: 'gray' }, formatter: function () { return calcAntiLog(this.y) == null ? 0 : calcAntiLog(this.y); } }, tooltip: { formatter: function () { return '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + (calcAntiLog(this.y) == null ? 0 : calcAntiLog(this.y)); } }, plotOptions: { column: { dataLabels: { enabled: true , formatter: function () { return calcAntiLog(this.y) == null ? 0 : calcAntiLog(this.y); } } } }, series: source }); } ```
2014/03/10
[ "https://Stackoverflow.com/questions/22297101", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1266399/" ]
If that is enough to pick the middle column, and show a zero above, then something like this would do the trick: <http://jsfiddle.net/6hxPU/20/> Of course if you have even number of columns, the zero won't be centered. That case I think the best you can do is to find where to put the zero, based on the column heights and draw it directly with `Highcharts.Renderer()`.
You can use loop on each point, and remove stackLabel's SVG object.
57,746,350
I have an entity (named Parent) with a @OneToOne mapping to a Child entity. Currently defined with FetchType.EAGER, but it doesn't matter to the problem at hand here. I am trying to perform a query on Parent that does a LEFT JOIN on the Child entity, rendering the FetchType setting useless (supposedly). However, the query on the Child entity still gets executed, even though the join is performed correctly. ``` @Entity public class Parent { @NotFound(action = NotFoundAction.IGNORE) @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "id", insertable = false, updatable = false) private Child child; } @Entity public class Child { } CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder(); CriteriaQuery<Parent> criteriaQuery = criteriaBuilder.createQuery(Parent.class); Root<Parent> root = criteriaQuery.from(Parent.class); Fetch<Parent, Child> join = root.fetch("child", JoinType.LEFT); return session.createQuery(criteriaQuery).getSingleResult(); ``` I would have expected this to generate a single query with a LEFT JOIN that gathers all of the data, but instead it performs: ``` 1) SELECT * FROM parent LEFT JOIN child ... 2) SELECT * FROM child where id = ? ```
2019/09/01
[ "https://Stackoverflow.com/questions/57746350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7732544/" ]
This is underline of first `<a>` tag. Just apply `text-decoration: none` property to `<a>` tags in this block.
That black line in the underline of `a` tag. To remove it just use `text-decoration: none`, like this: ```css .mid > a { text-decoration: none; } .mid { margin-top: 0px; flex-wrap: wrap; justify-content: center; text-align: center; } .cfc-container { display: inline-block; width: 80%; padding-top: 30px; padding-bottom: 30px; margin-top: 5px; margin-bottom: 30px; color: inherit; border: 1px solid; background-color: white; background-image: linear-gradient(to right, rgba(228, 241, 254, 1), rgba(255, 255, 255, 0.2)), url(../Image/customer_service.png); background-repeat: no-repeat; background-position: right; } ``` ```html <div class="mid"> <a href="@Url.Action(" WesternCuisine ", "Home ")"> <img src="~/Image/western_cuisine.png" style="width: 40%; height: 40%;" /> </a> <a href="@Url.Action(" ChineseCuisine ", "Home ")"> <img src="~/Image/chinese_cuisine.png" style="width: 40%; height: 40%;" /> </a> <div class="cfc-container"> <h1 class="main-caption">&nbsp; Your precious <br />&nbsp; Feedback is our <br />&nbsp; Motivation to be better <br /><button type="button" class="main-button" onclick="window.location.href='/Home/Feedback';"><strong>Learn More</strong></button> </h1> </div> </div> ```
57,746,350
I have an entity (named Parent) with a @OneToOne mapping to a Child entity. Currently defined with FetchType.EAGER, but it doesn't matter to the problem at hand here. I am trying to perform a query on Parent that does a LEFT JOIN on the Child entity, rendering the FetchType setting useless (supposedly). However, the query on the Child entity still gets executed, even though the join is performed correctly. ``` @Entity public class Parent { @NotFound(action = NotFoundAction.IGNORE) @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "id", insertable = false, updatable = false) private Child child; } @Entity public class Child { } CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder(); CriteriaQuery<Parent> criteriaQuery = criteriaBuilder.createQuery(Parent.class); Root<Parent> root = criteriaQuery.from(Parent.class); Fetch<Parent, Child> join = root.fetch("child", JoinType.LEFT); return session.createQuery(criteriaQuery).getSingleResult(); ``` I would have expected this to generate a single query with a LEFT JOIN that gathers all of the data, but instead it performs: ``` 1) SELECT * FROM parent LEFT JOIN child ... 2) SELECT * FROM child where id = ? ```
2019/09/01
[ "https://Stackoverflow.com/questions/57746350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7732544/" ]
This is because of the default behavior of tag - text-decoration, ``` .mid a { text-decoration: none; } ``` ```css .mid { margin-top: 0px; flex-wrap: wrap; justify-content: center; text-align: center; } .mid a { text-decoration: none; } .cfc-container { display: inline-block; width: 80%; padding-top: 30px; padding-bottom: 30px; margin-top: 5px; margin-bottom: 30px; color: inherit; border: 1px solid; background-color: white; background-image: linear-gradient(to right,rgba(228,241,254,1),rgba(255,255,255,0.2)), url(../Image/customer_service.png); background-repeat: no-repeat; background-position: right; } ``` ```html <!DOCTYPE html> <html> <body> <div class="mid"> <a href="@Url.Action("WesternCuisine", "Home")"> <img src="https://thewindowsclub-thewindowsclubco.netdna-ssl.com/wp-content/uploads/2018/01/Password-Spoofing.jpg" style="width: 40%; height: 40%;" /> </a> <a href="@Url.Action("ChineseCuisine", "Home")"> <img src="https://thewindowsclub-thewindowsclubco.netdna-ssl.com/wp-content/uploads/2018/01/Password-Spoofing.jpg" style="width: 40%; height: 40%;" /> </a> <div class="cfc-container"> <h1 class="main-caption">&nbsp; Your precious <br />&nbsp; Feedback is our <br />&nbsp; Motivation to be better <br /><button type="button" class="main-button" onclick="window.location.href='/Home/Feedback';"><strong>Learn More</strong></button> </h1> </div> </div> </body> </html> ```
This is underline of first `<a>` tag. Just apply `text-decoration: none` property to `<a>` tags in this block.
57,746,350
I have an entity (named Parent) with a @OneToOne mapping to a Child entity. Currently defined with FetchType.EAGER, but it doesn't matter to the problem at hand here. I am trying to perform a query on Parent that does a LEFT JOIN on the Child entity, rendering the FetchType setting useless (supposedly). However, the query on the Child entity still gets executed, even though the join is performed correctly. ``` @Entity public class Parent { @NotFound(action = NotFoundAction.IGNORE) @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "id", insertable = false, updatable = false) private Child child; } @Entity public class Child { } CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder(); CriteriaQuery<Parent> criteriaQuery = criteriaBuilder.createQuery(Parent.class); Root<Parent> root = criteriaQuery.from(Parent.class); Fetch<Parent, Child> join = root.fetch("child", JoinType.LEFT); return session.createQuery(criteriaQuery).getSingleResult(); ``` I would have expected this to generate a single query with a LEFT JOIN that gathers all of the data, but instead it performs: ``` 1) SELECT * FROM parent LEFT JOIN child ... 2) SELECT * FROM child where id = ? ```
2019/09/01
[ "https://Stackoverflow.com/questions/57746350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7732544/" ]
kindly add below code in your css ``` a:-webkit-any-link { text-decoration: none; } ```
That black line in the underline of `a` tag. To remove it just use `text-decoration: none`, like this: ```css .mid > a { text-decoration: none; } .mid { margin-top: 0px; flex-wrap: wrap; justify-content: center; text-align: center; } .cfc-container { display: inline-block; width: 80%; padding-top: 30px; padding-bottom: 30px; margin-top: 5px; margin-bottom: 30px; color: inherit; border: 1px solid; background-color: white; background-image: linear-gradient(to right, rgba(228, 241, 254, 1), rgba(255, 255, 255, 0.2)), url(../Image/customer_service.png); background-repeat: no-repeat; background-position: right; } ``` ```html <div class="mid"> <a href="@Url.Action(" WesternCuisine ", "Home ")"> <img src="~/Image/western_cuisine.png" style="width: 40%; height: 40%;" /> </a> <a href="@Url.Action(" ChineseCuisine ", "Home ")"> <img src="~/Image/chinese_cuisine.png" style="width: 40%; height: 40%;" /> </a> <div class="cfc-container"> <h1 class="main-caption">&nbsp; Your precious <br />&nbsp; Feedback is our <br />&nbsp; Motivation to be better <br /><button type="button" class="main-button" onclick="window.location.href='/Home/Feedback';"><strong>Learn More</strong></button> </h1> </div> </div> ```
57,746,350
I have an entity (named Parent) with a @OneToOne mapping to a Child entity. Currently defined with FetchType.EAGER, but it doesn't matter to the problem at hand here. I am trying to perform a query on Parent that does a LEFT JOIN on the Child entity, rendering the FetchType setting useless (supposedly). However, the query on the Child entity still gets executed, even though the join is performed correctly. ``` @Entity public class Parent { @NotFound(action = NotFoundAction.IGNORE) @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "id", insertable = false, updatable = false) private Child child; } @Entity public class Child { } CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder(); CriteriaQuery<Parent> criteriaQuery = criteriaBuilder.createQuery(Parent.class); Root<Parent> root = criteriaQuery.from(Parent.class); Fetch<Parent, Child> join = root.fetch("child", JoinType.LEFT); return session.createQuery(criteriaQuery).getSingleResult(); ``` I would have expected this to generate a single query with a LEFT JOIN that gathers all of the data, but instead it performs: ``` 1) SELECT * FROM parent LEFT JOIN child ... 2) SELECT * FROM child where id = ? ```
2019/09/01
[ "https://Stackoverflow.com/questions/57746350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7732544/" ]
This is because of the default behavior of tag - text-decoration, ``` .mid a { text-decoration: none; } ``` ```css .mid { margin-top: 0px; flex-wrap: wrap; justify-content: center; text-align: center; } .mid a { text-decoration: none; } .cfc-container { display: inline-block; width: 80%; padding-top: 30px; padding-bottom: 30px; margin-top: 5px; margin-bottom: 30px; color: inherit; border: 1px solid; background-color: white; background-image: linear-gradient(to right,rgba(228,241,254,1),rgba(255,255,255,0.2)), url(../Image/customer_service.png); background-repeat: no-repeat; background-position: right; } ``` ```html <!DOCTYPE html> <html> <body> <div class="mid"> <a href="@Url.Action("WesternCuisine", "Home")"> <img src="https://thewindowsclub-thewindowsclubco.netdna-ssl.com/wp-content/uploads/2018/01/Password-Spoofing.jpg" style="width: 40%; height: 40%;" /> </a> <a href="@Url.Action("ChineseCuisine", "Home")"> <img src="https://thewindowsclub-thewindowsclubco.netdna-ssl.com/wp-content/uploads/2018/01/Password-Spoofing.jpg" style="width: 40%; height: 40%;" /> </a> <div class="cfc-container"> <h1 class="main-caption">&nbsp; Your precious <br />&nbsp; Feedback is our <br />&nbsp; Motivation to be better <br /><button type="button" class="main-button" onclick="window.location.href='/Home/Feedback';"><strong>Learn More</strong></button> </h1> </div> </div> </body> </html> ```
That black line in the underline of `a` tag. To remove it just use `text-decoration: none`, like this: ```css .mid > a { text-decoration: none; } .mid { margin-top: 0px; flex-wrap: wrap; justify-content: center; text-align: center; } .cfc-container { display: inline-block; width: 80%; padding-top: 30px; padding-bottom: 30px; margin-top: 5px; margin-bottom: 30px; color: inherit; border: 1px solid; background-color: white; background-image: linear-gradient(to right, rgba(228, 241, 254, 1), rgba(255, 255, 255, 0.2)), url(../Image/customer_service.png); background-repeat: no-repeat; background-position: right; } ``` ```html <div class="mid"> <a href="@Url.Action(" WesternCuisine ", "Home ")"> <img src="~/Image/western_cuisine.png" style="width: 40%; height: 40%;" /> </a> <a href="@Url.Action(" ChineseCuisine ", "Home ")"> <img src="~/Image/chinese_cuisine.png" style="width: 40%; height: 40%;" /> </a> <div class="cfc-container"> <h1 class="main-caption">&nbsp; Your precious <br />&nbsp; Feedback is our <br />&nbsp; Motivation to be better <br /><button type="button" class="main-button" onclick="window.location.href='/Home/Feedback';"><strong>Learn More</strong></button> </h1> </div> </div> ```
57,746,350
I have an entity (named Parent) with a @OneToOne mapping to a Child entity. Currently defined with FetchType.EAGER, but it doesn't matter to the problem at hand here. I am trying to perform a query on Parent that does a LEFT JOIN on the Child entity, rendering the FetchType setting useless (supposedly). However, the query on the Child entity still gets executed, even though the join is performed correctly. ``` @Entity public class Parent { @NotFound(action = NotFoundAction.IGNORE) @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "id", insertable = false, updatable = false) private Child child; } @Entity public class Child { } CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder(); CriteriaQuery<Parent> criteriaQuery = criteriaBuilder.createQuery(Parent.class); Root<Parent> root = criteriaQuery.from(Parent.class); Fetch<Parent, Child> join = root.fetch("child", JoinType.LEFT); return session.createQuery(criteriaQuery).getSingleResult(); ``` I would have expected this to generate a single query with a LEFT JOIN that gathers all of the data, but instead it performs: ``` 1) SELECT * FROM parent LEFT JOIN child ... 2) SELECT * FROM child where id = ? ```
2019/09/01
[ "https://Stackoverflow.com/questions/57746350", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7732544/" ]
This is because of the default behavior of tag - text-decoration, ``` .mid a { text-decoration: none; } ``` ```css .mid { margin-top: 0px; flex-wrap: wrap; justify-content: center; text-align: center; } .mid a { text-decoration: none; } .cfc-container { display: inline-block; width: 80%; padding-top: 30px; padding-bottom: 30px; margin-top: 5px; margin-bottom: 30px; color: inherit; border: 1px solid; background-color: white; background-image: linear-gradient(to right,rgba(228,241,254,1),rgba(255,255,255,0.2)), url(../Image/customer_service.png); background-repeat: no-repeat; background-position: right; } ``` ```html <!DOCTYPE html> <html> <body> <div class="mid"> <a href="@Url.Action("WesternCuisine", "Home")"> <img src="https://thewindowsclub-thewindowsclubco.netdna-ssl.com/wp-content/uploads/2018/01/Password-Spoofing.jpg" style="width: 40%; height: 40%;" /> </a> <a href="@Url.Action("ChineseCuisine", "Home")"> <img src="https://thewindowsclub-thewindowsclubco.netdna-ssl.com/wp-content/uploads/2018/01/Password-Spoofing.jpg" style="width: 40%; height: 40%;" /> </a> <div class="cfc-container"> <h1 class="main-caption">&nbsp; Your precious <br />&nbsp; Feedback is our <br />&nbsp; Motivation to be better <br /><button type="button" class="main-button" onclick="window.location.href='/Home/Feedback';"><strong>Learn More</strong></button> </h1> </div> </div> </body> </html> ```
kindly add below code in your css ``` a:-webkit-any-link { text-decoration: none; } ```