Posts

Showing posts from September, 2003

Can I Rsync To Multiple Destinations Using Same Filelist?

Answer : Solution 1: Here is the information from the man page for rsync about batch mode. BATCH MODE Batch mode can be used to apply the same set of updates to many identical systems. Suppose one has a tree which is replicated on a number of hosts. Now suppose some changes have been made to this source tree and those changes need to be propagated to the other hosts. In order to do this using batch mode, rsync is run with the write-batch option to apply the changes made to the source tree to one of the destination trees. The write-batch option causes the rsync client to store in a "batch file" all the information needed to repeat this operation against other, identical destination trees. Generating the batch file once saves having to perform the file status, checksum, and data block generation more than once when updating multiple destination trees. Multicast transport protocols can be used to transfer the batc

Creating An Index On A Table Variable

Answer : The question is tagged SQL Server 2000 but for the benefit of people developing on the latest version I'll address that first. SQL Server 2014 In addition to the methods of adding constraint based indexes discussed below SQL Server 2014 also allows non unique indexes to be specified directly with inline syntax on table variable declarations. Example syntax for that is below. /*SQL Server 2014+ compatible inline index syntax*/ DECLARE @T TABLE ( C1 INT INDEX IX1 CLUSTERED, /*Single column indexes can be declared next to the column*/ C2 INT INDEX IX2 NONCLUSTERED, INDEX IX3 NONCLUSTERED(C1,C2) /*Example composite index*/ ); Filtered indexes and indexes with included columns can not currently be declared with this syntax however SQL Server 2016 relaxes this a bit further. From CTP 3.1 it is now possible to declare filtered indexes for table variables. By RTM it may be the case that included columns are also allowed but the current position is that they "will

Alter Sequence Restart With Postgres Code Example

Example: postgresql alter table sequence alter sequence your_sequence restart with 1000 ;

Can Anybody Please Explain (my $self = Shift) In Perl

Answer : First off, a subroutine isn't passed the @ARGV array. Rather all the parameters passed to a subroutine are flattened into a single list represented by @_ inside the subroutine. The @ARGV array is available at the top-level of your script, containing the command line arguments passed to you script. Now, in Perl, when you call a method on an object, the object is implicitly passed as a parameter to the method. If you ignore inheritance, $obj->doCoolStuff($a, $b); is equivalent to doCoolStuff($obj, $a, $b); Which means the contents of @_ in the method doCoolStuff would be: @_ = ($obj, $a, $b); Now, the shift builtin function, without any parameters, shifts an element out of the default array variable @_ . In this case, that would be $obj . So when you do $self = shift , you are effectively saying $self = $obj . I also hope this explains how to pass other parameters to a method via the -> notation. Continuing the example I've stated a

Angular @Output & EventEmitter Not Working

Answer : You should put the showEvent on the actual component selector app-navbar that has the @Output decorator and not on the nav element: <app-navbar (showEvent)="getToggle($event)"></app-navbar> You've got your handler on the wrong element (nav instead of app-navbar) <app-navbar (showEvent)="getToggle($event)"></app-navbar>

Android Resource Linking Failed Unity Code Example

Example: android resource linking failed Change the following settings in build . gradle file to : classpath 'com.android.tools.build:gradle:3.4.2'

C Code To Print Name Code Example

Example: My name is c You Have Gone Mad

C# Parameterized Query MySQL With `in` Clause

Answer : This is not possible in MySQL. You can create a required number of parameters and do UPDATE ... IN (?,?,?,?). This prevents injection attacks (but still requires you to rebuild the query for each parameter count). Other way is to pass a comma-separated string and parse it. You could build up the parametrised query "on the fly" based on the (presumably) variable number of parameters, and iterate over that to pass them in. So, something like: List foo; // assuming you have a List of items, in reality, it may be a List<int> or a List<myObject> with an id property, etc. StringBuilder query = new StringBuilder( "UPDATE TABLE_1 SET STATUS = ? WHERE ID IN ( ?") for( int i = 1; i++; i < foo.Count ) { // Bit naive query.Append( ", ?" ); } query.Append( " );" ); MySqlCommand m = new MySqlCommand(query.ToString()); for( int i = 1; i++; i < foo.Count ) { m.Parameters.Add(new MySqlParameter(...)); } You cann

Android With Kotlin - How To Use HttpUrlConnection

Answer : Here is a simplification of the question and answer. Why does this fail? val connection = HttpURLConnection() val data = connection.inputStream.bufferedReader().readText() // ... do something with "data" with error: Kotlin: Cannot access '': it is 'protected/ protected and package /' in 'HttpURLConnection' This fails because you are constructing a class that is not intended to directly be constructed. It is meant to be created by a factory, which is in the URL class openConnection() method. This is also not a direct port of the sample Java code in the original question. The most idiomatic way in Kotlin to open this connection and read the contents as a string would be: val connection = URL("http://www.android.com/").openConnection() as HttpURLConnection val data = connection.inputStream.bufferedReader().readText() This form will auto close everything when done reading the text or on an exception. If you

Convert Std::string To QString

