_id stringlengths 2 6 | text stringlengths 4 46k | title stringclasses 1 value |
|---|---|---|
d10101 | The problem was that I called setData() for the wrong panel. Instead of setting it to the panel with the placeholders, I used the parent panel. After changing this, everything works fine now. | |
d10102 | You could do it like this making use of repmat():
%% pick a color
cl = uisetcolor; %1-by-3 vector
im = ones(3, 3, 3)/2; % gray image
mask = rand(3, 3);
mask_idx = mask > 0.5; % create a mask
cl_rep = repmat(cl,[sum(mask_idx(:)) 1]);
im(repmat(mask_idx,[1 1 3])) = cl_rep(:);
What I have done is to repeat the mask three times to get all three layers of the image. To be able to match this with the colour-vector cl it also has to be repeated. The number of times it is repeated is the same as the amount of pixels that are to be changed, sum(mask_idx(:)). | |
d10103 | os.path.getmtime takes a file path, not a file object:
>>> os.path.getmtime('/')
1359405072.0
If f is an open file, try passing in f.name. | |
d10104 | use aggregate function
select EMPOYEEID, max(AwardDate) LastDate, min(AwardDate) FirstAward
from table_name t1
group by EMPOYEEID | |
d10105 | j2objc-master $ make dist
I am getting below error
building j2objc jar
javac: invalid source release: 1.8
Usage: javac
use -help for a list of possible options
make[1]: * [/Users/Downloads/j2objc-master/translator/build_result/j2objc.jar] Error 2
make: * [translator] Error 2
Please suggest
A: That's a javac error, stating that the version of javac on your system (which is part of the JDK you have installed) does not support the j2objc project's Java 8 minimum version. Upgrade your system to JDK 8 from Oracle to support this minimum. | |
d10106 | Intercepting the up ActionBar button press is trivial because everything is done through onOptionsItemSelected. The documentation, recommends that you use android.R.id.home to go up with NavUtils (provided that you set the metadata for the parent activity so NavUtils doesn't throw an Exception, etc):
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
Your DialogFragment should offer an confirmation to actually go back. Since you're now working with the Fragment and not the Activity, you're going to want to pass getActivity() to NavUtils.
NavUtils.navigateUpFromSameTask(getActivity());
and change onOptionsItemSelected() to
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
new ConfirmationDialog().show(getSupportFragmentManager(), "confirmation_dialog");
return true;
}
return super.onOptionsItemSelected(item);
}
ConfirmationDialog is your custom DialogFragment.
Note that for this example, I am using the support Fragment APIs,. If you are not, make sure to change getSupportFragmentManager() to getFragmentManager().
A: Yes. Pressing the "up" button just calls the option menu callback with R.id.home. So you could just grab that, display the dialog box and if the positive button is pressed call NavUtils.navigateUpTo(). | |
d10107 | On the use of writer.setPageEmpty
You use
writer.setPageEmpty(true);
You should use
writer.setPageEmpty(false);
instead to indicate that the current page shall not be considered empty. As long as it is considered empty, newPage won't change anything.
Adding content to multiple pages manually
If you really want to create PDF content using low level methods (i.e. directly positioning text on a PdfContentByte canvas instead of leaving the layouting to iText), you have to realize that each page has its own content canvas of which a rectangle (the crop box defaulting to the media box) is displayed while the rest remains hidden.
The PdfContentByte returned by writer.getDirectContent is automatically switched when a new page is started.
Thus, for content spread across pages, you have to call itextDocument.newPage exactly when you want to get to the next page, and then start filling the crop box again.
Along the lines of your sample code lines:
Document itextDocument = new Document(PageSize.A4, 50, 50, 30, 65);
PdfWriter writer = PdfWriter.getInstance(itextDocument, new FileOutputStream(RESULT));
itextDocument.open();
PdfContentByte canvas = writer.getDirectContent();
BaseFont romanFont = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
// first page content
canvas.setFontAndSize(romanFont, 10);
canvas.beginText();
canvas.showTextAligned(Element.ALIGN_LEFT, "Line 1 on page 1", 50, 800, 0);
canvas.showTextAligned(Element.ALIGN_LEFT, "Line 2 on page 1", 50, 785, 0);
canvas.showTextAligned(Element.ALIGN_LEFT, "Line 3 on page 1", 50, 770, 0);
canvas.showTextAligned(Element.ALIGN_LEFT, "................", 50, 755, 0);
canvas.showTextAligned(Element.ALIGN_LEFT, "................", 50, 740, 0);
canvas.showTextAligned(Element.ALIGN_LEFT, "................", 50, 725, 0);
canvas.setFontAndSize(romanFont, 800);
canvas.showTextAligned(Element.ALIGN_LEFT, "1", 0, 100, 0);
canvas.endText();
itextDocument.newPage();
// first page content
canvas.setFontAndSize(romanFont, 10);
canvas.beginText();
canvas.showTextAligned(Element.ALIGN_LEFT, "Line 1 on page 2", 50, 800, 0);
canvas.showTextAligned(Element.ALIGN_LEFT, "Line 2 on page 2", 50, 785, 0);
canvas.showTextAligned(Element.ALIGN_LEFT, "Line 3 on page 2", 50, 770, 0);
canvas.showTextAligned(Element.ALIGN_LEFT, "................", 50, 755, 0);
canvas.showTextAligned(Element.ALIGN_LEFT, "................", 50, 740, 0);
canvas.showTextAligned(Element.ALIGN_LEFT, "................", 50, 725, 0);
canvas.setFontAndSize(romanFont, 800);
canvas.showTextAligned(Element.ALIGN_LEFT, "2", 0, 100, 0);
canvas.endText();
itextDocument.close();
This produces these two pages:
Alternatively you could also create an independent, larger PdfTemplate (derived from PdfContentByte), draw all your content on it, and then show sections of it on different pages:
Document document = new Document(PageSize.A4);
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("big-panel.pdf"));
document.open();
PdfContentByte cb = writer.getDirectContent();
PdfTemplate tp = cb.createTemplate(PageSize.A4.getWidth(), 3 * PageSize.A4.getHeight());
// draw all your content on tp
cb.addTemplate(tp, 0, -2 * PageSize.A4.getHeight());
document.newPage();
cb.addTemplate(tp, 0, -PageSize.A4.getHeight());
document.newPage();
cb.addTemplate(tp, 0, 0);
document.newPage();
cb.addTemplate(tp, 0.3333f, 0, 0, 0.3333f, PageSize.A4.getWidth() / 3, 0);
document.close(); | |
d10108 | Well, with javascript, this could be a way:
HTML:
<iframe id="dataframe" name="dataTable" width="720px" height="620px" align="middle" frameborder="0">
</iframe>
(removed the src attribute)
Then, when you want to load the datatable with your jsp content
JS:
document.getElementById("dataframe").src = 'dataTable.jsp';
Hope this helps, Cheers | |
d10109 | Replace
((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
with
((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
plz update your minimum version to 12 and
<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="key hidden"/>
should be inside application tag
A: In the XML you are using SupportMapFragment
android:name="com.google.android.gms.maps.SupportMapFragment"
hence you should use SupportMapFragment and getSupportFragmentManager instead of MapFragment and getFragmentManager
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
Change the above line to
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
I can see that you have android.support.v4.app.Fragment imported. Import com.google.android.gms.maps.SupportMapFragment
Also make sure that you have android.support.v4.jar in your libs folder and in the project build path. | |
d10110 | You cannot do this with .live() (or .delegate()). Those are for binding event handlers for events which may not yet exist.
Description: Attach a handler to the event for all elements which match the current selector, now and in the future.
The image tick box plugin you're using is not any sort of "event." You will have to explicitly call the initialization code (e.g. $('selector').imageTickBox(...)) whenever a new checkbox is added.
A: This is definitely a duplicate question: Please see
jquery live event for added dom elements
Event binding on dynamically created elements?
A: .live() is for listening to events and then detecting where those events originated from. Adding elements to the page doesn't trigger anything that .live() can listen to. You'll have to call your plug-in initialization whenever you are adding the checkbox to the page. | |
d10111 | I try to follow the patterns employed by the system as much as possible. In particular, look to the definitions of NSRect, NSPoint, and other structures.
In other words, group together structures that are related into a single header file. For many projects, that would lead to exactly one header full of structure declarations. | |
d10112 | You do not need the data-bind attribute from what I can see in your current code (though you may have a reason outside of what you've shown). Edit: For Knockout.js, you will of course need the data-bind attribute.
All you need to do is set a value for your <progress> element, and then make sure you're updating it as whatever process it represents is progressing.
<progress id="myProgress" value="10" max="100"></progress>
Edit:
For Knockout.js, you need to tie your data-bind attributes to a ViewModel field, and that ViewModel field would need to be associated with an Observable.
You could do something like this (a toy example that just increments the progress value by 10 each second, but shows how you could update your ViewModel, as well as trigger a class change after reaching a threshold value):
<div class="card-header float-right" style="width:50% ; padding-left:100px">
<progress
id="myProgress"
data-bind="value: progressValue, class: progressClass"
max="100"
></progress>
</div>
<script>
const INITIAL_PROGRESS = 1;
const PROGRESS_THRESHOLD = 90;
const BELOW_THRESHOLD_CLASS = "progress-below";
const ABOVE_THRESHOLD_CLASS = "progress-100";
let progressViewModel = {
progressValue: ko.observable(INITIAL_PROGRESS),
progressClass: ko.observable(BELOW_THRESHOLD_CLASS)
};
ko.applyBindings(
progressViewModel,
document.getElementById("myProgress")
);
ko.when(
function() {
return progressViewModel.progressValue() > PROGRESS_THRESHOLD;
},
function(result) {
progressViewModel.progressClass(ABOVE_THRESHOLD_CLASS);
}
);
for (let i = 1; i < 11; i++) {
window.setTimeout(function() {
progressViewModel.progressValue(i * 10);
}, i * 1000);
}
</script>
Then you have to figure out how you want your Observable value(s) updated.
A: If you're using KnockoutJS, the actual progress is probably an observable property on your viewmodel. Let's say it is actually called progress, then you would bind to it like this:
<div class="card-header float-right" style="width:50% ; padding-left:100px">
<progress id="myProgress" data-bind="attr: { value: progress }" min="0" max="100"></progress>
</div>
For styling, you should use the css or class bindings to assign a class to the progress bar, based on the progress. Here's a Fiddle with a little example, although I've used the Bootstrap progress element and not the actual native progress element since it's a nightmare to style: https://jsfiddle.net/thebluenile/20zsqn5w/ | |
d10113 | The show-for-large-up and related classes apply display: inherit !important;, which is overriding your display: table. As a result, the whole div shrinks down to the minimum width that it can be (just large enough to fit the text), making it left aligned within its container.
The text itself appears to be left-aligned in all scenarios, regardless of the value of display. You will need text-align: center to change that (or you could apply a Foundation class like large-text-left). | |
d10114 | gulp.task('watch', gulp.series('clean', gulp.parallel('css')), () => {
gulp.watch(['./app/scss/**/*.scss'], gulp.series('clean', gulp.parallel('css')))
}
);
It appears the issue is calling the gulp.watch function directly rather than from inside of a function. The above code fixes the issue. | |
d10115 | Your text is not valid JSON (you can check this here), as it's missing quotation marks around attribute strings. While it might be a JavaScript object, that's not synonymous with valid JSON. NSJSONSerialization (which is surely what's backing that function) will correctly reject the input.
You should fix your JSON - preferably at the source. You could do it by post-processing with string editing functions in Swift, but this is a bad idea. | |
d10116 | You can use list comprehension to convert the usernames in current_users to lowercase. Secondly, you've to check whether the new_user is already present in current_users to do that you have to use in keyword.
The in keyword
tests whether or not a sequence contains a certain value.
here is code,
current_users = ['Andy', 'Brett', 'Cassie', 'Derek', 'Eric']
new_users = ['eric', 'greg', 'hank', 'ian', 'john', 'andy', 'frank']
new_users.sort()
current_users = [user.lower() for user in current_users]
for new_user in new_users:
if new_user in current_users:
print(f"\n{new_user}, Please enter a new username!")
else:
print(f"\n{new_user}, Username is available.")
Hope it helps!
A: You should try using in to the list:
current_users = ['Andy', 'Brett', 'Cassie', 'Derek', 'Eric']
new_users = ['eric', 'greg', 'hank', 'ian', 'john', 'andy', 'frank']
new_users.sort()
current_users = [i.lower() for i in current_users]
for new_user in new_users:
if new_user in current_users:
print(f"\n{new_user}, Please enter a new username!")
else:
print(f"\n{new_user}, Username is available.")
A: a single equal mark is used to assign a value to a variable, whereas two consecutive equal marks is used to check whether 2 expressions give the same value .
= is an assignment operator
== is an equality operator
current_users = ['Andy', 'Brett', 'Cassie', 'Derek', 'Eric']
new_users = ['eric', 'greg', 'hank', 'ian', 'john', 'andy', 'frank']
new_users.sort()
for current_user in current_users:
current_user == current_user.lower()
for new_user in new_users:
if new_user == current_user:
print(f"\n{new_user}, Please enter a new username!")
else:
print(f"\n{new_user}, Username is available.") | |
d10117 | I'd suggest to import TouchableOpacity from here:
https://github.com/software-mansion/react-native-gesture-handler
Both overlapping touchables should fire onPress prop | |
d10118 | I looked into this earlier, it seems that...
*
*You can't send a deep link in an FCM message using the firebase Compose Notification UI.
*You probably can send a deep link in an FCM message using the FCM REST API. More in this stackoverflow post.
The REST API looks so cumbersome to implement you're probably better off the way you're doing it: Using the firebase message composer with a little data payload, and your app parses the message data with Invertase messaging methods firebase.messaging().getInitialNotification() and firebase.messaging().onNotificationOpenedApp().
As for deep linking, which your users might create in-app when trying to share something, or you might create in the firebase Dynamic Links UI: For your app to notice actual deep links being tapped on the device, you can use Invertase dynamic links methods firebase.dynamicLinks().getInitialLink() and firebase.dynamicLinks().onLink(). | |
d10119 | Just a few notes:
First, you should make sure to send your data from the app with the enctype of multipart/form-data before submitting to the server.
Second, try variants of this simplified code:
if(isset($_FILES['image']))
{
$fileTmp = $_FILES['image']['tmp_name'];
$fileName = $_FILES['image']['name'];
move_uploaded_file($fileTmp, "/var/www/html/uploads/" . $fileName);
echo "Success";
}
else
{
echo "Error";
}
And finally, assuming you're using Apache and the user name is www-data, you'll need to make sure it can write to the upload folder:
sudo chown www-data:www-data /var/www/html/uploads
sudo chmod 755 /var/www/html/uploads | |
d10120 | *
*Most probably it's due to the white space characters introduced when fetching the text using textContent. See here for ways to trim the white space in a string.
*There's a typo in the script. HTML says Scissors whereas the script says Sciccors.
// credit: https://stackoverflow.com/a/6623263/6513921
if (timesClicked == 1) {
playerOneInput = this.textContent.replace(/\s/g,'');
document.getElementById('player').innerHTML =
'Player 2, choose your option!';
} else {
playerTwoInput = this.textContent.replace(/\s/g,'');
compareInputs(playerOneInput, playerTwoInput);
}
Working example:
const options = document.querySelectorAll('.options')
var timesClicked = 0
//console.log(options)
let playerOneInput = ''
let playerTwoInput = ''
options.forEach((option) => {
option.addEventListener('click', function() {
timesClicked++
console.log(timesClicked)
if (timesClicked == 1) {
playerOneInput = this.textContent.replace(/\s/g,'');
document.getElementById('player').innerHTML =
'Player 2, choose your option!';
} else {
playerTwoInput = this.textContent.replace(/\s/g,'');
compareInputs(playerOneInput, playerTwoInput);
}
console.log(playerOneInput.trim())
console.log(playerTwoInput.trim())
})
})
function compareInputs(playerOneInput, playerTwoInput) {
// Tie check
if (playerOneInput == playerTwoInput) {
document.getElementById('result').innerHTML = 'Its a Tie!'
}
// Rock
if (playerOneInput == 'Rock') {
alert('Hello! I am an alert box!!')
switch (playerTwoInput) {
case 'Scissors':
document.getElementById('result').innerHTML = 'Player one wins!'
break
case 'Paper':
document.getElementById('result').innerHTML = 'Player two wins!'
break
}
}
// Paper
if (playerOneInput == 'Paper') {
switch (playerTwoInput) {
case 'Rock':
document.getElementById('result').innerHTML = 'Player one wins!'
break
case 'Scissors':
document.getElementById('result').innerHTML = 'Player two wins!'
break
}
}
// Scissors
if (playerOneInput == 'Scissors') {
switch (playerTwoInput) {
case 'Paper':
document.getElementById('result').innerHTML = 'Player one wins!'
break
case 'Rock':
document.getElementById('result').innerHTML = 'Player two wins!'
break
}
}
}
<h1 id="player">Player 1, choose your option!</h1>
<div id="buttons">
<button class="options">
Rock<img src="rock.jpg" alt="Hand gesture of rock" />
</button>
<button class="options">
Paper<img src="paper.png" alt="Hand gesture of paper" />
</button>
<button class="options">
Scissors<img src="scissors.png" alt="Hand gesture of scissors" />
</button>
</div>
<br /><br />
<div id="result"></div> | |
d10121 | add this if you haven't added in your manifest
<gap:config-file platform="android" parent="/manifest">
<application android:largeHeap="true"
android:hardwareAccelerated="false"></application>
A: in some of the web apps sometimes you have to downgrade the library of googleAuth you are using and it can be library conflict we can say.
Some libs are working in Latest versions, so maybe you should try downgrading the libraries. | |
d10122 | Let's first look at what those tabs mean, and then discuss what your best approach should be.
node.js vs JSON tabs
The "node.js" tab shows what the code looks like using the actions-on-google library. For the most part, this library uses the same code if you're using either the Action SDK or using Dialogflow to implement. Where there are differences, the documentation does note how you have to handle them - this is particularly true when it comes to how you have to handle responses.
The "JSON" tab shows what the JSON would look like if you are not using the actions-on-google library and need to send JSON yourself. You might do this because you're using a language besides node.js, or you just want to know what the underlying protocol looks like.
The catch is that the JSON illustrated here is what would be used by the Action on Google JSON protocol. If you're using Dialogflow, then this JSON would be wrapped inside the payload.google field and there are a couple of other differences documented. So when generating JSON for a Dialogflow response, you should use this as a guide, but need to be aware of how it might differ.
What should you use?
What you use depends on what your needs are and what your goals are for developing.
If you are trying to develop something you intend to release, or might do so someday, and you are new to voice or bot interfaces, then you'll probably want to use Dialogflow - no matter what other choices you may make.
If you have your own Natural Language Processing (NLP) system, then you will want to use the Action SDK instead of Dialogflow. How you handle it (using the actions-on-google library or using JSON) will depend on how you need to integrate with that NLP.
If you're familiar with node.js, or want to learn it, then using the actions-on-google library is a good choice and that first tab will help you. (There are other choices. Dialogflow also has a dialogflow-fulfillment library, which is good if you want to be able to support the bot platforms it supports as well. The multivocal library has a more configuration-driven template approach to building a conversational backend that was designed to work with the Assistant and Dialogflow. Both of these illustrate how to do the same things that Google's documentation does.)
If you would rather use another language, you'll need to reference the JSON documentation because there are few complete libraries for these platforms. Your best bet would be to use Dialogflow with JSON. Dialogflow has some example JSON for how to apply the Google documentation you cite to their fulfillment protocol.
Summary
*
*You should probably use Dialogflow.
*If you can, use actions-on-google or another library.
*If you have a need to use another language or want to use the JSON, be aware of the possible differences. | |
d10123 | If condition is wrong Try this
if(formElements[x]["value"] == "" || formElements[x]["value"] == null){
A: Try this:
var formElements = $("#ImageSliderForm").serializeArray();
$(formElements).each(function (x, element) {
if (element.value == "" || element.value == null) {
//get the respective html element and add a class
$("[name='" + element.name + "']").addClass('someclass');
}
}); | |
d10124 | AFAIK, there is no equivalent of WM_MEASUREITEM for a TreeView control. | |
d10125 | You should press "Use large resource rows." to see more data.
A: If you are using the latest version of Chrome (like 78+), you can check "Use large request rows" under the settings icon.
Doc: https://developer.chrome.com/docs/devtools/network/reference/#uncompressed
A: I was stuck because only the name of the file was showing up (no other columns), but I realized that you must close the "details" view that shows on the right side when you click a row to see any other columns. Posting the answer here since search brought me here, though it wasn't the OP's actual issue. | |
d10126 | FIELD-function does not match the NULL-stock_id as NULL value (NULL does not have any value).
You could use a magic number:
ORDER BY FIELD(IFNULL(items.stock_id,-1), 1, 5, -1, 3, 6) | |
d10127 | You need to bind to an explicit IP address rather than INADDR_ANY as binding to INADDR_ANY will mean that calling getsockname() on the socket to get the local address will simply return INADDR_ANY.
So, what you need to do is iterate the available endpoints (using getaddrinfo()) and create a socket on each. These will then give you the correct address if you call getsockname() on them later. | |
d10128 | Something like this will do it:-
INSERT INTO my_table (the_date)
SELECT ADDDATE('2013-04-13', INTERVAL SomeNumber DAY)
FROM (SELECT a.i+b.i*10+c.i*100+d.i*1000 AS SomeNumber FROM integers a, integers b, integers c, integers d) Sub1
WHERE SomeNumber BETWEEN 0 AND 1000
Relies on a table called integers with a single column called i with 10 rows, values from 0 to 9.
The Between clause is just there so you can limit the range of numbers to add to the date
A: Try this code:
$starDate = new DateTime('2013-05-07');
for ($i=0; $i < 1000; $i++) {
$consulta ="INSERT INTO my_table (the_date) VALUES ('".date_format($starDate, 'Y-m-d')."');";
$starDate = date_add($starDate, date_interval_create_from_date_string('1 days'));
echo $consulta."</br>";
//try somthing like mysqli_query($consulta);
}
With php and mysqli....you can do this with pure sql too ;)
I give you this way to do.
Saludos ;) | |
d10129 | You can't extract anything from the inside of an iframe. There cannot be any interaction from the parent to the iframe. There can, therefore, be interaction between the iframe and the parent, but since you are not the owner of the iframe's webpage, this is not your case.
It's a security issue. People could get scammed if this wasn't this way. For example, designing a full-page iframe with a bank webpage and retrieving everything user types... Or designing a 1x1px iframe with a facebook page to see if your user is logged on fb and check all his/her personal information.
You can use a server-side language, such us PHP and get the HTML of that webpage using file_get_contents() | |
d10130 | Assuming that you're still working on an HTA, something like this should work:
id = "Division"
If window.document.getElementById(id) Is Nothing Then
MsgBox "Element not found."
Else
MsgBox "Element found."
End If | |
d10131 | I think you should drop these jars in a folder named /libs at the root of your project. See this SO question: How can I use external JARs in an Android project?
A: Have you included your libs in the java build path and checked it in the Order and Export Tab?
i.e
Project > Properties > Java Build Path > Order and Export > and finally, checkmark your imported library. | |
d10132 | I think you should concatenate the files together first before you read them into pandas, here is how you'd do it in bash (you could also do it in Python):
cat `find *typeA` > typeA
cat `find *typeB` > typeB
Then you can import it into pandas using io.json.json_normalize:
import json
with open('typeA') as f:
data = [json.loads(l) for l in f.readlines()]
dfA = pd.io.json.json_normalize(data)
dfA
# that this.first this.second
# 0 otherthing thing thing
# 1 otherthing thing thing
# 2 otherthing thing thing | |
d10133 | After some research, here is solution:
Create an interface:
interface MyRepositoryCustom {
<S extends Number> S sum(Specification<MyEntity> spec, Class<S> resultType, String fieldName);
}
Implementation:
@Repository
class MyRepositoryCustomImpl implements MyRepositoryCustom {
@Autowired
private EntityManager entityManager;
@Override
public <S extends Number> S sum(Specification<MyEntity> spec, Class<S> resultType, String fieldName) {
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<S> query = builder.createQuery(resultType);
Root<MyEntity> root = applySpecificationToCriteria(spec, query);
query.select(builder.sum(root.get(fieldName).as(resultType)));
TypedQuery<S> typedQuery = entityManager.createQuery(query);
return typedQuery.getSingleResult();
}
protected <S> Root<MyEntity> applySpecificationToCriteria(Specification<MyEntity> spec, CriteriaQuery<S> query) {
Root<MyEntity> root = query.from(MyEntity.class);
if (spec == null) {
return root;
}
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
Predicate predicate = spec.toPredicate(root, query, builder);
if (predicate != null) {
query.where(predicate);
}
return root;
}
}
Main repository should extend both JpaRepository and MyRepositoryCustom:
@Repository
interface MyEntityRepository extends JpaRepository<MyEntity, Long>, MyRepositoryCustom {
} | |
d10134 | There is currently no way to open Commit Details straight to a new tab. This is feedback that we've heard a few times since we built the Git Repository window and embedded the commit details, so it is on our radar to improve the window handling in a future update. | |
d10135 | Create a new configuration, tell xbuild to use it:
*
*In Visual Studio, create a new configuration that excludes the projects you're not interested in. -(Build -> Configuration Manager..., select on the Active solution platform: drop down list)
*Using the Configuration Manager, remove unwanted solutions from the configuration.
*Next, close VisualStudio, which will save changes to the .sln and .csproj The .sln will record which projects are associated with the configuration. The .csproj will record the settings of the configuration, such as whether TRACE or DEBUG is defined.
*Finally, when calling xbuild assign your configuration's name to the Configuration property.
E.g.
xbuild /p:Configuration="NoUnitTests" ServerResource.sln
The above will build the projects associated with the NoUnitTests configuration. | |
d10136 | try to wrap your Column inside Expanded,
Container(
child: Row(
children: <Widget>[
Container(
height: 150,
width: 100,
child: Image(
image: NetworkImage(
'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQLBtBU3nUOK7osT41ZsQhP4VBV7fd9euqXvXVKQH0Q7bl4txeD'),
fit: BoxFit.contain,
),
),
Expanded(
child: Column(
children: <Widget>[
Text(
'Reallly looooooooooooooooooooooooooooooong textttttttttttttttttttttttttttttttttttttttttttttttt'),
Text(
'Reallly looooooooooooooooooooooooooooooong textttttttttttttttttttttttttttttttttttttttttttttttt'),
],
),
),
],
),
);
output:
Additionally if you want to limit lines of Text use,
Text(
'Reallly looooooooooooooooooooooooooooooongtextttttttttttttttttttttttttttttttttttttttttttttttt',
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
Output:
A: Just wrap your column inside expanded widget
Expanded(child:
Column(
children: <Widget>[
Container(
height: 50,
width: MediaQuery.of(context).size.width * 0.8,
child:
Text(snapshot.data.documents[index]['title']),
),
Container(
height: 50,
width: MediaQuery.of(context).size.width * 0.8,
child:
Text(snapshot.data.documents[index]['body']),
),
],
),
),
Expanded widget is useful when you want to fill all the remaining space when a column or row widget have 2 or more child widgets. so wrapping a child inside an expanded widget will fill up the remaining space accordingly.
A: return Container(child: Row(
children: <Widget>[
Container(
height: 150,
width: 100,
child: Image(
image: NetworkImage(snapshot.data.documents[index]['dpURL']), fit: BoxFit.contain,
),
),
new Expanded(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: TitleText(
text:snapshot.data.documents[index]['title'] ,
maxLine: 5,
),
),
Container(
height: 50,
width: MediaQuery.of(context).size.width * 0.8,
child: TitleText(
text:snapshot.data.documents[index]['body']),
),
],
),
),
],
),
); | |
d10137 | I dont know if it is efficient but you can use worker and producers scheme. Basically you define a multiprocessing Q and the producer process adds something into the Q. The Worker listens to the Q and starts working as soon some information is put into the Q.
Here is a good example.
http://danielhnyk.cz/python-producers-queue-consumed-by-workers/
The problem you have with Multiprocessing is that you have to take care about shared data and also the time to schedule the processes must be taken into account which makes the Multiprocessing in Python not very usable for small tasks. However, If you do that tasks very often or you create the process once and just run the tasks when there is one you get a benefit. | |
d10138 | Move reportico to components array:
'components' => [
//...
'reportico' => [
'class' => 'reportico\reportico\Module' ,
'controllerMap' => [
'reportico' => 'reportico\reportico\controllers\ReporticoController',
'mode' => 'reportico\reportico\controllers\ModeController',
'ajax' => 'reportico\reportico\controllers\AjaxController',
]
]
] | |
d10139 | You surely don't need to perform segue in didSelectRowAtIndexPath, if you have already configured it like cell -> next view.
But, removing the call from there doesn't work for you then you can try the segue from view controller (ctrl+drag from view area) to next view and keep the segue call in didSelectRowAtIndexPath
I always use one of the following methods
Method 1:
Segue from UITableViewCell to Next View Controller
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Nothing
}
Method 2:
Segue from Main View Controller to Next View Controller
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self performSegueWithIdentifier:@"subjectDrillDown" sender:nil];
}
The error you are getting is because you have segue and you perform the segue manually when selected - hence, it is resulting in nested push animation
Make sure the name of the segue is correct and you are using ONLY one of the above methods | |
d10140 | Use parameterized SQL instead of building the SQL dynamically. This avoids SQL injection attacks and string formatting differences, as well as making the code clearer.
Additionally, I believe both "date" and "time" are keywords in T-SQL, so you should put them in square brackets when using them as field names.
You should attempt to perform as few string conversions as possible. Without knowing exactly what your web page looks like it's hard to know exactly how you want to parse the text, but assuming that Convert.ToDateTime is working for you (sounds worryingly culture-dependent to me) you'd have code like this:
protected void btn Submit_Click(object sender, EventArgs e)
{
// TODO: Ideally use a date/time picker etc.
DateTime date = Convert.ToDateTime(txtdate.Text);
DateTime time = Convert.ToDateTime(txttime.Text);
// You'd probably want to get the connection string dynamically, or at least have
// it in a shared constant somewhere.
using (var con = new SqlConnection(connectionString))
{
string sql = "insert [date], [time] into DateTimeDemo values (@date, @time)";
using (var cmd = new SqlCommand(sql))
{
cmd.Parameters.Add("@date", SqlDbType.Date).Value = date;
cmd.Parameters.Add("@time", SqlDbType.Time).Value = time.TimeOfDay;
int rows = cmd.ExecuteNonQuery();
string message = rows > 0 ? "success" : "failed";
Response.Write(message);
}
}
}
I've guessed at what SQL types you're using. If these are meant to represent a combined date and time, you should at least consider using a single field of type DateTime2 instead of separate fields. | |
d10141 | Of course you can do this. Initiate a RefreshControl and simply put it as subview of your tableview. You don't necessarily need a UITableViewController for this.
EDIT:
Try something like this:
let control = UIRefreshControl()
control.addTarget(self, action: "action", forControlEvents: .ValueChanged)
tableView.addSubview(control)
A: Here's the Objective-C version that worked for me in case anyone needs it. I added it to viewDidLoad:
UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
[refresh addTarget: self action: @selector(didPullToRefresh:) forControlEvents: UIControlEventValueChanged];
[self.tableView addSubview: refresh];
Not a fan of UITableViewController... | |
d10142 | What you probably want is to save a Bitmap of what you see on the screen. See this answer. | |
d10143 | Franklin you can use in react google maps. It has two advantages that takes it to use over info window or simple Marker component. We have Icon options to customize our marker. We have div elements that are fully customizable. You just pass icon url. LabelStyling is optional. Feel free to ask any question.
import { MarkerWithLabel } from 'react-google-maps/lib/components/addons/MarkerWithLabel';
var markerStyling= {
clear: "both", display: "inline-block", backgroundColor: "#00921A", fontWeight: '500',
color: "#FFFFFF", boxShadow: "0 6px 8px 0 rgba(63,63,63,0.11)", borderRadius: "23px",
padding: "8px 16px", whiteSpace: "nowrap", width: "160px", textAlign: "center"
};
<MarkerWithLabel
key={i}
position={marker.position}
labelAnchor={new google.maps.Point(75, 90)}
labelStyle={markerStyling}
icon={{
url: '/build/icon/markPin.svg',
anchor: new google.maps.Point(5, 58),
}}
>
<div>
<p> My Marker </p>
</div>
</MarkerWithLabel>
A: The Marker spread operator was missing above key={index}. This is the correct code. The icon itself is defined in another file called mapDefaults.js if anyone comes across this issue don't hesitate to reach out to me.
<Marker
{...marker}
key={index}
position={marker.position}
onClick={() => props.onMarkerClick(marker)}
>
A: this is how I fixed that
let iconMarker = new window.google.maps.MarkerImage(
"https://lh3.googleusercontent.com/bECXZ2YW3j0yIEBVo92ECVqlnlbX9ldYNGrCe0Kr4VGPq-vJ9Xncwvl16uvosukVXPfV=w300",
null, /* size is determined at runtime */
null, /* origin is 0,0 */
null, /* anchor is bottom center of the scaled image */
new window.google.maps.Size(32, 32)
);
return(
<Marker
icon={iconMarker}
key={marker.id}
onClick={onClick}
position={{ lat: parseInt(marker.latitude), lng: parseInt(marker.longitude)}}>
{props.selectedMarker === marker &&
<InfoWindow>
<div style={{'color':'black'}}>
Shop {marker.name} {stretTexte}
</div>
</InfoWindow>}
</Marker>
) | |
d10144 | If you don't tell CMake about the compiler you want to use, it will try to discover it in the project(...) call. If they don't match, a check performed by a Conan macro will fail.
Typically, if you want to use a compiler version different from the default you need to inform CMake about it. One of the most common ways to do it using Conan profiles is to add the CC and CXX variables to the profile itself.
[settings]
...
compiler=gcc
compiler.version=10.3
...
[env]
CC=/usr/bin/gcc-10
CXX=/usr/bin/g++-10
Conan will add these variables to the environment before calling the build system and most of them (CMake, Autotools,...) will take them into account.
This way, you don't need to modify the conanfile.py file. | |
d10145 | The Uri class is not a data type that is supported in Firebase. The List should contain String objects and not Uri objects.
My code works when I simply change this
public List<Uri> getPhotoUrls() {
return mPhotoUrls;
}
to this
public List<String> getPhotoUrls() {
List<String> photoUrlStrings = new ArrayList<String>();
for(int i=0; i<mPhotoUrls.size(); i++){
photoUrlStrings.add(mPhotoUrls.get(i).toString());
}
return photoUrlStrings;
} | |
d10146 | Remove the forward slash and escape the curly braces.
str_match_all(s, "\\{([^}]*)\\}")
or
str_match_all(s, "\\{\\K[^}]*(?=\\})") | |
d10147 | This is the result of having multiple different ways of pulling in resources that aren't part of a WAR or exploded directory. Frankly it is a mess long overdue a clean-up. The 'overlay' (or whatever it ends up being called) feature proposed for Servlet 3.1 (i.e. Tomcat 8) has prompted a major clean-up. All the current implementations will be unified into a single implementation. It isn't pretty though, and it is going to take a while to complete.
Aliases are treated as external to the web application resources. The DirContext checks aliases before it checks its internal resources. Hence when you request the real path you get the original.
If you use extraResourcePaths they are treated as part of the web application resources. It looks like Eclipse has triggered a copy of application resources to the work directory. This is usually done to avoid file locking. Since the extraResourcePaths are treated as part of the webapp, they get copied too and getRealPath() reports the copied location since that is where Tomcat is serving the resources from.
A: After investigating further, I found this difference.
The results of this Java code is different. I still don't know why.
String path = getServletContext().getRealPath("/images");
Using extraResourcePaths, path is below, which is a folder under where Eclipse explodes my web app and not a valid directory.
C:\Projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\Eclipse_Project\images
Using aliases, path is below and is what I actually need.
D:\path\to\images
Now if someone could actually explain this. :-) | |
d10148 | In your Codepen, some URLs have an error, missing one "i". | |
d10149 | For such a query, I would think exists and not exists:
select m.*
from master m
where exists (select 1 from new n where n.urn = m.urn) and
not exists (select 1 from old o where o.urn = m.urn);
I prefer exists to an explicit join because there is no danger that duplicates in new will result in duplicates in the result set. I also find that it more closely represents the purpose of the query.
A: You are missing the WHERE condition probably like
SELECT *
FROM `master`
JOIN `new` ON `master`.`urn` = `new`.`urn`
LEFT JOIN `old` ON `old`.`urn` = `new`.`urn`
WHERE `old`.`urn` IS NULL; | |
d10150 | Check out this question.
When you call rl.AddView(tv), you should include the LayoutParams rl.AddView(tv, lp).
A: You have to use
imageView.setLayoutParams(lp) in order to assign the params to your view.
How do you setLayoutParams() for an ImageView?
A: Since my content is not dynamic, I worked around the issue by simply editing my image in Paint and placing text below the image. Then I made that the background for the ImageView. | |
d10151 | Index won't give you what you want, as it will only tell you where the element lies within a given set of elements; $(this).index() will always return 0. You need to calculate the depth based on the parent ul's:
$('.topnav').find('ul').each(function(){
$(this).attr('deep', $(this).parents('ul').length);//set attr deep
}) | |
d10152 | A common, general purpose technique is to wrap a Comparator in a reverse Comparator by simply swapping the arguments.
class ReverseComparator<T> implements Comparator<T> {
private final Comparator target;
public ReverseComparator(Comparator<T> target) {
super();
this.target = target;
}
public int compare(T first, T second) {
return target.compare(second, first);
}
}
To use it with our example:
Comparator original = new Comparator() {
public int compare(Object o1, Object o2) {
return ((Comparable) ((Map.Entry) (o2)).getValue())
.compareTo(((Map.Entry) (o1)).getValue());
}
};
Collections.sort(list, new ReverseComparator(original));
A: The simple general answer is to use java.util.Collections.reverseOrder(Comparator).
Comparator myComparator = new Comparator() {
public int compare(Object o1, Object o2) {
return ((Comparable) ((Map.Entry) (o2)).getValue())
.compareTo(((Map.Entry) (o1)).getValue());
}
}
// ... or whatever.
Comparator myReverseComparator = Collections.reverseOrder(myComparator);
Alternatively, a specific solution would be to flip the parameters in the compare method:
Comparator myReverseComparator = new Comparator() {
public int compare(Object o2, Object o1) { // <== NOTE - params reversed!!
return ((Comparable) ((Map.Entry) (o2)).getValue())
.compareTo(((Map.Entry) (o1)).getValue());
}
}
Note that multiplying by -1 is an incorrect solution because of the Integer.MIN_VALUE edge case. Integer.MIN_VALUE * -1 is ... Integer.MIN_VALUE
A: It's all about changing the content of the method below:
public int compare(Object o1, Object o2)
{
return ((Comparable) ((Map.Entry) (o2)).getValue())
.compareTo(((Map.Entry) (o1)).getValue());
}
Return a different result than the value of the statement below:
((Comparable)((Map.Entry)(o2)).getValue()).compareTo(((Map.Entry)(o1)).getValue());
Let's say the statement above is assigned to x. Then you should return 1 if x < 0,
return -1 if x > 0 and return 0 if x == 0, just inside the compare() method.
So your method could look like this:
public int compare(Object o1, Object o2)
{
int x = ((Comparable)((Map.Entry)(o2)).getValue())
.compareTo(((Map.Entry)(o1)).getValue());
if(x > 0)
return -1;
else if (x < 0)
return 1;
return 0;
} | |
d10153 | It means exactly "unsupported video".
Twitter has a strict video format requirement: https://dev.twitter.com/rest/public/uploading-media#videorecs.
Example: sample mp4 files containing 6-channel audio won't be supported.
Check out my project: https://github.com/mtrung/TwitterVideoUpload. | |
d10154 | Kubernetes itself provides Jobs for ad hoc executions. Jobs do not integrate very tightly with existing Pods/Deployments/Statefulsets.
Helm is a deployment orchestrator and includes pre and post hooks that can be used during an install or upgrade.
The helm docco provides a Job example run post-install via annotations.
metadata:
annotations:
# This is what defines this resource as a hook. Without this line, the
# job is considered part of the release.
"helm.sh/hook": post-install
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": hook-succeeded
If you have more complex requirements you could do the same with a manager or Jobs that query the kubernetes API's to check on cluster state.
Helm 3
A warning that helm is moving to v3.x soon where they have rearchitected away a lot of significant problems from v2. If you are just getting started with helm, keep an eye out for the v3 beta. It's only alpha as of 08/2019. | |
d10155 | AppleScript's text item delimiters define the substrings to use when breaking up strings into a list of text items, and the substring that is used when reassembling a list of text items back into a string.
*
*The text item delimiters just define where the string is broken up, not which pieces to keep or discard. In your script, you can throw away the first text item in your extraction handler with something like:
set liste to rest of text items of SearchText
*Getting the text items results in a list of strings (the text items).
*Just as you use text item delimiters to break the strings apart, you can use them when putting the pieces back together, for example setting the text item delimiters to a comma or line-break before coercing the list back to text. The "www.ft.com/cms/s" part can also be put in there, although (like #1 above), you will also need to add it before the first item, for example:
set tempTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to ("," & return & "www.ft.com/cms/s")
set ex to ex as text
set AppleScript's text item delimiters to tempTID
return "www.ft.com/cms/s" & ex | |
d10156 | Try ARRAY instead of []:
SELECT ARRAY(select struct(dd.Level as Level, dd.TypeId as typeid)
from unnest(tablee.Skills) as dd) as skills
FROM tablee | |
d10157 | You need to do a couple things in order for this to work properly.
First, you need to wrap the HTML in a div to act as the container:
HTML:
<div id="container">
<div id="hoverAnchor">hover me</div>
<div id="hoverMe" style="display:none">arbitrary text
<div id="dateSelector"></div>
</div>
</div>
Next, rather than using .hover() (which can sometimes be unreliable), I recommend using .mouseenter() along with .mouseleave(). Also use a var to hold boolean of whether datepicker open/closed. The reason for this boolean is due to the input. On click, a second .mouseenter() event will be called, so without it, #hoverme would toggle a second time.
$(document).ready(function () {
$("#dateSelector").datepicker({
changeMonth: true,
changeYear: true
});
var _enter = false;
$("#container").add(
$("#container")).mouseenter(function () {
if (!_enter) {
$("#hoverMe").stop(true, false).animate({
height: 'toggle',
opacity: 'toggle'
}, 200);
}
_enter = true;
}).mouseleave(function () {
_enter = false;
$("#hoverMe").stop(true, false).animate({
height: 'toggle',
opacity: 'toggle'
}, 200);
});
});
DEMO:
http://jsfiddle.net/dirtyd77/e3zP2/18/
Hope this helps! | |
d10158 | / takes as arguments one or more numbers, but in your code you're passing it a list - clearly this will not work. The function apply is your friend here - (apply #'foo a b (list c d e)) is equivalent to (foo a b c d e). Note the the arguments to apply between the function to use and the final list are optional, so (apply #'/ '(20 2 5)) is equivalent to (/ 20 2 5).
Also, your attempt at removing zeros will not work. dolist is evaluating its body for each item in the argument list elements, but you're not actually doing anything to change the content of elements (the result of evaluating dolist s body is not reassigned to the source element as you seem to expect).
The functions remove-if (and its destructive counterpart, delete-if) are what you are looking for. The following shows how to use it (it takes lots of optional arguments, which you don't need to worry about for this purpose).
(defun divtest (elements)
(apply #'/ (remove-if #'zerop elements)))
Also note that this won't behave correctly if the elements list has zero as its first element (assuming I understand what the function's meant to do). So you might instead want something like
(defun divtest (elements)
(apply #'/ (first elements) (remove-if #'zerop (rest elements))))
See the Hyperspec for more details.
A: Try (apply / elements) in place of (/ elements). I think(?) that should work in most dialects of Lisp.
A: Or you can write it like this
(defun divtest (elements)
(if (member 0 elements)
0
(apply #'/ elements)))
A: (block exit
(reduce #'/ '(1 2 3 0 5)
:key (lambda (x)
(if (zerop x)
(return-from exit 0)
x)))) | |
d10159 | Change your Save() method. The current one is only overwriting the start of the file but not removing the old (longer) content.
private void saveFile()
{
//fs = new FileStream(this.openedXml, FileMode.Open, FileAccess.Write, FileShare.Write);
fs = new FileStream(this.openedXml, FileMode.Create);
xmlDoc.Save(fs);
fs.Close();
} | |
d10160 | The problem is the space around the argument to Enum.into. It's not interpreted as parenthesis for the function call, but rather as a grouping mechanism around one of the arguments. Space is not allowed between function name and arguments.
1..5 |> Enum.into ([]) is the same as 1..5 |> Enum.into(([])) (if we fill the missing parenthesis compiler is complaining about). What you wanted is probably 1..5 |> Enum.into([]), which is a correct call, that the compiler does not complain about.
A: To get rid of the warning, put your parentheses around the whole Enum.into shebang:
(1..5) |> (Enum.into [] )
I'm not 100% sure why Elixir complains here; the warning mentions
foo 1 |> bar 2 |> baz 3
should be rewritten as
foo(1) |> bar(2) |> baz(3)
which - to my understanding - is exactly what you did. Probably related to the partial application of Enum.into to []. | |
d10161 | In case params[:after] is given I would do the following:
Post.where('table_name.id > ?', start).order('id desc').limit(10)
If you don't cheat on created_at column, the order on created_at and id columns should be the same, and ordering is much faster in id column (it has an index of numbers and that stuff)
Including the table name in the start condition is optional, but will help you avoid ambiguous SQL in case you want to join several tables.
A: You can try this
Post.where('id > ?', start_id).order('created_at').limit(10)
Hope this will work for you | |
d10162 | The message in the callstack is the relevant hint: You need to load more debug symbols for the callstack to be displayed correctly. You can right-click on the first entry in the callstack (the KernelBase.dll... line) and select "Load symbols". You might have to load symbols for more modules than this, but you should get new messages telling you about this.
This issue is unique to 32bit applications. Due to the way the 32bit calling convention works, it is not possible to generate a call stack without debug symbols for all the topmost stack entries. If you compile your application for 64bit, this problem will go away. | |
d10163 | You need to bind your dropdownlist to property WorkZoneID
@Html.DropDownListFor(m => m.WorkZoneID, Model.Workzones)
and if your wanting to preselect an option, you need to set the value in the controller before you pass the model to the view. And since your model contains a property for the SelectList, then use it (don't use ViewBag)
Company model = new Company
{
WorkZoneID = 1 // set to a value that matches one of your options
Workzones = cmpRep.GetWorkzoneDrop();
};
return View(model);
and when you submit to
[HttpPost]
public ActionResult Edit(Company model)
the value of model.WorkZoneID will contain the value of the selected option. | |
d10164 | Which way you will use to let the pods going to be executed on the right node?
nodeSelector, simplest way because you add a label to the node kubectl label nodes k8s-node-1 disktype=ssd which can be verified by kubectl get nodes --show-labels and inside pod yaml under spec you add:
nodeSelector:
disktype: ssd
Node affinity, is more complex and more expressive as you are no longer limited to exact matches. Keep in mind this is still a beta feature.
A second doubt I have is the service have to be reachable from the external word directly from the node, so if I want to use replicas, the Web1 and Web2 should listen on same IP address the service is exposed, I suppose, or could this be managed via the kube-proxy?
Here, I think you will need to use Type LoadBalancer as a Service, most cloud providers have they own internal LoadBalancer GCP, AWS, Azure. There is also MetalLB which is implementation for bare metal Kubernetes clusters.
Hope this helps You.
EDIT:
OP recommends using Node restriction which in his example a better solution to let pods running dynamically on a sub-set of node in the cluster. | |
d10165 | Well, I suggest trying one of the followings:
*
*If you are using Cordova, use the cordova-status-bar plugin and try setting the statusBar color in the config.xml:
<preference name="StatusBarBackgroundColor" value="#000000" />
or
<preference name="StatusBarBackgroundColor" value="#ffffff" />
setting it to a value in hex color, probably you want it black, and then setting the text and icons to light or lightcontent as you did in Android by using:
<preference name="StatusBarStyle" value="lightcontent" />
*If you are using Capacitor, install the Capacitor plugin
npm install @capacitor/status-bar
npx cap sync
and then set the color of the background and text using
import { StatusBar, Style } from '@capacitor/status-bar';
// iOS only
window.addEventListener('statusTap', function () {
console.log('statusbar tapped');
});
const setStatusBarStyleDark = async () => {
await StatusBar.setStyle({ style: Style.Dark });
};
*Finally, if none of that works, or you just want to change it on iOS try setting it in the global.scss as you were doing but also changing the backgound color and the color:
.ios {
ion-header {
margin-top: var(--ion-safe-area-top);
background-color: black;
color: white;
}
ion-toolbar {
margin-top: var(--ion-safe-area-top);
--padding-top: var(--ion-safe-area-top);
padding-top: var(--ion-safe-area-top);
background-color: black;
color: white;
}
}
A: I don't know about Capacitor, but I know that on Cordova for iOS, you need to include viewport-fit=cover in the <meta name="viewport" content="..."> tag of your index.html to do this, e.g.
<meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
This works for me when using the cordova-plugin-statusbar plugin, anyway. | |
d10166 | The generic types don't match: Your .ToList() is of CmsContent, but your return type is an IEnumerable of CmsGroupsType. I'm not sure if that was intentional, but changing the return type to IEnumerable<CmsContent> will make everything work.
A: Change your return type from CmsGroupsType to WebProject.DataAccess.DatabaseModels.CmsContent | |
d10167 | As the other commenters were alluding to, you just need a separate CSS rule (#signin a) for the nested anchor tag.
#navbar a {
text-decoration: none;
width: 200px;
color: #4c4c4c;
font-size: 14px;
}
#signin {
background-color: blue;
font-weight: 800;
color: #ffffff;
padding: 7px 12px;
}
#signin a {
color: #ffffff;
}
<div id="contents">
<div id="navbar">
<ul>
<li id="signin"><a href="https://accounts...">Sign In</a></li>
</ul>
</div>
</div> | |
d10168 | Dependencies can be added in the build.gradle and podspec of the plugin. Though if it depends on a non-standard Maven or CocoaPods repo, users will need to specify that in their project.
Permissions are added by the user if needed. Same with configuration files. Use the README of the plugin to explain what needs to be done.
If the configuration info is the same across iOS and Android (API keys etc), passing it from Dart to native is a good practice to avoid duplication. If the configuration info is different for each platform, having it be read out of a file by the plugin (or specified in the AppDelegate/Activity) allows the Dart to be agnostic to which platform it's on.
Check out the google_sign_in plugin for inspiration. | |
d10169 | Sometimes the transaction is indeed uncommitable, for example if you're trying to INSERT a row, and there's a trigger on the target table, and the trigger fails.
You should always check XACT_STATE() in BEGIN CATCH block to see if you can commit the transaction. See the docs for more info.
And if you want to log the failure reliably, I'd recommend using SQL Audit feature, and EXEC sp_audit_write procedure in BEGIN CATCH block. Again, see the docs for more info. Alternatively there's RAISERROR ... WITH LOG which logs messages to SQL Server Error Log, if you can't use the Audit.
A: Entity Framework threw this exception.
TRIGGERS were the culprits. I had modified some Models, added migrations, updated the databse ... but NOT the TRIGGERS
This exception was thrown at some point in the processing.
Fixing the TRIGGERS solved the problem. | |
d10170 | Kafka and Spark are distributed processes; and its a bad practice to use more than one process inside a Docker container.
Instead, add more services to your existing Docker Compose file, copied from existing Docker Compose setups from Kafka.
My requirements.txt file contains only four packages: pyspark, kafka, python-kafka & tweepy
You don't need two Kafka dependencies ; you only need pyspark and tweepy since Spark can write to Kafka on its own.
Or you could create a 5th (if counting Zookeeper), for a plain Python container with your producer application that has no Spark dependencies | |
d10171 | Working DEMO
Try this
I guess this is what you need
$(document).ready(function () {
$tabs = $('#tabs').tabs({
cache: false,
});
if ($('#tabs').hasClass('ui-tabs')) { // check if tabs initilized
$('.tab').each(function () {
var tab = $(this);
$.ajax({
url: '/echo/html/',
success: function (data) {
tab.html("success"); // for demo
}
});
});
}
}); | |
d10172 | Your'e missing a parenthesis at the end of your statement :
social_media_varray_type (
social_media_type ('TWITTER', 'ALLIANCE'),
social_media_type ('FACEBOOK', 'ALLIANCE'),
social_media_type ('INSTAGRAM', 'ALLIANCE'))); | |
d10173 | I assume you want a docker image that is suiteable for plenty of rails apps.
I do not know docker at all, but maybe ignore what Docker offers to you, and do it yourself:
Create an image with all great ruby versions, maybe 1.9 and 2.3,
but i think you should just stick with latest ruby.
Use https://github.com/rbenv/rbenv to provide a ruby env
Every Rails applications usually ships with a Gemfile.
In production releases, the gem versions are locked in the Gemfile.lock file.
In case the gems need an update, you will need to update the app code and then the gems with
bundle install
So i think it´s not possible to have a docker "one-fits-all" image for plenty of rails apps nicely.
Something i do when installing productive rails apps is to install their gems in the app folder.
bundle install --path vendor/bundle
This puts the gem apps inside their vendor directory. I see no big chance here either to make update life easier.
As i never tried docker, or even visited their website, my post might be useless (sry)
I hope i understood your intentions, at least. | |
d10174 | printList :: IO ()
printList = do putStrLn "Printed Combined List"
zip [NameList][PriorityList]
There are many things wrong with this code.
The parse error you are seeing is because the do block is not properly aligned. The zip on the last line must line up with the putStrLn on the line before. So either
printList :: IO ()
printList = do putStrLn "Printed Combined List"
zip [NameList][PriorityList]
or
printList :: IO ()
printList = do
putStrLn "Printed Combined List"
zip [NameList][PriorityList]
But that still won't work. printList is declared to be an IO action, which means the final line of the do block must be an IO action also... but zip produces a list. You may have meant this:
printList :: IO [(String, Int)]
printList = do
putStrLn "Printed Combined List"
return (zip [NameList][PriorityList])
but that will only print out the result when you run it directly from the ghci prompt. Better to print it out explicitly:
printList :: IO ()
printList = do
putStrLn "Printed Combined List"
print (zip [NameList][PriorityList])
But it still won't do what you want! Because NameList and PriorityList are, presumably, lists. That you want zipped together. But that's not what you're giving to zip: you're giving zip two new single element lists. You no doubt intended just to pass the lists directly.
printList :: IO ()
printList = do
putStrLn "Printed Combined List"
print (zip NameList PriorityList)
Oh, but it still won't work. Won't even compile. And why is that? Because variable names must start with lower case letters (or an underscore). And you've started both NameList and PriorityList with capital letters. Which is one reason why your first block of code so obviously could not have worked.
printList :: IO ()
printList = do
putStrLn "Printed Combined List"
print (zip nameList priorityList)
A: Using the above assistance, i have been able to construct a function (below) to achieve a successful ZIP (Excluding information gathering).
printList :: IO ()
printList = do
let nameList = ["test1", "test2", "test3"]
let prioirtyList = [1, 2, 3]
putStrLn "Printed Combined List"
print (zip nameList prioirtyList)
My output is as follows:
*Main> printList
Printed Combined List
[("test1",1),("test2",2),("test3",3)] | |
d10175 | Use the "Add Existing Module" function to handle this.
For this First of all add HTML module on page.
To add that HTML module on another page use Add Existing Module instead of Add New Module.
You can choose page from drop down on which you added HTML module.
Then add to new page. Content will also be placed. | |
d10176 | What you are looking for is an autoloader that can map your namespaces to actual paths and include the class files before you're creating an instance of them. Take a look at the commonly used PSR-0 autoloader.
<?php
function autoload($className)
{
$className = ltrim($className, '\\');
$fileName = '';
$namespace = '';
if ($lastNsPos = strrpos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
}
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
require $fileName;
}
spl_autoload_register('autoload');
If you include this code in /var/www/html/project/example.php, what happens then when you try to make an instance
$redis = new \file\library\storage\redis\Redis();
Is that it will try to include this file first
/var/www/html/project/file/library/storage/redis/Redis.php
A: You should include the file that contains the class. You can do it manually using: require_once 'redis.php' OR create a rontina autoload as stated in the first answer | |
d10177 | After of checking the code and the variables, I discovered I had a problem with the ctime of stats, I do not know why the ctimes does not change when a file content is modified, so I only used mtime instead of ctime and it start serving the content in the right way....
thanks... | |
d10178 | Objective-C:
// Remove and disable all URL Cache, but doesn't seem to affect the memory
[[NSURLCache sharedURLCache] removeAllCachedResponses];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
You can find more information in http://blog.techno-barje.fr/post/2010/10/04/UIWebView-secrets-part2-leaks-on-release/
Swift:
URLCache.shared.removeAllCachedResponses()
URLCache.shared.diskCapacity = 0
URLCache.shared.memoryCapacity = 0
A: You can change your cache policy, using the code:
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval: 10.0];
A: I try to answer a similar question here. I hope it was useful for you! The last solution works for HTML but not for images, css and js linked in html.
How to clear UIWebView cache?
A: I've tried all of these solutions but none of them work every single time. My main test was an html page with an image set as a background in the html page. This html page and image are downloaded locally on my iPad through a "sync" method i have written. The only way to keep the cache fully reset is the constantly change the url of the image in the html page so it thinks it's a unique image each time. For example in my html:
<body background="image.png?v123">
So each page change i make i have to update the version number:
<body background="image.png?v1234">
etc, etc. You can change the url in anyway you want, it just has to be different.
Well i'm tired of doing this. Now When i download content locally, I am instead dynamically changing the containing folder's name. Since this folder is a parent folder and all of my links are relative it means i don't have to edit my html files each time. So far it seems to be working ok. I wish these other methods were consistent as it would be so much easier to simply reset the cache.
So in my requests its the baseURL which is causing my cache to reset, not the query string to my url or background image, or css file, etc, etc.
NSString *myURL = @"index.html";
NSURL *baseURL = [NSURL fileURLWithPath:@"FULL_PATH_TO_DOCS/MYFOLDERV123"];
[myTargetWebView loadHTMLString:myURL baseURL:baseURL]; | |
d10179 | David's answer is good. But if you don't want to use Jquery, you can use document.querySelectorAll instead of $(this.el).find("li") and then add the click handlers with addEventListener in the directive.
Having said that, you don't have to add event listeners to all the elements in a directive (even though a directive might be the best solution for this). Another approach would be to do what you suggest, put the handlers on the parent elements, and then implement some logic depending on which element the function was called from. Example:
https://jsfiddle.net/q7xcbuxd/33/
<div id="app">
<ul class="UL_items" v-on="click:Menu(1)">
<li>Menu 1 item 1</li>
</ul>
<ol class="OL_items" v-on="click:Menu(2)">
<li>Menu 2 item 1</li>
<li>Menu 2 item 2</li>
<li>Menu 2 item 3</li>
</ol>
<div class="DIV_items" v-on="click:Menu(3)">
lots<br/>
of<br/>
items<br/>
</div>
</div>
var vue = new Vue({
el: '#app',
methods: {
Menu: function(id){
console.log('You invoked function Menu' + id + ' ' +
'by clicking on ' + event.path[0].innerHTML + ' ' +
'which is of type ' + event.srcElement.nodeName + '.\n' +
'The parent element\'s class name is \'' + event.srcElement.parentElement.className + '\' ' +
'which is of type ' + event.srcElement.parentElement.nodeName + '.');
}
}
});
A: I would write a directive for <ol> and <ul> that adds click handlers for all <li> children.
Something like:
Vue.directive('menu', {
bind: function () {
$(this.el).find("li").on("click", function (event) {
this.menu_click(event);
});
},
update: function (value) {
this.menu_click = value;
},
unbind: function () {
$(this.el).find("li").off("click", this.menu_click);
}
})
And use it like this:
<ul class="container" v-menu="container_click">
<li>Menu 1</li>
</ul>
<ol class="click" v-menu="click">
<li>Menu 1</li>
<li>Menu 2</li>
</ol> | |
d10180 | You could use the IEnumerable extension Where applied to your files array
First you need to define the upper and lower limit of your allowed file sizes, then ask the Where extension to examine your files collection to extract the files that are between your limits
int upperLimit = (1024 * 1024) + userSize;
int lowerLimit = Math.Max(0, usersize - (1024 * 1024));
var result = files.Where(x => x.Length >= lowerLimit && x.Length <= upperLimit);
foreach(FileInfo fi in result)
Console.WriteLIne(fi.Name + " size = " + fi.Length);
A: FileInfo[] files = files.GetLegnth(userSize);
this is called wishful programming. Just hoping that the system will have a function that does exactly what you need.
What you need to do in go through the files collection and look at each length in turn. SOmething like
var matched = files.Where(f=>f.Size > userSize);
if you like LINQ or
foreach(var file in files)
{
if (file.Size>userSize)
{
}
}
if you dont
note - I doubt this code works as typed, I have not read up on the data in a File object, there must be a Size of some sort
A: You can try this code, please confirm, if this what you need
using System;
using System.IO;
using System.Linq;
namespace ConsoleApplication1
{
internal class Program
{
private static void Main(string[] args)
{
DirectoryInfo folderInfo = new DirectoryInfo("C:\\Windows");
FileInfo[] files = folderInfo.GetFiles();
Console.WriteLine("Enter a file size in Bytes i.e 500 bytes");
int userSize = int.Parse(Console.ReadLine());
FileInfo[] totalFiles = files.Where(x => x.Length == userSize).ToArray();
}
}
}
A: I won't provide a code in this answer, because it's really basic and you should be the one who finds the final solution. If you need to get files of size within some set bounds (+- 1MB for instance), you first need to get all the files and loop through them to find their sizes. In the loop you'd be checking if it's within these bounds or not. If it is, you can assign the file/size/whatever, into an array of found stuff. If not, simply go to the next file.
I'd really AVOID linq solutions, because you need to learn and understand the principles first and then use shortcuts. Otherwise you'd be dependent on SO help for a looooong time.
I'll just show you how you get the bounds, rest is up to you:
Console.Write("Type the desired size in bytes: ");
string userInput = Console.ReadLine();
int userSize = int.Parse(userInput); // you might consider using TryParse here
int upperBound = userSize + 1048576;
int lowerBound = userSize - 1048576;
// get the files of a directory you want to search
// loop through and compare their size
// if their size is > or = to the lower bound
// AND < or = to the upper bound,
// you've found match and add it to results
Just a note: 1048576 bytes = 1 megabyte
Second note: you should probably check if the lower bound is higher or equal to zero, if the user typed in a valid number and so on... | |
d10181 | AFAIK mallocis NOT part of kernel32.dll. It is part of the MS C runtime DLLs - since you don't provide any details about how/where you want to use this just some links with relevant information:
*
*http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx
*http://www.codeproject.com/Articles/20248/A-Short-Story-about-VC-CRT
Basically you have to load the respective DLL and then resolve the needed function, as an example:
let SomeMSCRT = LoadLibrary @"SomeMSCRT.dll";;
let malloc = GetProcAddress(SomeMSCRT, "malloc");;
One note though:
Depending on what exactly you want to do you might run into serious and hard to debug problems - for example using malloc from F# is IMHO a bad idea... you need to keep in mind that the C runtime needs proper initialization (in case of MS CRT you need to call CRT_INIT as the very first thing) etc. The C runtime is NOT aware of any .NET specifics and thus may lead to unstable behaviour... esp. since the CLR might be using the CRT (perhaps a different version) internally...
Another point:
Generating machine code at runtime and executing it by jumping into that memory area is subject to several security measures (depending on Windows version etc.). You might need to mark the respective memory segment as "executable" which is NOT possible via C runtime, it is only possible using Windows API calls (like VirtualAllocEx) with proper permissions... see for a starting point here and here.
A: I don't believe malloc is part of kernel32.dll. However, if I recall correctly, all malloc implementations eventually drill down to HeapAlloc, which is available in kernel32.dll.
A:
I want to resolve the addresses of functions like those from the C stdlib
There's your problem. You speak as if there's a single C runtime library. In fact there are many. Every compiler provides its own, in several different flavors (debug, release, static link, dynamic link) and all of these are mutually incompatible.
If you knew which one you were trying to use, the answer to your question would become obvious.
If you want the OS-provided libraries shared between all Windows applications, then kernel32.dll is the correct place to look, but the functions conform to the Win32 API specification, not the ANSI or ISO C standard. | |
d10182 | You need to add an http header to specify the content type for your http request body. If you are sending a json body, the header is content-type: application/json
You can update actionService.ts
deleteRow(selection: any): Observable<{}> {
let headers = new Headers();
headers.append('Content-Type', 'application/json');
const queryParams = [selection._selection].map((row: { value: any; }) => `id=${row.value}`);
const url = `http://localhost:15217/actions/deleteRow`;
const options = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
}),
body: {}
}
return this.http.delete<any>(url, options);
} | |
d10183 | My approach would be like this:
I would use radio buttons instead, to ensure a type is selected.
Form Bits:
<input type="radio" name="file_type" value="0" checked="checked"> None<br />
<input type="radio" name="file_type" value="1"> Filer<br />
<input type="radio" name="file_type" value="2"> Statistik
PHP Bits:
$field = false;
// set the field name based on the file type selected in the form
switch($_POST['file_type'])
{
case 1:
$field = '`das_file_categories_id`';
break;
case 2:
$field = '`das_custermer_upload_id`';
break;
default:
$field = false;
}
// if a field has been set ( i.e file_type != 0 ) then build and run the query
if($field)
{
$query = "INSERT INTO `das_custermer_files` (`url`, " . $field . ", `das_custermers_id`, `name`) ";
$query .= "VALUES ('" . $fileurl . "', 1, " . $user_custermers_id . ", '" . $name . "')";
mysql_query($query);
echo "Inserting to db: " . $query;
} else {
echo "No field set: ";
print_r($_POST);
}
Things worth noting
*
*You're using mysql_query which is outdated, see here: http://php.net/manual/en/function.mysql-query.php
*Even though you are using $fileurl, $user_custermers_id,$name i cannot see these being set, so i am assuming they are set somewhere higher in the file
A: your check_box names should be different. yours the same.
<input type="checkbox" name="file_type" value="1"> Filer<br />
<input type="checkbox" name="file_type" value="1"> Statistik
A: Html code :
<form action="test.php" method = 'post'>
<input type="checkbox" name="file_type[]" value="1"> Filer<br />
<input type="checkbox" name="file_type[]" value="2"> Statistik
<input type="submit" value="submit" />
checkbox will contain its value in array $_POST['file_type']
and you may inter its value to db as follows :-
if(isset($_POST['file_type'])){
foreach($_POST['file_type'] as $keys)
{
mysql_query("INSERT INTO das_custermer_files (url, das_file_categories_id, das_custermers_id, name)
VALUE('$fileurl', $keys, $user_custermers_id, '$name')"
) or die(mysql_error());
}
}
else if(isset($_POST['statistik_type'])){
mysql_query("INSERT INTO das_custermer_files (url, das_custermer_upload_id, das_custermers_id, name)
VALUE('$fileurl', 1, $user_custermers_id, '$name')"
) or die(mysql_error());
}
else{
echo "no choices";
}
this maybe your requirement...
A: Try this .Should work.
if(isset($_POST['file_type'])){
mysql_query("INSERT INTO das_custermer_files (url, das_file_categories_id, das_custermers_id, name)
VALUE('$fileurl', 1, $user_custermers_id, '$name')"
) or die(mysql_error());
}
else if(isset($_POST['statistik_type'])){
mysql_query("INSERT INTO das_custermer_files (url, das_custermer_upload_id, das_custermers_id, name)
VALUE('$fileurl', 1, $user_custermers_id, '$name')"
) or die(mysql_error());
}
else{
echo "no choices";
}
A: You approach is totally wrong. You should follow this structure
<form action="test.php" method = 'post'>
<input type="checkbox" name="file_type" value="1"> Filer<br />
<input type="checkbox" name="file_type" value="2"> Statistik
<input type="submit" value="submit" />
</form>
Now with php
$query = '';
if($_POST['file_type'] == 1){
$query = "INSERT INTO das_custermer_files
(url, das_file_categories_id, das_custermers_id, name)
VALUE
('$fileurl', 1, $user_custermers_id, '$name')";
}else if($_POST['file_type'] == 2){
$query = "INSERT INTO das_custermer_files
(url, das_custermer_upload_id, das_custermers_id, name)
VALUE
('$fileurl', 1, $user_custermers_id, '$name')";
}
mysqli_query($query);
A: You probably forgot to <form action = "..." method = "POST"> </form>.
First step, you should do the test:
print_r($_POST);
What you get by this test?
If the first step is correct (not empty array), we can finish:
if (isset($_POST['file_type'])) {
...
};
// OR use alternative
if ($_POST['file_type'] == 1) {
...
};
A: Clicking on a checkbox doesen't change the value attribute but adds "checked" in the dome like this:
<input type="checkbox" name="file_type" value="1" checked> Filer<br />
So the submitted value of the checked box will stay forever at "1"
EDIT
When you replace the values with strings you can check against it in php.
HTML
<form action="" method="post" enctype="multipart/form-data">
<input type="checkbox" name="file_type" value="Filer"> Filer<br />
<input type="checkbox" name="file_type" value="Statistik"> Statistik
</form>
PHP
if($_POST['file_type'] == "Filer"){
mysql_query("INSERT INTO das_custermer_files (url, das_file_categories_id, das_custermers_id, name)
VALUE('$fileurl', 1, $user_custermers_id, '$name')"
) or die(mysql_error());
}
elseif($_POST['file_type'] == "Statistik"){
mysql_query("INSERT INTO das_custermer_files (url, das_custermer_upload_id, das_custermers_id, name)
VALUE('$fileurl', 1, $user_custermers_id, '$name')"
) or die(mysql_error());
}
else{
echo "no choices";
} | |
d10184 | Ok, I will answer my question with what worked for me.
On server side, I changed the way I was compressing the data. I am using deflate method of Zlib module instead of gzip. Also changed the response header with these values.
Content-Encoding: deflate and Content-Type: application/deflate
I am still not sure why gzip does not work (or at least did not work for me) but because of time constraint I am going with deflate for now.
Also gzip and deflate uses same compression algorithm and deflate is faster in encoding and decoding. I hope this helps and please correct me if I'm wrong at any place. Thanks!
A: In modern browsers, according to https://developer.mozilla.org/en-US/docs/Web/API/Headers,
For security reasons, some headers can only be controlled by the user agent. These headers include the forbidden header names and forbidden response header names.
Forbidden header names include "Accept-Encoding". | |
d10185 | This is roughly equivalent:
def convert(input):
#do something with your input
import sys
for line in sys.stdin:
convert(int(line))
A: In Python, instead of using scanf and friends, usually you read a line or an entire file into a string, and use string operations to get the results you want.
In your example, you could do something like:
import sys
for line in sys.stdin:
for word in line.split():
number = int(word)
... = convert(number)
A: it can be done using try except
link below can be used
https://stackoverflow.com/a/38621838/4557946 | |
d10186 | The colour property in CSS is 'color' not 'text-color'.
A: Use color: black; "text-color" is not a function.
A: Use color
#horizontal > ul > li > a:hover {
background-color: rgb(255,101,101);
color: black; | |
d10187 | Yes, it will solve browser compatibility issues, and could work on both Mac OS and Windows with the very same code.
The only drawback is that, the first time your user connect to your application, he will need to download the Silverlight plugin.
Awesome you would say? Well, unfortunately some people that probably never try to do something like image processing or advanced line of business application in a browser decide that plugins are not so cool and that you would be able to do the same thing with the magic power of HTML5.
We are still waiting to have the same possibility in HTML5 that we have in Silverlight or Flash, but plugins are already dead. At least as long as no big compay want to push them again.
So, my advice would be: don't start a project in Silverlight. You will have problems, even if you do not target mobile. For example it becomes harder and harder to find compatible good tools (like ReSharper, NCrunch, or even just a decent unit testing library). And in further release of Windows and Mac OS, it will probably not be supported at all (IE for Windows RT already does not support Silverlight).
Sorry man, Silverlight is dead, you arrive after the battle.
A: If your developing your application for an Intranet, I would say Silverlight is an excellent choice.
If you are developing for the Internet, use an HTML based language | |
d10188 | Not really sure why you're mixing javascript with your php code. Nevertheless, this is the approach you should follow:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
<?php
$url = urlencode("https://google.com");
$api_url = "vurl.com/api.php?url=".$url;
$arr_output = json_decode(file_get_contents($api_url), true);
echo $arr_output;
?>
</script> | |
d10189 | Quickfix.
Try this:
wp_register_script('jquery', "//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", false, '1.11.1', true);
Update:
Let's split this string into 3 parts:
*
*"http"
*($_SERVER['SERVER_PORT'] == 443 ? "s" : "")
*"//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", false, '1.11.1', true);
*
*"http" - We don't need beucase jQuery starts with //
*This is if/else statemnt which was causing the problem, it was adding localhost/demo/CybarMagazinehttp to your output results
*This what link to jQuery DNS which we want to leave without changes | |
d10190 | The problem is that you execute shell commands instead of actually changing the directory using os.chdir()
Each os.system() call executes the given command in a new shell - so the script's working directory is not affected at all.
A: The directory actually is changed, but in another process, the child of your script. There's one simple rule to remember: a child can never affect the environment (PATH, CWD etc) of its parent.
A: sh("cd /home")
sh("pwd")
^ this spawns 2 separate shells, try:
sh("cd /home; pwd")
A: When you run sh function you spawn a new bash process which then changes current directory and exits. Then you spawn a new process which knows nothing about what happened to the first bash process. Its current directory is, again, set to the home directory of the current user.
To change Python process' current working directory use
os.chdir("blah")`
A: Each sh( ) call is generating a different shell, so you are affecting the shell's working directory, not python's. To change pythons working directory, use chdir() | |
d10191 | It's not got anything to do with the ImageSharp library.
You need to reset your outStream position after saving. BlobContainerClient is trying to read from the end of the stream. | |
d10192 | Without seeing the code, it's hard to say for sure but you could try:
*
*Check any code you changed in the front end, specifically in your code you may have something like this:
const contractInstance = new state.web3.eth.Contract(
MyContract.abi,
"0x.....", // contract address
{
from: state.accounts[0],
gasPrice: 1000,
gas: 100000
}
);
Make sure the gas prices are similar to those, you may have to adjust for your case.
*Re-compile and redeploy --> for truffle, run truffle develop first, then compile then migrate --reset for local deployment.
*In Metamask, reset your test account. Metamask > Select Account > Settings > Advanced > Reset account. Only do this for testing accounts
A: Previously it used to happen in older versions due to a gas specification issue which was fixed. rpcErrors.internal` expects a string as the first argument, with arbitrary data being the optional second argument. Passing in a non-
string first argument results in the error being shadowed by an error
from eth-json-rpc-errors.
Please check what you are passing to Metamask.
A: In my case, after trying so many options I have restarted Ganache and re-imported new account from Ganache to Metamask.
I connected this new account with localhost application.
This resoles my issue.
A: Before performing any transaction the sending ETH address must be connected to your own site or UI. So it can get the address of sending account and goes towards the further transaction in the metamask.
Make sure Your sending account address must be connected to your UI. | |
d10193 | Use fgets() get file all string in variable $date, then mb_convert_encoding() convert encoding, then str_getcsv() convert string to array.
if (($handle = fopen("books.csv", "r")) === FALSE)
throw new Exception("Couldn't open books.csv");
$data = "";
// get file all strin in data
while (!feof($handle)) {
$data .= fgets($handle, 5000);
}
// convert encoding
$data = mb_convert_encoding($data, "UTF-8", "auto");
// str_getcsv
$array = str_getcsv($data); | |
d10194 | Please check Add Configuration button on lower right corner of launch.json.
Sample npm task configuration generated from same:
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"debug"
],
"port": 9229
}
Screenshot:
Adding additional configuration: | |
d10195 | Puppatlabs describe that Puppet 3.7.3 is not supported on Ruby 2.2 but now thay change status to resolved. So you should go more into this and find rid of this problem. You can show this issue from puppatlabs ticket Puppet 3.7.3 is not supported on Ruby 2.2 | |
d10196 | Do you want the thread to perform more than one job? If not, you don't need the loop. If so, you need something that's going to make it do that. A loop is a common solution. Your sample data contains five job, and the program starts five threads. So you don't need any thread to do more than one job here. Try adding one more URL to your workload, though, and see what changes.
A: The loop is required as without it each worker thread terminates as soon as it completes its first task. What you want is to have the worker take another task when it finishes.
In the code above, you create 5 worker threads, which just happens to be sufficient to cover the 5 URL's you are working with. If you had >5 URL's you would find only the first 5 were processed. | |
d10197 | I got it. It's because I'm running debug, therefore the 'default' location is at the debug folder. So I just needed to move the database location to the debug folder when I'm developing.
Thanks. | |
d10198 | Please refer this jsFiddle code. I hope this solves your problem.
You just needed to add the CSS to your style.css
.myspotlight{
background-color:red;
}
and
the javascript to the particular php file which runs the loop of all your articles and creates the list of articles.
$( "article" ).first().addClass("myspotlight");
The jquery code basically appends the necessary class to the first tag that it finds | |
d10199 | OpenCV will make it more easy. You will find more problem in your method. To use opencv you have to install 1 more package known as numpy (numerical python). It's easy to install. If you want to install it automatically:
Install
*
*Install pip manually
*After that go to your cmd>python folder>Lib>site-packages and type pip install numpy *but for using pip you have to be in internet access.
*After installation of numpy just type pip intall opencv.
Now you can import all the packages. If numpy somehow fails, maunually downlaod numpy 1.8.0 and install it. | |
d10200 | :type> b; // Does not compile: error: template argument for template template parameter must be a class template or type alias template
B<typename A::template type> b; // Does not compile: error: expected an identifier or template-id after '::'
B<typename A::template <typename> type> b; // Does not compile
B<typename A::template <typename> class type> b; // Does not compile
A: A::type is a template, not a typename.
B<A::template type> b1; // OK
B<A::type> b2; // OK |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.