on-internet

Check if a value exists before updating a column for a already existing record in mysql

Lets say I have table called Tokens, with columns: id, refresh_token, and token. refresh_token column should be unique. But we may have many refresh_token fields that are null. These null refresh_token fields should be updated later, but there is a possibility that we may try to enter a refresh_token value that is contained in another field, and that will cause a conflict. So, what I wanted to do is: First check if the refresh_token value is contained in any other fields. If it is not contained or if unique, the that new refresh_token value can be used to update a specific row with a given id.

Join the discussion →

Is dereferencing a pointer that's equal to nullptr undefined behavior by the standard?

A blog author has brought up the discussion about null pointer dereferencing. I've put some counter arguments here. His main line of reasoning quoting the standard is this: The '&podhd->line6' expression is undefined behavior in the C language when 'podhd' is a null pointer. The C99 standard says the following about the '&' address-of operator (6.5.3.2 "Address and indirection operators"): The operand of the unary & operator shall be either a function designator, the result of a [] or unary * operator, or an lvalue that designates an object that is not a bit-field and is not declared with the

Join the discussion →

How to run JUnit SpringJUnit4ClassRunner with Parametrized?

The following code is invalid due to duplicate @RunWith annotation: @RunWith(SpringJUnit4ClassRunner.class) @RunWith(Parameterized.class) @SpringApplicationConfiguration(classes = {ApplicationConfigTest.class}) public class ServiceTest { } But how can I use these two annotations in conjunction?

Join the discussion →

database connection pdo php test database connection

