Posts

Showing posts from September 11, 2018

Using variables within sed

Image
Clash Royale CLAN TAG #URR8PPP Using variables within sed I am trying to use a variable within sed but cant work it out. I have tried read -p " enter your name" name sed -i 's/myname/$name/g' file But unfortunately it just replaces myname with "$name". Is there an alternative way? have you tried with $name ? – Preuk Apr 27 '15 at 13:31 $name This should work! Do you use some type of exotic shell? – hek2mgl Apr 27 '15 at 13:35 that works great too, thank you – rog Apr 27 '15 at 13:48 possible duplicate of sed with & in variable – NeronLeVelu Apr 27 '15 at 14:02 possible duplicate of sed substitution with bash variables – Etan Reisner Apr 27 '15 at 14:43 1 Answer 1 The problem is that the bash shell does not do variable expansion within single quotes. For example: bash pax> name=paxdiablo pax> echo 'Hello, $name, how are you?' Hello, $name, how are you? For simple cases like t

Dice/Jaccard Coefficient Optimization in Tensorflow

Image
Clash Royale CLAN TAG #URR8PPP Dice/Jaccard Coefficient Optimization in Tensorflow I am trying to optimize my network with either Dice's or Jaccard's coefficient. My issue is an image segmentation problem so my output is a tensor of shape (1, 256, 256, 11). In order to calculate the intersection of my output and the truth image I take tf.argmax(output, axis = 3) which returns a datatype of "int" which tensorflow optimizers (specifically AdamOptimizer ) don't seem to take so I then convert this to a float with AdamOptimizer tf.cast(tf.argmax(output, axis = 3), tf.float32) However, it doesn't seem as though there is a gradient defined for tf.cast (or tf.argmax for that matter). Has anybody been able to sucessfully implement 2 Answers 2 The operation tf.argmax() is not differentiable, that's why the gradient is not implemented. You can not optimize Jaccard directly, because it is not differentiable. tf.argmax() The same happens with accuracy, when

Column index to number

Image
Clash Royale CLAN TAG #URR8PPP Column index to number I get alot of raw data from querys into excel, and when preforming VLOOKUP's sometimes I have to count or calculate by hand what column I am going to refer to. What I want to do now is a calculator were I type in userform textbox ex: "M", and the other textbox will show the correct column number for "M" (13). My userform looks like this: https://ibb.co/iug3WU So far I have only come up with something like the code below, I dim every letter as an integer and when that is typed in to the textbox it will just add each others values. But I am stuck and dont know how to code the CommandButton1_click "Räkna". Best regards Private Sub CommandButton1_Click() 'how do i transform letters into numbers here? End Sub Sub raknare() Dim a As Integer Dim b As Integer Dim c As Integer Dim d As Integer Dim e As Integer Dim f As Integer Dim g As Integer Dim h As Integer Dim i As Integer Dim j As Integer Di

more pythonic way to concatenate pandas data frames

Image
Clash Royale CLAN TAG #URR8PPP more pythonic way to concatenate pandas data frames So I've been having to write programs which do something to an existing pandas data frame and then at that data frame to the end of a big data frame in a for loop. I've found a way to do this, by setting the first data frame to be the end data frame for the first iteration, and then concatenating data frames to this end data frame in later iterations but it doesn't seem to be the most efficient way to do this to me. I've been using python for a while but have only recently started using pandas so I don't know if there is an easier way to do this. I've attached a simple sample code which hopefully demonstrates what I'm doing and was wondering whether it can be done more pythonically. df = pandas.DataFrame([0,1,2,3]) for i in range(3): if i == 0: end_df = df else: end_df = pandas.concat([end_df,df],ignore_index=True) What's wrong with end_df = pandas.concat([df, d

QMap::clear() crash

Image
Clash Royale CLAN TAG #URR8PPP QMap::clear() crash I'm running Qt-4.8.6 on Linux i686 I have a QMap<quint32, QTreeWidgetItem *> mymap; and when I simply call mymap.clear(); the program crashes with stacktrace ... #7 <signal handler called> #8 0x0806f50c in QBasicAtomicInt::deref (this=0x34) at /usr/local/Trolltech/Qt-4.8.6/include/QtCore/qatomic_i386.h:110 #9 0xa968c452 in QMap<unsigned int, QTreeWidgetItem*>::operator= (this=0xc53c51c, other=@0xbfa04b28) at /usr/local/Trolltech/Qt-4.8.6/include/QtCore/qmap.h:412 #10 0xa968c4d1 in QMap<unsigned int, QTreeWidgetItem*>::clear (this=0xc53c51c) at /usr/local/Trolltech/Qt-4.8.6/include/QtCore/qmap.h:424 ... Sorry I can't paste full stacktrace/code cuz I don't own the code. This problem doesn't happen every time , or I should say it happens very rarely, but it did happen. I googled but only found things like "reinstall Qt", "use same compiler", etc. Is there anything else I