Answer : QString::fromStdString(content) is better since it is more robust. Also note, that if std::string is encoded in UTF-8, then it should give exactly the same result as QString::fromUtf8(content.data(), int(content.size())) . There's a QString function called fromUtf8 that takes a const char* : QString str = QString::fromUtf8(content.c_str()); Usually, the best way of doing the conversion is using the method fromUtf8, but the problem is when you have strings locale-dependent. In these cases, it's preferable to use fromLocal8Bit. Example: std::string str = "ëxample"; QString qs = QString::fromLocal8Bit(str.c_str());

Adding Border Only To The One Side Of The Component In React Native (iOS)

Answer : Even though borderBottom doesn't work on the Text component, it did work for me on the TextInput component, just set editable to false and set the value to your desired text as so... <TextInput style={styles.textInput} editable={false} value={'My Text'}/> const styles = StyleSheet.create({ textInput: { borderBottomColor: 'black', borderBottomWidth: 1, } }); This isn't currently possible. See the following RN issue: https://github.com/facebook/react-native/issues/29 and this ticket on Product Pains: https://productpains.com/post/react-native/add-borderwidth-left-right-top-bottom-to-textinput-/

Fafa Facebook Code Example

Example: fa fa-facebook < i class = "fa fa-facebook-square" aria - hidden = "true" > < / i >

Bootstrap V4.4.1 Cdn Code Example

Example 1: bootstrap 4 cdn < link rel = "stylesheet" href = "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" > Example 2: bootstrap 4 cdn < ! - - Boostrap 4 CSS - -> < link rel = "stylesheet" href = "https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity = "sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin = "anonymous" > < script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity = "sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin = "anonymous" > < / script > < ! - - Boostrap JS - -> < script src = "https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity = "sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin = "ano

Android - Snackbar Vs Toast - Usage And Difference

Answer : If I don't require user interaction I would use a toast? You can still use Snackbar. It is not mandatory to have an action with Snackbar. What is meant by "system messaging"? Does that apply to displaying information when something important happened between my app and the Android system? I believe this means that Toasts are to be used if there are some messages pertaining to the system. Either android as a whole or some background service you may be running. E.g. Text-To-Speech is not installed. OR No Email client found. What I like is the swipe off screen feature - would that be a reason to start replacing toasts with Snackbar? (this is a bit opinion based question though) That is one reason. But there are several other plus points. For an example: Your toast remains on screen even when the activity is finished. Snackbar doesn't. There is less confusion if the toast does not popup (or keep popping up in case of multiple Toast creation in seq

Android SetVisibility Does Not Display If Initially Set To Invisble

Answer : Had similar error but it was due to my silly mistake of not using the UiThread. Activity act = (Activity)context; act.runOnUiThread(new Runnable(){ @Override public void run() { mLayoutLights.setVisibility(View.VISIBLE); } }); Got it. You have to set the visibility of all the items in the layout, not just the layout. So this code worked: if (mLayoutLights.getVisibility() == View.VISIBLE) { ((Button) findViewById(R.id.btnLightsOK)).setVisibility(View.GONE); ((Button) findViewById(R.id.btnLightsCnc)).setVisibility(View.GONE); mLayoutLights.setVisibility(View.GONE); } else { mLayoutLights.setVisibility(View.VISIBLE); ((Button) findViewById(R.id.btnLightsOK)).setVisibility(View.VISIBLE); ((Button) findViewById(R.id.btnLightsCnc)).setVisibility(View.VISIBLE); } In my case, with a plain SurfaceView, I just set the View to GONE in xml, not INVISIBLE. Then I can set VISIBILITY correctly after that.

Android Change Background Drawable Programmatically Code Example

Example: android studio setbackground RelativeLayout layout = ( RelativeLayout ) findViewById ( R . id . background ) ; layout . setBackgroundResource ( R . drawable . ready ) ;

Convert XML To JSON With NodeJS

Answer : I've used xml-js - npm to get the desired result. First of all I've installed xml-js via npm install xml-js Then used the below code to get the output in json format var convert = require('xml-js'); var xml = require('fs').readFileSync('./testscenario.xml', 'utf8'); var result = convert.xml2json(xml, {compact: true, spaces: 4}); console.log(result); You can use xml2json npm for converting your xml in to json. xml2json. Step 1:- Install package in you project npm install xml2json Step 2:- You can use that package and convert your xml to json let xmlParser = require('xml2json'); let xmlString = `<?xml version="1.0" encoding="UTF-8"?> <TestScenario> <TestSuite name="TS_EdgeHome"> <TestCaseName name="tc_Login">dt_EdgeCaseHome,dt_EdgeCaseRoute</TestCaseName> <TestCaseName name="tc_Logout">dt_EdgeCaseRoute</TestCaseName> &l

Correct Mime Type For .mp4

Answer : According to RFC 4337 § 2, video/mp4 is indeed the correct Content-Type for MPEG-4 video. Generally, you can find official MIME definitions by searching for the file extension and "IETF" or "RFC". The RFC (Request for Comments) articles published by the IETF (Internet Engineering Taskforce) define many Internet standards, including MIME types. video/mp4 should be used when you have video content in your file. If there is none, but there is audio, you should use audio/mp4 . If no audio and no video is used, for instance if the file contains only a subtitle track or a metadata track, the MIME should be application/mp4 . Also, as a server, you should try to include the codecs or profiles parameters as defined in RFC6381, as this will help clients determine if they can play the file, prior to downloading it.