<?php global $dbh; $dbname='userdb' ; $userlist_tbl="userlist_tbl" ; try { $dbh=n ew PDO( "mysql:host=localhost", "root", ""); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $dbname = "`".str_replace("`","``",$dbname)."`"; $dbh->query("CREATE DATABASE IF NOT EXISTS $dbname"); $dbh->query("SET CHARACTER SET utf8"); $dbh->query("use $dbname"); $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sql ="CREATE TABLE IF NOT EXISTS $userlist_tbl ( user_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, user_fname VARCHAR(50) NOT NULL, user_lname VARCHAR(50) NOT NULL, user_i

Join the discussion →

Sending an email message with highpriority using Exchange API for java

I wan to set my email priority. I am using API for exchange server. I suppose with this method "msg.setImportance(value);" i can resolve my prob. but I did not handle the syntax. Please, someone if can explain to me how I do that ExchangeService service = new ExchangeService(); ExchangeCredentials credentials = "email", "pass"); service.setCredentials(credentials); service.setUrl(new java.net.URI("https://"server" + "/EWS/Exchange.asmx")); service.setTraceEnabled(true); EmailMessage msg = new EmailMessage(service); msg.setImportance(value); msg.setSubject("Hello world!"); msg.setBody(MessageBo

Join the discussion →

How to set column width to autofit in Kendo Grid MVC

I use to my page of Kendo grid that have multi columns. I want set a column width to autofit and change width automatically. Plz help me , thanks @(Html.Kendo().Grid<GardeshKar.Models.v_marhaleh_marahel>() .Name("grdMarahel_Gardeshkar") .ToolBar(toolbar => toolbar.Custom().Name("btnAddMarhaleh").Text("اضافه").HtmlAttributes(new { id = "btnAddMarhaleh", href = "#" })) .Columns(columns => { columns.Bound(c => c.Code).Width(50).Title("کد"); columns.Bound(c => c.Desc).Width(150).Title("شرح");//Autofit columns.Command(c => c.Destroy().Text("حذف")).Width(70).Title("عملیات"); }) .HtmlAttributes(new {

Join the discussion →

PhpMyAdmin export does not include PRIMARY KEY as mysqldump

Export of the struture of the same table with PhpMyAdmin: `DROP TABLE IF EXISTS `test_apprentis`; CREATE TABLE IF NOT EXISTS `test_apprentis` ( `a_id` smallint(10) NOT NULL, `a_promo_id` smallint(11) NOT NULL, `a_cursus` smallint(10) DEFAULT NULL ) ENGINE=MyISAM AUTO_INCREMENT=3665 DEFAULT CHARSET=utf8;` Export with mysqldump: DROP TABLE IF EXISTS `test_apprentis`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `test_apprentis` ( `a_id` smallint(10) NOT NULL AUTO_INCREMENT, `a_promo_id` smallint(11) NOT NULL, `a_cursus` smal

Join the discussion →

How to import a spring application context into another application context?

I have two spring application contexts. One is local to my application and the other is from one of the maven dependencies. Now, my applicationContext.xml file look like this. <import resource="classpath*:**/sample-applicationContext.xml" /> and I have <context:component-scan> in the sample-applicationContext.xml file which scans for components. and Now, when I do the following.. ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml"); MyClass m=ctx.getBean(MyClass.class); Unfortunately, when I get the MyClass object, the object is created however, I see that depend

Join the discussion →

Convert current date to char in DB2

I have a INSERT + SELECT statement. One column is a VARCHAR but must be filled with a date with 'yyyyMMdd' format in 3 different dialect. With SQL server and Oracle there's no problem, but in Db2 I didn't find anything to do this stuff. In SQLServer is CONVERT(VARCHAR,S.DT_NASCITA,112) In Oracle is TO_CHAR(S.DT_NASCITA,'YYYYMMDD') Any1 can help me pls ? ty in advice !

Join the discussion →

reading and writing from hive tables with spark after aggregation

We have a hive warehouse, and wanted to use spark for various tasks (mainly classification). At times write the results back as a hive table. For example, we wrote the following python function to find the total sum of original_table column two, grouped by original_table column one. The function works, but we are worried that it is inefficient, particularly the maps to convert to key-value pairs, and dictionary versions. Functions combiner, mergeValue, mergeCombiner are defined elsewhere, but work fine. from pyspark import HiveContext rdd = HiveContext(sc).sql('from original_table select *') #

Join the discussion →

Get to El Calafate from the end of the W-Trek (Torres del Paine)

I am wondering how to best get to El Calafate after having finished the W-Trek in Torres del Paine (at the West side, Laguna Amarga I guess). Is there a way to get to El Calafate directly (without having to pass through Puerto Natales again) from the end of the W-trek by public transportation? I heard of a border crossing at Cerro Castillo, but I don't know if there are any buses to catch there.

Join the discussion →

Disable url encoding in Chrome & Firefox

One of our partner sites has a webpage with a form where I enter 2-3 number fields, a captcha and then submit the form. It opens a pop-up showing the requested details. The pop-up url is something like this https://abc.co/xyz/gef/sample/certificate?Values=123456789|2011|A1563894a|y6zs8v|'1373550','4148114' This thing works fine only in IE. The same process doesn't work in Chrome or Firefox, because the ' in the url is encoded to something like this https://abc.co/xyz/gef/sample/certificate?Values=123456789|2011|A1563894a|y6zs8v|%271373550%27,%274148114%27 I am shown an error We are unable to p

Join the discussion →

Open cshtml page as a modal popup in MVC

We need to open a Chart.cshtml page as a modal popup (gray parent window) in our application in center of a parent screen with some values as a input of popup. On popup closing we return some values to parent screen. Chart.cshtml directory is Views => Home => Chart.cshtml of my MVC application. Please help me with a sample code. Its really very helpful for me. Thanks, Sufyan

Join the discussion →

How to make a snow fall on web page text?

I have this JavaScript code for snow falling effect. It's working really nice, but I decided to create a snow falling on web page text. I have tried, but not getting how to do it. How to make snow fall on that "I love you" text? http://jsfiddle.net/DgrxX/22/ I have already seen in VB6 code where snow fall on text. If it is possible in Visual Basic 6 seven years ago, why not today in JavaScript or CSS3 or jQuery? function vp(woh) { var viewportwidth; var viewportheight; if (typeof window.innerWidth != 'undefined') { viewportwidth = window.innerWidth, viewportheight = window.innerHeight } else i

Join the discussion →

Functional pipes in python like %>% from R's magrittr

In R (thanks to magrittr) you can now perform operations with a more functional piping syntax via %>%. This means that instead of coding this: > as.Date("2014-01-01") > as.character((sqrt(12)^2) You could also do this: > "2014-01-01" %>% as.Date > 12 %>% sqrt %>% .^2 %>% as.character To me this is more readable and this extends to use cases beyond the dataframe. Does the python language have support for something similar?

Join the discussion →

programming snake in c# with console

I'm trying to make a snake in the console to keep me in training in c #. I have a problem in the movement. To test I wanted to do so by pressing the letter "a" would shift the "food" on the X I noticed that in terms of graphics, but does not move through a Console.Write is incremented. Can you give me a hand? I am attaching the main classes, world food Main: namespace Snake { class Program { static void Main(string[] args) { char s; World mondo = new World(20, 10); do { s = char.Parse(Console.ReadLine()); mondo.update(); mondo.drawWorld(); } while (s == 'a'); Console.ReadLine(); } } } World: n

Join the discussion →

How to overcome the git error `Unknown SSL protocol error in connection`

I'm trying to git clone some repository, but then I get the error: $ git clone --recursive https://some-url.git Cloning into 'project'... fatal: unable to access 'https://https://some-url.git/': Unknown SSL protocol error in connection to some-url.git:443 I've read that the git repositories moved to force the TLS1.0 and no more support SSLv3 communication due to the POODLE vulnerability. But I don't know whether this error message means that my git client only knows to talk SSLv3 and the server denies or that the server only knows to talk SSLv3 and my client denies. If the problem is in my cli

Join the discussion →

bash upload to sftp and moving files. looping around

Im somewhat beginner in bash scripting. I have here part of script that uploades files to sftp server. Then it shoud move files to other directory. Else echo info about no files in source_dir. Problem is that its not moving files and is looping back to sftp login after files are already uploaded. cd /dest_dir/ for file5 in *.test do if test -f $file5 then echo 'some text.' (( echo " cd /dest_dir/ lcd /source_dir/ mput *.test exit " ) | sftp "user"@"host") sleep 3 mv /source_dir/$file5 /source_dir/test/ else echo -e 'some text' fi

Join the discussion →

Windows command line for Disk Space usage report - sub directory level

Is there any windows command which can be used with cmd prompt to check for disk space use. The report should be detailed in terms of sizes in GB i.e. list out folders with size greater than 1 Also, I wouldn't prefer to use any third party tool. There are restrictions of using any third party software in the particular machine. So a cmd line command would be the best solution.

Join the discussion →

Excel VB Copy and Pasting Hyperlinks

I am having trouble copying and pasting the hyperlinks from one sheet to another using VB. I am using a database connection to pull the hyperlinks into Sheet1 and then using a macro to copy and paste the database data into another sheet, however the copy and pasting doesnt paste the "Clickable" link, only plain text. How do I go about copying a hyperlink using VB, is this even possible?? Sheets("Sheet1").Select Range("J19:K100").Select Application.CutCopyMode = False **Selection.SpecialCells(xlCellTypeVisible).Copy** Sheets("Sheet2").Select Range("C5:D100").Select ActiveSheet.Paste **Link:=Tru

Join the discussion →

Java FTP connection timed out

I am working on a project which will later upload a few files to an FTP server after they are modified...I have everything but uploading the file figured out. I can successfully connect to the FTP server, but once the file goes to upload, the program hangs for a couple minutes, then it states that it timed out. java.net.ConnectException: Connection timed out: connect at java.net.DualStackPlainSocketImpl.connect0(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at j

Join the discussion →

Fully robust message queue in Linux/BASH [closed]

I'm trying to implement a message queueing system using a named pipe. To read from the pipe I've used: pump_read=1 while [[ ${pump_read} -eq 1]]; do IFS="|" read pump_f1 pump_f2 pump_f3 < queuefile echo "${pump_f1}|${pump_f1}|${pump_f3}" >> pump.log done To write to the named pipe I've used echo "x|y|z" | ssh user@host "cat > queuefile" I'm using this method because the reader and writers may not be on the same hosts. Mostly this works but reasonably frequently I will get rows in my log of "||" as though an empty line has been written into the pipe. I also have times when messages will disappe

Join the discussion →

Prevent XSS on client-side (Pure Javascript)

I have a simple project but it is giving me headaches because Client-Side programming is not my thing. Basically I have a login page and the client wants me to prevent XSS attacks not allowing users not submit malicious code on username/password fields. I would do it on server side easily, but they do not want give to us access. Any chance to someone give me hints how can i do this? Even tough I know the basics of javascript/HTML, my experience is nearly null. I know that are several questions about this topic, but sincerely, I got lost with all information.

Join the discussion →

SourceTree very slow with many repositories

I work on a lot of small projects on daily basis and need to switch often. I have over 50 Git Repositories in Sourcetree. Usually 5 projects are open in "Tabs". Switching from "Tab" in SourceTree is very slow. Sometimes up to 15 seconds. How can I improve this behaviour?

Join the discussion →

browse file system of android device in MTP mode via powershell using a wmiobject

I've gone through few posts and articles that discuss how to use powershell access usb drive like: Browse files on camera using PowerShell List all devices, partitions and volumes in Powershell https://superuser.com/a/377008/9546 But none of them actually "answers" the question. The last post shared also says no one has ever created an MTP solution because of certain limitations that MTP (protocol) itself has. One route I've taken kind of hit a wall; I don't know what to do next (with the wmi object). I've used the following vbscript program, and made note of the device id of the device I am i

Join the discussion →

After running android app imported packages are visible on phone

I have created my first Android App which uses a QR code package (com.jwetherell.quick_response_code). The integration works good. However, when I deploy the application to the phone, not only the app icon is visible but also some android package icons which are useless without the app's functionality. In what way should I configure the deployment that only the app icon is visible?

Join the discussion →

How to insert HTML from a button click?

I am trying to insert a form when a button is clicked but cannot find a way that does not make me put all of the HTML on one line with back slashes or many ugly lines of code. Something that does not include adding something like jQuery or PHP. How can I make this that is all on one line: <script> function newMsg() { document.getElementById("add_message").innerHTML = "<div class=\"message\">Add Message<br>Title: <input type=\"text\" id=\"title\"><br>Text: <input type=\"text\" id=\"message\"><br><br></div>"; } </script> Look more like this (that has good formatting and is on multiple lines): <s

Join the discussion →

Getting a Mailbox unavailable. Too many invalid recipients error

Our application sends out emails using the new SmtpClient(smtpServer).Send(message); We are making sure that the smtpServer is valid, the message has To and From addresses, a subject and a body. If any of these are missing, we would log an exception before even attempting to send a message. But the application frequently fails with the below exception. Email Fail: System.Net.Mail.SmtpException: Mailbox unavailable. The server response was: Too many invalid recipients. Now, please note that the email send functionality is not failing always. For the same "To" address, it fails, may be about hal

Join the discussion →

Rounded QComboBox without square box behind

I'm styling a QComboBox in Qt. It is rounded how the figure shows. The problem is that is shows a strange square box behind the rounded border. Can someone tell me what this box is and how to make it invisible? By the way, I'd like to take the shadow away too. Here is my current code: QComboBox { border: 1px solid gray; border-radius: 10px; min-width: 6em; } QComboBox:on { border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; } QComboBox QAbstractItemView { border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; background: white; border: 1px solid gray; box-shadow: trans

Join the discussion →
Older stories