SQL: Mege two rows in one

Image
Clash Royale CLAN TAG #URR8PPP SQL: Mege two rows in one On MySQL I'd like to merge 2 rows in 1, for example: | Name | Value | Res | | foo | Type | 0.2 | | foo | Group | aaa | | bar | Type | 0.3 | | bar | Group | bbb | my expected result would be: | Name | Type | Group | | foo | 0.2 | aaa | | bar | 0.3 | bbb | I'd like to merge two entries with some common values in one that has two column that distinct a value in a Res column on the value of a Type column. How can I do this? Thanks Res Type Why would a value of type1 appear in column called type? – P.Salmon Aug 10 at 8:35 @P.Salmon, yeh you're right it was a bit confusing, now I've corrected the question. Thanks – NickF_93 Aug 10 at 8:38 Do you only have 2 distinct values or are there lots and you are only using 2 as an example? – P.Salmon Aug 10 at 8:39 @P.Salmon I have about 1'000'000 of values, now I've solved with an INNER JOIN on same table but it take too much – NickF_9

Return all column names for a duplicate value in a table

Image
Clash Royale CLAN TAG #URR8PPP Return all column names for a duplicate value in a table I would like to know is it possible to return all value for duplicate column with same ID value for oracle sql My table design would below Table A Name ID Order Year ------ ------ ------- ------ JOHN 1 ORD123 2017 JAKE 2 ORD122 2018 JES 2 ORD111 2017 JOHN 3 ORD323 2012 NICK 4 ORD133 2011 AMY 4 ORD222 2010 MUS 4 ORD132 2010 I want the result of the query to be as below Name ID Order Year ------ ------ ------- ------ JAKE 2 ORD122 2018 JES 2 ORD111 2017 NICK 4 ORD133 2011 AMY 4 ORD222 2010 MUS 4 ORD132 2010 Sure thing it is possible, you could do it with a subselect or a group by having count('X') > 1 . Anyway this is a common problem and is pretty much already answered in stackoverflow – bradbury9 Aug 10 at 7:26 group by having count('X') > 1 I would suggest you marking the question that you think is best as accepted If you hadn't tried I would encourage give

Division on MySQL

Image
Clash Royale CLAN TAG #URR8PPP Division on MySQL Please help me. I have division problem on mysql. I have query like this : SELECT (8/10) as res This query result is 0.8000 and I want the result is 0.8 not 0.8000. Does someone have a solution? 80/10 = 8.0000? – P.Salmon Aug 10 at 7:51 Possible duplicate of Format number to 2 decimal places – juzraai Aug 10 at 7:51 SELECT (80/10) as res this query results in 8.0000 and SELECT (80/100) as res results in 0.8000 and SELECT ROUND((80/100), 1) as res results in 0.8 – codtex Aug 10 at 7:51 SELECT (80/10) as res 8.0000 SELECT (80/100) as res 0.8000 SELECT ROUND((80/100), 1) as res 0.8 @codtex how with 15/100 ? it will result 0.2. i wanna remove 0 after 8, so the result is 0.8 or with case 15/100, the result is 0.15 not 0.1500 – Al-kadafi Aug 10 at 8:14 2 Answers 2 EDIT :Trim with add 0 value SELECT TRIM((80/100))+0 is it wrong answer ? why isnot useful ? – Yogi Prayoga Aug 10 at 8:13 how wit

Firebase: Firestore Query for Longest Match

Image
Clash Royale CLAN TAG #URR8PPP Firebase: Firestore Query for Longest Match My document looks like: ABC: 1 ABCD: 2 ABCDE: 3 ABCDEF: 4 I want to query for longest match, in other words, myVar = ABCDEFGHIJ and I want the field with value 4 (the longest match). myVar = ABCDEFGHIJ 4 By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

how to add new event to flink CEP data stream?

Image
Clash Royale CLAN TAG #URR8PPP how to add new event to flink CEP data stream? I am using flink 1.5.2 to solve a CEP problem. my data is from a List, some other process will add new Event object to that list while system is running. It is not socket or network message. I've been reading the official site example. Here are the steps I imagine I should be doing. But my input stream should be unbounded. I didn't find any add() method in DataStream<> object. How do I accomplish this? and also, do I need to tell DataStream<> when to clean up obsolete events? 1 Answer 1 Collections are only suitable as an input source for Flink when working with a bounded input set that's fixed up front, as when writing a test or just experimenting. If you want an unbounded stream you will need to choose a different source, such a socket or a message queuing system like Kafka. Sockets are easy to work with for experimentation. On Linux and MacOS systems you can use nc -lk 999

jquery Datatable ajax Error

