_id
stringlengths 2
6
| partition
stringclasses 3
values | text
stringlengths 4
46k
| language
stringclasses 1
value | title
stringclasses 1
value |
---|---|---|---|---|
d12001 | train | Add tabindex=0 attribute to the div you want to foucs and you will be able to set focus on the div using .focus()
A: You can not focus controls like div, span etc. You can move to that div if required using book marks.
A: Do you want to highlight the div then you can use the jquery and following code to give highlight effect.
$("div").click(function () {
$(this).effect("highlight", {}, 3000);
});
A: Good morning,
I've read a few times now, that one can't focus table rows but only can focus elements, which accepts input by the user. Otherwise I think there must be a way to simulate a click on a table row by jquery/javascript! I tried the following:
document.onkeydown = function(event) {
...
else if (event.keyCode == 9 && event.ctrlKey) {
$('#messagelist tr').on('click', function () {
alert('I was clicked');
});
$('#messagelist tr').eq(1).click();
}
...
}
The alert is shown! But the row isn't "marked"!? | unknown | |
d12002 | train | Putting the sleep in the xargs is a bit wonky. I advise the following approach which is more likely to supply the desired result.
#!/bin/sh
siteCommon="--location --request POST 'https://g.com' \
--header 'Authorization: Bearer cc' \
--header 'Content-Type: application/json' "
while read -r line
do
eval curl ${siteCommon} --data-raw \'{ \"c_ids\": [ \"${line}\" ] }\'
sleep 5m
done < ~/recent.txt
A: Escaping arbitrary strings into valid JSON is a job for jq.
If you don't have a particular reason to define the curl args outside your loop:
while IFS= read -r json; do
curl \
--location --request POST 'https://g.com' \
--header 'Authorization: Bearer cc' \
--header 'Content-Type: application/json' \
--data-raw "$json"
sleep 5m
done < <(jq -Rc '{"c_ids": [ . ]}' recent.txt)
...or if you do:
curl_args=(
--location --request POST 'https://g.com' \
--header 'Authorization: Bearer cc' \
--header 'Content-Type: application/json' \
)
while IFS= read -r json; do
curl "${curl_args[@]}" --data-raw "$json"
sleep 5m
done < <(jq -Rc '{"c_ids": [ . ]}' recent.txt) | unknown | |
d12003 | train | Is there a way to automatically update the status of a Work Item
within Azure DevOps from 'New' to 'Active' when the item is added to
my 'In Progress Work' from within the 'Available Work Items' section
of Visual Studio?
The status of the work items in Azure DevOps is not a one-to-one relationship with the work item status of My work in Visual Studio.
The status of work item in Visual Studio is used to classify the work items not change the status of the work item, so that we can more clearly distinguish which work items are being processed.
You can view the description of In Progress Work in Visual Studio is:
drag a work item here to get started
This looks more like a swim lanes, giving developers a clearer idea of which workitems are associated with development.
Besides, when we commit the code and status of work items, there is option which we could select only with Associate and Resolve:
Only if we confirm that the currently associated work item is completed, we will choose the option to Resolve, otherwise it will be Associate.
On the other hand, we could add a custom status of work item on the Azure DevOps. Obviously, we could not match our new custom state to the status of work item in Visual Studio.
Hope this helps. | unknown | |
d12004 | train | :active Adds a style to an element that is activated
:focus Adds a style to an element that has keyboard input focus
:hover Adds a style to an element when you mouse over it
:lang Adds a style to an element with a specific lang attribute
:link Adds a style to an unvisited link
:visited Adds a style to a visited link
Source: CSS Pseudo-classes
A: :focus and :active are two different states.
*
*:focus represents the state when the element is currently selected to receive input and
*:active represents the state when the element is currently being activated by the user.
For example let's say we have a <button>. The <button> will not have any state to begin with. It just exists. If we use Tab to give "focus" to the <button>, it now enters its :focus state. If you then click (or press space), you then make the button enter its (:active) state.
On that note, when you click on an element, you give it focus, which also cultivates the illusion that :focus and :active are the same. They are not the same. When clicked the button is in :focus:active state.
An example:
<style type="text/css">
button { font-weight: normal; color: black; }
button:focus { color: red; }
button:active { font-weight: bold; }
</style>
<button>
When clicked, my text turns red AND bold!<br />
But not when focused only,<br />
where my text just turns red
</button>
edit: jsfiddle
A: There are four cases.
*
*By default, active and focus are both off.
*When you tab to cycle through focusable elements, they will enter :focus (without active).
*When you click on a non-focusable element, it enters :active (without focus).
*When you click on a focusable element it enters :active:focus (active and focus simultaneously).
Example:
<div>
I cannot be focused.
</div>
<div tabindex="0">
I am focusable.
</div>
div:focus {
background: green;
}
div:active {
color: orange;
}
div:focus:active {
font-weight: bold;
}
When the page loads both are in case 1. When you press tab you will focus the second div and see it exhibit case 2. When you click on the first div you see case 3. When you click the second div, you see case 4.
Whether an element is focusable or not is another question. Most are not by default. But, it's safe to assume <a>, <input>, <textarea> are focusable by default.
A: :focus is when an element is able to accept input - the cursor in a input box or a link that has been tabbed to.
:active is when an element is being activated by a user - the time between when a user presses a mouse button and then releases it.
A: Active is when the user activating that point (Like mouse clicking, if we use tab from field-to-field there is no sign from active style. Maybe clicking need more time, just try hold click on that point), focus is happened after the point is activated. Try this :
<style type="text/css">
input { font-weight: normal; color: black; }
input:focus { color: green; outline: 1px solid green; }
input:active { color: red; outline: 1px solid red; }
</style>
<input type="text"/>
<input type="text"/>
A: Using "focus" will give keyboard users the same effect that mouse users get when they hover with a mouse. "Active" is needed to get the same effect in Internet Explorer.
The reality is, these states do not work as they should for all users. Not using all three selectors creates accessibility issues for many keyboard-only users who are physically unable to use a mouse. I invite you to take the #nomouse challenge (nomouse dot org).
A: Focus can only be given by keyboard input, but an Element can be activated by both, a mouse or a keyboard.
If one would use :focus on a link, the style rule would only apply with pressing a botton on the keyboard. | unknown | |
d12005 | train | This should do it: http://jsfiddle.net/Gajotres/Nc98p/
$(function () {
$('#clone-page').click(function () {
if($('#page-2').length == 0){
var newPage = $('#page-1').clone();
newPage.prop('id', 'page-2');
newPage.find('#header-1')
.prop('id', 'header-2')
.find('h1')
.html('Page 2');
newPage.find('#content-1')
.prop('id', '#content-2')
.html('<a href="#page-1" data-role="button"> to Page 1</a>');
newPage.appendTo($.mobile.pageContainer);
}
$.mobile.changePage('#page-2');
});
}); | unknown | |
d12006 | train | A million years ago, I made a program that would play WinMine (Windows' MineSweeper) for me.
This involved
*
*(a) Get the HWND of the window with the title "Minesweeper"
*(b) Calling setWindowForeground on it
*(c) Opening the memory of the process and reading some data that
corresponded to the current game state.
*(d) Examining this memory to determine the number and position of the
mines
*(e) Moving the mouse to the center of each 'safe' tile before sending
a left-button down, then a left-button up message
The game could be successfully completeed 100% of the time in under 1 second - the time-remaining component of the high-score was always the same as the total time available for solving the problem. For kicks, I also added code that would set the playing field to be a 1bit image - I.e each cell was safe or not.
Anyhow, the following code works for me: It's just scrolled this post-entry box by 4 lines.
If it's run in debug mode, or with a visible console window - the events are swallowed by it, since it's the foreground window. I've run this code without a window. Editing the code, followed by hitting build, before switching back to this window while the code is building resulted in the scrolling of this input box.
#include <windows.h>
#include <winuser.h>
const int minWheelMovement = 120;
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
HWND foregroundWindow;
foregroundWindow = GetForegroundWindow();
mouse_event(MOUSEEVENTF_WHEEL, 0,0,4*minWheelMovement, 0);
} | unknown | |
d12007 | train | Use @ImportResource to load your xml file.
@Configuration
@ImportResource(locations = "classpath:/database.xml")
....
public class PersistenceJpaConfig {
Change the location appropriately.
A: You have to load the xml. See docs
You can use @ImportXml("classpath:com/company/app/datasource-config.xml")
on your configuration class | unknown | |
d12008 | train | Cause runSomething is not a Promise. You must change.
runSomething() {
return new Promise((resolve, reject) => {
this.setState({ status: "running" });
// simulate running something that takes 8s
setTimeout(() => {
this.setState({ status: "idle" });
resolve(true);
}, 3000);
});
}
A working sandbox here https://codesandbox.io/s/fragrant-cloud-5o2um
A: Using async in a function declaration automatically returns a Promise wrapped around whatever you are returning from your function. In your case, it's undefined. This is why your current code is not throwing any errors at the moment.
You will need a mechanism to wait for the setTimeout. Changing the runSomething function like this will work
async runSomething() {
this.setState({ status: "running" });
// simulate running something that takes 8s
return new Promise(resolve => {
setTimeout(() => {
this.setState({ status: "idle" }, resolve);
}, 3000);
});
}
Do notice the line this.setState({ status: "idle" }, resolve);. It makes sure that your promise resolves not only after the setTimeout but also after the child's state is changed to "idle". Which is the correct indication that your child component has moved to "idle" state.
Codesandbox: https://codesandbox.io/s/epic-boyd-12hkj
A: Here is the sandbox implementation of what you are trying to achieve. Sanbox
Here i have created a state in parent component that will be updated when child is running.
this.state = {
callbacks: [],
components: [
{
index: 0, // we don't need this field its just for your info you can just create [true,false] array and index will represent component index.
status: false
},
{
index: 1,
status: false
}
]
};
When all the status in component array is true we update the idle status of parent to running.
getAllRunningStatus() {
let { components } = this.state;
let checkAllRunning = components.map(element => element.status);
if (checkAllRunning.indexOf(false) === -1) { // you can also use !includes(false)
return true;
}
return false;
}
inside your render function
<h1>Parent {this.getAllRunningStatus() ? "running" : "idle"}</h1>
Note:- I have just written a rough code. You can optimise it as per your requirements. Thanks | unknown | |
d12009 | train | Formula used in H2
=IF(AND(AND(B2>=50,C2>=50,D2>=50),OR(E2>=50,F2>=50,G2>50)),"Pass","Fail") | unknown | |
d12010 | train | No, this is not the right way. The correct way is to exclude the creator field from the form, then set it on save:
if form.is_valid:
obj = form.save(commit=False)
obj.creator = request.user
obj.save()
... redirect ... | unknown | |
d12011 | train | Use the click event not change event.
$('.group_1').click(function() {
$(this).addClass(selectedMarkerClass);
if ($('.' + selectedMarkerClass).length == $('.group_1').length) {
$('#2').removeClass('red');
}
});
Update:
if ($('.' + selectedMarkerClass).length == $('.group_1').length)
Is tripping you up. You are removing the red class only if the selected class has been added to each radio and you can only add the selected class if you click each radio.
A better way would be:
$('.group_1').click(function() {
$('#2').removeClass('red');
});
Less code is often times better. You can't unselect a radio. So any click on the radios ensures at least one is clicked.
A: Try it with click event instead. You see the change take place after the second click because change gets fired after the first radio button loses focus.
A: After both radio button changed, $('.' + selectedMarkerClass).length == 2 and $('.group_1').length == 4 because you are using .group_1 class for radio buttons and as well as for input[type=text] too.
need filter your radio button, use "[name=referral_open]",
var selectedMarkerClass = 'was-selected';
$('.group_1').change(function () {
$(this).addClass(selectedMarkerClass);
if ($('.' + selectedMarkerClass).length == $('.group_1[name=referral_open]').length) {
$('#2').removeClass('red');
}
}); | unknown | |
d12012 | train | After a lot of searching and asking around I solved the problem.
This question (or rather the answer) gave me a hint:
Does getting random SIGTRAP signals (in MinGW-gdb) is a sign of memory corruption?
It seems to be a matter of trying to access corrupted memory, which is caused by using an uninitialized dynamic library.
By using the static (debug) versions of the boost::filesystem and boost::system library, and activating the -static switch for the linker, one can get rid of the problem. | unknown | |
d12013 | train | @Leiaz You are right, I've been working in a virtual machine.
When running the program on my host system (which is also ubuntu) it works as expected.
Thank you for your help.
It even works in my VM now, after I've disabled the mouse integration.
Thanks all. | unknown | |
d12014 | train | When you do:
Integer('10')
you are essentially calling the Integer class method defined in Kernel, passing it the argument 10.
To achieve what you want you can do:
[:Integer, :Float].each { |c| puts method(c).call(x) } | unknown | |
d12015 | train | Answering my own question. I was trying to run jython commands with a python interpreter.
There is several ways to run jython code.
If you are using a python IDE like Pycharm it is easiest to use the pyimagej package:
pip install pyimagej
After installing it, you can create a conda imagej environment.
conda create -n imagej -c conda-forge openjdk=8 pyimagej
Be careful, jython is only compatible with python2.7, so far. | unknown | |
d12016 | train | You can use = sign to set new value into array. If you have array inside ArrayList you have to get it first:
arrList.get(0)[0] = 9;
Full code:
// create an arraylist
List<int[]> arrList = new ArrayList<>();
// populate an arraylist
arrList.add(new int[] { 1, 2 });
arrList.add(new int[] { 4, 5 });
// print arraylist before changing
System.out.println("The value before changing: " + arrList.get(0)[0]); // prints
// 1
arrList.get(0)[0] = 9;
System.out.println("The value after changing: " + arrList.get(0)[0]); // prints
// This is what I have come up with.
// the loop changes the values of the first array in a given arraylist
int[] is = arrList.get(0);
for (int i = 0; i < is.length; i++) {
is[i] = i * i;
}
// print arraylist after changing
System.out.println("The value after changing: " + arrList.get(0)[0]); // prints
// 9
A: Instead of arrays better to create Segment class that represent one segment of your snake. Something like that:
public class Segment {
private int x;
private int y;
public Segment (int x, int y) {
this.x = x;
this.y = y;
}
public void setNewPosition(int x, int y) {
this.x = x;
this.y = y;
}
}
with this class you have simple:
for (Segment segment : segments) {
segment.setNewPosition(x, y);
}
p.s. after that you maybe to decide create class Snake that contains from sequence of Segment instances (incapsulate List presented now to class Snake), btw this depends of logic of your game, what methods will be present in Snake class. | unknown | |
d12017 | train | Further to my comment, I think this may be due to a bug in Tapestry's PlasticInternalUtils.getStreamForPath method. Here you'll find:
if (url.getProtocol().equals("file"))
{
String urlPath = url.getPath();
String decoded = urlPath.replaceAll("%20", " ");
return new FileInputStream(new File(decoded));
}
So spaces are dealt with but other escape sequences are not. I suggest filing a bug and look to build your own version of Tapestry with all escape sequences decoded using:
URLDecoder.decode(urlPath, "UTF-8") | unknown | |
d12018 | train | I think this code is a little simpler and taking more help from AR
Sprocket
.joins(cogs: {rotations: :machinist})
.where({ machinists: { machine_id: 123, shop_id: 1 } } )
.group(:bar)
.average('CAST(rotations.foo AS decimal)')
The select clause was unnecessary, you don't have to select values since you only need them internally in the query, AR helps you decide what you need afterwards.
I tested this out using a similar structure in one of my own projects but it is not the exact same models so there might be a typo or something in there if it does not run straight up. I ran:
Activity
.joins(locations: {participants: :stuff})
.where({ stuffs: { my_field: 1 } })
.group(:title)
.average('CAST(participants.date_of_birth as decimal)')
producing this query
SELECT AVG(CAST(participants.date_of_birth as decimal)) AS average_cast_participants_date_of_birth_as_decimal, title AS title
FROM `activities`
INNER JOIN `locations` ON `locations`.`activity_id` = `activities`.`id`
INNER JOIN `participants` ON `participants`.`location_id` = `locations`.`id`
INNER JOIN `stuffs` ON `stuffs`.`id` = `participants`.`stuff_id`
WHERE `stuffs`.`my_field` = 1
GROUP BY title
which AR makes in to a hash looking like this:
{"dummy title"=>#<BigDecimal:7fe9fe44d3c0,'0.19652273E4',18(18)>, "stats test"=>nil} | unknown | |
d12019 | train | You need to change the stroke fill color here for either even value of i in for loop or odd value
-(void)drawDateWords
{
CGContextRef ctx=UIGraphicsGetCurrentContext();
int width=self.frame.size.width;
int dayCount=[self getDayCountOfaMonth:currentMonthDate];
int day=0;
int x=0;
int y=0;
int s_width=width/7;
int curr_Weekday=[self getMonthWeekday:currentMonthDate];
// Normaly big Font
[array_Date addObject:@""];
[array_Month addObject:@""];
[array_Year addObject:@""];
[array_Desc addObject:@""];
[array_LastDate addObject:@""];
[self.array_Name addObject:@""];
UIFont *weekfont=[UIFont boldSystemFontOfSize:20];
for(int i=1;i<dayCount+1;i++)
{
day=i+curr_Weekday-2;
x=day % 7;
y=day / 7;
NSString *date=[[[NSString alloc] initWithFormat:@"%d",i] autorelease];
for (int j=0; j<[array_Date count]; j++) {
NSString *date1 = [array_Date objectAtIndex:j];
int month1 = [[array_Month objectAtIndex:j] intValue];
int year1 = [[array_Year objectAtIndex:j] intValue];
if ([date isEqualToString:date1] && currentMonthDate.month == month1 && currentMonthDate.year == year1)
{
//[@"*" drawAtPoint:CGPointMake(x*s_width+18,y*itemHeight+headHeight+18) withFont:[UIFont boldSystemFontOfSize:25]];
//[date drawAtPoint:CGPointMake(x*s_width+18,y*itemHeight+headHeight+18) withFont:[UIFont boldSystemFontOfSize:25]];
[[UIColor redColor] set];
}
else{
//[[UIColor redColor] set];
[date drawAtPoint:CGPointMake(x*s_width+15,y*itemHeight+headHeight) withFont:weekfont];
}
}
if([self getDayFlag:i]==1)
{
CGContextSetRGBFillColor(ctx, 1, 0, 0, 1);
[@"." drawAtPoint:CGPointMake(x*s_width+19,y*itemHeight+headHeight+6) withFont:[UIFont boldSystemFontOfSize:25]];
}
else if([self getDayFlag:i]==-1)
{
CGContextSetRGBFillColor(ctx, 0, 8.5, 0.3, 1);
[@"." drawAtPoint:CGPointMake(x*s_width+19,y*itemHeight+headHeight+6) withFont:[UIFont boldSystemFontOfSize:25]];
}
CGContextSetRGBFillColor(ctx, 0, 0, 0, 1);
}
} | unknown | |
d12020 | train | An array usually consists of values all of the same type. That fits perfectly to a database column, where all values have the same type as well. Hence, for e.g. an array of double, you could create a column that takes float values and insert each member of the array as individual row. 500 rows is nothing, you could insert millions that way.
A: *
*below query works to insert array of string to the column in MYSql Workbench
insert into tableName (column1) values ('["Lorem Ipsum","Lorem Ipsum","Lorem Ipsum","Lorem Ipsum","Lorem Ipsum"]') | unknown | |
d12021 | train | Actually you don't need lodash to achieve the result you're expecting:
const books = [
{
'book_name': 'book1',
'authors': [
{
author_id: 'value2',
author_name: 'Name2',
},
],
},
{
'book_name': 'book2',
'authors': [
{
author_id: 'value1',
author_name: 'Name1',
},
{
author_id: 'value2',
author_name: 'Name2',
}
],
},
];
const transformed = books.reduce((accumulator, book) => {
const authors = book.authors.map(author => ({
...book,
authors: [author]
}));
return accumulator.concat(authors);
}, []);
console.log('original', books);
console.log('transformed', transformed);
A: It can be done with simple JavaScript.
const books = [{ 'book_name': 'book1',
'authors': [{author_id:'value2',
author_name: 'Name2'}] },
{'book_name': 'book2',
'authors': [{author_id:'value3',
author_name: 'Name3'},
{author_id:'value4',
author_name: 'Name4'}] }];
const arr = [];
books.map((book)=>{
book.authors.forEach((author) => {
arr.push({
book_name: book.book_name,
authors: [author]
});
});
})
console.log(arr); | unknown | |
d12022 | train | well I fixed this with just float
.choices input[type="radio"]{
float:left;
}
* {
font-family: helvetica, arial, sans-serif
}
input[type="radio"] {
margin: 6px;
padding: 6px;
}
.choices {
border: 1px solid skyblue;
padding: 6px;
width: 600px;
border-radius: 8px;
}
.choice {
line-height: 24px;
margin: 4px;
display: inline-block;
}
.choices input[type="radio"]{
float:left;
}
.choices .choice4{
margin: 4px;
}
<div class="choices">
<div class="choice">
<input type="radio" name="answer" id="radio2" value="2">
<label for="radio2">Fusce euismod augue at diam semper congue.</label>
</div>
<div class="choice">
<input type="radio" name="answer" id="radio3" value="3">
<label for="radio3">Nullam nec ullamcorper justo, at lobortis libero. Praesent congue erat nibh, non tincidunt nisi tempor in. Nam eu mi sed nisl commodo dignissim sed non urna.</label>
</div>
<div class="choice4">
<input type="radio" name="answer" id="radio4" value="4">
<label for="radio4">Integer at convallis lorem.</label>
</div>
</div>
A: Add the .row class to your div. See the example below.
* {
font-family: helvetica, arial, sans-serif
}
input[type="radio"] {
margin: 6px;
padding: 6px;
}
.choices {
border: 1px solid skyblue;
padding: 6px;
width: 600px;
border-radius: 8px;
}
.choice {
line-height: 24px;
margin: 4px;
display: inline-block;
}
<div class="choices">
<div class="choice">
<input type="radio" name="answer" id="radio2" value="2">
<label for="radio2">Fusce euismod augue at diam semper congue.</label>
</div>
<div class="choice row">
<label for="radio3"><input type="radio" name="answer" id="radio3" value="3"> Nullam nec ullamcorper justo, at lobortis libero. Praesent congue erat nibh, non tincidunt nisi tempor in. Nam eu mi sed nisl commodo dignissim sed non urna.</label>
</div>
<div class="choice4">
<input type="radio" name="answer" id="radio4" value="4">
<label for="radio4">Integer at convallis lorem.</label>
</div>
</div>
* {
font-family: helvetica, arial, sans-serif
}
input[type="radio"] {
margin: 6px;
padding: 6px;
}
.choices {
border: 1px solid skyblue;
padding: 6px;
width: 600px;
border-radius: 8px;
}
.choice {
line-height: 24px;
margin: 4px;
display: inline-block;
}
<div class="choices">
<div class="choice">
<input type="radio" name="answer" id="radio2" value="2">
<label for="radio2">Fusce euismod augue at diam semper congue.</label>
</div>
<div class="choice">
<input type="radio" name="answer" id="radio3" value="3">
<label for="radio3">Nullam nec ullamcorper justo, at lobortis libero. Praesent congue erat nibh, non tincidunt nisi tempor in. Nam eu mi sed nisl commodo dignissim sed non urna.</label>
</div>
<div class="choice4">
<input type="radio" name="answer" id="radio4" value="4">
<label for="radio4">Integer at convallis lorem.</label>
</div>
</div>
* {
font-family: helvetica, arial, sans-serif
}
input[type="radio"] {
margin: 6px;
padding: 6px;
}
.choices {
border: 1px solid skyblue;
padding: 6px;
width: 600px;
border-radius: 8px;
}
.choice {
line-height: 24px;
margin: 4px;
display: inline-block;
}
<div class="choices">
<div class="choice">
<input type="radio" name="answer" id="radio2" value="2">
<label for="radio2">Fusce euismod augue at diam semper congue.</label>
</div>
<div class="choice">
<input type="radio" name="answer" id="radio3" value="3">
<label for="radio3">Nullam nec ullamcorper justo, at lobortis libero. Praesent congue erat nibh, non tincidunt nisi tempor in. Nam eu mi sed nisl commodo dignissim sed non urna.</label>
</div>
<div class="choice4">
<input type="radio" name="answer" id="radio4" value="4">
<label for="radio4">Integer at convallis lorem.</label>
</div>
</div> | unknown | |
d12023 | train | There are two ways to create PDFs in iOS:
If you want text in your PDF, you need to use Quartz 2D
There is no API that helps you to draw in tabular format. You need to draw lines, text by calculating x and y positions, all done manually. If you have fixed set of fields then only you can follow this approach.
Else, you can create a html page for your required format, and then set this page in PDF as an image, a very simple approach.
Both will be done using Quartz 2D
Hope this helps :)
A: Best place to start here and then here
need to draw a table with lines and add text and image to it also :)
For info refer
and docs
A: There are two ways to draw PDF.
*
*Using UIKit API:
For this your can draw pdf line by line & image by imagem i.e. Object by Object.
Link to this is : http://www.raywenderlich.com/6581/how-to-create-a-pdf-with-quartz-2d-in-ios-5-tutorial-part-1
*Using Quartz 2D Api:
Using this You can draw pdf using the UIViews. Link for the same is:
http://mobile.tutsplus.com/tutorials/iphone/generating-pdf-documents/
http://www.ioslearner.com/generate-pdf-programmatically-iphoneipad/
The UIKit Api creates a nice clean & smooth PDF. While Quartz2D framework creates a little blur pdf. So you need to be sure before using it.
Let me know if it works or any issues. | unknown | |
d12024 | train | I have similar problems. Also I often need to add and remove containers, so I don't whant to edit nginx conf everytime. My solution was using jwilder/nginx-proxy.
then you just start containers with exposed port (--expose 80, not -p 80:80) and add env variables:
-e VIRTUAL_HOST=foo.bar.com
Don't forget to transfer with your main nginx traffic with right headers:
server {
listen 80;# default_server;
#send all subdomains to nginx-proxy
server_name *.bar.com;
#proxy to docker nginx reverse proxy
location / {
proxy_set_header X-Real-IP $remote_addr; #for some reason nginx
proxy_set_header Host $http_host; #doesn't pass these by default
proxy_pass http://127.0.0.1:5100;
}
}
A: Have a look at the nginx-proxy project (https://github.com/jwilder/nginx-proxy). I wrote a tutorial in my blog which demonstrates exactly what you want to achieve using it: https://blog.florianlopes.io/host-multiple-websites-on-single-host-docker
This tool automatically forwards requests to the appropriate container (based on subdomain via the VIRTUAL_HOST container environment variable).
For example, if you want to access your container through test1.example.com, simply set the VIRTUAL_HOST container environment variable to test1.example.com. | unknown | |
d12025 | train | Unfortunately, there is no proper way of doing this without code repetition. The newly added "auto as template parameter" in C++17 only supports non-type template parameters.
The only way I can think this could work is by using a code generator to generate a fixed amount of permutations of auto and class. E.g.
template <
template <class, auto...> class T,
class... Args>
constexpr auto construct(Args&&... args) // ...
template <
template <class, auto, class...> class T,
class... Args>
constexpr auto construct(Args&&... args) // ...
template <
template <auto, class, auto...> class T,
class... Args>
constexpr auto construct(Args&&... args) // ...
template <
template <auto, class, auto, class...> class T,
class... Args>
constexpr auto construct(Args&&... args) // ...
template <
template <auto, class, auto, class, auto...> class T,
class... Args>
constexpr auto construct(Args&&... args) // ...
// and so on...
live example on wandbox
Sounds like you have a good idea for a proposal... | unknown | |
d12026 | train | try {
URL url = new URL("https://www.google.com/");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.connect();
int code = connection.getResponseCode();
if (code == HttpURLConnection.HTTP_OK) {// status 200
Scanner s = new Scanner(url.openStream());
while (s.hasNextLine()) {
s.nextLine();
break;
}
}else if(code == HttpURLConnection.HTTP_NOT_FOUND){//status 404
// TODO: url not found
}else{
// TODO: other reponse status
}
}
catch (IOException ex) {
Logger.getLogger(Week8.class.getName()).log(Level.SEVERE, null, ex);
}
This is sample code for your scenario. I used google site for URL. | unknown | |
d12027 | train | table values are references in lua. when you do
playingLevel=levels[1]
you are not copying the table value at levels[1] into playingLevel, you are getting a reference to the actual data at levels[1], so changing an array value through playingLevel is essentially the same as changing the value as if you wrote levels[1][some_index] = new_value.
if you want a copy of the data, you will need a function that will create the copy for you. (either a shallow or deep copy depending on your use case)
so your code would look like playingLevel = copyTable(levels[1]) instead where copyTable is your custom implementation of a function that knows how to create a copy of the target table. | unknown | |
d12028 | train | You can use CSS selector div.hdg:contains("Origin:") to select <div> with class="hdg" that contains word "Origing:". To get next element with class grp, you can add + .grp.
For example:
import requests
from bs4 import BeautifulSoup
url = 'https://www.helpmefind.com/rose/l.php?l=2.65689'
soup = BeautifulSoup( requests.get(url).content, 'html.parser' )
origin = soup.select_one('div.hdg:contains("Origin:") + .grp').text
class_ = soup.select_one('div.hdg:contains("Class:") + .grp').text
bloom = soup.select_one('div.hdg:contains("Bloom:") + .grp').text
parentage = soup.select_one('div.hdg:contains("Parentage:") + .grp').text
print(origin)
print(class_)
print(bloom)
print(parentage)
Prints:
Bred by Arai (Japan, before 2009).
Floribunda.
Light pink and white, yellow stamens. Single (4-8 petals), cluster-flowered bloom form. Blooms in flushes throughout the season.
If you know the parentage of this rose, or other details, please contact us. | unknown | |
d12029 | train | if it has to be an integer and integer only this is how I like to do it.
if (is_numeric($r_haslo) == false || ((int)$r_haslo != $r_haslo)) {
//is an integer
$wszystko_ok = false;
$_SESSION['e_haslo'] = "<i class=\"fas fa-user-times\"></i> Podaj tylko cyfry!";
}
With the updated code above, this now makes sure that $r_haslo is not a number first, and if it is a number, that the number is not an int. So if it's not a number or not an int then it will save the warning to the session.
This way if I send 23 and "23" both are true.
If I send 23 and "23" to is_int() function only 23 will be true.
If you never send string input then is_int() is probably the better way to go.
Update
if (strpos($mystring, ".") || is_numeric($r_haslo) == false || ((int)$r_haslo != $r_haslo))
{
//is an integer
$wszystko_ok = false;
$_SESSION['e_haslo'] = "<i class=\"fas fa-user-times\"></i> Podaj tylko cyfry!";
}
The updated code above will also make sure that there is not a '.' in the input.
Note
if the value is being passed as a number, PHP will automatically convert 12.0 and 12. to 12. if the value is being passed as a string, the srtpos() method will catch it.
A: When you say this code accepts, I'll interpret that as you are taking user input by way of a HTTP POST or GET.
The following will only assign and cast to an integer if the posted string contains digits (an unsigned integer within) otherwise it will be assigned null.
<?php
$id = isset($_POST['id']) && ctype_digit($_POST['id'])
? (int) $_POST['id']
: null;
A: You can us is_int() to check.
if (is_int($r_haslo) == false) {
$wszystko_ok = false;
$_SESSION['e_haslo'] = "<i class=\"fas fa-user-times\"></i> Podaj tylko cyfry!";
} | unknown | |
d12030 | train | With <title> it works nice, the below example shows title (acts like alt for images) for more than one path:
<svg height="200pt" viewBox="0 0 200 200" width="200pt" style="background-color: var(--background);">
<g>
<title>Gray path</title>
<path fill="none" stroke="gray" stroke-width="20" d="M 179.89754857473488 95.95256479386293 A 80 80 0 0 0 100 20">
</path>
</g>
<g>
<title>Red path</title>
<path fill="none" stroke="red" stroke-width="20" d="M 91.90160519334194 179.58904448198567 A 80 80 0 0 0 179.89754857473488 95.95256479386293">
</path>
</g>
<g>
<title>Blue path</title>
<path fill="none" stroke="blue" stroke-width="20" d="M 32.111795102681654 57.67752800438377 A 80 80 0 0 0 91.90160519334194 179.58904448198567">
</path>
</g>
<g>
<title>Green path</title>
<path fill="none" stroke="green" stroke-width="20" d="M 99.99999999999999 20 A 80 80 0 0 0 32.111795102681654 57.67752800438377">
</path>
</g>
</svg>
A: You should use title element, not alt tag, to display tooltips:
<svg version="1.1" id="svg-header-filter" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="27px" height="27px" viewBox="0 0 37 37" enable-background="new 0 0 37 37" xml:space="preserve">
<title>Hello world!</title>
<path class="header-filter-circle" d="M17.796,0C7.947,0,0,7.988,0,17.838s7.947,17.787,17.796,17.787c9.848,0,17.829-7.935,17.829-17.783 C35.625,7.988,27.644,0,17.796,0z"/>
<g>
<path class="header-filter-icon" fill="#FFFFFF" d="M15.062,30.263v-9.935l-8.607-8.703h22.343l-8.744,8.727v5.029L15.062,30.263z M8.755,12.625l7.291,7.389 v7.898l3.025-2.788v-5.086l7.426-7.413H8.755z"/>
</g>
</svg>
for chrome34: wrap graphics by g element and insert title element to this.
<svg version="1.1" id="svg-header-filter" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="27px" height="27px" viewBox="0 0 37 37" enable-background="new 0 0 37 37" xml:space="preserve">
<g>
<title>Hello world!</title>
<path class="header-filter-circle" d="M17.796,0C7.947,0,0,7.988,0,17.838s7.947,17.787,17.796,17.787c9.848,0,17.829-7.935,17.829-17.783 C35.625,7.988,27.644,0,17.796,0z"/>
<g>
<path class="header-filter-icon" fill="#FFFFFF" d="M15.062,30.263v-9.935l-8.607-8.703h22.343l-8.744,8.727v5.029L15.062,30.263z M8.755,12.625l7.291,7.389 v7.898l3.025-2.788v-5.086l7.426-7.413H8.755z"/>
</g>
</g>
</svg> | unknown | |
d12031 | train | I know this is an old question but I was looking for an answer to this question and wanted to post the answer based on comments posted here.
It looks like the answer is no, there is no single command to get the output buffer and erase it without turning it off. However, instead of repeatedly starting a new buffer, you could just erase the current buffer with ob_clean() in between calls of ob_get_contents()
For example:
ob_start();
include 'first_page.php';
$first_page = ob_get_contents();
ob_clean();
include 'second_page.php';
$second_page = ob_get_contents();
ob_end_clean(); | unknown | |
d12032 | train | Use str2func:
x = 'abs';
fh = str2func(x);
fh(-5) % Prints 5 | unknown | |
d12033 | train | I suspect the most likely answer is, sadly, that String is still the path of least resistance: the ability to reuse all the familiar list functions (and the very good support for lists in parsing libraries) is so convenient that a largish collection of libraries continue to use String despite possible technical advantages of choosing a different type.
Until the cost of the "worse" (but more convenient) choice is carefully quantified and a fix written by somebody who cares, you can expect that to pretty much stay unchanged in any given library. | unknown | |
d12034 | train | Simply add this to your java module's build.gradle.
mainClassName = "my.main.Class"
jar {
manifest {
attributes "Main-Class": "$mainClassName"
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
This will result in [module_name]/build/libs/[module_name].jar file.
A: I found this project very useful. Using it as a reference, my Gradle uberjar task would be
task uberjar(type: Jar, dependsOn: [':compileJava', ':processResources']) {
from files(sourceSets.main.output.classesDir)
from configurations.runtime.asFileTree.files.collect { zipTree(it) }
manifest {
attributes 'Main-Class': 'SomeClass'
}
}
A: I replaced the task uberjar(.. with the following:
jar {
from(configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
manifest {
attributes 'Implementation-Title': 'Foobar',
'Implementation-Version': version,
'Built-By': System.getProperty('user.name'),
'Built-Date': new Date(),
'Built-JDK': System.getProperty('java.version'),
'Main-Class': mainClassName
}
}
The exclusions are needed because in their absence you will hit this issue.
A: Have you tried the fatjar example in the gradle cookbook?
What you're looking for is the shadow plugin for gradle | unknown | |
d12035 | train | No, it is not possible with a standard ClickOnce deployment scenario.
ClickOnce is a sandboxed installation on the client side. It will not know about version 1.0 that's already installed. It is simply going to check to see whether its GUID has already been installed via ClickOnce and if so update it, but only if the previous version was deployed via ClickOnce.
In your case, if the user installed Version 1.1, both versions will be installed side by side. Version 1.0 will not be updated, because ClickOnce doesn't know there's an association since it was deployed via a different method. If they don't want version 1.0 anymore, they'll need to remove it manually. Once you've got version 1.1 deployed via ClickOnce, subsequent updates will work correctly.
Don't think of ClickOnce as something you're "including", think of it as a method of deployment.
Alternatively:
I should clarify that what you're looking for is not possible with standard ClickOnce deployment. However, you mentioned you're going to send them an initial setup file. In that case you may have a workaround that's possible:
*
*Script the setup file to remove the version 1.0 installation automatically
*Script the setup file to launch the ClickOnce installation.
For subsequent updates, simply point the user to the "pure" ClickOnce setup package, and your updates should work fine.
A: Make sure to test out your ClickOnce deployment very thoroughly in your client's environment. I am omitting details here, but there are many problems with ClickOnce. I have been supporting a ClickOnce application for 3.5 years now and have run into many problems with manifests, having to manually delete the sandbox storage folders so the updates install correctly, etc. - if you search online for ClickOnce problems you'll find quite a few issues in the MSDN forums and elsewhere, many of which MS does not appear to want to resolve as they've been open since Visual Studio 2005.
Also, be aware of a potential gotcha in ClickOnce prior to .NET 3.5 SP1. If you do not have your own software deployment certificate from a CA recognized by the client machines, Visual Studio uses a "temporary" certificate (*.pfx) which expires one year from creation. After that time, subsequent update releases will probably not install, and will show users scary messages about certificate expiration. Microsoft fixed this in .NET 3.5 SP1, but you had to dig through the release notes to find the comments that temporary or permanent certificates were no longer required. So - if you don't have a public CA certificate, and you'll be supporting this application for some time, then make sure you're on .NET 3.5 SP1.
Depending on the complexity of your scenario, since you ask about other solutions, we wound up using a "roll your own" approach that goes something like this.
Each updated release increments the assembly version as needed.
Build contains a custom step to auto-generate a file with the new assembly version.
The deployment project copies the version file to the output directory with MSI.
Each time the installed application runs, it compares its own version to the version in the version file in the deploy folder. If they differ, quit the application and launch the MSI, which we set to automatically remove older application versions.
This is a "poor man's ClickOnce" for an environment where there are no application deployment tools whatsoever avl (not even AD application advertising) so we made do. Again, this approach may not be sophisticated enough for you, but it works fine for us.
Best of luck.
A: I think in this case the "easiest" solution would be to just use the ClickOnce deployment for the 1.1 version and as part of that new version of your application have a default configuration file with a first-run flag of some sort that, when it gets to run the first time by the user and sees that first-run flag, it looks for the previous version, copies over any existing configuration settings, and then uninstalls the previous version automatically.
It would require some programming on your part, but it's the solution I settled on at a previous job to do a similar task to upgrade a utility application to use Clickonce where it didn't have that before.
A: The best way I know would be to send them an install program that:
*
*Uninstalls the current version
*Launches the ClickOnce application residing on the web.
With this, you'd have a reasonable upgrade experience, and from there out, ClickOnce can handle the upgrades on its own. | unknown | |
d12036 | train | Generally, sharing data between a group of related functions is what OOP is for - define a class that contains the functions (as methods), then instantiate the class with the particular data.
In this case though there is a class already associated with the data - it's a QuerySet of People objects. So you could define a custom QuerySet subclass for People that contains the deform methods - unfortunately in Django to get that to work you also need to define a custom Manager, overriding get_query_set to return your QuerySet subclass. | unknown | |
d12037 | train | +(MySingleton *)singleton {
static dispatch_once_t pred;
static MySingleton *shared = nil;
dispatch_once(&pred, ^{
shared = [[MySingleton alloc] init];
shared.someVar = someValue; // if you want to initialize an ivar
});
return shared;
}
From anywhere:
NSLog(@"%@",[MySingleton singleton].someVar);
Note that your iOS app already has a singleton that you can access anywhere:
AppDelegate *delegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
A: a simple singleton would be something like... in the .h:
@interface Foo : NSObject
+ (Foo *)sharedInstance;
@end
and in the .m:
static Foo *_foo = nil;
@implementation Foo
+ (Foo *)sharedInstance {
if (!_foo)
_foo = [[Foo alloc] init];
return _foo;
}
@end | unknown | |
d12038 | train | jQuery doesn't really help much with manipulating text nodes, but here it is:
var tn = $('a[name="uniqueLink1"]')[0].nextSibling;
tn.nodeValue = tn.nodeValue.replace('[', '');
Demo
$()[n] is a shorthand for $().get(n), so [0] will return a reference to the first matched DOM element inside the jQuery object, the uniqueLink1 anchor.
nextSibling, as the name implies, grabs the next sibling node. In this case, the text node that follows the given anchor element.
nodeValue gets and sets the content of the text node.
String.replace() given a string as the first argument replaces only the first occurrence, thus this should be enough enough given the DOM structure is similar to the posted one.
A: This will filter the textnodes, and remove a [ from the first on it finds:
var textNode = $('body').contents().filter(function() {
return this.nodeType == 3;
}).eq(1);
textNode.replaceWith(document.createTextNode(textNode[0].textContent.replace('[','')));
Example fiddle | unknown | |
d12039 | train | You could assign to a temporary int:
int n = t;
switch (n) {
...
}
In the context of switch (t), the compiler considers coercion to integer types including int, unsigned int, long. By assigning to a variable of type int, we collapse the wave function force it to pick the conversion we want, and there's no ambiguity when we get to the switch.
You should also seriously consider making your template conversion operator explicit if you can, as a catch-all conversion can lead to unpleasant surprises.
A: switch(t)
{
case 1:
break;
}
Here the compiler doesn't know what conversion operator to call; it's ambiguous. It could instantiate your templated conversion operator for a few different integral types or call your int conversion operator. The fact that the templated conversion operator function is undefined doesn't matter to overload resolution.
The simplest solution is to use switch (static_cast<int>(t)). | unknown | |
d12040 | train | You have to filter it by yourself.
val coll = db.collectionNames().filterNot(_.startsWith("system.")) | unknown | |
d12041 | train | You can use Math.Ceiling, you just need to divide by ten first and multiply by 10 afterwards. Divide by 10.0 to avoid integer division(Math.Ceiling takes double):
int num = 43;
int nextHigherTen = (int)Math.Ceiling(num / 10.0) * 10;
This "rounds" 41-50 up to 50. If you want it from 40-49 you could use this:
int nextHigherTen = (int)Math.Ceiling((num + 1) / 10.0) * 10; | unknown | |
d12042 | train | What is the best way to learn for
beginner?
*
*http://svnbook.red-bean.com/nightly/en/svn.intro.quickstart.html
*http://book.git-scm.com/
How do you upload updated project from
local machine to live website to a
different server, how that be done
from subversion / git? and reupload to
new version again?
With version control, you have a central repository and one or more working copies (git adds in a local repository at every working copy to allow distributed storage/management).
In your case, your live website and your development copy are both working copies - you checkout from the central repository to each of these locations. You then work on the development copy, and commit those changes to the central repository. Once you are ready to release, you simply perform an update on the live working copy which pulls all the changes from the central repository.
Can 2 or 3 people work on the same
project at the same time? do they load
the code files from the server?
wouldn't it conflict each other...
like they had removed the class
objects, functions, etc.
Yes - each person has a working copy which they make changes to.
Conflicts are likely, and will happen from time to time - but SVN and Git can deal with a lot very easily. For example, changes to code in different places of the same file are simply merged in. Changes to code at the same place in the same file will typically require manual intervention.
Perhaps the worst conflicts that can occur are what SVN calls 'tree conflicts' - changes in the folder structure. This can be a real PITA to fix - but you have to really go out of your way to cause them.
That said, the potential for conflicts (and difficulty in resolving them) in non-version controlled environments is far, far greater.
There are some practices which help prevent major conflicts from occurring:
*
*Modular code
*Clear delineation of work - stop programmers treading on each others toes
*Update your local copy before committing
*Commit small, commit often - how small? Hard to say, you start to get a feel for this... but think in terms of functions and functionality.
I think Git is probably better to start with if you don't use anything else already - the distributed system means that you are more able to resolve conflicts at the local level before pushing up to the central repository. All of my projects are use SVN (at the office and at home), but I'm starting to use Git through the Drupal project, and like what I've seen so far.
A: GIT is the newer paradigm for version control. SVN has been around for a while but GIT and Mercurial are gaining traction as they allow for "distributed version control." This means that there is no central server for your code. Everyone has the entire history and can send "patches" to each other to share code. However, git and mercurial do support a workflow very similar to having a central repository. Integrating git and "gerrit" is really great for working on a project with multiple people.
I suggest skipping svn because svn is an older technology that will actually hinder your understanding of git / mercurial because it is a different paradigm and uses different processes. GIT / mercurial works awesome just locally (no server and you are the only one using) and also for large teams.
GIT is more powerful but harder to use while mercurial has the basics in a more usable form factor.
A: I will suggest , go for git , you can access your repository on web also. With subversion, as far my knowledge goes, there is no such provision. But this should not be only reason. I have used both, git is very useful. Git's main advantage is that you don't have to be connected to master repository always. You can read more in this question which has been explained in nice way Why is Git better than Subversion?
A: As you are new to the whole Version/Source Control concept. I suggest you read a bit about VC in general.
The best way to learn would be to actually use a VCS for your day to day projects. Yes many people can work on the same things at once. And then 'conflicts' can happen. But the modern VCS lets you do something called merging.
I suggest you start with learning about git. As you are new to the whole thing it shouldn't be very hard for you. But IMHO learning SVN(which is a 'centralized version control system) and then moving in to git (which is a distributed version control system) tends to complicate things. A lot of people feel distributed VCS are the future. So i suggest you start learning either git or Hg, both are good VCSs.
Good Luck!
A: You should read a tutorial on Subversion and stay very far away from Git until you are reasonably experienced in SVN.
The best way to learn is follow a hands-on tutorial and then try the same things out yourself during your normal development workflow.
And certainly many people can work on the same project, that is one of the main reasons we use version control.
A: I would strongly recommend checking out http://hginit.com/ It uses Mercurial which is very similar to Git, but the important thing to gain from hginit is how distributed version control (and version control in general) work both independently and as part of a team. Once you understand the concepts in hginit, which distributed source control tool tool you pick is not nearly as important.
A: Subversion and git are very different in the way they deal with code, but the goal is the same.
Subversion is a centralized solution to source control. Git is a distributed solution to source control. In both cases, you can use them by yourself only or an arbitrarily large team can use them.
Subversion is centralized, meaning there is only one server. All the code lives on that machine. It's a little simpler conceptually to deal with this.
Git is distributed, meaning there are a lot of servers (everyone is a server and a client). This makes it a little more complicated to understand which one is the "right" server.
Right now, you are creating a copy of the files you want to keep somewhere else on the disk and using that as a backup. When you do this, you are doing several steps at a time (at a conceptual level):
*
*Deciding which files you want to backup
Most source control needs your help to tell it which files to track. This is known as the add command in both git and subversion.
*Backing up those files so that future changes do not impact them
This is done by commiting the changes to the files your source control is tracking for you. In subversion this is done with commit. In git, add makes git aware of the changes you make to the files and commit makes the changes saved in a permanent manner.
*Labeling the copy of the files in a manner that makes sense to you
This is done in multiple manners in the different source control technologies. Both have a history of the commits, the concept of branches/tags and different repositories (though code doesn't normally change between repositories in subversion).
In Subversion, the code is on a single server. Everyone gets it from there (originally with checkout, afterward with update). In git, you fetch remote changes from another repository.
Git has somewhat superior conflict resolution (two people changing the same thing at the same time) to subversion, but you can still get into plenty of merge headaches if you are not careful. Git rebase can be helpful, though I've only used it in an individual manner so I have not had much conflict resolution practice yet.
Git has some tools that some people swear by (bisect and grep) that I have found to be somewhat useful. Your mileage may vary :)
A: It's largely a matter of comfort, but since you are a beginner (and presumably willing to spend some time learning a new skill), I will recommend git. As someone who has used svn and git, I think your workflow looks like it would be helped by git.
Here's some questions you need to answer for yourself when thinking svn vs. git:
*
*Are you in a company where policy prevents you from using git? (If yes, use svn).
*Do you have a workflow wherein you like to create a 'topic branch' to develop a feature, and then merge it into main when you believe that feature works well? (If yes, git is better, because it actually encourages you to create branches, and merge them back very easily, whereas svn is total hell as far as creating branches and merging them into main is concerned).
*Do you prefer to commit often in small chunks so that you have a nice clean record of changes that you can selectively unroll? (I would argue that this style of development is supported better by git).
*Look at this command: http://www.kernel.org/pub/software/scm/git/docs/git-cherry-pick.html . I cannot tell you how many times I have had to do a custom release wherein I pull specific features and 'compose' an image / website / app for a quick demo. If you think you will be doing this often, think how you would do it in subversion. I can predict in advance that it's not going to be a picnic :)
There are tons of other reasons, but if your workflows look like what I have described, then you should go with git.
You can learn git from this great resource: http://progit.org/book
And remember, if you are stuck with svn and would still like to use git, that is easy too!
http://progit.org/book/ch8-1.html | unknown | |
d12043 | train | I think the root cause is that modules are separated.
If you created vapor project as vapor new, main.swift is in Run module, modelName.swift is in App module.
// Package.swift
let package = Package(
name: "hello",
targets: [
Target(name: "App"),
Target(name: "Run", dependencies: ["App"]),
],
When access to other module class, target class's access level is must use open or public.
// modelName.swift
public class moduleName: Model {
...
Please note that you must also modify other method declarations according to this change.
Thanks.
A: move modelName.swift to run folder | unknown | |
d12044 | train | Here's the problem, in your callback function, you are using animate on the $icon variable. But when you hover an other element, that variable is changed for the new hovered element.
Use $(this) in the callback or the natural queuing :
Natural queuing
jQuery('h1.sc_blogger_title').on('mouseenter', function(){
$icon = jQuery('.sc_title_bubble_icon', this);
if( ! $icon.is(':animated') ){
$icon.animate({ "margin-left" : "+=7px" }, 200).animate({ "margin-left" : "-=7px" }, 400);
}
});
http://jsfiddle.net/yhJst/1/
$(this)
jQuery('h1.sc_blogger_title').on('mouseenter', function(){
$icon = jQuery('.sc_title_bubble_icon', this);
if( ! $icon.is(':animated') ){
$icon.animate({ "margin-left" : "+=7px" }, 200, function(){
$(this).animate({ "margin-left" : "-=7px" }, 400);
});
}
});
http://jsfiddle.net/yhJst/2/
Or use a local variable.
as you discovered, the current variable is a global one. Just add the keyword var.
jQuery('h1.sc_blogger_title').on('mouseenter', function(){
var $icon = jQuery('.sc_title_bubble_icon', this);
if( ! $icon.is(':animated') ){
$icon.animate({ "margin-left" : "+=7px" }, 200, function(){
$icon.animate({ "margin-left" : "-=7px" }, 400, function(){
$icon.css('margin-left','auto');
} );
} );
}
}); | unknown | |
d12045 | train | This is the approach you want:
ngOnInit() {
this.activeRoute.queryParams.subscribe(queryParams => {
// do something with the query params
});
this.activeRoute.params.subscribe(routeParams => {
this.loadUserDetail(routeParams.id);
});
}
See https://kamranahmed.info/blog/2018/02/28/dealing-with-route-params-in-angular-5/ | unknown | |
d12046 | train | Rather than use the decodeURIComponent($.param(data)), simply use the encode method .param as $.param(data),
decodeURIComponent does just what it says, decodes it and you want to use the encoded which $.param should do for you: http://api.jquery.com/jquery.param/
NOTE: on that page they use the decodeURIComponent in an example so you can see the original decoded value/put it in a variable.
Reworked code (my assumption is that you DO return "success" string and not the actual file here?):
var myparam = var data = {File: file,NAME: 'file.txt'};
$.ajax({
url: 'requestFile?' + $.param(myparam),
type: 'GET'
}).done(function (data) {
if (data == "success") {
alert('request sent!');
}
});
NOTE: You did not show how file was defined so I can only make the assumption that it is a JavaScript object somewhere. | unknown | |
d12047 | train | It is way easier to read your file by whole lines:
char line[1024];
while(!feof(fptr))
{
if(!fgets (line , 1024 , fptr))
continue;
if(line[0] == '#') // comment
continue; // skip it
//... handle command in line here
} | unknown | |
d12048 | train | *
*It's hard to figure out the problem without any given code/model structure. From your loss graph I can see that your model is facing underfitting (or it has a lots of dropout). Common mistakes, that make models underfit are: very high lr and primitive structure (so model can't figure out the dependencies in your data). And you should never forget about the principle "garbage in - garbage out", so double-check tour data for any structure roughness.
*Well, validation accuracy in you model training logs is mean accuracy for validation set. Validation technique is based on statistics - you take random N% out of your set for validation, so average is always better if we're talking about multiple experimets (or cross validation).
*I'm not sure if I've understood your question correct here, but if you want to evaluate your model with the metric, that you've specified for it after the training process (fit() function call) you should use model.evaluate(val_x, val_y). Or you may use model.predict(val_x) and compare its results to val_y via your metric function.
*If you are using default weights for keras pretrained models (imagenet weights) and you want to use your own fully-connected part with it, you may use ONLY pretrained feature extractor (conv blocks). So you specify include_top=False. Of course there will be some positive effect (I'd say it will be significant in comparison with randomly initialized weights) because conv blocks have params that were trained to extract correct features from image. Also would recommend here to use so called "fine-tuning" technique - freeze all layers in pretrained part except a few in its end (may be few layers or even 2-3 conv blocks). Here's the example of fine-tuning of EfficientNetB0:
effnet = EfficientNetB0(weights="imagenet", include_top=False, input_shape=(540, 960, 3))
effnet.trainable = True
for layer in effnet.layers:
if 'block7a' not in layer.name and 'top' not in layer.name:
layer.trainable = False
Here I freeze all pretrained weights except last conv block ones. I've looked into the model with effnet.summary() and selected names of blocks that I want to unfreeze. | unknown | |
d12049 | train | setText() of TextView either accepts a String value as parameter to display or a integer value which is a string resource id that you have described in res/values/strings.xml
The integer value you passing is a real value and you have make the TextView to understand it as real value and not a String resource reference. So convert the integer to String and then set the value inside text view.
Solution:
l.add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int i= Integer.parseInt(l.input1.getText().toString());
int j= Integer.parseInt(l.input2.getText().toString());
int sum = i+j;
l.result.setText(String.valueOf(sum));
}
}); | unknown | |
d12050 | train | Java 8 is TLS/1.2 by default.
*
*https://blogs.oracle.com/java-platform-group/entry/java_8_will_use_tls
You can diagnose TLS in the JVM using the techniques at:
*
*https://blogs.oracle.com/java-platform-group/entry/diagnosing_tls_ssl_and_https
If you want to force TLS/1.2, see the prior answer at:
How to force java server to accept only tls 1.2 and reject tls 1.0 and tls 1.1 connections
Know that the ciphers and protocols you expose in Jetty's SslContextFactory will also have an influence on your TLS support level. (For example: you can exclude the ciphers that TLS/1.0 knows about leaving no ciphers to negotiate against)
A: Yeah, I resolved this question just now.
We can customize it by org.eclipse.jetty.util.ssl.SslContextFactory just like this:
*
*exclude TLSv1、TLSv1.1 protocol etc.
sslContextFactory.addExcludeProtocols("TLSv1", "TLSv1.1");
By the way, my jetty version is 9.4.45, default protocols("SSL", "SSLv2", "SSLv2Hello", "SSLv3") have already excluded by Jetty.
// org.eclipse.jetty.util.ssl.SslContextFactory#DEFAULT_EXCLUDED_PROTOCOLS
private static final String[] DEFAULT_EXCLUDED_PROTOCOLS = {"SSL", "SSLv2", "SSLv2Hello", "SSLv3"};
*include only TLSv1.2 protocol (some protocols etc.)
sslContextFactory.setIncludeProtocols("TLSv1.2");
The final protocols selected you can see in the method org.eclipse.jetty.util.ssl.SslContextFactory#selectProtocols , you can debug yourself. | unknown | |
d12051 | train | No idea where that specific error is coming from (it looks like it should actually be an error 1004), but I'm guessing just switching from using Activate and Select will resolve it. Try the following:
'Set source workbook
Set FonteB = ActiveWorkbook
'Open the target workbook
vFile = Application.GetOpenFilename
'if the user didn't select a file, exit sub
If TypeName(vFile) = "Boolean" Then Exit Sub
'Set targetworkbook
Set FonteA = Workbooks.Open(vFile)
Dim ws As Worksheet
Set ws = FonteB.Worksheets("USD - SCHEDULE A")
lColor = RGB(0, 0, 255)
For Each rCell In ws.Cells.CurrentRegion
If rCell.Font.Color = lColor Then
If rColored Is Nothing Then
Set rColored = rCell
Else
Set rColored = Union(rColored, rCell)
End If
End If
Next | unknown | |
d12052 | train | When using scipy.sparse.hstack() you have to ensure that all the elements you try to stack have the same 0's dimension, i.e., same number of rows. See the following example:
import numpy as np
from scipy.sparse import hstack
a = np.array([1, 2, 3, 4, 5])
b = np.array([1, 2, 3, 5])
c = hstack([a, b])
print(c)
Output:
(0, 0) 1
(0, 1) 2
(0, 2) 3
(0, 3) 4
(0, 4) 5
(0, 5) 1
(0, 6) 2
(0, 7) 3
(0, 8) 5
On the other hand when the number of rows does not match - it results in the error you are getting:
import numpy as np
from scipy.sparse import hstack
a = np.array([1, 2, 3, 4, 5, 6])
b = np.array([[1, 2, 3], [4, 5, 6]])
c = hstack([a, b])
print(c)
Output:
ValueError: blocks[0,:] has incompatible row dimensions. Got blocks[0,1].shape[0] == 1, expected 2.
So you should check that all your items are of the same number of rows to join them row-wise
Cheers. | unknown | |
d12053 | train | Taking the relevant bit of code:
public class Animal
{
//...
Organs [] vitalOrgans = new Organs[3];
//...
}
Since your declaration of vitalOrgans was never given an access modifier (i.e. one of private, public, protected) it took on default access, which means only other classes in the same package can see it. Since your other block of code is not in the same package, it cannot see the field.
A minimally viable modification to just make it work would be to set the access to public:
public class Animal
{
//...
public Organs [] vitalOrgans = new Organs[3];
//...
}
While this works, it's not necessarily the best solution, as if you ever change how vitalOrgans is represented, or need to perform any validation, those edits would have to be done throughout the application. Thus, a better solution (and also, a major stylistic convention in Java for those exact reasons) is to make it (and all your fields, in fact) private and access via methods:
public class Animal {
private String nameOfAnimal;
private Organs[] vitalOrgans = new Organs[3];
//...
public Organs[] getVitalOrgans() {
return vitalOrgans;
}
//Alternative accessor that fetches only one organ.
public Organs getVitalOrgan(int index) {
if(index >= 0 && index < vitalOrgans.length)
return vitalOrgans[index];
else
return null;
}
public void setVitalOrgans(Organs[] vitalOrgans) {
this.vitalOrgans = vitalOrgans
}
//...
}
Your caller could then access Organs via either form of the get method (note, you probably want Organs to be public):
Animal.Organs futureMammalHeart = mamal.getVitalOrgan(0); //Animal.Organs due to Organs being an inner class.
if(futureMammalHeart != null) //Demonstration of null check. Safety first!
futureMammalHeart.setNameOfOrgan("Heart");
Animal.Organs[] mammalianVitalOrgans = mamal.getVitalOrgans();
if(mammalianVitalOrgans != null) //Just in case...
System.out.println(mamal.mammalianVitalOrgans[0].getNameOfOrgan());
Also, as Ari mentioned in his answer, don't forget to initialize the organs in your array, otherwise you will get a NullPointerException!
A: You would need to initialize the vitalOrgrans with new Organs(). Like:
public Animal() {
for (int i = 0; i < vitalOrgans.length; i++) {
vitalOrgans[i] = new Organs();
}
}
Because when you say :
Organs[] vitalOrgans = new Organs[3];
You are creating an array of 3 null Organs. Hence the null pointer exception, when accessing "vitalOrgans[i].". | unknown | |
d12054 | train | This looks like a problem with the VS variable watch, that it is having trouble parsing the contents of the variable.
If you check the values in myMap using QDebug(), you'll probably find that the pairs have inserted correctly but VS is not interpreting the contents correctly.
Try uninstalling and re-installing your VS plugin and, if the problem persists, log a bug with Qt that their QMap parsing script in the VS plugin might be faulty. | unknown | |
d12055 | train | Try putting your code in Private Sub Worksheet_Change(ByVal Target as Range).
This Sub runs te code every time a cell is changed. | unknown | |
d12056 | train | Im quite certain that GMail only accepts SSL Connections. Try following Code:
import com.sun.mail.pop3.POP3Store;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.Session;
import java.io.IOException;
import java.util.Properties;
public class receive_Email {
public static void main(String[] args) {
String host="pop.gmail.com";
int port=995;
String mailStorType="pop3";
String Username="***********@gmail.com";
String Password="*******";
receiveMail(host, port, mailStorType, Username, Password);
}
// method for Receive email.....!
public static void receiveMail(String pop3Host, int port, String sotreType,String user,String password){
/// 1) get session object
Properties props = new Properties();
props.put("mail.pop3.ssl.enable", "true"); // Use SSL
Session sessEmail = Session.getInstance(props);
// 2) create pop3 store object and connect with pop server
try {
POP3Store emailStore = (POP3Store) sessEmail.getStore(sotreType);
emailStore.connect(pop3Host, port, user, password);
// 3) create Folder object and open it
Folder emailFolder=emailStore.getFolder("INBOX");
emailFolder.open(Folder.READ_ONLY);
// 4) Retrieve the messages in the folder and display it
Message[] messages=emailFolder.getMessages();
for(Message m : messages){
System.out.println("------------------------------------------------");
System.out.println("Email Number : "+m.getMessageNumber());
System.out.println("Subject : "+m.getSubject());
System.out.println("From : "+m.getFrom());
try {
System.out.println("Subject : "+m.getContent().toString());
} catch (IOException e) {
System.out.println("No messages are available.............!");
e.printStackTrace();
}
} // end for loop
// 5) Close the Folder and email store
emailFolder.close(false);
emailStore.close();
} catch (NoSuchProviderException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
}
}
}
A: I got Answer as i required thanks user user1232141 for ur kind replay..
I got the solution from this reference stactoverflow : reding all new mails
Here is the code that worked for me :
public static void receiveEmail(String pop3Host, String storeType,final String user, final String password) {
try {
//1) get the session object
Properties props = new Properties();
props.put("mail.pop3.host", "pop.gmail.com");
props.put("mail.pop3.ssl.enable", "true"); // Use SSL
props.put("mail.pop3.user", user);
props.put("mail.pop3.socketFactory", 995);
props.put("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.pop3.port", 995);
Session session = Session.getDefaultInstance(props, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, password);
}
});
//2) create the POP3 store object and connect with the pop server
Store emailStore = (Store) session.getStore(storeType);
emailStore.connect("pop.gmail.com",995,user, password);
//3) create the folder object and open it
Folder emailFolder = emailStore.getFolder("INBOX");
emailFolder.open(Folder.READ_ONLY);
//4) retrieve the messages from the folder in an array and print it
Message[] messages = emailFolder.getMessages();
for (int i = 0; i < messages.length; i++) {
Message message = messages[i];
System.out.println("---------------------------------");
System.out.println("Email Number " + (i + 1));
System.out.println("Subject: " + message.getSubject());
System.out.println("From: " + message.getFrom()[0]);
System.out.println("Text: " + message.getContent().toString());
}
//5) close the store and folder objects
emailFolder.close(false);
emailStore.close();
} catch (MessagingException e) {e.printStackTrace();}
catch (IOException e) {e.printStackTrace();}
}
as you can see i edited provided method receiveEmail(..){....} and got the answer,
Thank you srackoverflow user @wael your question helped me to find my required solution... Thank u all... | unknown | |
d12057 | train | Best place for getting dk support now is probably here: https://discuss.dronekit.io/c/python
In answer, I have not tried this on Linux. I suspect the connection string is correct, but you may have to also set the baud rate using baud=57600 | unknown | |
d12058 | train | (Assuming .NET given your user name...) These three options are different ways to use a delegate.
Creating a new thread doesn't specifically "call a method", but rather starts a new thread using a specified delegate as the method to run within the new thread. This will launch an entire new thread for you, and run your delegate within the separate thread.
Asynchronously calling the delegate via BeginInvoke/EndInvoke is similar, except that it will use the ThreadPool instead of creating a new thread.
Synchronously calling the delegate via Invoke will just call the delegate directly on the currently executing thread. This effectively just calls the method being referenced by the delegate. | unknown | |
d12059 | train | I'll come to the loop error later.
There is one little byte too much at the source:
public void sendFile(OutputStream os, String fileName) throws Exception {
File myFile = new File(fileName);
if (myFile.length() > Integer.MAX_VALUE) {
throw new IllegalStateException();
}
Either
byte[] mybytearray = Files.readAllBytes(myFile.toPath());
Or
byte[] mybytearray = new byte[(int) myFile.length()]; // No +1.
// BufferedInputStream here not needed.
try (BufferedInputStream bis = new BufferedInputStream(
new FileInputStream(myFile))) {
bis.read(mybytearray);
} // Always closed.
and then
System.out.println("Sending File!");
os.write(mybytearray);
os.flush();
}
Alternatively I have added the java 7 Files.readAllBytes. It could even be simpler using Files.copy.
I just see the main error is mentioned already. Basically there is a misconception: you may read a byte array in its entirety. It will block till the end is read. If there is less to read ("end-of-file" reached), then the number of bytes is returned. So to all purposes you might read it in a whole.
One often sees similar code to read a fixed size (power of 2) block (say 4096) repeated and written to the output stream.
Again java 7 Files simplifies all:
Files.copy(is, Paths.get("RECEIVED_" + fileName));
In Short:
public void receiveFile(InputStream is, String fileName) throws Exception {
Files.copy(is, Paths.get("RECEIVED_" + fileName),
StandardCopyOption.REPLACE_EXISTING);
}
public void sendFile(OutputStream os, String fileName) throws Exception {
Files.copy(Paths.get(fileName), os);
}
A: You probably want your condition to read:
} while (bytesRead > -1 && current < mybytearray.length);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
At the moment, when you have read the entire file, your read statement keeps reading zero bytes (mybytearray.length - current) which succeeds and returns zero, so your loop never terminates.
A: It would be much simpler to not keep appending to the input buffer
public void receiveFile(InputStream istream, String fileName) throws Exception {
System.err.println("Receving File!");
try (BufferedOutputStream ostream = new BufferedOutputStream(
new FileOutputStream("RECEIVED_" + fileName))) {
int bytesRead;
byte[] mybytearray = new byte[1024];
do {
bytesRead = istream.read(mybytearray);
if (bytesRead > 0) {
ostream.write(mybytearray, 0, bytesRead);
}
} while (bytesRead != -1);
System.err.println("Loop done");
ostream.flush();
}
}
If you can use Guava, you can use ByteStreams.copy(java.io.InputStream, java.io.OutputStream) (Javadoc) | unknown | |
d12060 | train | Why dont you assign the Key manually?
Go into each one and add [Key] above the field that should be the Key.
That should get rid of these errors. | unknown | |
d12061 | train | In your XSLT make use of:
<xsl:preserve-space elements="*" />
See: http://www.w3schools.com/xsl/el_preserve-space.asp
When I have the following input XML:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<Table1>
<row_description>Low Touch</row_description>
<_x0038_/>
<_x0039_/>
<_x0031_0/>
<_x0031_1/>
<_x0031_2/>
</Table1>
<Table1>
<row_description> DMA/ALGO</row_description>
<_x0038_/>
<_x0039_/>
<_x0031_0/>
<_x0031_1/>
<_x0031_2/>
</Table1>
<Table1>
<row_description> PT</row_description>
<_x0038_/>
<_x0039_/>
<_x0031_0/>
<_x0031_1/>
<_x0031_2/>
</Table1>
</data>
And I use the following XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" indent="yes"/>
<xsl:preserve-space elements="*" />
<xsl:template match="@*|node()">
<xsl:apply-templates select="@*|node()" />
</xsl:template>
<xsl:template match="Table1">
<xsl:for-each select="*">
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<xsl:if test="position()=1">
<Paragraph>
<Span>
<Run>
<xsl:value-of select="text()" />
</Run>
</Span>
</Paragraph>
</xsl:if>
<xsl:if test="position()>1">
<Paragraph TextAlignment="Right">
<Span>
<Run>
<xsl:value-of select="text()"/>
</Run>
</Span>
</Paragraph>
</xsl:if>
</TableCell>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The output shows as expected:
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph><Span><Run>Low Touch</Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph><Span><Run> DMA/ALGO</Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph><Span><Run> PT</Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
<TableCell Padding="10,1" BorderThickness="1,1,1,1" BorderBrush="#FF888888">
<Paragraph TextAlignment="Right"><Span><Run></Run>
</Span></Paragraph>
</TableCell>
The value <Run> PT</Run> still has the spaces in it. As XSLT processor I used Altova XMLSpy.
A: I am OP and I did this to overcome my problem
<Run xml:space="preserve"><xsl:value-of select="text()" /></Run>
Note: After writing xml:space="preserve", please make sure <xsl:value-of select="text()" />is in the same line. If we write like this
<Run xml:space="preserve">
<xsl:value-of select="text()" />
</Run>
it will also consider the indentation of xsl as text as we have said to preserve space. | unknown | |
d12062 | train | First, you need to validate your JWT token. Then when we register an application its getting registered with version V1 and Access token issuer comes with sts url and if we try to pass Access Token with V2 its failed V2 issuer is login.microsoft.com.
So fix is to go in manifest file "accessTokenAcceptedVersion": 2 for registered applications in AD. Refer to this issue. | unknown | |
d12063 | train | You should replace \r\n char with tag and create a MvcHtmlString when you want render the text, I use this:
@(MvcHtmlString.Create(Model.Text.Replace("\r\n","<br/>").Replace("\n\r","<br/>)))
Model.Text is a text from an TextArea, I've tested this line of code and it works as well on all five major browsers (IE, FF, Chrome, Opera, Safari).
A: I haven't found an actual solution but have implemented a work around.
When I set the property on my object to the submitted value from the TEXTAREA, I perform a regular expression replacement on the text to convert whatever characters are returned from the browser to '\n' which appears to work as a line break in all browsers I checked (IE8, Chrome & FireFox). Here is the code I'm using (in .NET):
cleanValue = Regex.Replace(value, "(\\n|\\\\n|\\r|\\\\r)+", "\n", RegexOptions.IgnoreCase); | unknown | |
d12064 | train | As far as I can guess, following line causing NullPointerException because your editText is null
billText.addTextChangedListener(new TextWatcher() {
May be the EditText you are trying to access here isn't in the activity_main.xml layout. So at first, make sure that the EditText with id billValue exists in the activity_main.xml.
A: You are creating a new instance of an interface not a class. Instead, you may write your activity class as
public class MainActivity extends ActionBarActivity implements TextWatcher
and add some methods to your class:
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
// TODO Auto-generated method stub
}
Try it, you will not have an exception I guess.
A: Do like the following -
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
billText.addTextChangedListener(new TextWatcher()
{
public void onTextChanged(CharSequence s,
int start, int before, int count)
{
EditText billText = (EditText) view.findViewById(R.id.billText);
billText_val = billText.getText().toString().toLowerCase();
//do anything with this value
}
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
public void afterTextChanged(Editable s)
{
}
});
}
A: You are doing that fine There Might be an Issue with the Reference of your EditText
Anyhow here is my sample code attached for this purpose.
et_email = (EditText) findViewById(R.id.et_regstepone_email);
et_email.addTextChangedListener(this);
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
if(count==0&&et_email.length()==0){
et_email.setCompoundDrawables(null, null, null, null);
}else if(count>0){
}
}
A: I had exactly the same problem.
Check the ID of your EditText in other layout xml files of the same activity. In my case it was the xml in layout-v21. I was overriding the ID of the EditText element in it. | unknown | |
d12065 | train | Go to CMD and check whether Java is installed, just type java in cmd and press enter. If java is installed it will display options etc.
If you have installed java and its not displaying even when you type this command it means java path needs to be added to the Environment variables. to do this
Select Start -> Computer -> System Properties -> Advanced system
settings -> Environment Variables -> System variables -> PATH.
Prepend C:\Program Files\Java\jdk.x.x.x\bin; to the beginning of the
PATH variable.
x.x.x is the version example jdk.6.0.27
Press OK to everything. | unknown | |
d12066 | train | Your selector:
#DropdownSeviceLink, #DropdownSeviceLinkAbandon, DropdownSeviceLinkAvgWaitingTime, DropdownSeviceLinkQueuedCalls
is wrong. You are missing #s to indicate IDs. | unknown | |
d12067 | train | You need to initialize display metrics object
You can try this:
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
flat density=metrics.density;
flat densityDpi=metrics.densityDpi;
A: Just like Surfman said. Your phone isn't at the maximum possible resolution. If you take the resolution reported within your screenshot and divide it by the reported 2.9 and multiply it by 4 you end up with roughly the maximum resolution of 2960x1440 | unknown | |
d12068 | train | private static string RpcRoutingKeyNamingConvention(Type messageType, ITypeNameSerializer typeNameSerializer)
{
string queueName = typeNameSerializer.Serialize(messageType);
return messageType.GetAttribute<GlobalRPCRequest>() != null || AvailabilityZone == null
? queueName
: queueName + "_" + AvailabilityZone;
}
where GetAttribute<GlobalRPCRequest>() is defined in public static class ReflectionHelpers
public static TAttribute GetAttribute<TAttribute>(this Type type) where TAttribute : Attribute;
then we have project B which have method:
public static string GetAttribute(this XElement node, string name)
{
var xa = node.Attribute(name);
return xa != null ? xa.Value : "";
}
I have to point out that we have reference to project B in project A.
Now what happens is that when I try to build I get compile error:
Error 966 The type 'System.Xml.Linq.XElement' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. D:\Repositories\website\website\submodules\core\src\A\Extensions\Extensions.cs 37 13 A
Whats happening is that compiler thinks that I am actually using GetAttribute method from project B(in my opinion!). Why this is happening? Since when I try to navigate to GetAttribute VS leads me to the right method (the one that is in ReflectionHelpers).
Could it be because of the reflection? NOTE: I fixed this issue by calling the method statically or adding reference to System.Xml.Linq in my project A, but I am curious of the strange behavior of VS/syntax-checking feature.
A: It's a guess, but I think your function:
private static string RpcRoutingKeyNamingConvention(Type messageType, ITypeNameSerializer typeNameSerializer) does not match your helper method signature because you try returning a string:
public static TAttribute GetAttribute<TAttribute>(this Type type) where TAttribute : Attribute; which expects a TAttribute return type.
Maybe, you can try modifiying your function RpcRoutingKeyNamingConvention to return GlobalRPCRequest and check if the compiler continues to go crazy.
A: Visual Studio gets confused all the times! I tried to reproduce the scenario in my VS 2015 (.NET 4.6) and it compiles just fine. I didn't have to add reference to System.Xml.Linq in my Project A.
My guess is that it might be a cache issue. You might want to try this:
*
*Remove reference to Project B
*Clean then rebuild both solutions
*Add the reference back
*Rebuild and voila!! Well.. hopefully
Hope it helps, let me know :)
A: I guess that's going on:
- B has reference to System.Xml.Linq
- B is built without a problem.
- You are referencing B in A
- A hasn't got a reference to System.Xml.Linq
- A seem to consume the function defined in B
- When you try to build project A, it produces that error
Am I right?
If that's the case, it is totally normal. Because a project which consumes a reference (A) must have a reference to what is referenced (System.Xml.Linq) by what it references (B).
Think like this: When you try to add a nuget package to your project if it has a dependency, nuget will install it too. Why? Because of this situation.
This is completely normal if I understand your answer correctly. | unknown | |
d12069 | train | Here is a way to fade the element when it is shown:
js <- "
$(document).ready(function(){
$('#plotContainer').on('show', function(event){
$(this).css('opacity', 0).animate({opacity: 1}, {duration: 1000});
});
});
"
ui <- fluidPage(
tags$head(tags$script(HTML(js))),
sidebarPanel(
actionButton("showplot", "Show")
),
mainPanel(
conditionalPanel(
condition = "input.showplot > 0",
id = "plotContainer",
plotOutput("plot")
)
)
)
server <- function(input, output) {
x <- rnorm(100)
y <- rnorm(100)
output$plot <- renderPlot({
plot(x, y)
})
}
shinyApp(ui, server)
EDIT
And also an effect on the hide event:
js <- "
$(document).ready(function(){
$('#plotContainer').on('show', function(){
$(this).css('opacity', 0).animate({opacity: 1}, {duration: 1000});
}).on('hide', function(){
var $this = $(this);
setTimeout(function(){
$this.show().hide(1000);
})
});
});
"
ui <- fluidPage(
tags$head(tags$script(HTML(js))),
sidebarPanel(
actionButton("showplot", "Show/Hide")
),
mainPanel(
conditionalPanel(
condition = "input.showplot % 2 == 1",
id = "plotContainer",
plotOutput("plot")
)
)
)
server <- function(input, output) {
x <- rnorm(100)
y <- rnorm(100)
output$plot <- renderPlot({
plot(x, y)
})
}
shinyApp(ui, server)
EDIT
Funny effects with the libraries Animate.css and jQuery-animateCSS:
js <- "
$(document).ready(function(){
$('#plotContainer').on('show', function(){
var $this = $(this);
$this.css('opacity', 0).
animate({opacity: 1}, 500, function(){
$this.animateCSS('jello', {
delay: 0,
duration: 2000
});
});
}).on('hide', function(){
var $this = $(this);
setTimeout(function(){
$this.show().animateCSS('heartBeat', {
delay: 0,
duration: 2000,
callback: function(){$this.hide(500);}
});
}, 0);
});
});
"
ui <- fluidPage(
tags$head(
tags$link(rel = "stylesheet", href = "https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.0/animate.compat.min.css"),
tags$script(src = "https://cdnjs.cloudflare.com/ajax/libs/animateCSS/1.2.2/jquery.animatecss.min.js"),
tags$script(HTML(js))
),
sidebarPanel(
actionButton("showplot", "Show/Hide")
),
mainPanel(
conditionalPanel(
condition = "input.showplot % 2 == 1",
id = "plotContainer",
plotOutput("plot")
)
)
)
server <- function(input, output) {
x <- rnorm(100)
y <- rnorm(100)
output$plot <- renderPlot({
plot(x, y)
})
}
shinyApp(ui, server)
EDIT
I've done some convenient R functions to bind these animations in a Shiny app. Here is the code:
library(shiny)
animateCSS <- function(effect, delay = 0, duration = 500, then = NULL){
effect <- match.arg(effect, c(
"bounce",
"flash",
"pulse",
"rubberBand",
"shakeX",
"shakeY",
"headShake",
"swing",
"tada",
"wobble",
"jello",
"heartBeat",
"backInDown",
"backInLeft",
"backInRight",
"backInUp",
"backOutDown",
"backOutLeft",
"backOutRight",
"backOutUp",
"bounceIn",
"bounceInDown",
"bounceInLeft",
"bounceInRight",
"bounceInUp",
"bounceOut",
"bounceOutDown",
"bounceOutLeft",
"bounceOutRight",
"bounceOutUp",
"fadeIn",
"fadeInDown",
"fadeInDownBig",
"fadeInLeft",
"fadeInLeftBig",
"fadeInRight",
"fadeInRightBig",
"fadeInUp",
"fadeInUpBig",
"fadeInTopLeft",
"fadeInTopRight",
"fadeInBottomLeft",
"fadeInBottomRight",
"fadeOut",
"fadeOutDown",
"fadeOutDownBig",
"fadeOutLeft",
"fadeOutLeftBig",
"fadeOutRight",
"fadeOutRightBig",
"fadeOutUp",
"fadeOutUpBig",
"fadeOutTopLeft",
"fadeOutTopRight",
"fadeOutBottomRight",
"fadeOutBottomLeft",
"flip",
"flipInX",
"flipInY",
"flipOutX",
"flipOutY",
"lightSpeedInRight",
"lightSpeedInLeft",
"lightSpeedOutRight",
"lightSpeedOutLeft",
"rotateIn",
"rotateInDownLeft",
"rotateInDownRight",
"rotateInUpLeft",
"rotateInUpRight",
"rotateOut",
"rotateOutDownLeft",
"rotateOutDownRight",
"rotateOutUpLeft",
"rotateOutUpRight",
"hinge",
"jackInTheBox",
"rollIn",
"rollOut",
"zoomIn",
"zoomInDown",
"zoomInLeft",
"zoomInRight",
"zoomInUp",
"zoomOut",
"zoomOutDown",
"zoomOutLeft",
"zoomOutRight",
"zoomOutUp",
"slideInDown",
"slideInLeft",
"slideInRight",
"slideInUp",
"slideOutDown",
"slideOutLeft",
"slideOutRight",
"slideOutUp"
))
js <- paste(
" $this.animateCSS('%s', {",
" delay: %d,",
" duration: %d,",
" callback: function(){",
" %s",
" }",
" });",
sep = "\n"
)
sprintf(js, effect, delay, duration, ifelse(is.null(then), "", then))
}
onShowJS <- function(animation, fadeDuration){
sprintf(paste(
"$('#%%s>div').on('show', function(){",
" var $this = $(this);",
" $this.css('opacity', 0).animate({opacity: 1}, %d, function(){",
animation,
" });",
"});",
sep = "\n"
), fadeDuration)
}
onHideJS <- function(animation, fadeDuration){
paste(
"$('#%s>div').on('hide', function(){",
" var $this = $(this);",
" setTimeout(function(){",
sub(
"^(\\s.*?\\$this\\.animateCSS)",
"$this.show().animateCSS",
sub(
"\\{\n \n \\}",
sprintf("{$this.hide(%d);}", fadeDuration),
animation
)
),
" }, 0);",
"});",
sep = "\n"
)
}
animatedConditionalPanel <-
function(condition, ..., onShow = NULL, fadeIn = 600, onHide = NULL, fadeOut = 400){
id <- paste0("animateCSS-", stringi::stri_rand_strings(1, 15))
jsShow <- ifelse(!is.null(onShow), sprintf(onShowJS(onShow, fadeIn), id), "")
jsHide <- ifelse(!is.null(onHide), sprintf(onHideJS(onHide, fadeOut), id), "")
script <- tags$script(HTML(paste(jsShow,jsHide,sep="\n")))
condPanel <- conditionalPanel(condition, ...)
tags$div(id=id, tagList(condPanel, script))
}
You have to use animateCSS and animatedConditionalPanel only. The animateCSS function defines an animation. You can chain the animations with the then argument. The animatedConditionalPanel functions replaces conditionalPanel. Here is an example:
ui <- fluidPage(
tags$head(
tags$link(rel = "stylesheet", href = "https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.0/animate.compat.min.css"),
tags$script(src = "https://cdnjs.cloudflare.com/ajax/libs/animateCSS/1.2.2/jquery.animatecss.min.js")
),
sidebarPanel(
actionButton("showplot", "Show/Hide")
),
mainPanel(
animatedConditionalPanel(
condition = "input.showplot % 2 == 0",
onShow = animateCSS("swing", duration = 1000, then = animateCSS("jello")),
fadeIn = 400,
onHide = animateCSS("pulse", then = animateCSS("bounce")),
plotOutput("plot")
)
)
)
server <- function(input, output) {
x <- rnorm(100)
y <- rnorm(100)
output$plot <- renderPlot({
plot(x, y)
})
}
shinyApp(ui, server)
UPDATE JUNE 2022
These animations will be available in the next version of the shinyGizmo package.
library(shiny)
library(shinyGizmo)
ui <- fluidPage(
sidebarPanel(
actionButton("showplot", "Show/Hide")
),
mainPanel(
fluidRow(
column(
10,
conditionalJS(
plotOutput("plot"),
condition = "input.showplot % 2 === 1",
jsCalls$animateVisibility("jello", "tada", duration = 1500)
)
),
column(2)
)
)
)
server <- function(input, output) {
x <- rnorm(100)
y <- rnorm(100)
output[["plot"]] <- renderPlot({
plot(x, y, pch = 19)
})
}
shinyApp(ui, server) | unknown | |
d12070 | train | Use minimum date property of the date picker to disable the all date before the minimum date. The date picker would also allow you to define range as minimum and maximum date so that it can show the date from minimum to maximum date range and remaining all other date will be disabled in picker view.
A: swift 3
datePickerEndDate.minimumDate = datePickerStartDate.date | unknown | |
d12071 | train | First of all, if you are saying autorelease, don't. Stop using manual memory management and use ARC. It knows more than you do.
Okay, so let's say you do say autorelease. Then it is placed in the autorelease pool and its retain count remains incremented. Its retain count will be decremented again when the autorelease pool is drained. When that happens depends on what autorelease pool you're talking about.
*
*If you actually made this autorelease pool, then it drains when you tell it to drain. Under ARC, that happens when we come to the end of the @autoreleasepool{} directive block.
*If it's the default autorelease pool, the runtime takes care of it and you have no knowledge or control over the matter. You can be pretty sure there will be a drain call after all you code finishes and the app is idle, but there's nothing guaranteed about it. | unknown | |
d12072 | train | To print the A1 style address to the Immediate Window, use the following. By specifying that you don't want the columns or rows to be absolute, you don't have to use the replace function.
Public Sub Test()
Debug.Print Range("A1").Offset(2, 3).Address(RowAbsolute:=False, ColumnAbsolute:=False)
End Sub
A: MyWorksheet.Range("A1").Offset(2,3).Address(False,False)
The arguments (all optional) for address are
RowAboslute - False for no dollars signs
ColumnAbsolute - False for no dollar signs
ReferenceStyle - default is xlA1 (constant value is 1 if your late binding)
External - include the workbook/worksheet name
RelativeTo - This one's a complete mystery to me. It never works how I expect. | unknown | |
d12073 | train | Resolved !
I had to downgrade to Jasmine core 2.4.1 . | unknown | |
d12074 | train | The exit code of a pipeline is the exit code of the last process in the pipeline. So here, even if process exits with code 10, the whole pipeline process | tee ... will exit with code 0.
You can change this behaviour using the pipefail option
set -o pipefail
Now the exit code of a pipeline will be the last non-zero exit code of any of the piped processes, or 0 if they all exit successfully.
This blog post explains it nicely, the official reference is the last paragraph from this section of the Bash manual.
A: Try grabbing the result of the first part of the pipe with ${PIPESTATUS[0]}:
#!/bin/sh
process() {
echo "Start..."
echo "Stop..."
exit 10
}
result=0
until [ $result -eq 10 ]
do
process | tee -a myLog.log
result=${PIPESTATUS[0]}
echo $result
done
A: Move the pipe behind the loop; the result is the same but the breaking will work:
#!/bin/sh
process() {
echo "Start..."
echo "Stop..."
exit 10
}
until [ $? -eq 10 ]
do
process
done | tee -a /home/temp/myLog.log
As others pointed out before me, the pipe's exit status is complex, so you cannot just use $? to get it. Best solution seems to be to get rid of the pipe in the context you need the exit status.
Maybe you do not even need the -a anymore this way. | unknown | |
d12075 | train | Copied From ColeX at:
https://forums.xamarin.com/discussion/179775/build-error-with-missing-file-icon1024-png
*
*Edit csproj file to remove the bogus entries (just delete them)
*Ensure that a 1024*21024 png icon (file does not have Alpha or transparent) add into Assets.xcassets
*Ensure the 1024 file information included in csproj file
Refer
Where to find 'Missing Marketing Icon'
https://forums.xamarin.com/discussion/129252/problems-with-missing-appicons-files | unknown | |
d12076 | train | Try removing getClassLoader() call:
File file = new File(getClass().getResource(fileName).getFile());
You can also open the jar file manually and check if the file is actually packaged into the jar file.
A: I solved it with the tip of EJP & What's the difference between a Resource, URI, URL, Path and File in Java?
Instead of passing a File like this:
private String fileName = "deutsch.txt";
File file = new File(getClass().getClassLoader().getResource(fileName).getFile());
private RemoteAdapter() {
this.spellchecker = SpellcheckerFactory.createSpellchecker(file);
}
I now pass a URL to the file like this:
private String fileName = "deutsch.txt";
URL url = ClassLoader.getSystemClassLoader().getResource(fileName);
private RemoteAdapter() {
this.spellchecker = SpellcheckerFactory.createSpellchecker(url);
}
Inside of the Spellchecker constructor I then just get an Inputstream of the URL and read from it. | unknown | |
d12077 | train | I don't know if this is the lightbox way to do it, but it seems to do the trick:
.lightbox .lb-image {
height : 400px !important;
width : 400px !important;
display: block;
height: auto;
border-radius: 3px;
/* Image border */
border: 4px solid white;
}
fiddle | unknown | |
d12078 | train | That is expected behavior. Technically, in cases where ALL unique keys (not just primary key) on the data to be replaced/inserted are a match to an existing row, MySQL actually deletes your existing row and inserts a new row with the replacement data, using the same values for all the unique keys. So, if you look to see the number of affected rows on such a query you will get 2 affected rows for each replacement and only one for the straight inserts.
A: This is an expected behavior if you have another UNIQUE index in your table which you must have otherwise it would add the row as you would expect. See the documentation:
REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted. See Section 13.2.5, “INSERT Syntax”.
https://dev.mysql.com/doc/refman/5.5/en/replace.html
This really also makes lot of sense because how else would mySQL find the row to replace? It could only scan the whole table and that would be time consuming. I created an SQL Fiddle to demonstrate this, please have a look here | unknown | |
d12079 | train | If you have not yet done it, create a file with dependencies for your code and specify versions explicitly (example):
Flask==0.8
Jinja2==2.6
Werkzeug==0.8.3
certifi==0.0.8
chardet==1.0.1
distribute==0.6.24
gunicorn==0.14.2
requests==0.11.1
Then (if you didn't create it yet), set up a new virtual environment, install all the requirements and check that your code is running by using the python from this environment.
*
*Install virtualenv:
python3 -m pip install --user virtualenv
*Create a virtual environment: python3 -m venv env
*Activate the virtual environment source env/bin/activate
*Install all the requirements pip install -r requirements.txt
*Run your application in the same console where you activated the virtual environment.
The Heroku uses the following command for installing dependencies pip install -r requirements.txt. So if it gives you error on your local machine you would know what's the problem. | unknown | |
d12080 | train | HttpResponse takes only one body argument, you are passing in two.
Don't create two JSON strings, build one, using a custom serializer to handle multiple querysets:
import json
from django.core.serializers.json import DjangoJSONEncoder
from django.core import serializers
from django.db.models.query import QuerySet
def get_all_from_database():
urls = Url.objects.all()
ips = Ip.objects.all()
return urls, ips
class HandleQuerySets(DjangoJSONEncoder):
""" JSONEncoder extension: handle querysets """
def default(self, obj):
if isinstance(obj, QuerySet):
return serializers.serialize("python", obj, ensure_ascii=False)
return super(HandleQuerySets, self).default(obj)
@csrf_exempt
def send_results(request):
if request.is_ajax():
address = request.POST.get('url')
urls, ips = get_all_from_database()
data = HandleQuerySets().encode({'urls': urls, 'ips': ips})
return HttpResponse(data, content_type='application/json')
I've also set the correct Content-Type header for you. | unknown | |
d12081 | train | I had the same issue with Visual Studio running on windows 8.1 in vmware player
What I had to do to solve the problem was this :
Tick the box "Virtualize Intel VT-x/EPT or AMD-V/RVI" in the processor settings of your VM
Add the line "hypervisor.cpuid.v0 = FALSE" in the file "Windows 8 x64.vmx" (add it between line 5 and 6. Not sure this matters, but at this line I'm sure it works)
Should be working fine
A: "You cannot host it in Azure. It needs to be a physical machine." -- Jeff Sanders (MSFT)
A: Florian.C's answer got me on the right track to get the emulator working correctly in VMware Fusion on my MacBook Pro. In Fusion, the settings are under the "Processors & Memory" section. You have to open the "Advanced" section at the bottom and check the "Enable hypervisor applications for this virtual machine". Once that was done, I had to also open the .vmx file and add the "hypervisor.cpuid.v0 = "FALSE"" line. Originally I copied and pasted from SO and the VM threw an error when I booted it. It turns out the " I added around FALSE were not normal quotes. Once I fixed that, the VM booted and the emulator ran just fine under Fusion. Thanks for the great info! | unknown | |
d12082 | train | The correct thing to do is not use a delimited list of filenames but use an array (and avoid uppercase variable names), this will avoid the problem of filenames containing your separator (e.g. ,) and is the idiomatic approach:
files=( *foo*.ext1 *bar*.ext2 file1 "file 2 with a space" )
for file in "${files[@]}"; do
[ -e "${file}" ] || continue
do_something_with "${file}"
done
Unless you have no control over how $files is populated this is what you want, if your script gets fed a comma-separated list and you absolutely cannot avoid it then you can set IFS accordingly as in @BroSlow's answer.
Since globbing does the right thing when expanding filenames with spaces are not a problem (not even in your example).
You might also want to check extended globbing (extglob) to be able to match more specifically.
A: If I am interpreting your question correctly you can just the internal field separator (IFS) in bash to comma and then have word-splitting take care of the rest, e.g.
#!/bin/bash
FILES="file1,file2 with space,file3,file4 with space"
IFS=','
for i in $FILES; do
echo "File = [$i]"
done
Which would output
File = [file1]
File = [file2 with space]
File = [file3]
File = [file4 with space]
Note, as Adrian Frühwirth pointed out in comments, this will fail if the filenames can contain commas. | unknown | |
d12083 | train | I'm not sure that what you want to achieve is possible. And even if a hack is possible, you don't know if a day it will be broken because of version update or API change.
In addition, using a personal account into an app running on a VM is not a good idea. The log will trace you as user and not the app identity (the service account). What are your personal actions (on your computer and your access to the Cloud) and the app actions (those perform on behalf of you)?
If your concern is about the deployment, you can have a look to terraform or you can even script you own deployment.
I'm not sure to have caught all your blockers and problems, tell us more, maybe there is good workaround!! | unknown | |
d12084 | train | It seems like your module was built on a python using USC4 encoding, while your python is using USC2.
From the python documentation:
Python was built using 2-byte Unicode characters, and the extension module was compiled using a Python with 4-byte Unicode characters.
This can easily occur when using pre-built extension packages.
The only way to solve this problem is to use extension modules
compiled with a Python binary built using the same size for Unicode
characters.
You should try to install the packages from source. The how-to for sklearn is described in the link you provided with your question - and for the scipy suite you can find instruction here. If you're not using a mac, the links on the top-right menu on that page show the guides for windows and linux as well.
A: As you are new to this, I suggest you to install https://www.continuum.io/downloads#linux
It will solve you problem as it contains scikit-learn and python and all dependencies and also a long list libraries which are used in Python for various task. Also i suggest you to use PyCharm Community Edition as IDE where you can add easily any kind of library you needed without feeling any worry.
https://www.jetbrains.com/pycharm/ | unknown | |
d12085 | train | Use getTextContent() or, even better, use a better XML API (jdom springs to mind).
A: The fact is that the node you're getting is not the text node itself. It's an Element and getNodeValue will return null (see table here). You'll have to use getTextContent instead. | unknown | |
d12086 | train | The solution below uses the tabibitosan method to create the groups. If you are not familiar with this concept, google for it - you will find many good write-ups on it. (Sometimes also called the "fixed differences" method.) The heart of the method is the creation of groups in the subquery; select the subquery and run it by itself, without the outer query, to see what it does. Look particularly at the GRP column in the subquery; if you ask yourself HOW it does that, that's where you need to read about the method.
As I explained in a Comment under your question, the SERV_YRMO column is not needed (if it is computed from the RUN_DATE value anyway), and in fact your INSERT statements have errors in that column. The solution below only uses RUN_DATE - you may as well drop the SERV_YRMO column, which will only cause trouble.
Note also that, as I pointed out in another Comment under your question, your arithmetic seems wrong. My output is different from yours, for that reason.
select to_char(min(run_date), 'yyyymm') as min_yrmo,
to_char(max(run_date), 'yyyymm') as max_yrmo,
sum(distance_in_miles) as total_distance
from (
select rl.*,
add_months( trunc(run_date, 'mm'),
-dense_rank() over (order by trunc(run_date, 'mm'))
) as grp
from running_log rl
)
group by grp
order by min_yrmo
;
MIN_YRMO MAX_YRMO TOTAL_DISTANCE
-------- -------- --------------
201801 201802 23
201812 201903 16
202003 202003 1
202103 202103 1
EDIT
The OP's version is 11 of some description. Still, for readers who may have the same question and have Oracle version 12.1 or higher, MATCH_RECOGNIZE can be used for a more efficient solution. It looks like this:
select *
from running_log
match_recognize(
order by run_date
measures to_char(first(run_date), 'yyyymm') as min_yrmo,
to_char(last (run_date), 'yyyymm') as max_yrmo,
sum(distance_in_miles) as total_distance
pattern ( a b* )
define b as run_date < add_months(trunc(prev(run_date), 'mm'), 2)
)
;
A: One method is uses dense_rank() and truncating dates to months:
select to_char(min(run_date), 'YYYY-MM'), to_char(max(run_date), 'YYYY-MM'), sum(distance)
from (select t.*,
dense_rank() over (order by trunc(run_date, 'Month')) as seqnum
from t
) t
group by trunc(run_date, 'Month') - seqnum * interval '1' month
order by min(run_date);
A: Check below SQL which use tabibitosan method of finding gap. resut consider count=1 as lake count >1 as Island
select min(run_date), MAX(run_date), count(grp), decode (count(grp),1,'LAKE','ISLAND')
from (
select run_date, run_date - rownum as grp
from omc.running_log
order by RUN_DATE
)
group by grp ; | unknown | |
d12087 | train | I suppose you'd want to go through the HTTP Protocol to create communication between the two.
In ReactJSX you want to make a fetch/get call that is provided with an EndPoint/REST from your backend.
// at the beginning of your file
import axios from 'axios';
// in your component constructor
state = {
yourStateWithTheRecievedData: "",
}
// as a component method
componentDidMount = () => {
axios
.get('http://localhost:8080/YourBackendAPI')
.then(response => {
this.setState({
yourStateWithTheRecievedData: response.data.yourStateWithTheRecievedData
})
console.log(response.data.yourStateWithTheRecievedData)
})
}
You should now have a state with the data you've recieved. If you have a hard time doing this, i suggest you start off by first applying it to a public API.
You can find a list of public API's here | unknown | |
d12088 | train | All these answers are poor and honestly none of you would be touching my databases. You are teaching him the wrong way. Tell me why should you delete from a table when there is no relationship between Fruit and User table? You DELETE only from the HREF/link table for there is the only relationship. Otherwise your database Architecture is badly designed. There should be A CASCADE DELETE on UserID on the Mapping table.
A: Create a simple stored procedure for this
CREATE PROCEDURE Delete_ThreeTablesData
@UserId INT
AS
BEGIN
DELETE FROM Fruit
WHERE FruitId = (SELECT TOP 1 FruitId
FROM UserFruitMapping
WHERE UserId = @UserId)
DELETE FROM UserFruitMapping
WHERE UserId = @UserId
DELETE FROM User
WHERE UserId = @UserId
END
A: Deleteing records from all tables can be a really messy task. Especially when there are lots of Foregin Key constraints.
If I find myself in a similar situation, I prefer to Script out the database obviously without the data and just drop the old database.
Finally create a new Fresh database using the script.
Where to find Advance Scripting options
To select "Schema Only" when generating scripts | unknown | |
d12089 | train | Yes - you suppose the problem is related to cross-site access, while in reality it's related to cross-thread access (first line of error indicates this clearly).
I'm assuming you're trying to set some UI element's data bound (or not, doesn't matter) property directly from the callback handling the service call. (edit) Forgot to clarify - where the callback is running on a thread different from the UI thread. Silverlight like most other frameworks disallows modifying UI except from the UI thread.
If so, take a look at how to use Dispatcher in order to switch back to the UI thread. | unknown | |
d12090 | train | These are considered Unicode properties.
The Unicode property \p{L} — shorthand for \p{Letter} will match any kind of letter from any language. Therefore, \p{Lu} will match an uppercase letter that has a lowercase variant. And, the opposite \p{Ll} will match a lowercase letter that has an uppercase variant.
Concisely, this would match any lowercase/uppercase that has a variant from any language:
AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz | unknown | |
d12091 | train | The key here is that you need to JOIN your other tables, then ORDER BY some expression on their fields.
SELECT key_value
FROM table
LEFT JOIN table_b on table_b.field = table.key_value
LEFT JOIN table_c on table_c.field = table.key_value
LEFT JOIN table_d on table_d.field = table.key_value
ORDER BY table_b.some_field DESC, (table_c.another_field / table_d.something_else) ASC
;
Depending on the join conditions, you may need to GROUP BY table.key_value or even use subqueries to attain the appropriate effect. | unknown | |
d12092 | train | Change your code to the following:
bTijd.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
You have set the color to transparent by adding the first '0'.
A: You have made their Foreground transparent by setting a zero alpha value in Color.FromArgb.
Set the Foreground to Colors.Black instead, e.g.
bTijd.Foreground = new SolidColorBrush(Colors.Black);
or of course
bTijd.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
A: pName.Foreground = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
The first parameter of Color.FromArgb is the alpha channel. That is, the opacity. And you're setting it to 0, which explains why the TextBlock is invisible. Just set it to 255 instead:
pName.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
Or use the Colors enumeration:
pName.Foreground = new SolidColorBrush(Colors.Black); | unknown | |
d12093 | train | if you use dnn and routing, I have found usefull to use #
Usually I insert in Angular useHash: true:
imports: [RouterModule.forRoot(routes, { useHash: true })],
Let me know
Matteo | unknown | |
d12094 | train | You should pass in the application context rather than a context from the local activity. I.e. use context.getApplicationContext() and save that in a local variable in your AsyncTask subsclass.
The code might looks something like this:
public class MyAsyncTask extends AsyncTask {
Context context;
private MyAsyncTask(Context context) {
this.context = context.getApplicationContext();
}
@Override
protected Object doInBackground(Object... params) {
...
}
@Override
protected void onPostExecute(List<VideoDataDescription> result) {
super.onPostExecute(result);
MainActivity.progressDialog.dismiss();
context.startActivity(new Intent(context, ResultsQueryActivity.class));
}
}
you'd call it like this:
new MyAsyncTask(context).execute();
A: I tried this just now ... it works in PostExecute Method!!!
Intent intent_name = new Intent();
intent_name.setClass(getApplicationContext(),DestinationClassName.class);
startActivity(intent_name);
A: But its better if you start a new Intent Based on the response(result) obtained from the previous activities.
This will eliminate the possibility of the error response from invoking the new intent.
Example if the previous activity was supposed to return Succesfully... or Welcome to allow the new intent to start, the i could check it out in this way
protected void onPostExecute(String result) {
if (result.equals("Succesfully...")){
context.startActivity(new Intent(context, Login_Activity.class));
Toast.makeText(context, result, Toast.LENGTH_LONG).show();
}else if (result.contains("Welcome")){
context.startActivity(new Intent(context, MainActivity.class));
}else {
Toast.makeText(context,result,Toast.LENGTH_LONG).show();
}
} | unknown | |
d12095 | train | self.l.VAR2 = (self.datas[0].close * 2 + self.datas[0].high + self.datas[0].low) / 4
self.l.VAR3 = bt.talib.EMA(self.l.VAR2, timeperiod=self.params.ema1)
self.l.VAR4 = bt.talib.STDDEV(self.l.VAR2, timeperiod=self.params.ema1, nbdev = 1.0)
self.l.VAR5 = ((self.l.VAR2 - self.l.VAR3) / self.l.VAR4 * 100 + 200) / 4
self.l.VAR6 = (bt.talib.EMA(self.l.VAR5, timeperiod=self.params.ema2) - 25) * 1.56
self.l.AK = bt.talib.EMA(self.l.VAR6, timeperiod=self.params.ema3)* 1.22
self.l.AD1 = bt.talib.EMA(self.l.AK, timeperiod=self.params.ema3)
self.l.AJ = 3 * self.l.AK - 2 * self.l.AD1 | unknown | |
d12096 | train | For this, if you want to create a new event for each new entry in spread sheet you could use Calender class and create an event.
If you want to edit an already created event and add new guests you could use CalendarEvent class and add guests.
Hope that helps! | unknown | |
d12097 | train | I solved this problem in this way:
*
*Go to Settings > Apps
*Find your app and open the App Info
*Open the overflow menu (3 vertical dots)
*Choose Uninstall for all users.
A: For Redmi or Mi Phones, the debug app was got installed on second space.
*
*Go To Setting -> Second Space -> Open Second Space.
*Settings -> App - > downloaded app list.
*Click on the application, You want to Uninstall.
*Click on Uninstall.
*Back to First space from setting.
Or For Other Phones
*
*Go to settings -> apps -> downloaded app list
*You can see the installed applications in the list
*Click on the Application
*Click on uninstall for all users options.
A: I solved this issue by uninstalling debug version of the app and then clearing data of play store app.
If this still doesn't work, you can follow these steps given in this site.
Go to any root file manager, and navigate to directory: root >>
data/data folder.
Find the relevant folder of that app which you were installing from
play store.
Then delete that folder. [Note: Here you will loose all data related
to that app].
Now go to play store, and try to install that app again.
Check you have fixed your error.
Hope this helps!
Update:
Thanks Abhishek, you can also try uninstalling the app using adb:
adb shell pm uninstall com.packagename
A: Somehow adb shell pm uninstall com.packagename
did not work for me. I am not sure if this was because I was on a lollipop device.
The answer suggested in this link did the trick. Hope this helps someone else.
A: *
*Go to settings > apps > downloaded app list
*You can see the installed applications in the list (may be towards the very end)
*Click on the application,go to the menu option
*Click on uninstall for all users options | unknown | |
d12098 | train | PCA is a type dimension reduction and I quote wiki:
It is commonly used for dimensionality reduction by projecting each
data point onto only the first few principal components to obtain
lower-dimensional data while preserving as much of the data's
variation as possible.
To me, your data X[0] and only 1 dimension.. How much more can you reduce it?
If it is a case of testing the rmse for the first entry, you still need to fit the pca on the full data (to capture the variance), and only subset the rmse on 1 data point (though it might be meaningless, because for n=1 it is not rmse but square of residuals)
You can see below:
import numpy as np
from sklearn import datasets
from sklearn.decomposition import PCA
from sklearn.metrics import mean_squared_error
iris = datasets.load_iris()
Xdata = iris.data
components = [2,3]
for n in components:
pca = PCA(n_components=n)
recon = pca.inverse_transform(pca.fit_transform(Xdata))
rmse = mean_squared_error(Xdata[0], recon[0],squared=False)
print("RMSE: {} with {} components".format(rmse, n))
The output:
RMSE: 0.014003180182090432 with 2 components
RMSE: 0.0011312185356586826 with 3 components | unknown | |
d12099 | train | The links to your website should have a parameter with some key that will allow you to identify the partner site.
Another approach would use the Referer http header but is less reliable.
A: Sorry, I din't understood at first place the question.
You can grab the referer using PHP or link the banners to a landing page instead of to the home directly (ex: http://yoursite.com/banner.php?id=N, you can identify the referer with PHP and with the banner ID and then redirect the user to your home. | unknown | |
d12100 | train | Just add overflow: hidden to your .nav > li class. Like this one:
nav > li {
position: relative;
display: block;
overflow: hidden;
}
A: If your goal is to hide the horizontal scroll bar as in the image above, you can try:
<style type="text/css">
body {
overflow-x:hidden;
}
</style> | unknown |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.