Image
Clash Royale CLAN TAG #URR8PPP jquery Datatable ajax Error DataTables warning: table id=assetTable - Ajax error. For more information about this error, please see https://datatables.net/tn/7 Error View Controller Welcome to Stack Overflow! Please visit the help center to see what and How to Ask. HINT: Post effort and CODE, not pictures of code - and first read the URL in the image, it redirects to datatables.net/manual/tech-notes/7 – mplungjan Aug 10 at 9:01 After 'please see' in the error message is a URL you should visit. It explains the problem and tell you the solutions. – Rory McCrossan Aug 10 at 9:01 By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Import a table from one user to another Oracle SQL

Image
Clash Royale CLAN TAG #URR8PPP Import a table from one user to another Oracle SQL Is it possible to import a table from one user to another from export dmp file in Oracle? If yes, how to do it? I have 2 users: MILLER and DUMMY. MILLER has table Planets. I've made export from MILLER (last.dmp) using Command Prompt, and I want to make import the table into DUMMY user from export file. I have already tried use information from here but it didn't help me. I also can add log of command prompt, if necessary. I think you're looking for the REMAP_SCHEMA option. Find out more. – APC Aug 9 at 13:35 What utility did you use? exp or expdp ? – Dmitry Demin Aug 9 at 14:04 exp expdp I use exp and imp – Бурхан Ондар Барази Aug 10 at 5:24 2 Answers 2 If you are using the "Original Import" Utility, you should consider that: More information here Thank you to all of you. Here is the solution: 1)grant IMP_FULL_DATABASE to DUMMY; 2)alter user DUMM

Sony Audio Control API - Can't Change Input on AV Receiver

Image
Clash Royale CLAN TAG #URR8PPP Sony Audio Control API - Can't Change Input on AV Receiver I've been playing around with Sony's Audio Control API recently, with the aim of setting up 'scenes' at home, where I can switch devices on/off, set lighting, etc with one command. I can list available inputs with getCurrentExternalTerminalsStatus, but can't actually change inputs via setActiveTerminal. Request "method": "setActiveTerminal", "id": 13, "params": [ "active": "active", "uri": "extInput:sat-catv" ], "version": "1.0" Response "error": [ 15, "unsupported operation" ], "id": 13 Judging by the response given, I'm guessing that my AV receiver (STR-DN860) doesn't support this for some reason, but I'm posting this here since Sony's support pages suggest to do so. 2 Answers 2 I think you want to use &q

Django Import Error: cannot import name “Shift”

Image
Clash Royale CLAN TAG #URR8PPP Django Import Error: cannot import name “Shift” I'm pretty sure it's due to a circular import but I'm not too sure how to solve my issue in mysite/shifts/models.py from django.db import models class Shift(models.Model): # defines a shift` in mysite/shifts/scrapes.py from shifts.models import Shift I can share more code if you need but I believe the issue is here, I've added my apps to settings.py and I get this error when I run scrapes.py as a django-admin command settings.py scrapes.py from shifts.models import Shift ImportError: No module named 'shifts' project_structure it looks like the Python path has been set wrong. You probably have set one above mysite . – Willem Van Onsem Aug 10 at 9:03 mysite What do you mean set one above? – Connor McCann Aug 10 at 9:13 Would you show your folder structure? – guillermo chamorro Aug 10 at 14:40 2 Answers 2 from mysite.shifts.models import Shift This

MS-access Pass-Through Query to SQL Server 2008 Adding Prefix

Image
Clash Royale CLAN TAG #URR8PPP MS-access Pass-Through Query to SQL Server 2008 Adding Prefix I am hoping someone can point me in the right direction with this. I am relatively new to using pass-through queries but think I have a grip of the basics, I have come across a stumbling block however when trying to add a prefix to query result I have a select query which includes a line to convert a date into the financial year i.e 01/01/2018 would return 2017 as the result using the code below: [Created FY] = (CASE WHEN Month(create_date) IN (1, 2, 3) THEN DatePart(year,create_date)-1 ELSE DatePart(year,create_date) END), I would like to add a prefix to the result so that it would read FY2017. The pass-through is running on SQL Server 2008. I have researched and so far have not come up with any resolutions. Any help with this conundrum would be greatly appreciated. 1 Answer 1 + concatenates strings, but numbers must be converted first. + As there is a MONTH() function, there is

Div with background matches text height

Image
Clash Royale CLAN TAG #URR8PPP Div with background matches text height Note: IE 8+ is a must :-( What I currently have, This is what I want, It is about the part <div style="background-color: red;height: 20px;width: 10px; ... This is what I am trying - https://jsfiddle.net/w3tjbvef/3/ <table id="sometable" style="display: table;"> <tbody> <tr class="s-row"> <td>Name</td> <td>:</td> <td>Name With Colour Yellow 1</td> </tr> <tr class="t-row"> <td>Tag</td> <td>:</td> <td> <div style="vertical-align: middle;"> <div style="background-color: red;height: 20px;width: 10px;/* margin-top: 10px; */display: inline-block;"></div>Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live.</div> </td> </tr> <tr class="time-row"