Id
int64 2.49k
75.6M
| PostTypeId
int64 1
1
| AcceptedAnswerId
int64 2.5k
75.6M
| Question
stringlengths 7
28.7k
| Answer
stringlengths 0
24.3k
| Image
imagewidth (px) 1
10k
|
---|---|---|---|---|---|
22,524,367 | 1 | 22,524,918 | I have edittext and below that one listview now if need to search means based on text on edittext i need to update the list view.the listview values stored in arraylist
<IMAGE> | This is the search function in my applicaton,hope u get him idea from it..
'''
et_artists_searchWord.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// TODO Auto-generated method stub
List<AdapterDTOArtist> list = filter(s.toString(),
mAdapterDTOsBackup, true);
mAdapterDTOs.clear(); // <--- clear the list before add
mAdapterDTOs.addAll(list); // <--- here is the double add if
// you// do not clear before
mLazyAdatper.setDataSet(mAdapterDTOs);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
'''
out side oncreate search method:
'''
public static List<AdapterDTOArtist> filter(String string,
Iterable<AdapterDTOArtist> iterable, boolean byName) {
if (iterable == null)
return new LinkedList<AdapterDTOArtist>();
else {
List<AdapterDTOArtist> collected = new LinkedList<AdapterDTOArtist>();
Iterator<AdapterDTOArtist> iterator = iterable.iterator();
if (iterator == null)
return collected;
while (iterator.hasNext()) {
AdapterDTOArtist item = iterator.next();
// if(item.getmTag_Name().startsWith(string))
if (item.getmTag_Name().toLowerCase().startsWith(string)){
// if
// (item.getmTag_Name().toLowerCase(Locale.getDefault()).contains(string))
collected.add(item);
}
else if(item.getmTag_Name().toUpperCase().startsWith(string)){
collected.add(item);
}
}
return collected;
}
}
''' | |
28,270,039 | 1 | 28,270,149 | I have made some changes through repo at . you can see the changes made as below
What command can I use to do such?
For instance if I was to roll back to the last one 0416f69, what command can I execute ?
Later if I were to readd the changes back, what command can I use?
<IMAGE> | There are few options:
1. Do a git patch from your changes and later apply them.
2. Checkout the lats required commit (Detached head) and then create a new branch form the point that you wish to keep. git checkout <commit id>
3. Do a git revert on the unwanted commits
4. Backup your current work to a new branch and later on do a cherry pick on the required commits.
Good luck and hope it was helpful for you. | |
22,878,285 | 1 | 22,878,425 | I have created a layout as shown in image below:
<IMAGE>
Now the problem its having so space between the image and the like/heart layout which i have highlighted in red line. I have tried a lot to remove it but the thing is it does not show the space in the graphical layout. But whenever i try to run the application the space always shown.
I don't understand where exactly this space is coming from. I have tried all the possible things.
Please help me out to remove the space.
Here is the layout code:
'''
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/bg_selector">
<LinearLayout
android:id="@+id/sp_color"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight=".9"
android:orientation="vertical"
android:padding="10dp" >
<ImageView
android:id="@+id/sp_image"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight=".8"
android:background="@drawable/baby1"
android:scaleType="fitXY" />
<TextView
android:id="@+id/sp_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:gravity="center"
android:text="Hello World" />
</LinearLayout>
<LinearLayout
android:id="@+id/sp_linh"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="15dp"
android:layout_weight=".10"
>
<LinearLayout
android:id="@+id/ll_clk_hrts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp" >
<ImageView
android:id="@+id/sp_imageHeart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="5dp"
android:src="@drawable/heart" />
<TextView
android:id="@+id/sp_hearts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="12"
android:textSize="15sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/sp_ll_like_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="5dp" >
<ImageView
android:id="@+id/sp_imageLike"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:paddingLeft="5dp"
android:src="@drawable/ic_like" />
<TextView
android:id="@+id/sp_likes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:text="4"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
'''
code:
'''
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#EBEBEB" />
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
<stroke android:width="1dp"
android:color="@android:color/black"
/>
</shape>
'''
Thanks. | Two ideas:
- 'LinearLayout''android:layout_height="wrap_content"'- 'Space''@+id/sp_linh' | |
13,055,001 | 1 | 13,055,152 | I need to create a custom checkBox control. So far I have:
<IMAGE>
So at the root instead of having UserControl or Window I have Checkbox. (On my code behind I inherit from CheckBox in order for this to work)
When I make that change I get the box that I highlighted on the first image. I do not want to have that box.
Also I will like to overide the functionality of the checkbox control. I will like for it to be checked when I click on the image that shows the 0 or 1. Right now if I click outside the image on the shade of the square for example I will fire the Cheked event. How can I overide that functionality? I already have my own animations that trigger when the mouse enters the number image and also when the mouse is down etc.
## Edit
The reason why I avoided having visual states is because I need to fire events when the mouse enters a spesific image not any part of the control. In other words when using the visual states and I applied a style for the mouse over event that event fired if I placed my mouse anywhere inside the usercontrol. | '''
<CheckBox x:Class="WpfApplication1.MyCustomCheckBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<CheckBox.Template>
<ControlTemplate>
<TextBlock>Whatever</TextBlock>
</ControlTemplate>
</CheckBox.Template>
</CheckBox>
''' | |
26,554,890 | 1 | 26,555,013 | I am trying to add Volley to my android project in Android Studio.
I downloaded Volley from git, and added it as a module using the Project Structure tool, as an android library. I fixed the errors regarding the build version an was able to compile with the new module added to my project. I started writing code and the Volley stuff even shows up in my auto complete and the packages were automatically added to my source file.
But when I compile, i get 'error: package com.android.volley does not exist'
Does anyone know what my problem is?
here is my project structure:
<IMAGE>
here is my apps build.gradle:
'''
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.loop"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v13:20.0.0'
compile 'com.google.android.gms:play-services:4.4.+'
}
'''
and settings.gradle:
'include ':app', ':volley'' | I had to add 'compile project(':volley')' to my dependencies under build.gradle
so final code is
'''
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v13:20.0.0'
compile 'com.google.android.gms:play-services:4.4.+'
compile project(':volley')
}
''' | |
30,437,029 | 1 | 30,437,713 | My need is very generic, I have to implement an UIView subclass which groups an UIImageView, x-centered on the screen and distant 20 pts from top, and a UILabel with a description.
I have no problems doing it with interface builder, but since I needed to make it programmatically I looked after techniques and best practices.
So far I came up with this code, starting to visualize just the image. Despite it is very basic, I am not able to understand why the view isn't deriving (as you can see from the screenshot) the proper frame which should be "offsetted" 20 points on all edges from the image view.
Here's my subclass:
'''
@interface ProgrammaticAutolayoutView : UIView
@property (nonatomic, strong) UIImageView *imageView;
@end
'''
'''
#import "ProgrammaticAutolayoutView.h"
@implementation ProgrammaticAutolayoutView{
BOOL _didUpdateConstraints;
}
- (instancetype)init
{
return [self initWithFrame:CGRectZero];;
}
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
_didUpdateConstraints = NO;
_imageView = [UIImageView new];
[_imageView setTranslatesAutoresizingMaskIntoConstraints: NO];
[self addSubview: _imageView];
}
return self;
}
- (void) updateConstraints{
if(!_didUpdateConstraints){
[self setupConstraints];
}
[super updateConstraints];
}
- (void) setupConstraints{
[self.imageView addConstraint:[NSLayoutConstraint constraintWithItem:self.imageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:50]];
[self.imageView addConstraint:[NSLayoutConstraint constraintWithItem:self.imageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:50]];
[self addConstraint:[NSLayoutConstraint constraintWithItem: self.imageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:20.0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem: self.imageView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:20.0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem: self.imageView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeading multiplier:1.0 constant:20.0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem: self.imageView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:20.0]];
_didUpdateConstraints = YES;
}
@end
'''
and this is the snippet of code I use to instantiate and draw this uiview subclass:
'''
- (void)viewDidLoad {
[super viewDidLoad];
ProgrammaticAutolayoutView *test = [[ProgrammaticAutolayoutView alloc] init];
[test setTranslatesAutoresizingMaskIntoConstraints:NO];
test.imageView.image = [UIImage imageNamed:@"dmy"];
test.backgroundColor = [UIColor redColor];
[self.view addSubview: test];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem: test attribute:NSLayoutAttributeCenterX relatedBy: NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem: test attribute:NSLayoutAttributeCenterY relatedBy: NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
[test setNeedsLayout];
[test layoutIfNeeded];
}
'''
I was expecting to see the subview with an offset of 20 points from all edges of the uiimageview, but the result is completely different, I have no debugger logs or inconsistencies whatsoever, clearly I must be missing something very basic, but so far I didn't understand what.
<IMAGE> | The constants describe X and Y offsets. Your 4 constraints say:
- - - -
That is what your picture shows.
To make the red box frame the image you can make two of your constants negative:
'''
[self addConstraint:[NSLayoutConstraint constraintWithItem: self.imageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:20.0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem: self.imageView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-20.0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem: self.imageView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeading multiplier:1.0 constant:20.0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem: self.imageView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:-20.0]];
'''
switch the order of the items in the bottom and trailing constraints:
'''
[self addConstraint:[NSLayoutConstraint constraintWithItem: self.imageView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:20.0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem: self attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.imageView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:20.0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem: self.imageView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeading multiplier:1.0 constant:20.0]];
[self addConstraint:[NSLayoutConstraint constraintWithItem: self attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.imageView attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:20.0]];
'''
---
The new suggested constraints say:
- -
- - | |
3,287,318 | 1 | 3,287,343 | i am on windows/apache/mysql/php setup. i have recently reinstalled PHP. but i found that it broke certian things. simple scripts like just 'phpinfo()', 'echo', simple OO class definitions etc works. but my Zend Framework app failed. same as the doctrine 2 sandbox i am working on. they both returned the ... below ... screen
<IMAGE>
i also noticed that if i accessed the zend framework app without 'vhost' ('http://localhost/php/learningzf/public' vs 'http://learningzf'), it works, except that css which points to the wrong place (server root) fails
# UPDATE
it seems to work again now. not sure why too | have you configured your vhosts? | |
29,867,865 | 1 | 29,868,411 | I have build a rest service using tomcat and jersey.
The used web.xml contains only:
'''
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
'''
The pom.xml file contains:
'''
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.pi4j</groupId>
<artifactId>pi4j-core</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
</project>
'''
This is part of the java file I use as the implementation of the service:
'''
@Path("/light")
public class Hello {
// This method is called if TEXT_PLAIN is requested
@GET
@Path("/state/")
@Produces(MediaType.TEXT_PLAIN)
public String getStateOfLights() {
return "hi";//getLightsStateAsJSON();
}
}
'''
<IMAGE>
The index.html file directly under the WebContent directory is reachable through localhost:8080/ha/index.html. This is working as expected.
If I want to test my rest service I call: <URL>
And what do I get: HTTP Status 404: Not found
What am I missing here?
This is the server log :
'''
Apr 25, 2015 7:07:32 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:ha' did not find a matching property.
Apr 25, 2015 7:07:32 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/werner/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Apr 25, 2015 7:07:32 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Apr 25, 2015 7:07:32 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Apr 25, 2015 7:07:32 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 620 ms
Apr 25, 2015 7:07:32 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 25, 2015 7:07:32 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.59
Apr 25, 2015 7:07:33 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [548] milliseconds.
Apr 25, 2015 7:07:34 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Apr 25, 2015 7:07:34 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Apr 25, 2015 7:07:34 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2641 ms
''' | You are missing '<init-param>' in your web.xml. it should be:
'''
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.example</param-value> <!-- where com.example.Hello is your Hello class -->
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
'''
Replace 'com.example' with the package of your 'Hello' class. | |
26,858,689 | 1 | 26,858,995 | I want to create button click to navigate one activity to another activity screen looks like iPhone navigation. Here below I have added another activity call code but if I use this code I can call another activity with popup option. I need navigation Right to Left with second activity page back button...
'''
Intent intent = new Intent(AppMainActivity.this, ForgotPasswordActivity.class);
AppMainActivity.this.startActivity(intent);
'''
<IMAGE> | If I understand you correctly you can use animation and maybe this tutorial is your friend
<URL>
Sorry I'm not familiar with formatting links correctly in stack overflow. Hop it is allowed to post link directly like this..
In the activity which slides from left to right I would place a back button with a ''reverse animation'' which just slides back from right to left the activity you started from. Hope it helps..
Regarding to your second question in the coments below:
Simply create two more XML-files in the anim ordner and call them animation3.xml animation4.xml:
animation3 include:
'''
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="-100%p"
android:toXDelta=" 0%p"
android:duration="500">
</translate>
'''
animation4:
'''
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta=" 0%p"
android:toXDelta=" 50%p"
android:duration="500">
</translate>
'''
and call These XML-files in your onCLick-Method of the Back-button the same way you did before for slide to the nex activity ! ;-)
means the Offset on the X-Axis in centum. Example: 100%p means view is on the right sight completely out of view(for your eye, because in reality, the Animation is just an Illusion, it's not really sliding out). Example 2: 50%p means it half slided to the right, so 50% of the view is visible on the right side of your Screen.
means where you want to slide(direction) and how far you want to slide
gives you the power to decide how much time the Animation should take until it's finished. The duration is setted in milliseconds.
So now you are more flexibly of using transitions.
English is not my native language, but i give my best to make it clear to you. I hope it helps you. | |
28,878,070 | 1 | 28,882,882 | I have deployed a cxf-jaxws-javafirst maven project with its default method: HelloWorld.sayHi(String text).
<URL>
<IMAGE>
On the other hand, I have a soap client implemented on Nodejs with soap module.
'''
var express = require('express')
var app = express()
//soap module
var soap = require('soap');
//url of the wsdl
var url = 'http://localhost:8080/prueba/HelloWorld?wsdl';
//variable
var args = {arg0: 'friend'};
app.get('/', function (req, res) {
soap.createClient(url, function(err, client) {
client.sayHi(args, function(err, result) {
res.send(result);
});
});
})
var server = app.listen(3000, function () {
var host = server.address().address
var port = server.address().port
console.log('Example app listening at http://%s:%s', host, port)
})
'''
I have try to send soap message to other WebService, e.g. <URL> and my client code works, so I think I have some error in my WebService.
In my maven project I have just added this line of code just above the declaration of the interface for debugging messages into and out of my web service :
'''
@org.apache.cxf.feature.Features(features = "org.apache.cxf.feature.LoggingFeature")
'''
In this way I got the input message(soap client) and output message(WebService response):
Input Message:
'''
mar 05, 2015 1:33:08 PM org.apache.cxf.services.HelloWorldImplService.HelloWorldImplPort.HelloWorld
INFORMACION: Inbound Message
----------------------------
ID: 17
Address: http://localhost:8080/prueba/HelloWorld
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml; charset=utf-8
Headers: {Accept=[text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8], accept-charset=[utf-8], accept-encoding=[none], connection=[close], Content-Length=[230], content-type=[text/xml; charset=utf-8], host=[localhost:8080], SOAPAction=[""], user-agent=[node-soap/0.8.0]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://prueba.prueba/"><soap:Body><sayHi><arg0>Hola</arg0></sayHi></soap:Body></soap:Envelope>
'''
Output Message:
'''
mar 05, 2015 1:33:08 PM org.apache.cxf.services.HelloWorldImplService.HelloWorldImplPort.HelloWorld
INFORMACION: Outbound Message
---------------------------
ID: 17
Response-Code: 500
Encoding: UTF-8
Content-Type: text/xml
Headers: {}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Unexpected wrapper element sayHi found. Expected {http://prueba.prueba/}sayHi.</faultstring></soap:Fault></soap:Body></soap:Envelope>
'''
And Java error:
'''
mar 05, 2015 1:33:08 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
ADVERTENCIA: Interceptor for {http://prueba.prueba/}HelloWorldImplService#{http://prueba.prueba/}sayHi has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unexpected wrapper element sayHi found. Expected {http://prueba.prueba/}sayHi.
at org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:106)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:251)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:171)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:293)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:212)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:268)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
'''
Whit SoapUI, I achieve send the string:
This is the InputMessage (Client: SoapUI).
'''
ID: 18
Address: http://localhost:8080/prueba/HelloWorld
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml;charset=UTF-8
Headers: {accept-encoding=[gzip,deflate], connection=[Keep-Alive],
Content-Length=[285], content-type=[text/xml;charset=UTF-8], host=[localhost:8080],
SOAPAction=[""], user-agent=[Apache-HttpClient/4.1.1 (java 1.5)]}
Payload: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pru="http://prueba.prueba/">
<soapenv:Header/>
<soapenv:Body>
<pru:sayHi>
<!--Optional:-->
<arg0>"?"</arg0>
</pru:sayHi>
</soapenv:Body>
</soapenv:Envelope>
'''
I do not know I'm doing wrong, I hope someone can help me.
Thank you in advance. | I have tried to remove the namespace 'pru' from SoapUI and I have got the same error so this is my error, I have to get add the namespace. 'Pru' refers to namespace 'tns' of my wsdl.
I read the issues of github of node-soap and one refers to the namespace 'tns'.
<URL>
I have changed these line of wsdl.js file:
'''
this.ignoredNamespaces= [ 'tns', 'targetNamespace', 'typedNamespace']
WSDL.prototype._ignoredSchemaNamespaces = ['tns', 'xs', 'xsd'];
'''
by
'''
this.ignoredNamespaces= [ 'targetNamespace', 'typedNamespace']
WSDL.prototype._ignoredSchemaNamespaces = ['xs', 'xsd'];
'''
and my code works.
Thank you herom | |
25,611,637 | 1 | 25,611,956 | ## My aim
I'm trying to display, for every table in my database, an HTML one which should have:
- -
Just like this one:
<IMAGE>
## My code
'''
<?php
$num = 0;
$connessione = mysqli_connect();
$tables = mysqli_query($connessione,"SHOW TABLES");
while($row = mysqli_fetch_array($tables)){
echo '<i>'.$row['Tables_in_my_db'].'</i><table border="1px"><tr>';
$columns = mysqli_query($connessione,"SHOW COLUMNS FROM ".$row['Tables_in_my_db']);
while($row2 = mysqli_fetch_array($columns)){
echo '<td><b>'.$row2['Field'].'</b></td> ';
}
echo '</tr>';
$query = "SELECT * FROM ".$row['Tables_in_my_db'];
$fields = mysqli_query($connessione,$query);
echo '<tr>';
while($row3 = mysqli_fetch_array($fields)){
echo '<td>'.$row3[$num].'</td>';
$temp = $num+1;
if($row3[$temp]==""){break;}
$num = $temp;
}
echo '</tr></table>';
$num = 0;
}
?>
'''
## What's not working
I get only the first two lines per table as output (the first containing the names of the columns, the second one with some values which aren't in the same record of database).
## Debugging
'error_reporting(E_ALL)' returns a bunch of 'Notice: Undefined offset on line 19'
## My question
How can I fix this code? | Try this one:
'''
$connessione = mysqli_connect();
$tables = mysqli_query( $connessione, "SHOW TABLES" );
while( $row = mysqli_fetch_array( $tables ) ){
echo '<i>' . $row[ 'Tables_in_my_db' ] . '</i><table border="1px">';
// Show columns
$columns = mysqli_query( $connessione, "SHOW COLUMNS FROM ".$row[ 'Tables_in_my_db' ] );
// Here we collect column names to output row values in the same order
$columnNames = array();
echo '<tr>';
while( $row2 = mysqli_fetch_array( $columns ) ){
$columnNames []= $row2[ 'Field' ];
echo '<td><b>' . $row2[ 'Field' ] . '</b></td> ';
}
echo '</tr>';
// Show table rows
$query = "SELECT * FROM " . $row[ 'Tables_in_my_db' ];
$fields = mysqli_query( $connessione, $query );
$maxRows = 10;
while( $row3 = mysqli_fetch_array( $fields ) ){
echo '<tr>';
foreach( $columnNames as $columnName ) {
echo '<td>' . $row3[ $columnName ] . '</td>';
}
echo '</tr>';
$maxRows--;
if( !$maxRows ) {
break;
}
}
echo '</table>';
}
''' | |
10,042,857 | 1 | 10,045,279 | <IMAGE>
Is there any filters available in ios to convert a image to cartoonistic image like exactly in the above picture? | For a much faster solution than ImageMagick, you could use the GPUImageToonFilter from my <URL> framework:
<IMAGE>
It combines Sobel edge detection with posterization of the image to give a good cartoon-like feel. As implemented in this framework, it's fast enough to run on realtime video from the iPhone's camera, and is probably at least an order of magnitude faster than something similar in ImageMagick. My framework's also a little easier to integrate with an iOS project than ImageMagick.
If you want more of an abstract look to the image, the GPUImageKuwaharaFilter converts images into an oil painting style, as I show in <URL>. | |
33,381,251 | 1 | 33,408,543 | How do I set gravity to any body or screen center? I wondering that's logic..
I have two circle body aBody is staticBody, bBody is dynamic and world 'gravity(0,0)'.
<IMAGE> | All you have to do is to apply a force that will simulate gravity with center of screen (let's imagine that in the center there is very very heavy object that will be pulling other objects).
The equation is well known and easy to implement - <URL>.
Having equation you just have to implement it like:
'''
Body body, centerBody;
Vector2 center = new Vector2(0, 0);
...
//in render method
float G = 1; //modifier of gravity value - you can make it bigger to have stronger gravity
float distance = body.getPosition().dst( center );
float forceValue = G / (distance * distance);
// Vector2 direction = center.sub( body.getPosition() ) );
// Due to the comment below it seems that it should be rather:
Vector2 direction = new Vector2(center.x - body.getPosition().x, center.y - body.getPosition().y);
body.applyForce( direction.scl( forceValue ), body.getWorldCenter() );
'''
Of course you can modify the "center of the gravity" with modifying Vector2. | |
29,631,806 | 1 | 29,632,175 | The jCountdown plugin has good effect.
<URL>
However by Inspecting the resources, it seems like the plugin is using css sprite animation to achieve the effect. wondering how difficult it would be to make it become
responsive/albe to view without seeing horizontal overflow-x scroll bar
on small dimensions that is < 485px.
I'll be using "slide" effect so below img is slide_black skin.
maybe can share some tips on customizing script / css / or photoshop the image to create diff dimensions to fit responsive.
<IMAGE>
using the width option is one option to do but I think the pitfall is that result would be blur especially for the day/hour/min/sec label picture text
'''
$("#timer").jCountdown({
timeText: tdate,
timeZone: 8,
style: "slide",
color: "black",
width: 225,
textGroupSpace: 15,
textSpace: 0,
reflection: !1,
reflectionOpacity: 10,
reflectionBlur: 0,
dayTextNumber: 2,
displayDay: !0,
displayHour: !0,
displayMinute: !0,
displaySecond: !0,
displayLabel: !0,
onFinish: function() {}
});
''' | You can do this playing with 'transform:scale()' property, adding some jQuery to find the correct scale value and applying it. Exemple :
'''
var value = yourOwnRatioCalculDependingOnClosestResponsiveParent;
$('.jCountdownContainer').css({
"-moz-transform" : "scale("+value+")",
"-webkit-transform" : "scale("+value+")",
"-ms-transform" : "scale("+value+")",
"-o-transform" : "scale("+value+")",
"transform" : "scale("+value+")",
});
'''
As you can see inspecting this plugin, adding a css scale to '.jCountdownContainer' works fine (with Chrome Dev Tool for exemple). | |
29,742,703 | 1 | 29,764,910 | I was following the <URL>
<IMAGE>
Could anyone help me to point out the problem here?
'''
osgi> ss
"Framework is launched."
id State Bundle
0 ACTIVE org.eclipse.osgi_3.8.1.v20120830-144521
1 ACTIVE org.eclipse.kura.core.cloud_1.0.2
2 ACTIVE org.apache.commons.io_2.4.0
3 ACTIVE org.hsqldb.hsqldb_2.3.0
4 ACTIVE com.gwt.user_0.2.0
**5 ACTIVE com.help.iot.example.configurable_1.0.0.qualifier**
6 ACTIVE org.eclipse.kura.deployment.agent_1.0.1
7 ACTIVE org.eclipse.equinox.util_1.0.400.v20120522-2049
8 ACTIVE org.eclipse.kura.core.configuration_1.0.1
9 ACTIVE org.eclipse.equinox.http.jetty_3.0.0.v20120522-1841
10 ACTIVE org.json_1.0.0.v201011060100
11 ACTIVE org.eclipse.kura.core.net_1.0.2
12 ACTIVE org.eclipse.paho.client.mqttv3_1.0.1
13 ACTIVE org.apache.felix.gogo.shell_0.8.0.v201110170705
14 ACTIVE org.eclipse.jetty.servlet_8.1.3.v20120522
15 RESOLVED slf4j.log4j12_1.6.0
Master=32
16 ACTIVE javax.servlet_3.0.0.v201112011016
17 ACTIVE org.eclipse.jetty.util_8.1.3.v20120522
18 ACTIVE org.eclipse.kura.emulator_1.0.2.qualifier
19 ACTIVE org.apache.felix.deploymentadmin_0.9.5
20 ACTIVE log4j_1.2.17
Fragments=37
21 ACTIVE org.eclipse.jetty.security_8.1.3.v20120522
22 ACTIVE org.eclipse.equinox.ds_1.4.0.v20120522-1841
23 ACTIVE org.eclipse.kura.core_1.0.2
24 ACTIVE org.eclipse.equinox.cm_1.0.400.v20120522-1841
25 ACTIVE org.apache.commons.fileupload_1.2.2.v20111214-1400
26 ACTIVE org.eclipse.soda.dk.comm_1.2.1
27 ACTIVE org.eclipse.equinox.metatype_1.2.0.v20120522-1841
28 ACTIVE org.apache.felix.dependencymanager_3.0.0
29 ACTIVE javax.usb.common_1.0.2
30 ACTIVE org.eclipse.jetty.http_8.1.3.v20120522
31 ACTIVE org.eclipse.osgi.services_3.3.100.v20120522-1822
32 ACTIVE slf4j.api_1.6.4
Fragments=15
33 ACTIVE com.hp.iot.example.hello_osgi_1.0.0.qualifier
34 ACTIVE javax.usb.api_1.0.2
35 ACTIVE org.eclipse.equinox.event_1.2.200.v20120522-2049
36 ACTIVE org.eclipse.jetty.continuation_8.1.3.v20120522
37 RESOLVED log4j.apache-log4j-extras_1.1.0
Master=20
38 ACTIVE com.google.protobuf_2.6.0
39 ACTIVE org.apache.commons.net_3.1.0.v201205071737
40 ACTIVE org.eclipse.equinox.console_1.0.0.v20120522-1841
41 ACTIVE osgi.cmpn_4.3.0.201111022214
42 ACTIVE org.eclipse.jetty.io_8.1.3.v20120522
43 ACTIVE org.eclipse.jetty.server_8.1.3.v20120522
44 ACTIVE org.eclipse.equinox.http.servlet_1.1.300.v20120522-1841
45 ACTIVE org.eclipse.kura.core.crypto_1.0.1
46 ACTIVE org.eclipse.osgi.util_3.2.300.v20120522-1822
47 ACTIVE org.apache.felix.gogo.runtime_0.8.0.v201108120515
48 ACTIVE org.eclipse.equinox.io_1.0.400.v20120522-2049
49 ACTIVE org.eclipse.kura.api_1.0.2
''' | I had the same problem... The answer was I downloaded the wrong package.
There are 2 Developers Workspaces for download. On the left side without the WebUI.
Try to download the Developers Workspace on the right side (Extended Downloads) <URL> | |
10,365,958 | 1 | 10,367,144 | <IMAGE>
What is the
'''
HEAD
master [branch]
'''
?
What should I choose for the "Source ref" and "Destination ref", respectively? | You see this screen in <URL>:
<IMAGE>
That is where you define the <URL>:
> A "refspec" is used by fetch and push operations to .
Semantically they define how local branches or tags are mapped to branches or tags in a remote repository.
In native git they are combined with a colon in the format '<src>:<dst>', preceded by an optional plus sign, '+' to denote forced update.
.The "left-hand" side of a RefSpec is called source and the "right-hand" side is called destination.
Depending on whether the RefSpec is used for fetch or for push, the semantics of source and destination differ:
For a Push RefSpec, the source denotes a Ref in the source Repository and the destination denotes a Ref in the target Repository.
### Push Refspecs
A typical example for a Push RefSpec could be
'''
HEAD:refs/heads/master
'''
> This means that the currently checked out branch (as signified by the 'HEAD' Reference, see <URL> will be pushed into the master branch of the remote repository. | |
14,606,141 | 1 | 14,606,261 | I have 2 simple functions, one function inputs in the the NxM array not including N+2 and M+2. So the original array must be surrounded by zeros and the other outputs the whole array. When the out function is called I have a very strange output:
<IMAGE>
But when I move the code to the main function everything is totally fine. I tried compiling this code in CodeBlocks and NetBeans.Behaviour is the same.
I don't know what's going on there. Can somebody explain?
'''
.....
int main()
{
int array[N+2][M+2]={{0}};
local_in(N,M,array);
local_out(N,M,array);
return 0;
}
void local_in(int len, int len2,int arr[][len2])
{
int i;
int j;
for(i = 1; i <= len; i++)
for(j = 1; j <= len2; j++){
scanf("%d",&arr[i][j]);
}
}
void local_out(int len, int len2,int arr[][len2])
{
int i;
int j;
for(i = 0; i < len+2; i++){
for(j = 0; j < len2+2; j++)
printf("%d ",arr[i][j]);
printf("
");
}
}
''' | Your 'local_*' functions pass the array as 'int arr[][len2]'; but should use 'int arr[][len2+2]' instead.
In general, the code should be much clearer if you passed the correct array dimensions around then implemented any policy on which items to read or write inside the 'local_*' functions. | |
8,302,586 | 1 | 8,302,714 | I have an mvc3 webgrid that contains results that I would like to filter by for each column. I'm looking for something similar to the screenshot below regarding filtering (dropdowns with multiple checkboxes for each column entry)? Can somebody provide code or available jquery controls to achieve this UI functionality?
<IMAGE>
DISCLAIMER for editors: This is a general ask. Not sure what "technical" criteria needs to be called out here but if you need more info please inquire about what I can include to make this helpful or less ambigous and I can edit my response. | You could simply query your result set for distinct values on the column you want to do this for, then add a row to your grid which contains drop down lists of those values. And then combine that with <URL> as .
or use something like <URL>
Or you could use <URL> | |
11,886,764 | 1 | 12,034,190 | I currently encounter an issue with Chrome and Safari but not with Firefox.
I'm just trying to send a basic 'GET' request to the server. This one use SSL and the basic authentication with '"username:password"' encoded in base64. Below, an example :
'''
$.ajax({
url: 'https://(...)',
type: "GET",
beforeSend: function(xhr) {
var base64 = 'dXNlcm5hbWU6cGFzc3dvcmQ=';
return xhr.setRequestHeader("Authorization", "Basic " + base64);
}
});
'''
The Chrome developer tool shows me an error :
'''
OPTIONS https://(...) Resource failed to load
f.support.ajax.f.ajaxTransport.send
f.extend.ajax
'''
<IMAGE>
What could I do ? Thanks for your help. | '''
var auth;
function make_base_auth(user, password) {
var tok = user + ':' + password;
var hash = Base64.encode(tok);
return "Basic " + hash;
}
function getAuthCookie() {
var cn = "Authorization=";
var idx = document.cookie.indexOf(cn)
var end;
if(idx != -1) {
var end = document.cookie.indexOf(";", idx + 1);
if(end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(idx + cn.length, end));
} else {
return "";
}
}
document.cookie = encodeURIComponent("Authorization") + "=deleted; expires=" + new Date(0).toUTCString();
auth = make_base_auth($.trim($('#email').val()), $.trim($('#password').val()));
document.cookie = "Authorization=" + auth;
$.ajax({
url : BASE_URI + "user",
method : "GET",
beforeSend : function(xhr) {
xhr.setRequestHeader('Authorization', getAuthCookie());
},
xhrFields : {
withCredentials : true
},
accept : "application/json",
contentType : "application/json",
cache : false,
cookie : false,
statusCode : {
404 : function() {
console.log("Page Not Found");
}
}
}).success(function(response) {
console.log("Login SUCCESS " + JSON.stringify(response));
}).fail(function(response) {
}).then(function() {
});
''' | |
46,372,756 | 1 | 46,376,582 | I am using firebase in swift to read some data from firebase realtime database. When I had one project in firebase panel its work fine, but after adding another project today I got error like this
> 2017-09-23 00:15:18.360 AfgDate[2816] [Firebase/Database][I-RDB034028] Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ".indexOn": "date" at /data to your security rules for better performance
This is my database structure
<IMAGE>
my role was
'''
{
"rules": {
".read": true,
".write": true,
}
}
'''
after that i changed my roles to this one
'''
{
"rules": {
"data": {
".indexOn": "date",
".read": true,
".write": true
}
}
}
'''
in this time also i cant read data and and i didn't see any error in console
this is my code in swift
'''
ref = Database.database().reference()
ref.child("data").queryOrdered(byChild: "date").queryEqual(toValue: "1396/06/05").observeSingleEvent(of: .value, with: { (snapShot) in
if let snapDict = snapShot.value as? [String:AnyObject]{
for each in snapDict{
let key = each.key as String
let date = each.value["date"] as!String
let name = each.value["text"] as! String
print(key)
print(name)
self.lblshow.text = name
}
}
}, withCancel: {(Err) in
print(Err.localizedDescription)
})
'''
how | *
Try this, and with the same 'Data'(with capital "D") in rules as well as in your query like Jen suggested .
'''
{
"rules": {
".read": true,
".write": true,
"Data" : {
".indexOn": "date"
}
}
}
'''
And try this
'''
var ref: FIRDatabaseReference!
ref = FIRDatabase.database().reference()
'''
instead of
'''
ref = Database.database().reference()
''' | |
7,319,560 | 1 | 7,321,359 | In this project i got some run time error which i tired it to resolve it by pasting the error in the google and get the appropriate result for that. But am not able to solve that and
<IMAGE>
and other code of that is fine But manifest file is showing some warning.And the code is
'''
'<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.collabera.labs.sai.maps"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".SampleMapActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest> '
'''
and it is showing some warning in the first line and that is "Attribute minSdkVersion (3) is lower than the project target API level (8)"
this is my java class
'''
package com.collabera.labs.sai.maps;
import java.util.List;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.TextView;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
public class MyMapActivity extends MapActivity implements LocationListener {
/** Called when the activity is first created. */
TextView myLoc = null;
MapView myMapView = null;
MapController myMC = null;
GeoPoint geoPoint = null;
double latitude = 12.937875, longitude = 77.622313;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Creating TextBox displaying Latitude, Longitude
myLoc = (TextView) findViewById(R.id.id1);
String currentLocation = "My location is: Lat: " + latitude + " Lng: " + longitude;
myLoc.setText(currentLocation);
// Creating and initializing Map
myMapView = (MapView) findViewById(R.id.myGMap);
geoPoint = new GeoPoint((int) (latitude * <PHONE>), (int) (longitude * <PHONE>));
myMapView.setSatellite(false);
//Getting the MapController to fine tune settings
myMC = myMapView.getController();
myMC.setCenter(geoPoint);
myMC.setZoom(15);
// Add a location mark
MyLocationOverlay myLocationOverlay = new MyLocationOverlay();
List<Overlay> list = myMapView.getOverlays();
list.add(myLocationOverlay);
// Adding zoom controls to Map
myMapView.setBuiltInZoomControls(true);
myMapView.displayZoomControls(true);
// Getting locationManager and reflecting changes over map if distance travel by
// user is greater than 500m from current location.
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 500.0f, this);
}
public void onLocationChanged(Location location) {
if (location != null) {
Log.v("loc...", "location chaaaaaaaaa");
double lat = location.getLatitude();
double lng = location.getLongitude();
String currentLocation = "The location is changed to Lat: " + lat + " Lng: " + lng;
myLoc.setText(currentLocation);
geoPoint = new GeoPoint((int) lat * <PHONE>, (int) lng * <PHONE>);
myMC.animateTo(geoPoint);
}
}
public void onProviderDisabled(String provider) {
// required for interface, not used
}
public void onProviderEnabled(String provider) {
// required for interface, not used
}
public void onStatusChanged(String provider, int status, Bundle extras) {
// required for interface, not used
}
protected boolean isRouteDisplayed() {
return false;
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_I) {
myMapView.getController().setZoom(myMapView.getZoomLevel() + 1);
return true;
} else if (keyCode == KeyEvent.KEYCODE_O) {
myMapView.getController().setZoom(myMapView.getZoomLevel() - 1);
return true;
} else if (keyCode == KeyEvent.KEYCODE_S) {
myMapView.setSatellite(true);
return true;
} else if (keyCode == KeyEvent.KEYCODE_M) {
myMapView.setSatellite(false);
return true;
}
return false;
}
/* Class overload draw method which actually plot a marker,text etc. on Map */
protected class MyLocationOverlay extends com.google.android.maps.Overlay {
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
Paint paint = new Paint();
super.draw(canvas, mapView, shadow);
// Converts lat/lng-Point to OUR coordinates on the screen.
Point myScreenCoords = new Point();
mapView.getProjection().toPixels(geoPoint, myScreenCoords);
paint.setStrokeWidth(1);
paint.setARGB(255, 255, 255, 255);
paint.setStyle(Paint.Style.STROKE);
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.marker);
canvas.drawBitmap(bmp, myScreenCoords.x, myScreenCoords.y, paint);
canvas.drawText("I am here...", myScreenCoords.x, myScreenCoords.y, paint);
return true;
}
}
}
'''
and my xml file is
'''
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/id1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</TextView>
<TextView
android:id="@+id/id2"
android:text="@string/index"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<com.google.android.maps.MapView
android:id="@+id/myGMap"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="true"
android:clickable="true"
android:apiKey="0YaGLMeMFKXrhzHL-uSYZSnqXqbGwE6kxF4VwFQ"
/>
</LinearLayout>
'''
can any one help me in this case.
thanks in advance | Create a Emulitor and set Target as Google And not as Android. :) | |
11,523,151 | 1 | 11,523,307 | Here's my custom buttons template:
'''
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Path x:Name="Inner" Stretch="Fill" Fill="{TemplateBinding Background}" Data="F1 M 249.989,59.8321L 399.989,59.8321L 429.989,88.1654L 399.989,120.165L 249.989,120.165L 279.989,88.1654L 249.989,59.8321 Z ">
<Path.Effect>
<DropShadowEffect BlurRadius="10" Opacity="0.5" ShadowDepth="4" />
</Path.Effect>
</Path>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
<Path x:Name="Border" Stretch="Fill" Stroke="{TemplateBinding BorderBrush}" Data="F1 M 249.989,59.8321L 399.989,59.8321L 429.989,88.1654L 399.989,120.165L 249.989,120.165L 279.989,88.1654L 249.989,59.8321 Z " />
</Grid>
</ControlTemplate>
</Button.Template>
'''
And here's how it displays:
<IMAGE>
What I'd like it to do is to size the 2 Path's so that it fits the content. This is part of a breadcrumb custom control, and I'd like each breadcrumb to only take up as much space as is needed. I can't figure out how to get the Path's to size to the ContentPresenter.
I've tried binding the width and height of the path's to the ContentPresenters width and height but no dice :/
Note that in the image above, the text fits in the width and height of the Path, however, when I add text or remove text from the ContentPresenter, it does not resize. | I'd suggest binding the 'Path' property to the 'ActualWidth'/'ActualHeight' of the ContentPresenter, using a 'Converter' to calculate the 'Path.Data'
Since two properties are needed (Height and Width), you'll need an <URL>, or you'll need to pass the entire 'ContentPresenter' into your binding, like this:
'''
Path Data="{Binding ElementName=MyContentPresenter,
Converter={StaticResource Path1Converter}}" />
'''
Also, don't forget you can use lowercase letters in your 'Path.Data' to specify relative points instead of always having to use absolute points. | |
22,898,043 | 1 | 22,898,262 | I'm using simple html dom in php to extract a table depending on its id. I have done this without any issues when the id doesn't involve any characters like hyphens(-). I suspect it is due to a hyphen because I used the same code with an id with no hyphens and no trouble receiving the data. The data I want to extract is also in a tab that is hidden, does this effect the process?
'''
<?php
include('simple_html_dom.php');
//Insert the url you want to extract data from
$html = file_get_html('http://espnfc.com/team/_/id/359/arsenal?cc=5739');
$i = 0;
$dataInTable = true;
while($dataInTable){
if($html->find('div[id=ui-tabs-1] table tbody', 0)->children(0)->children($i)){
for($j=0;$j<3;$j++){
if($html->find('div[id=ui-tabs-1] table tbody', 0)->children(0)->children($i)->children($j)){
$gk[] = $html->find('div[id=ui-tabs-1] table tbody', 0)->children(0)->children($i)->children($j)->plaintext;
}else{
$dataInTable = false;
}
}
//else if nothing is in the next cell return false.
}else{
$dataInTable = false;
}
$i+=2;
}
var_dump($gk);
?>
'''
<IMAGE> | When you take a look at the source(not via dev-tools, use browser->viewsource) of <URL> you'll not see anything with the ID 'ui-tabs-1'
This element has been created via javascript(I guess jQueryUI-tabs)
'simple_html_dom' parses HTML but did not evaluate javascript, so the answer is: | |
19,547,815 | 1 | 19,645,781 | I am running a slideshow using the javascript code below on my server Ubuntu 12.04.1. The problem, when I change the name of the images, then I get unlimited server responses 304 (not modified) on Chrome network tool. But, when I clear the browser history (cache), I get everything fine and just 5 network requests from Cache and not more like the screen shot attached.
I wonder why this happen and how to solve it? Screen shot attached for your kind reference! Would greatly appreciate if you hint me how to solve these unlimited requests? Thank you!
In the page index.php:
'''
<SCRIPT>
//set image paths
src = ["ic/photo1.jpg", "ic/photo2.jpg", "ic/photo3.jpg", "ic/photo4.jpg", "ic/photo5.jpg"]
//set duration for each image
duration = 4;
ads=[]; ct=0;
function switchAd(){
var n=(ct+1)%src.length;
if (ads[n] && (ads[n].complete || ads[n].complete==null)) {
document["Ad_Image"].src = ads[ct=n].src;
}
ads[n=(ct+1)%src.length] = new Image;
ads[n].src = src[n];
setTimeout("switchAd()",duration*1000);
}
onload = function(){
if (document.images)
switchAd();
}
//-->
</SCRIPT>
<IMG NAME="Ad_Image" SRC="ic/photo1.jpg" BORDER=0>
'''
<IMAGE> | I have solved this question buy calling the image once from the server instead of calling it each time to view, i.e. I added the images in the document, then added a src to each of one (ONCE - this means to call them once from server), then for each repetition, I show one image and hide the others! Because if I give a src to each image when viewing, then the server might be slow when the server requests to see if the image has been modified last time called (304 response), and this results in delaying the view! Thank you :) | |
27,158,174 | 1 | 27,166,694 | So a book I am reading has this nice image:
<IMAGE>
So it is suggested that once a client asks a DNS server an IP for a host, actually the DNS server does not respond back with the IP but rather find the IP, send the same request to the ip but the response comes back to the client..
This is very confusing for me since the accepted answer here: <URL> does not fit with this one at all.
Which is correct? | That image is completely wrong. It would probably be a good idea to stop reading that book. | |
27,980,003 | 1 | 28,281,376 | I am using ApiGility to update a shopping basket products and quantities and am testing with Chromes Postman.
I am using the PUT method to send my form data to the api and keep getting the following error:
'''
JSON decoding error: Syntax error, malformed JSON
'''
This is a screenshot of my PostMan setup:
<IMAGE>
I have tried setting Content-Type as Text however I then get a "INvalid content-type specified" error.
Is there a way to set PostMan to send Json? | The problem is that you're trying to send parameters as form data. Instead you'll want to send it as "raw." Click on the "raw" tab in the Headers section. Then enter your data as a JSON string.
'''
{"quantity_accumulation": "1"}
'''
<IMAGE> | |
9,159,774 | 1 | 9,159,889 | how can i put the div's from top to buttom and left to right
<URL>
<URL><IMAGE>
<URL> | You can use the 'column-count' property for this type of function:
Check my previous answers for this
<URL> | |
12,588,537 | 1 | 12,588,545 | I need to write a project that's only compatible with Java 1.5. I have Java 1.6 installed. Is there some form of backwards compatibility to get Eclipse to compile with 1.5?
Do I have to install Java 1.5 to get it to show here? Or maybe there is another way?
<IMAGE>. | Click on the button. It brings your <URL> to point to the Java location.
Select "", button right besides JRE home and point to the installed folder location.
Even though you want to just 1.5 compiler project, you can achieve it by changing compiler settings in Eclipse instead of removing 1.6 JRE and add 1.5 JRE.
'''
GOTO -->JAVA--Compiler---> and change compiler level to '1.5' instead of '1.6'
'''
As davidfmatheson suggested,
Just be careful, especially if you're setting this up for a team of people to work on. If anyone uses anything that is new or changed in 1.6, it will compile, but not run in an environment with JRE 1.5. | |
23,356,229 | 1 | 23,356,415 | I am creating a web application that supports both in desktop and mobile. I have a banner that contains a race circuit and a pointer. My question is how to make travel the pointer over the circuit path in Jquery. I know it will be doable in Flash. But I want to know if it is doable in Jquery. Please help me to achieve this. Thanks.<IMAGE> | You can try with an SVG animation:
<URL>
or else with a canvas animation:
<URL> | |
19,845,055 | 1 | 19,845,160 | I am trying to have my forms float right, so that it looks neat when everything is placed next to each other, and it works fine, EXCEPT for the first 2? That is what weirds me out? It works great after the first 2. Here is a screenshot that says it all and my HTML code
'''
<head>
<title>New user</title>
<style type="text/css">
#form_container {
width: 25%;
}
#form_container input {
float: right;
clear: both;
}
</style>
</head>
<body>
<div id="form_container">
<form action="" method="post">
Username: <input type="text" name="username" value="" /><br />
Password: <input type="text" name="username" value="" /><br />
Password again: <input type="text" name="username" value="" /><br />
Password triple: <input type="text" name="username" value="" /><br />
</form>
</div>
</body>
'''
<IMAGE>
Why is there that "space" between the first and second ones?
Thanks on advance everyone! | It's simply because you are asking for a password 3 times.. the markup doesn't like that and throws a random gap at you.
In all seriousness, there are a few ways to fix this.. the easiest is to set 'clear:both' on the 'br'.. that was causing the gap.
<URL>
'''
br {
clear:both;
}
'''
Also, remove 'clear:both' from '#form_container input' as that isn't needed anymore.
'''
#form_container input {
float: right;
}
'''
I'd also suggest adding a 'label' to each input for validation purposes. | |
20,773,692 | 1 | 20,776,082 | I'm solving the question.
It seems that my code makes a rotation, but leaves an X over the image.
So I'm guessing it's rotating the edges incorrectly.
I'm attaching two images as sample input and output.
<IMAGE>
What's wrong with my code:
'''
public static void rotateRight(float[][] img){
for (int i=0; i<N/2; i++){
for (int j=i; j<N-i; j++){
int J_COMP = N-j-1; //complement of J
int LEFT = i;
int RIGHT = N-i-1;
int TOP = i;
int BOTTOM = N-i-1;
float temp = img[J_COMP][LEFT];
img[J_COMP][LEFT] = img[BOTTOM][J_COMP];
img[BOTTOM][J_COMP] = img[j][RIGHT];
img[j][RIGHT] = img[TOP][j];
img[TOP][j] = temp;
}
}
}
''' | You are rotating main diagonals twice.
Fix inner loop (see "fix" comment)
'''
package tests.StackOverflow;
public class Question_20773692 {
private static int N;
public static void main(String[] args) {
float[][] img;
int count;
N=3;
count = 0;
img = new float[N][N];
for(int i=0; i<N; ++i) {
for(int j=0; j<N; ++j) {
img[i][j] = count++;
}
}
printImg(img);
rotateRight(img);
printImg(img);
}
public static void printImg(float[][] img) {
for(int j=0; j<N; ++j) {
System.out.print("-");
}
System.out.println();
for(int i=0; i<N; ++i) {
for(int j=0; j<N; ++j) {
System.out.print((int)(img[i][j]));
}
System.out.println();
}
for(int j=0; j<N; ++j) {
System.out.print("-");
}
System.out.println(); }
public static void rotateRight(float[][] img){
for (int i=0; i<N/2; i++){
for (int j=i; j<N-i; j++){
//for (int j=i+1; j<N-i; j++){ //fix
int J_COMP = N-j-1; //complement of J
int LEFT = i;
int RIGHT = N-i-1;
int TOP = i;
int BOTTOM = N-i-1;
float temp = img[J_COMP][LEFT];
img[J_COMP][LEFT] = img[BOTTOM][J_COMP];
img[BOTTOM][J_COMP] = img[j][RIGHT];
img[j][RIGHT] = img[TOP][j];
img[TOP][j] = temp;
}
}
}
}
''' | |
9,293,825 | 1 | 9,293,894 | Could any one let me know the css to create a custom scroll bar which looks like the one in the image? The background should be transparent, I have placed it on a green background for now.
<IMAGE> | You can do this using the jQuery plugin jScrollPane - <URL>
'''
$(function() {
$('.scroll-pane').jScrollPane();
});
'''
The above code with set a div with class "scroll-pane" to scroll.
You can't do with with standard CSS but with CSS3 you can:
'''
pre::-webkit-scrollbar {
height: 1.5ex;
-webkit-border-radius: 1ex;
}
pre::-webkit-scrollbar-thumb {
border-top: 1px solid #fff;
background: #ccc -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(240, 240, 240)), to(rgb(210, 210, 210)));
-webkit-border-radius: 1ex;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
''' | |
9,331,222 | 1 | 9,333,546 | Almost 2 years ago, I asked a question how easy it would be to convert an application from WPF to Silverlight. The result was that I couldn't do it in a few days.
Now we are considering moving in the opposite direction. We have an application that looks like this:
<IMAGE>
So when converting, the server would just stay the same. We don't have any idea what time it would need to make the changes. We figure that we need to redo all Views, but besides that, we don't know for sure what modifications are needed.
Has someone did something similar before? How did you do it? What were pitfalls? And how did you plan it?
Any advice/tips/guidance would be great. | One thing that may put a wrench in things is if you're using the async web service calls that are in silverlight you'll have to translate them in WPF because until .Net 4.5 async web calls aren't well supported. (looking for a reference on that fact, if someone has that'd be excellent)
also WPF offers some easier ways to do some of the tasks around binding and data templates which may wish to be explored and may change some of the design | |
18,073,754 | 1 | 18,073,830 | I have this problem: i am not a design person. i just simply dont know how to make this arrow under the rectangle:
<IMAGE>
i tried to make a div with this background color and hang some image under it, but i am trying to do this for 2 hours now and i am totally stuck not finding a image tool which cuts out in triangle form. then i decided to do this thru css, but cannot somehow do it.
how can i do this triangle in css and hang to div? i want that if i resize window, the triangle should stick to div and doesnot move.
many many thanks for help in advance. | <URL>
'''
<div class="arrow-down"></div>
'''
'''
.arrow-down {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #f00;
}
'''
<URL>
'''
<div id="div1"><div class="arrow-down"></div></div>
'''
'''
#div1{
width:200px;
height:200px;
background-color:#f00;
}
.arrow-down {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #f00;
position:absolute; //added position:absolute
}
'''
'''
$(document).ready(function () {
$('.arrow-down').css('top', $('#div1').height() + 5).css('left', '20px');
});
'''
or you can make use of ':after' only css effect
<URL>
'''
<div>
<p>Testing triangle</p>
</div>
'''
'''
div {
margin: 50px;
padding: 10px 20px;
float: left;
background-color: #f00;
position: relative;
}
div:after {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #f00;
content:"";
position: absolute;
bottom: -20px;
left: 20px;
}
''' | |
26,586,876 | 1 | 26,589,969 | I am trying to insert labels into a proportional barchart: one label per segment, with as text the percentage of each segment. With the help of thothal I managed to do this:
'''
var1 <- factor(as.character(c(1,1,2,3,1,4,3,2,3,2,1,4,2,3,2,1,4,3,1,2)))
var2 <- factor(as.character(c(1,4,2,3,4,2,1,2,3,4,2,1,1,3,2,1,2,4,3,2)))
data <- data.frame(var1, var2)
dat <- ddply(data, .(var1), function(.) {
res <- cumsum(prop.table(table(factor(.$var2))))
data.frame(lab = names(res), y = c(res))
})
ggplot(data, aes(x = var1)) + geom_bar(aes(fill = var2), position = 'fill') +
geom_text(aes(label = lab, x = var1, y = y), data = dat)
'''
I would like to have for labels the percentage of each level, and not the level name.
<IMAGE>
Any help appreciated! | Another way to get non-cumulative percentage plus centering the labels, for future reference:
'''
dat <- ddply(data, .(var1), function(.) {
good <- prop.table(table(factor(.$var2)))
res <- cumsum(prop.table(table(factor(.$var2))))
data.frame(lab = names(res), y = c(res), good = good, pos = cumsum(good) - 0.5*good)
})
ggplot(data, aes(x = var1)) + geom_bar(aes(fill = var2), position = 'fill') +
geom_text(aes(label = round(good.Freq, 2), x = var1, y = pos.Freq), data = dat)
'''
<IMAGE> | |
13,463,055 | 1 | 13,463,222 | When I run this simple example, igraph adds one vertex and my vertices start from 2 instead of 1
'''
# very very simple graph (1-2-3)
edges <- rbind(c(1,2), c(2,3))
write.table(edges, file="edgetest.txt", sep=" ", quote=F, row.names=F, col.names = F)
g <- simplify(read.graph(file="edgetest.txt", format="edgelist", directed=F))
plot(g)
'''
This is how it looks like after running the example
<IMAGE>
Does someone knows why this happens? Is this OK or am I missing something | I think you are introducing some error by writing out to text and reading back in.
You could just do:
'''
edges <- rbind(c(1,2), c(2,3))
g <- graph.edgelist(edges)
plot(g)
''' | |
12,975,575 | 1 | 14,376,960 | I have an issue with the WiFi shield. As you can see in the picture below, I am experimenting with the Arduino Mini and the WiFi shield.
I have read the tutorial-guide and connected all the necessary pins between the Mini and the shield. I use the example code which is provided in the tutorial, e.g. reading the WiFi shield's MAC-address or scanning for networks near me.
But there is a connection between the two Pin 7's (the handshake pins) and even to any other required pin.
I even support my circuit with an additional power supply of 5V (the voltage regulator in the picture), so what's wrong with it? Or might it be that the WiFi shield itself is damaged or has a malfunction? How to verify this?
One last question is: Do they deliver the shield with an installed firmware or does the user have to install it?
The code I use is for example:
'''
uint8_t wl_status = 0;
void setup()
{ // code to run once
// Open serial communications
Serial.begin(115200);
Serial.println("*** Arduino board online ***");
// check for the presence of the shield:
wl_status = WiFi.status();
if (wl_status == WL_NO_SHIELD)
{
Serial.println("-E- WiFi shield not present");
// don't continue:
//while(true);
}
else
{ // Initialize Wifi
Serial.println("-I- Initializing Wifi..");
printAddress(1);
// Scan for existing networks:
Serial.println("-I- Scanning available networks..");
listNetworks();
}
Serial.print("-D- Wifistatus : ");
Serial.print(wl_status, DEC);
Serial.println("");
}
'''
The printAddress()-function simply prints out the MAC-address of the shield.
<IMAGE> | I proved whether a different power source will work or not; the problem still remained.
Arduino support suggested that we should use the SPI connection of the board instead of wiring. It was worth a try, so I combined the WiFi-shield with an Arduino Uno and could finally start practising. Forget the Arduino Mini and use Uno or Mega instead.
According to the startup trouble, the current firmware version still has bugs, e.g. connection dies after a few seconds both on server side and client side. I recommend checking the Git repository frequently for updates. Issue #9 (Connection dies after a few seconds) has been solved on server side only, however the problem still exists on client side. I will wait for the next version of the firmware. | |
42,492,654 | 1 | 42,492,694 | I have a database and I'm tasked to find out how many times the book
'Hood' has been borrowed. I know it's twice
<IMAGE>
I have to write SQL to return how many times it was borrowed.
So far I have this but it only returns how many unique Books there are not how many times 'Hood' was borrowed
'''
select count('Hood') as lenttimes
from
(
select distinct bTitle from borrow
);
''' | All you need to do is apply a 'where' clause and count the results:
'''
SELECT COUNT(*)
FROM borrow
WHERE bTitle = 'Hood'
''' | |
27,939,828 | 1 | 27,940,119 | I have always been confused that which characters should be allowed in which field of a web form. I am just finding a list like First Name can have A-Z and a-z etc. Can anyone please tell me the same thing for all the fields for the form below? [Please note that the website is UK-based so the UK standards we need to follow].
<IMAGE> | Why would there be a limit on how a person can call himself or the place he lives in? Post code changes between countries and regions. Any of those fields might be in different languages in the future, too.
In short, there's no reliable way to determine allowable characters, you just need to make sure that if I decided to call my kid 'Robert'; DROP TABLE Students; --', that it doesn't have negative effects on your code. Bobby tables is a valid name. | |
6,609,046 | 1 | 6,610,164 | I want to Generate Calendar in c#.net to enter daily attendance.I have used jquery calendar for similar purpose in web. Is there any ways to create calendar control and get click event to mark and display values in that.
Thanks
Example image:
<IMAGE> | If you have a budget I would definitely go for a commercial component like <URL>. That will cost $999 for the collection, I've never used Telerik's controls before so I can't recommend them myself but by the looks it could be well worth it in the long run if you can reuse the components in other projects.
If that isn't an option, something as simple as your example would be fairly easy to roll yourself. I mainly work in WinForms so this is how I would go about building the form:
1. Create a custom control to display any given day. You will need a label in the top corner for the day of month, and a label to display the text for the day (the In/Out times). Maybe add a border.
2. Create a form or control that will contain the calendar
3. Add a toolstrip docked to the top with your month and year controls. Use a combo box or drop-down button.
4. Add a thin panel docked to the top and add labels for the days. Decide on the width you want each column to be and position the labels based on that.
5. Add a FlowLayoutPanel and set Dock to Fill. This will contain the 'day' controls, which will flow left to right, top to bottom.
Now you need to be working in code, not the designer. This could probably be done in the constructor, the 'Page_Load' handler, or somewhere that gets called when the month/year is set (or initialised):
1. Add enough empty panels to the FlowLayoutControl to pad out the start of the month. You can find out how many to add with new DateTime(year, month, 1).DayOfWeek to find the day that the first of the month falls on. The empty panels should be set to the same size as the 'day' control.
2. Add a day control to the FlowLayoutControl for each day in the month. Use DateTime.DayInMonth(year, month) to find the number of days in the selected month, and set each 'day' control up with the date (and probably the in/out data) as you're adding it.
3. Now play with padding and borders on the 'day' controls and padding panels until everything looks right. You can add some test 'day' controls and panels in the designer to test layouts there and just call flowLayoutControl.Items.Clear() in the setup code.
That should result in a control that can dynamically display any month. To add the attendance editing feature, set up a 'Click' handler either in the 'day' control or in the calendar control itself (when you're adding the 'day' controls to the 'FlowLayoutControl', and open up a modal form to edit or add the in/out times for the selected day.
If you wanted the day controls to resize dynamically register for the containing control's 'Resize' event and set the width and height of each day control to 'Math.Floor(control.Width / 7)' (seven days wide) and 'Math.Floor(control.Height / 5)' (five weeks high) or something similar. | |
19,808,803 | 1 | 19,819,714 | I am plotting 'hovmoller' plot for three rasters but the function plots the latitude on the x axis and the time on the y axis. normally (much easier to read) latitude is on the Y axis.
Reproducible example:
'''
library("rasterVis")
r <- raster(nrows=10, ncols=10)
r <- setValues(r, 1:ncell(r))
r1 <- raster(nrows=10, ncols=10)
r1 <- setValues(r1, 1:ncell(r))
r2 <- raster(nrows=10, ncols=10)
r2 <- setValues(r2, 1:ncell(r))
St=stack(r,r1,r2)
idx <- seq(as.Date('2008-01-15'), as.Date('2008-1-17'), 'day')
SISmm <- setZ(St, idx)
hovmoller(SISmm, contour=FALSE, panel=panel.levelplot.raster,
yscale.components=yscale.raster.subticks,
interpolate=TRUE, par.settings=RdBuTheme)
'''
This produces: <IMAGE>
So I want the time to be on the X axis and latitude on the Y axis! | That layout is not implemented in the 'rasterVis::hovmoller'
method. Only the common arrangement (time on the y-axis and
latitude/longitude on the x-axis) is available at the moment.
You can try a workaround using the most important parts of the
<URL>.
For your example, you have to create a 'RasterLayer' with the latitude
values. This 'RasterLayer' is used by 'zonal' to aggregate your
'RasterStack':
'''
library('raster')
dirLayer <- init(SISmm, v='y')
z <- zonal(SISmm, dirLayer, FUN='mean', digits=2)
'''
The result is a matrix which is converted to a 'data.frame' to be
displayed with 'lattice::levelplot'.
'''
## Time on the x-axis, latitude on the y-axis
dat <- expand.grid(y=z[,1], x=idx)
dat$z <- as.vector(z[,-1], mode='numeric')
levelplot(z ~ x*y, data=dat,
xlab='Time', ylab='Latitude',
panel=panel.levelplot.raster,
interpolate=TRUE,
par.settings=RdBuTheme())
'''
<IMAGE> | |
45,768,011 | 1 | 45,768,153 | I already asked one question about datepicker yesterday, but now I have faced a new problem that I was not able to fix by myself. I'm using JQuery Datepicker to make a calendar where I can choose a date range. When I'm trying to change dateformat from default (which is 'mm/dd/yy') to 'dd.mm.yy' it fails with error and stop working when I'm trying to select any date. Also with default dateformat doesn't work my code to have a default selected dates on load.
This is my code with current datepicker settings (it makes possible to choose date range and style it with additional classes, also it places dates and into hidden inputs and visible div's), with full styling it looks like on screenshot:
datepicker range work:
<IMAGE>
Hope you will be able to help me with this case!
'''
// This code doesn't work with default dateformat
// start date on default
//$('#start-date').val($.datepicker.formatDate('dd.mm.yy', new Date()));
//$('.start-date-visible').text($.datepicker.formatDate('dd.mm.yy', new Date()));
// end date on default
//$('#end-date').val($.datepicker.formatDate('dd.mm.yy', new Date(new Date().getTime() + 6 * 24 * 60 * 60 * 1000)));
//\$('.end-date-visible').text($.datepicker.formatDate('dd.mm.yy', new Date(new Date().getTime() + 6 * 24 * 60 * 60 * 1000)));
// jquery datepicker settings
$(function() {
$("#datepicker").datepicker({
numberOfMonths: 3,
showButtonPanel: false,
minDate: 0,
beforeShowDay: function(date) {
var date1 = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $('#start-date').val());
var date2 = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $('#end-date').val());
if (date1 && date && (date1.getTime() == date.getTime())) {
return [true, 'ui-red-start', ''];
}
if (date2 && date && (date2.getTime() == date.getTime())) {
return [true, 'ui-red-end', ''];
}
if (date >= date1 && date <= date2) {
return [true, 'ui-state-selected-range', ''];
}
return [true, '', ''];
},
onSelect: function(dateText, inst) {
var date1 = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $('#start-date').val());
var date2 = $.datepicker.parseDate($.datepicker._defaults.dateFormat, $('#end-date').val());
if (!date1 || date2) {
$('#start-date').val(dateText);
$('.start-date-visible').text(dateText);
$('#end-date').val('');
$('.end-date-visible').text('');
$(this).datepicker('option', dateText);
} else {
if (new Date(dateText) < date1) {
var sDate = $('#start-date').val();
$('.start-date-visible').text(dateText);
$('#start-date').val(dateText);
$(this).datepicker('option', null);
$('.end-date-visible').text(sDate);
$('#end-date').val(sDate);
} else {
$('.end-date-visible').text(dateText);
$('#end-date').val(dateText);
$(this).datepicker('option', null);
}
}
}
});
});
'''
'''
td.ui-state-selected-range:first-child a {
border-radius: 20px 0 0 20px;
}
td.ui-state-selected-range:last-child a {
border-radius: 0 20px 20px 0;
}
.ui-red-start a {
position: relative;
background-color: #F29676;
border-radius: 20px;
border: 1px solid #f29676 !important;
}
.ui-red-start a:before {
content: '';
right: -1px;
left: 50%;
top: -1px;
bottom: -1px;
position: absolute;
border: 1px solid #f29676;
border-right: none;
background-color: #f8c3b1;
z-index: -1;
}
.ui-red-end a {
position: relative;
background-color: #F29676;
border-radius: 20px;
border: 1px solid #f29676 !important;
}
.ui-red-end a:before {
content: '';
left: -1px;
right: 50%;
top: -1px;
bottom: -1px;
position: absolute;
border: 1px solid #f29676;
border-left: none;
background-color: #f8c3b1;
z-index: -1;
}
.ui-state-selected-range .ui-state-default {
border: 1px solid #f29676 !important;
border-left: none !important;
border-right: none !important;
background: #f8c3b1 !important;
box-sizing: border-box;
}
'''
'''
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/>
<input type="text" id="start-date" style="visibility:hidden">
<input type="text" id="end-date" style="visibility:hidden">
<div class="start-date-visible"></div>
<div class="end-date-visible"></div>
<div id="datepicker"></div>
''' | '''
// This code doesn't work with default dateformat
// start date on default
//$('#start-date').val($.datepicker.formatDate('dd.mm.yy', new Date()));
//$('.start-date-visible').text($.datepicker.formatDate('dd.mm.yy', new Date()));
// end date on default
//$('#end-date').val($.datepicker.formatDate('dd.mm.yy', new Date(new Date().getTime() + 6 * 24 * 60 * 60 * 1000)));
//\$('.end-date-visible').text($.datepicker.formatDate('dd.mm.yy', new Date(new Date().getTime() + 6 * 24 * 60 * 60 * 1000)));
// jquery datepicker settings
$(function() {
$("#datepicker").datepicker({
numberOfMonths: 3,
showButtonPanel: false,
minDate: 0,
dateFormat: 'dd/mm/yy',
beforeShowDay: function(date) {
var date1 = $.datepicker.parseDate("dd/mm/yy", $('#start-date').val());
var date2 = $.datepicker.parseDate("dd/mm/yy", $('#end-date').val());
// var date2 = $.datepicker.parseDate("dd/mm/yy", $('#end-date').val());
if (date1 && date && (date1.getTime() == date.getTime())) {
return [true, 'ui-red-start', ''];
}
if (date2 && date && (date2.getTime() == date.getTime())) {
return [true, 'ui-red-end', ''];
}
//change here for selection
if(date1 && date2 && date1-date2){
if (date2<=date && date<=date1) {
return [true, 'ui-state-selected-range', ''];
}
}
else if(date1 && date2 && date2-date1){
if (date2<=date && date<=date1) {
return [true, 'ui-state-selected-range', ''];
}
}
if (date1<=date && date<=date2) {
return [true, 'ui-state-selected-range', ''];
}
return [true, '', ''];
},
onSelect: function(dateText, inst) {
var date1 = $.datepicker.parseDate("dd/mm/yy", $('#start-date').val());
var date2 = $.datepicker.parseDate("dd/mm/yy", $('#end-date').val());
if (!date1 || date2) {
$('#start-date').val(dateText);
$('.start-date-visible').text(dateText);
$('#end-date').val('');
$('.end-date-visible').text('');
$(this).datepicker('option', dateText);
} else {
if (new Date(dateText) < date1) {
var sDate = $('#start-date').val();
$('.start-date-visible').text(dateText);
$('#start-date').val(dateText);
$(this).datepicker('option', null);
$('.end-date-visible').text(sDate);
$('#end-date').val(sDate);
} else {
$('.end-date-visible').text(dateText);
$('#end-date').val(dateText);
$(this).datepicker('option', null);
}
}
}
});
});
'''
'''
td.ui-state-selected-range:first-child a {
border-radius: 20px 0 0 20px;
}
td.ui-state-selected-range:last-child a {
border-radius: 0 20px 20px 0;
}
.ui-red-start a {
position: relative;
background-color: #F29676;
border-radius: 20px;
border: 1px solid #f29676 !important;
}
.ui-red-start a:before {
content: '';
right: -1px;
left: 50%;
top: -1px;
bottom: -1px;
position: absolute;
border: 1px solid #f29676;
border-right: none;
background-color: #f8c3b1;
z-index: -1;
}
.ui-red-end a {
position: relative;
background-color: #F29676;
border-radius: 20px;
border: 1px solid #f29676 !important;
}
.ui-red-end a:before {
content: '';
left: -1px;
right: 50%;
top: -1px;
bottom: -1px;
position: absolute;
border: 1px solid #f29676;
border-left: none;
background-color: #f8c3b1;
z-index: -1;
}
.ui-state-selected-range .ui-state-default {
border: 1px solid #f29676 !important;
border-left: none !important;
border-right: none !important;
background: #f8c3b1 !important;
box-sizing: border-box;
}
'''
'''
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/>
<input type="text" id="start-date" style="visibility:hidden">
<input type="text" id="end-date" style="visibility:hidden">
<div class="start-date-visible"></div>
<div class="end-date-visible"></div>
<div id="datepicker"></div>
'''
Use 'dateFormat: 'dd/mm/yy',' and while parsing the date use same format to parse it. | |
12,536,644 | 1 | 12,536,868 | If I have a MongoDB collection with documents and sub-documents, as illustrated:
<IMAGE>
And, if I want to increment the "damage" by 1 each time the method is called:
'''
private final static void incrementCount(String docID, String subDocID) {
BasicDBObject query = new BasicDBObject();
query.put("_id", docID);
query.put("items.id", subDocID);
BasicDBObject incValue = new BasicDBObject("damage", 1); // or "items.damage" ???
BasicDBObject intModifier = new BasicDBObject("$inc", incValue);
badgesCollection.update(query, intModifier, false, false, WriteConcern.SAFE);
}
'''
Question: do I refer to "damage" or "items.damage" ? | Neither. If you want to increment just the 'damage' value for the 'items' array element with the matching 'subDocID' you need to use the '$' <URL> to identify that element to the '$inc' operator. So it's:
'''
"items.$.damage"
''' | |
15,339,932 | 1 | 15,345,875 | According to this <URL>, developers of Chrome changed
'display: -webkit-box' to 'display: -webkit-flexbox'
However when I test it now (v25.0.1364), I see it's again changed and look what we have:
<IMAGE>
We again lost 'display:-webkit-flex' and '-webkit-flex-direction:column' rule.
(black fonts mean they are not applicable)
Therefore, I want to write a bulletproof rule so it will work in anyway. But, if I write something like this:
'''
<div id="box_container" class="horz_new horz_old"> <div>
'''
it again fails because it accepts some 'webkit-box' property as well as some '-webkit-flex' properties which makes some conflict between rules.
I've prepared a <URL> by including all needed.
Can anyone help me about this?
Or, maybe should I turn back to floated divs? | The old '-webkit-box-*' properties only apply (are pertinent) for containers that have 'display: -webkit-box' on them. You should be able to mix the new ('display: flex') and old flexbox ('display: box') which much issue. Here's a great article on using both together: <URL>
I've update your fiddle (<URL> with a few changes that gets everything working. Basically:
- '-webkit-flex-direction: row;''-webkit-flex-direction: column;'- 'stretch''justify-content'<URL>- '-webkit-flex:1''-webkit-box-flex:1'
I have some nice playable demos on <URL> to see how the different flexbox properties change the layout. Give it a try. | |
11,753,740 | 1 | 11,754,317 | I've a text in side heading with multiple lines. Want the spacing the two lines to increase, so I set a line-height. When I do this, not only does it increase space between the two lines, it also increases spacing above the first line (and maybe below the second). How can I increase spacing between the two lines only, without increasing above and below.
I know it's a behavior of 'Line-height'. but just curious if there is any good solution for this.
Jsfiddle: <URL>
<IMAGE> | You can use negative margins for this, although there is something to keep in mind:
'line-height' is a funny thing. According to <URL> it doesn't specify the line-height but the minimum height of line-blocks:
> On a block container element whose content is composed of inline-level elements, 'line-height' specifies the height of line boxes within the element. The minimum height consists of a minimum height above the baseline and a minimum depth below it, exactly as if each line box starts with a zero-width inline box with the element's font and line height properties. We call that imaginary box a "strut." (The name is inspired by TeX.).
A line box is defined in <URL>:
> In an inline formatting context, boxes are laid out horizontally, one after the other, beginning at the top of a containing block. Horizontal margins, borders, and padding are respected between these boxes. The boxes may be aligned vertically in different ways: their bottoms or tops may be aligned, or the baselines of text within them may be aligned. The rectangular area that contains the boxes that form a line is called a
This doesn't change in <URL>, at least if you don't change the 'line-stacking'. However, there is no property which targets your problem directly: you can't change the 'line-height' of the '::first-line', it will always get applied.
That said, use negative margins for the time being. Even better, wrap your elements in a generic container. By using ':first-child' and ':last-child' you can add as many elements as you like.
### Example
'''
<div>
<h1>I've a text in side heading with multiple lines. Want the spacing the two lines to increase, so I set a line-height. When I do this, not only does it increase space between the two lines, it also increases spacing above the first line.</h1>
<h1>I've a text in side heading with multiple lines. Want the spacing the two lines to increase, so I set a line-height. When I do this, not only does it increase space between the two lines, it also increases spacing above the first line.</h1>
</div>
'''
'''
body {padding:30px;background:yellow;border:1px solid red;margin:0}
div{background:red;margin:0;padding:0;border:1px solid green;}
h1{line-height:2em;}
div > h1:first-child{
margin-top:-.25em;
}
div > h1:last-child{
margin-bottom:-.25em;
}
''' | |
2,450,122 | 1 | 2,450,136 | '''
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if(section != 0) {
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 30)] autorelease];
view.backgroundColor = [UIColor redColor];
return view;
} else {
return tableView.tableHeaderView;
}
'''
}
This is my implementation of viewForHeaderInSection but whatever frame I make it's always showing me the same red frame. Do you see any problem with my code?
Image:
<IMAGE>
UPDATE:
Mhm now my red block is higher but my first tableHeader is now somehow hidden. The first one was implemented with the titleForHeaderInSection. I thought I just implement the height of the tableHeader height but that doesnt work
'''
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if(section == 1)
return 30;
else
return tableView.tableHeaderView.frame.size.height;
}
''' | You need to implement this delegate method
'''
- (CGFloat)tableView:(UITableView *)tableView
heightForHeaderInSection:(NSInteger)section;
'''
In your case, you can simply 'return 30;'.
---
Also, 'view'
Your '[view release]' happens after the 'return'. But as soon as the 'return' happens the method execution is aborted and your 'release' is never called.
So you want this instead
'''
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(10, 10, 100, 30)] autorelease];
'''
And get rid of the explicit 'release' down below. | |
31,210,799 | 1 | 31,304,406 | I have which contains many following . Each contains .
<IMAGE>
The target is to do a simple navigation between 4 at the right side.
Navigation logic:
- -
I tried to use but this didn't work. The way to instantiate VCs to
is not good idea. | The simplest way I found is to create custom .
<IMAGE>
1. Creating custom UIStoryboardSegue Go to File -> New -> File... and choose Cocoa Class Create a new class from UIStoryboardSegue Configurate MySegue
'''
import UIKit
class NewSegue: UIStoryboardSegue {
//Call when performSegueWithIdentifier() called
override func perform() {
//ViewController segue FROM
var sourceViewController: UIViewController = self.sourceViewController as! UIViewController
//ViewController segue TO
var destinationViewController: UIViewController = self.destinationViewController as! UIViewController
//Parent ViewController - ContainerViewController
var containerViewController: UIViewController = sourceViewController.parentViewController!
//Setting destinationViewController
containerViewController.addChildViewController(destinationViewController)
destinationViewController.view.frame = sourceViewController.view.frame
sourceViewController.willMoveToParentViewController(nil)
//Do animation
containerViewController.transitionFromViewController(sourceViewController,
toViewController: destinationViewController,
duration: 0.3,
options: UIViewAnimationOptions.TransitionCrossDissolve,
animations: nil, completion: { finished in
//Delete sourceViewController
sourceViewController.removeFromParentViewController()
//Show destinationViewController
destinationViewController.didMoveToParentViewController(containerViewController)
})
}
}
'''
1. Go to your Storyboard file and do control drag from ContainerViewController to needed Controller and choose Custom in context menu
<IMAGE>
3.Click on created segue and configure them
<IMAGE>
1. Now you can call performSegueWithIdentifier("SugueID", sender: self) in your ContainerViewController or in other ViewController | |
30,105,535 | 1 | 30,105,600 | Should I just remove the actionbar and create a custom view fragment? I'm assuming there is nothing standard that does this?
<IMAGE> | It's a search view and there's a library for that
<URL> | |
21,179,103 | 1 | 21,181,857 | i am doing my project in asp.net MVC4 using c#
I am trying to select a photo and save that image in a folder,
for that i have an html Begin form
'''
@using (Html.BeginForm("ImageReplace", "Member", new { imgid = @Model.Id }, FormMethod.Post,new { enctype = "multipart/form-data" }))
{
<input type="text" name="fake_section" class="fake_section"><button class="fake_section">Choose Photo</button>
<input type="file" style="display:none;" name="file" id="file" value="Choose Photo" accept="image/png,image/jpeg" />
<input type="submit" name="submit" value="Submit" />
}
'''
And i have a controller also
'''
public ActionResult ImageReplace(HttpPostedFileBase file,int imgid)
{
......
}
'''
For styling and validating the form (only select the gif and jpeg files) i use the following jquery
'''
$('.fake_section').click(function (e) {
e.preventDefault();
$('#file').trigger('click');
});
$('#file').change(function (e) {
var filename = $(this).val();
var ext = filename.split('.').pop().toLowerCase();
if ($.inArray(ext, ['gif', 'jpg', 'jpeg']) == -1) {
alert('not valid!');
}
else {
$('input[name="fake_section"]').val(filename);
}
});
'''
<IMAGE>
My problem is that | I think that button type is missig.
Look at this jsFiddle: <URL>
'''
<button class="fake_section" type="button">Choose Photo</button>
''' | |
30,185,199 | 1 | 30,185,975 | I am trying to draw a series of lines. The lines are all the same length, and randomly switch colors for a random length (blue to orange). I am drawing the lines in blue and then overlaying orange on top. You can see from my picture there are clipped parts of the lines where it is grey. I cannot figure out why this is happening. Also related I believe is that my labels are not moving to a left alignment like they should. Any help is greatly appreciated.
<IMAGE>
'''
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.lines as mlines
import random
plt.close('all')
fig, ax = plt.subplots(figsize=(15,11))
def label(xy, text):
y = xy[1] - 2
ax.text(xy[0], y, text, ha="left", family='sans-serif', size=14)
def draw_chromosome(start, stop, y, color):
x = np.array([start, stop])
y = np.array([y, y])
line = mlines.Line2D(x , y, lw=10., color=color)
ax.add_line(line)
x = 50
y = 100
chr = 1
for i in range(22):
draw_chromosome(x, 120, y, "#1C2F4D")
j = 0
while j < 120:
print j
length = 1
if random.randint(1, 100) > 90:
length = random.randint(1, 120-j)
draw_chromosome(j, j+length, y, "#FA9B00")
j = j+length+1
label([x, y], "Chromosome%i" % chr)
y -= 3
chr += 1
plt.axis('equal')
plt.axis('off')
plt.tight_layout()
plt.show()
''' | You're only drawing the blue background from x = 50 to x = 120.
Replace this line:
'''
draw_chromosome(x, 120, y, "#1C2F4D")
'''
with this:
'''
draw_chromosome(0, 120, y, "#1C2F4D")
'''
To draw the blue line all the way across.
Alternately, if you also want to move your labels to the left, you can just set 'x=0' instead of setting it to 50. | |
29,910,644 | 1 | 32,260,317 | I'm trying to develop a custom VBScript sensor for the PRTG monitoring tool and the interface seems fairly simple, returning just a 32-bit integral value and a status string such as with:
'''
WScript.echo "0:January 23, 2015"
'''
However, only the integer appears on the front screen, you have to go into the sensor detail screen itself to get the descriptive text.
Now I think you generate textual data to be displayed as the result (rather than the descriptive text) since the 'SSL security check' sensor displays 'Only Strong Protocols Possible':
<IMAGE>
I tried returning the date as an integer along the lines of '20150123' but that has two problems:
- -
So, my question is: how do you create and code up a custom sensor that can return a string rather than just an integer, float or counter, which seem to be the only three options available? | You should look at the SSH sensor and see if you can do something similar with the sensor you are trying to use. For the SSH sensor you return data in the format of returncode:value:message. Return code 0 is OK, 1-4 are errors, value is a 64-bit integer, and message can be a string. Take a look at <URL>
Since the value you are returning is a date, lookups won't help you much but I'm going to mention them anyways because if you look at some of the built-in sensor types that is how they get string messages. Specifically the SSL Security Rating channel. If you click on the gear for a Value channel one of the fields is Value Lookup. There are lots of preconfigured lookups, but you can also create your own. Here's a relevant <URL> | |
54,324,969 | 1 | 54,325,049 | i want to add graduation mark to an oval shape using css, to get the level, let say at 25 % , 50% and 75 %, just a A score mark ('-')
the code i'm using to draw the form is
'''
.circle {
background-color: red;
display: inline-block;
border-width: 10px;
border-radius: 50px;
height: 300px;
width: 200px;
margin-right: 10px;
}
'''
<URL>
what i want to get is something like this:
<IMAGE>
and thanks in advance for everyone | Use a gradient for the main coloration and also for the mark:
'''
.circle {
background:
linear-gradient(#000,#000) 0 25%/50px 5px, /*top */
linear-gradient(#000,#000) 0 50%/100px 5px, /*middle */
linear-gradient(#000,#000) 0 75%/50px 5px, /*bottom*/
/*main color*/
linear-gradient(red,red) bottom/100% 75%;
background-repeat:no-repeat;
display: inline-block;
border-radius: 50px;
height: 200px;
width: 150px;
margin-right: 10px;
border:1px solid;
}
'''
'''
<span class="circle"></span>
'''
And with CSS variable you can make it easy to adjust:
'''
.circle {
background:
linear-gradient(#000,#000) 0 25%/50px 5px,
linear-gradient(#000,#000) 0 50%/100px 5px,
linear-gradient(#000,#000) 0 75%/50px 5px,
/*main color*/
linear-gradient(red,red) bottom/100% var(--p,100%);
background-repeat:no-repeat;
display: inline-block;
border-radius: 50px;
height: 200px;
width: 150px;
margin-right: 10px;
border:1px solid;
}
'''
'''
<span class="circle"></span>
<span class="circle" style="--p:60%"></span>
<span class="circle" style="--p:50%"></span>
<span class="circle" style="--p:30%"></span>
''' | |
17,751,443 | 1 | 17,751,568 | For the love of all that is good, I cannot seem to get this to work. I keep getting the error mentioned above.
I have this table, and I'm trying to find out whether the code matches it's own sub-code somewhere within the other column, however it's erroring out. Your help is greatly appreciated.
<IMAGE>
'''
Sub testing()
Dim m1 As long
Dim myrange As Range
Set myrange = Worksheets("Sheet1").Range("B2:B23")
For e = 2 To 23
m1= Application.WorksheetFunction.Match(Cells(e, 1).Value, myrange, 0)
If m1 > 0 Then
Cells(e, 3).Value = "Yes"
Else
Cells(e, 3).Value = "No"
End If
Next e
MsgBox "Complete!"
End Sub
''' | Use the 'Application.Match' function which allows for better ability to trap errors. When using the 'WorksheetFunction.Match', when a match is not found, it returns an error, which is what you're experiencing.
'''
If Not IsError(Application.Match(Cells(e, 1).Value, myrange, 0)) Then
'Do stuff when the match is found
Cells(e, 3).Value = "Yes"
Else:
Cells(e, 3).Value = "No"
End If
'''
You could also potentially use the 'CountIf' function:
'''
If Application.WorksheetFunction.CountIf(myRange, Cells(e,1).Value) > 0 Then
Cells(e,3).Value = "Yes"
Else:
Cells(e,3).Value = "No"
End If
'''
Neither of these approaches requires you to use the 'm1' variable, you can assign this variable within the 'True' part of the 'If/Then' statement, if you need to identify the match is found. | |
11,377,233 | 1 | 11,377,282 | I am trying to automate a process which at the moment is done by hand.
I have several gif images which contain a currency symbol + a numeric value just like this one:
<IMAGE>
I am trying to obtain the numeric value directly from the GIF image but it looks like my strategy isn't working properly (I have tried several solutions concerning OCR).
Do you have any suggestions on how I could do this?
I have been thinking at saving somewhere an array of possible images which could be single numbers like 0 1 2 3 4 5 6 7 8 9 and search within the image for each occurrence of these numbers starting from left to right in order to create a numeric string with the solutions but I really don't know where to start.
Some more information: images contain always this kind of information:
- - - - -
As you can see according to the position of the number in the numeric value, the number itself will have a different background since the color is not plain. | Crop it with 'imagemagick' and scan with 'tesseract' | |
3,697,293 | 1 | 3,699,564 | I'm trying to add a 'ContextMenu' in a particular cell of a 'DataGridView'. Like the image below:
<IMAGE>
I found it very hard to do, but I did a it in a TextBox control using the below code:
'''
private void Form1_Load(object sender, EventArgs e)
{
foreach (Control control in this.Controls)
{
// Add KeyDown event to each control in the form.
control.KeyDown += new KeyEventHandler(control_KeyDown);
}
}
private void control_KeyDown(object sender, KeyEventArgs e)
{
Control ctrl = (Control)sender;
if (e.KeyData == Keys.F1) // Check if F1 is being pressed.
{
if (ctrl.GetType() == typeOf(TextBox)) // Check if the control is a TextBox
{
ToolStripControlHost lblInfo;
label1.Text = "This context menu is for TextBoxes.";
lblInfo = new ToolStripControlHost(label1); // some Label
contextMenuStrip1.Items.Add(lblInfo);
contextMenuStrip1.Show(ctrl, 0, 25); // Popups the contextMenu just below the textBox control.
}
}
}
'''
I just don't know how to do it in a particular cell of a DataGridView.
I tried experimenting on this code:
'''
if (ctrl.GetType() == typeOf(DataGridView)) // Check if the control is a DataGridView
{
DataGridViewCell testCell = dataGridView1[dataGridView1.CurrentCell.ColumnIndex, dataGridView1.CurrentRow.Index]; // Returns DataGridViewCell type
ToolStripControlHost lblInfo;
label1.Text = "test";
lblInfo = new ToolStripControlHost(label1); // some Label
contextMenuStrip1.Items.Add(lblInfo);
contextMenuStrip1.Show(testCell, 0, 25);
}
'''
But i think ContextMenu only accepts a 'Control' type on its first argument, and I got this exception:
'''
cannot convert from 'System.Windows.Forms.DataGridViewCell' to 'System.Windows.Forms.Control'
'''
Are there any workaround on this? Please advice me what to do.. thanks in advance. | Attach on DataGridView MouseDown event
'''
private void _dgwMain_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
DataGridView.HitTestInfo info = _dgwMain.HitTest(e.X, e.Y);
//now you can use info.RowIndex and info.CellIndex (not sure for porporty
//name) to generate menu you want
}
}
''' | |
29,314,141 | 1 | 29,314,170 | I am doing an android project using Android Studio. My project name is "Policia". I run the project on emulator and it shows another name "LoginActivity". Actually its the launcher activity. How can I solve this??
<IMAGE> | In your main activity listed in manifest file see the 'android:label' value
'''
android:label="@string/app_name"
'''
Then see 'string.xml' file in resource ('res') folder to see the actual String value of 'app_name'. Change it to whatever you desire.
Main activity will be the one with following intent-filter
'''
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
''' | |
10,902,208 | 1 | 10,904,409 | i have the current design in mysql :
Table
<IMAGE>
Is there a way in Kohana to set relationship in a way that if i make something like
ORM::factory('filesubject')->where('file_id','=',$file->id)->find_all()->as_array());
That i get all the joins from the other tables ? | I'm not sure about your question. To automatically join models, first setup your relationships ($_belongs_to etc) and then look at:
In your model:
'''
ORM property: $_load_with. eg: protected $_load_with= array(model1, model2, etc)
'''
Or at run time:
'''
ORM method: with(). eg: ORM::factory('filesubject')->with('model')->with('model2')->find_all()
'''
I don't think the as_array() function pulls in the joined data though. Once it's actually performing the join you'd need to overwrite as_array (or write your own function) to output the nested key/pair values from the joined properties. | |
46,698,156 | 1 | 46,698,277 | I am trying to display average vacation days and sick days for 3 periods.
So far I have this SQL query:
'''
SELECT AVG(VACATIONHOURS) AS 'Vacation hours', AVG(SICKLEAVEHOURS) AS 'SICK DAYS'
FROM HUMANRESOURCES.EMPLOYEE E
WHERE E.BIRTHDATE BETWEEN '01-01-1960' AND '12-31-1969'
UNION ALL
SELECT AVG(VACATIONHOURS) AS 'VACATION', AVG(SICKLEAVEHOURS) AS 'SICK DAYS'
FROM HUMANRESOURCES.EMPLOYEE E
WHERE E.BIRTHDATE BETWEEN '01-01-1970' AND '12-31-1979'
UNION ALL
SELECT AVG(VACATIONHOURS) AS 'VACATION', AVG(SICKLEAVEHOURS) AS 'SICK DAYS'
FROM HUMANRESOURCES.EMPLOYEE E
WHERE E.BIRTHDATE BETWEEN '01-01-1980' AND '12-31-1989'
;
'''
My output only has 2 columns sick and vacation day and 3 rows under with numbers.
<IMAGE>
My question is how to add a 3rd column that will show years?
I need that for report builder, so I can represent that information correctly | I hope you are looking to add the year in the where clause then just add max(years)
'''
SELECT AVG(VACATIONHOURS) AS 'Vacation hours',
AVG(SICKLEAVEHOURS) AS 'SICK DAYS',
max('1960 to 1969')
FROM HUMANRESOURCES.EMPLOYEE E
WHERE E.BIRTHDATE BETWEEN '01-01-1960' AND '12-31-1969'
''' | |
68,243,496 | 1 | 69,065,638 | So I'm experiencing issue when I'm trying to make a window transparent. I made 'tranparent: true, frame: false' but it doesn't really work. It removes the frame and stuff but doesn't do what I want till the end. I want it to be like really transparent. What I get is a: <IMAGE> frameless window which is not transparent.
Help would be appreciated. Some code:
'''
// main.js
// Modules to control application life and create native browser window
const { app, BrowserWindow } = require('electron')
const { maxHeaderSize } = require('http')
const path = require('path')
function createWindow () {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: maxHeaderSize,
height: maxHeaderSize,
transparent:true,
frame: false
})
// and load the index.html of the app.
mainWindow.loadFile('bodycam.html')
// Open the DevTools.
// mainWindow.webContents.openDevTools()
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.whenReady().then(() => {
function onAppReady() {
createWindow()
app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
}
setTimeout(onAppReady, 300)
})
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
// In this file you can include the rest of your app's specific main process
'''
'''
body {
margin: 0px auto;
overflow: hidden;
font-family: 'Share Tech Mono', monospace;
font-size: 13px;
}
''' | ## Why you are facing this issue
In your case, you are facing this issue because you are trying to define the size of the window from the 'maxHeaderSize' value, wich comes from the <URL>. And this... Actually makes no sense. The value of 'maxHEaderSize' is probably than the size of your screen. Electron seems to be suffering when creating a transparent window that big.
## How to fix
You just need to remove that crazy value when creating your BrowserWindow. For example :
'''
const mainWindow = new BrowserWindow({
transparent: true,
frame: false,
})
'''
If you want to set your window at the same size of your screen, you can use the 'fullscreen' option :
'''
const mainWindow = new BrowserWindow({
transparent: true,
frame: false,
fullscreen: true,
})
'''
Finally, if you want your user to be able to "click throught the window", you probably will be interested in the <URL> method :
'''
const mainWindow = new BrowserWindow({
transparent: true,
frame: false,
fullscreen: true,
})
mainWindow.setIgnoreMouseEvents(true)
''' | |
54,958,981 | 1 | 54,959,463 | Problem statement:
I have this webpage where each candidate in a list has link that contains some information that i want to scrape.
So for all candidates I have to click on the link and fetch details manually which is a tedious task.
I want to automate this please help me.
### Candidate List
<IMAGE>
### My solution:
I think that to automate this task i should write a script that would click on each link and scrape the data.
But I want to know how can i scrape a webpage that requires login.
The web page which you see can be accessed only by login page.
If apart from this method anyone has a better solution to do this task - please help.
Thanks:) | If you need to scrape the data once and store it, you can use <URL> chrome extension and save the data in the desired file format. Here the scraping will be done right in your browser so, you can manually log in once and start scraping.
Else if you want to integrate the scraping process in the server and serve the data to your users, you can use libraries like axios/request to make HTTP requests and use cheerio to extract required data from HTML.
You can also use headless chrome node API, Puppeteer. | |
9,826,002 | 1 | 9,826,436 | I am having a weird problem where lots of ^M characters show up in my git commit message. Please find a screenshot attached. This is not causing any problems, just makes it annoying to read through.
<IMAGE>
Tips appreciated. | "The Proper Way", if you use Git in cross-platform environment, contrary to Abhijeet's answer, is:
<URL>
Read local topic <URL> as good starting point | |
28,528,079 | 1 | 28,530,692 | I have a problem with unformatted data and I don't know where, so I will post my entire workflow.
I'm integrating my own code into an existing climate model, written in fortran, to generate a custom variable from the model output. I have been successful in getting sensible and readable output (values up to the thousands), but when I try to write output then the values I get are absurd (on the scale of 1E10).
Would anyone be able to take a look at my process and see where I might be going wrong?
I'm unable to make a functional replication of the entire code used to output the data, however the relevant snippet is;
'''
c write customvar to file [UNFORMATTED]
open (unit=10,file="~/output_test_u",form="unformatted")
write (10)customvar
close(10)
c write customvar to file [FORMATTED]
c open (unit=10,file="~/output_test_f")
c write (10,*)customvar
c close(10)
'''
The model was run twice, once with the FORMATTED code commented out and once with the UNFORMATTED code commented out, although I now realise I could have run it once if I'd used different unit numbers. Either way, different runs should not produce different values.
The files produced are available here;
- <URL>
In order to interpret these files, I am using R. The following code is what I used to read each file, and shape them into comparable matrices.
'''
##Read in FORMATTED data
formatted <- scan(file="output_test_f",what="numeric")
formatted <- (matrix(formatted,ncol=64,byrow=T))
formatted <- apply(formatted,1:2,as.numeric)
##Read in UNFORMATTED data
to.read <- file("output_test_u","rb")
unformatted <- readBin(to.read,integer(),n=10000)
close(to.read)
unformatted <- unformatted[c(-1,-2050)] #to remove padding
unformatted <- matrix(unformatted,ncol=64,byrow=T)
unformatted <- apply(unformatted,1:2,as.numeric)
'''
In order to check the the general structure of the data between the two files is the same, I checked that zero and non-zero values were in the same position in each matrix (each value represents a grid square, zeros represent where there was sea) using;
'''
as.logical(unformatted)-as.logical(formatted)
'''
and an array of zeros was returned, indicating that it is the just the values which are different between the two, and not the way I've shaped them.
To see how the values relate to each other, I tried plotting formatted vs unformatted values (note all zero values are removed)
<IMAGE>
As you can see they have some sort of relationship, so the inflation of the values is not random.
I am completely stumped as to why the unformatted data values are so inflated. Is there an error in the way I'm reading and interpreting the file? Is there some underlying way that fortran writes unformatted data that alters the values? | Following on from the comments of @Stibu and @IanH, I experimented with the R code and found that the source of error was the incorrect handling of the byte size in R. Explicitly specifying a bite size of 4, i.e
'''
unformatted <- readBin(to.read,integer(),size="4",n=10000)
'''
allows the data to be perfectly read in. | |
20,490,487 | 1 | 20,491,957 | I'm sure the example is out there, but having trouble finding it.
In thousands of static HTML files, I have a block of code as follows and I'm needing to swap out different AdSense code blocks with unique content:
'''
<div id="left">
<div style="margin-top:1px;">
<script type="text/javascript"><!--
google_ad_client = "pub-<PHONE>";
google_ad_slot = "<PHONE>";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</div>
<div id="content">
<div id="googlesquare">
<script type="text/javascript"><!--
google_ad_client = "pub-<PHONE>";
google_ad_slot = "68468464";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
'''
I have found some patterns which would match start and end for sed usage, but am missing the inner content matching.
I'm not tied to sed if it is better done in another CLI tool, but as common a Unix tool as possible is preferred.
Here is what I would like to be able to capture with one pattern, without grabbing the others:
<IMAGE> | '''
sed -n '
\|<script type="text/javascript">|,\|</script>| {
H
\|</script>| {
s/.*//
x
s/google_ad_client = "pub-<PHONE>";/&/
t catch
b nocatch
: catch
# catch code here
s/pub-<PHONE>/nopub-<PHONE>/
p
# end of catch block
b
}
}
\|<script type="text/javascript">|,\|</script>| !{
: nocatch
# no catch code here
p
# end of no catch block
}
' YourFile
'''
Catch the section and allow you to act on it (all the section is in the working buffer at this time so line a separated by
). For the purpose of sample, i just change the 'pub-<PHONE>' to 'nopub-<PHONE>' and no other action is made on the file.
A new line is added when a section is find. It's possible to remove it if mandatory
'\|'in \||' is used to change the default separator (/) with another (|) more interesting in this case due to <**s
The '\|</script>| {' into '\|<script type="text/javascript">|,\|</script>| {' block is used to occuring at last line of the block like $ occur on last line of the file.
In this sub block, the working and holding buffer are exchanged (goal is to get holfing into working buffer and have a empty holding buffer for next iteration)
The sed workflow is a bit strange with 'b' and 't' due to fact that 't' (like an ) only work after a s// that occur (missing the or ) | |
29,403,671 | 1 | 29,403,863 | I have a countdown in my app and I need to change the text to FINISH when the countdown hits the date.
<IMAGE>
Here is the code :
'''
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd"];
NSDate *startingDate = [NSDate date];
NSDate *endingDate = [dateFormatter dateFromString:[NSString stringWithFormat:@"%@", currentGame.gameDate]];
NSUInteger unitFlags = NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitMinute|NSCalendarUnitSecond;
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *componentsDaysDiff = [gregorianCalendar components:unitFlags
fromDate:startingDate
toDate:endingDate
options:0];
NSString *countdownText = [NSString stringWithFormat:@"%ld Months %ld Days %ld Minutes %ld Seconds", (long)componentsDaysDiff.month, (long)componentsDaysDiff.day, (long)componentsDaysDiff.minute, (long)componentsDaysDiff.second];
gamesCountdownLabel.text = countdownText;
''' | I found the answer
here is :
'''
)componentsDaysDiff.second];
if ((long)componentsDaysDiff.month <= 0 && (long)componentsDaysDiff.day <= 0 && (long)componentsDaysDiff.minute <= 0 && (long)componentsDaysDiff.second <= 0 ) {
gamesCountdownLabel.text = @"Released";
}else{
gamesCountdownLabel.text = countdownText;
}
''' | |
30,007,046 | 1 | 30,007,088 | I just upgraded to Yosemite and Xcode 6.3.1. Now, when I run my iPhone app in the simulator (set for iPhone 5S), it looks like this on my 24" screen:
<IMAGE>
It appeared about half this size in 6.1.1. Now, I actually have to scroll to see the whole simulator.
I've looked around on SO and Google, but am maybe using the wrong keywords. Anybody have any ideas why it has ballooned up like this? | In iOS Simulator, Window > Scale and select the scaling that you want.
Alternatively you can use command 1-5 to adjust the size. | |
26,796,260 | 1 | 26,796,825 | So I have a layout I created and I want to use that as a on a different layout.
I was able to figure out how to call it but it doesn't look right.
It called the ENTIRE layout, not just the content of it.
This is what I did:
'''
this.textAbsType.Click += (object sender, EventArgs e) => {
View absenceTypePopup = LayoutInflater.Inflate(Resource.Layout.AbsenceTypePopup, null);
Dialog absenceTypeDialog = new Dialog(context);
absenceTypeDialog.SetContentView(absenceTypePopup);
absenceTypeDialog.Show();
this.btnAbsTypePopupClose = absenceTypeDialog.FindViewById<Button> (Resource.Id.btnAbsTypePopupClose);
this.btnAbsTypePopupClose.Click += (object sender2, EventArgs e2) => {
absenceTypeDialog.Dismiss();
};
};
'''
So when textAbsType (TextView) is called, popup is shown.
And 2nd event if for the button on the popup to cancel it.
But this is how the popup shows up:
<IMAGE>
The extra black border on the top is part of the axml design file.
How can I get rid of that so I can just view the as the ?
Thank you for your time. | Just add the line 'absenceTypeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);' in your code and it will go away.
:
'''
this.textAbsType.Click += (object sender, EventArgs e) => {
Dialog absenceTypeDialog = new Dialog(context);
absenceTypeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
absenceTypeDialog.setContentView(R.layout.AbsenceTypePopup);
absenceTypeDialog.Show();
this.btnAbsTypePopupClose = absenceTypeDialog.FindViewById<Button> (Resource.Id.btnAbsTypePopupClose);
this.btnAbsTypePopupClose.Click += (object sender2, EventArgs e2) => {
absenceTypeDialog.Dismiss();
};
};
''' | |
20,483,848 | 1 | 20,484,987 | I have below my two tables and output
<IMAGE>
the SQL i used to get the output is
'''
SELECT t.empID, t.timesheet, r.Rate AS RateBilled
FROM Rates AS r, timesheet AS t
WHERE (((r.empid)=t.empid) And ((t.timeSheet)>=r.promotionDate))
GROUP BY t.empID, t.timesheet, r.Rate , r.promotiondate
HAVING (((r.promotionDate)=Max([r].[promotionDate])));
'''
my problem is that row 5 and 7 of Output table should also use $15 in Ratebilled (since the promotion date for emp 01 is may/1) , but it seems to still use the initial Jan-1 rate. Any help is appreciated. | '''
select m.*, r2.rate from
(SELECT t.empID, t.timesheet,
max(r.promotiondate) as promotiondate FROM timesheet AS t left join
rates r on r.empid=t.empid And t.timeSheet>=r.promotionDate
group by t.empid, t.timesheet) m
inner join rates r2 on m.empid=r2.empid and m.promotiondate=r2.promotionDate
''' | |
36,347,899 | 1 | 36,350,237 | <IMAGE>
> Error like this:- java.lang.ClassNotFoundException:
com.sun.jersey.spi.container.servlet.ServletContainer at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at
org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
It will work when I put all jar files under lib (WEB-INF/lib) folder.But I want pom file to solve this. | It's all about your configuration resp. and incomplete tutorials. If you want your pom.xml to solve this for you, you need to add a few things.
### Plugins
First things first. The little red cross and the fact, that your project is configured to run under Java 1.5 lets me guess, that you have compatibility issues with your deps. Especialy with 'javax.ws.rs \ javax.ws.rs-api'.
To solve this, you may want maven handle it by the <URL>:
'''
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
'''
Then, you possibly want to run the server "in" eclipse. Here you can use the <URL>:
'''
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8080</port>
<path>/</path>
</configuration>
</plugin>
'''
The last plugin to use is the <URL>
'''
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
'''
### Jersey Dependencies
To start with Jersey you just need to configure a single dep:
'''
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.19</version>
</dependency>
'''
<URL>
Your complete pom.xml should now look like:
'''
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sujith</groupId>
<artifactId>jersey-sample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.maven-compiler-plugin.version>3.5.1</project.maven-compiler-plugin.version>
<project.tomcat7-maven-plugin.version>2.2</project.tomcat7-maven-plugin.version>
<project.maven-war-plugin.version>2.6</project.maven-war-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.19</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<outputDirectory>${project.artifactId}</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${project.maven-compiler-plugin.version}</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>${project.tomcat7-maven-plugin.version}</version>
<configuration>
<port>8080</port>
<path>/</path>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${project.maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
'''
In Eclipse you now right click your project and select -> Run As / Debug As -> Maven build...
In the menu, you now add the goal: 'clean install tomcat7:run-war' and that's it.
Your server should start and the resource is available under 'http://127.0.0.1:8080' / '{web.xml\servlet-mapping\url-pattern}' / '{path-to-resource}'
One last thing. Please check out the original examples first. Most of the tutorial out there are crap. And finally, pls read the <URL> pages.
Have a nice day. | |
31,491,507 | 1 | 31,548,627 | I am getting a imagefile from Parse, basically user's profile image.
But now I am having trouble to display this in the NavDrawer, reason being that it is not a imageview and I am getting is a Image,
Here is my Mainactivity.xml
'''
public class MainActivity extends AppCompatActivity {
private Toolbar mToolbar;
private RecyclerView mRecyclerView;
private RecyclerView.LayoutManager mLayoutManager;
private DrawerLayout Drawer;
private RecyclerView.Adapter mAdapter;
private ActionBarDrawerToggle mDrawerToggle;
private List<DrawerItem> navigationItemsList;
public String HEADER_NAME;// = "bharath";
public String HEADER_EMAIL = "[email protected]";
public int HEADER_IMAGE ;//= R.drawable.bharath;
private final static int ATTENDANTS_LIST_FRAGMENT = 1;
private final static int EVENTS_LIST_FRAGMENT = 2;
private final static int ADD_ATTENDANT_FRAGMENT = 3;
private final static int ADD_EVENTS_FRAGMENT = 4;
private final static int MY_DONATIONS = 5;
private final static int SETTINGS_FRAGMENT = 6;
private int currentFragment = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
navigationItemsList = new ArrayList<DrawerItem>();
addItemsToNavigationList();
mRecyclerView = (RecyclerView) findViewById(R.id.RecyclerView);
mRecyclerView.setHasFixedSize(true);
ParseUser userName = ParseUser.getCurrentUser();
HEADER_NAME = userName.getUsername();
HEADER_EMAIL = userName.getEmail();
mAdapter = new com.charity.dogood.dogood.adapters.NavDrawerAdapter(navigationItemsList, this, HEADER_NAME, HEADER_EMAIL, HEADER_IMAGE);
mRecyclerView.setAdapter(mAdapter);
//Parse Image and details of the logged in user
// Locate the class table named "ImageUpload" in Parse.com
ParseQuery<ParseObject> query = new ParseQuery("User");
Log.d("Mainactivity", "After query 1");
ParseUser currentUser = ParseUser.getCurrentUser();
Log.d("Mainactivity", "After query 2");
query.whereEqualTo("username", "bro");
Log.d("Mainactivity", "After query 3");
Log.d("Mainactivity", currentUser.getUsername());
// String usernam = (String)currentUser;
if (currentUser != null) {
Log.d("Mainactivity", "came to current user check statement");
currentUser.fetchIfNeededInBackground(new GetCallback<ParseObject>() {
// query.getInBackground("bro", new GetCallback<ParseObject>() {
@Override
public void done(ParseObject object, ParseException e) {
if (e == null) {
ParseFile fileObject = (ParseFile) object.getParseFile("ImageProfile");
fileObject.getDataInBackground(new GetDataCallback() {
@Override
public void done(byte[] bytes, ParseException e) {
if (e == null) {
Toast.makeText(MainActivity.this, "we got data!", Toast.LENGTH_LONG).show();
Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
HEADER_IMAGE = (ImageView)findViewById(R.id.c)
// HEADER_IMAGE image = (ImageView) fin
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage(e.getMessage());
builder.setTitle("Sorry");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
}
});
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage(e.getMessage());
builder.setTitle("Sorry");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
}
});
Log.d("Mainactivity", "After query 4");
}
final GestureDetector mGestureDetector = new GestureDetector(MainActivity.this, new GestureDetector.SimpleOnGestureListener()
{
@Override
public boolean onSingleTapUp(MotionEvent e) {return true;}
});
mRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View child = recyclerView.findChildViewUnder(motionEvent.getX(),motionEvent.getY());
if (child != null && mGestureDetector.onTouchEvent(motionEvent)){
Drawer.closeDrawers();
onTouchDrawer(recyclerView.getChildLayoutPosition(child));
// onTouchDrawer(recyclerView.getChildLayoutPosition(child));
return true;
}
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});
mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);
Drawer = (DrawerLayout) findViewById(R.id.DrawerLayout);
mDrawerToggle = new ActionBarDrawerToggle(this, Drawer, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
}
};
Drawer.setDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
onTouchDrawer(1); }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
private void openFragments(final Fragment fragment)
{
getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left). replace(R.id.container, fragment).commit();
}
private void onTouchDrawer(final int position)
{
currentFragment = position;
switch (position)
{
case ATTENDANTS_LIST_FRAGMENT:
openFragments(new AttendanceListFragment());
setTitle(getString(R.string.all_charities));
break;
case ADD_ATTENDANT_FRAGMENT:
openFragments(new AddAttendantFragment());
setTitle(getString(R.string.view_causes));
break;
case EVENTS_LIST_FRAGMENT:
openFragments(new EventsListFragment());
setTitle(getString(R.string.add_charity));
break;
case ADD_EVENTS_FRAGMENT:
openFragments(new AddEventFragment());
setTitle(getString(R.string.make_donation));
break;
case MY_DONATIONS:
openFragments(new AddEventFragment());
setTitle(getString(R.string.my_dontations));
break;
case SETTINGS_FRAGMENT:
startActivity(new Intent(this, PreferenceActivity.class));
//ToDO
default:
return;
}
}
private void setTitle(String title)
{
getSupportActionBar().setTitle(title);
}
private void addItemsToNavigationList(){
navigationItemsList.add(new DrawerItem(getString(R.string.all_charities), R.drawable.ic_action_attendant_list));
navigationItemsList.add(new DrawerItem(getString(R.string.add_charity), R.drawable.ic_action_events_list));
navigationItemsList.add(new DrawerItem(getString(R.string.view_causes), R.drawable.ic_action_add_attendant));
navigationItemsList.add(new DrawerItem(getString(R.string.make_donation), R.drawable.ic_action_add_event));
navigationItemsList.add(new DrawerItem(getString(R.string.my_dontations), R.drawable.ic_action_add_attendant));
navigationItemsList.add(new DrawerItem(getString(R.string.settings), R.drawable.ic_action_settings));
}
'''
my NavDrawerAdapter
'''
package com.charity.dogood.dogood.adapters;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.charity.dogood.dogood.R;
import com.charity.dogood.dogood.models.DrawerItem;
import java.util.List;
/**
* Created by Valentine on 6/18/2015.
*/
public class NavDrawerAdapter extends RecyclerView.Adapter<NavDrawerAdapter.ViewHolder> {
//Declare variable to identify which view that is being inflated
//The options are either the Navigation Drawer HeaderView or the list items in the Navigation drawer
private static final int TYPE_HEADER = 0;
private static final int TYPE_ITEM = 1;
// String Array to store the passed titles Value from MainActivity.java
private String mNavTitles[];
// Int Array to store the passed icons resource value from MainActivity.java
private int mIcons[];
//String Resource for header View Name
private String name;
//int Resource for header view profile picture
private int profile;
//String for the email displayed in the Navigation header
private String email;
private Context mContext;
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == TYPE_ITEM) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.nav_drawer_row,parent,false); //Inflating the layout
ViewHolder vhItem = new ViewHolder(v,viewType); //Creating ViewHolder and passing the object of type view
return vhItem; // Returning the created object
//inflate your layout and pass it to view holder
} else if (viewType == TYPE_HEADER) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.header,parent,false); //Inflating the layout
ViewHolder vhHeader = new ViewHolder(v,viewType); //Creating ViewHolder and passing the object of type view
return vhHeader; //returning the object created
}
return null;
}
//Next we override a method which is called when the item in a row is needed to be displayed, here the int position
// Tells us item at which position is being constructed to be displayed and the holder id of the holder object tell us
// which view type is being created 1 for item row
@Override
public void onBindViewHolder(NavDrawerAdapter.ViewHolder holder, int position) {
if(holder.Holderid ==1) { // as the list view is going to be called after the header view so we decrement the
// position by 1 and pass it to the holder while setting the text and image
holder.textView.setText(mNavTitles[position - 1]); // Setting the Text with the array of our Titles
holder.imageView.setImageResource(mIcons[position -1]);// Settimg the image with array of our icons
}
else{
holder.profile.setImageResource(profile); // Similarly we set the resources for header view
holder.Name.setText(name);
holder.email.setText(email);
}
}
@Override
public int getItemCount() {
return mNavTitles.length + 1;
}
public static class ViewHolder extends RecyclerView.ViewHolder{
int Holderid;
TextView textView;
ImageView imageView;
ImageView profile;
TextView Name;
TextView email;
public ViewHolder(View itemView,int ViewType) { // Creating ViewHolder Constructor with View and viewType As a parameter
super(itemView);
// Here we set the appropriate view in accordance with the the view type as passed when the holder object is created
if(ViewType == TYPE_ITEM) {
textView = (TextView) itemView.findViewById(R.id.rowText); // Creating TextView object with the id of textView from nav_bar_rowrow.xml
imageView = (ImageView) itemView.findViewById(R.id.rowIcon);// Creating ImageView object with the id of ImageView from nav_bar_row.xmlxml
Holderid = 1; // setting holder id as 1 as the object being populated are of type item row
}
else{
Name = (TextView) itemView.findViewById(R.id.name); // Creating Text View object from header.xml for name
email = (TextView) itemView.findViewById(R.id.email); // Creating Text View object from header.xml for email
profile = (ImageView) itemView.findViewById(R.id.circleView);// Creating Image view object from header.xml for profile pic
Holderid = 0; // Setting holder id = 0 as the object being populated are of type header view
}
}
}
/**
* With this method we determine what type of view being passed.
* @param position
* @return
*/
@Override
public int getItemViewType(int position) {
if (isPositionHeader(position))
return TYPE_HEADER;
return TYPE_ITEM;
}
private boolean isPositionHeader(int position) {
return position == 0;
}
public NavDrawerAdapter(List<DrawerItem> dataList, Context context, String Name, String Email, int Profile){ // MyAdapter Constructor with titles and icons parameter
// titles, icons, name, email, profile pic are passed from the main activity as we
mNavTitles = new String[dataList.size()];
mIcons = new int[dataList.size()];
for (int i = 0; i < dataList.size(); i++){
mNavTitles[i] = dataList.get(i).getItemName();
mIcons[i] = dataList.get(i).getImgResId();
}
mContext = context;
name = Name;
email = Email;
profile = Profile; //here we assign those passed values to the values we declared here
//in adapter
}
}
'''
I am able to get the username and email in my drawer but what should I do with the bmp , the bitmap that I downloaded to get it displayed in the app Navigation Drawer? like this the image,
<IMAGE> | In NavDrawerAdapter.java
define field
'''
Bitmap bitmapAvatar = null;
'''
then in function onBindViewHolder(NavDrawerAdapter.ViewHolder holder, int position)
replace
'''
holder.profile.setImageResource(profile);
'''
with
'''
if (bitmapAvatar != null) {
holder.profile.setImageBitmap(bitmapAvatar);
} else {
holder.profile.setImageResource(profile);
}
'''
and create a function(in outer class)
'''
public void setAvatar(Bitmap bmp) {
this.bitmapAvatar = bmp;
notifyDataSetChanged();
}
'''
callig notifyDatasetChanged() will update the Views with current data with adapter instance.
In MainActivity.java
use
'''
private NavDrawerAdapter mAdapter;
'''
instead of
'''
private RecyclerView.Adapter mAdapter;
'''
and in GetDataCallback, after Bitmap is ready to use with bmp variable, remove the line
'''
HEADER_IMAGE = (ImageView)findViewById(R.id.c)
'''
it isn't required to intialize ImageView in MainActivity and you don't have semicolon also.
After removal, put the following calling code at the same place after bmp is created:
'''
mAdapter.setAvatar(bmp);
'''
it will call the function we created in adapter class and change the image dynamically. | |
24,964,836 | 1 | 24,964,875 | After reading some answers from the site and viewing some sources, I thought that the compiler converts high-level language (C++ as an example) to machine code directly as the computer itself doesn't need to convert it to assembly, it only converts it to assembly for the user to view the code and can have more control over the code if needed.
But this was found in one of my lecture sheets, so can I would appreciate if someone could explain further and correct me if I am wrong, or the screenshot below.
<IMAGE> | There is a 1-to-1 mapping between assembly and machine code. Assembly is a textual representation of the information, and machine code is a binary representation.
Some machines however, support additional assembly instructions, but what instructions are included in the produced assembly code is still determined at compile time, not runtime. Generally speaking however, this is determined by the processor in the system (intel, amd, ti, nvidia, etc..) not the manufacturer that you purchase the whole system from. | |
20,676,620 | 1 | 20,676,828 | I am using Tesseract OCR for getting an exclusively numeric string in a PDF file.
The PDF contains : 66600O3377.pdf
but Tesseract recognizes : 66600Q3377.pdf
The input is a TIFF file, the quality is good enough (see the screenshot).
Is there a way to improve the Tesseract accuracy ? I could always change Q for a 0 but I'm afraid of further unexpected mistakes.
<IMAGE> | This is in <URL>:
Run a tesseract command like this to only permit digits in input image:
'''
tesseract imagename outputbase digits
''' | |
21,477,481 | 1 | 21,478,022 | In TFS I have a started a Scrum project, but I want to add some fields to a Work Item.
So I'm following <URL> on how to add and work hour fields to a Work Item.
I added one field in the layout, like shown in the tutorial. But when I try to save it I then get the following error:
'''
TF237113: You don't have enough permissions to complete the import operation.
'''
I think I have all the needed permissions. I changed all my user permissions and also the permissions I have in the TFS project that I'm working on.
<IMAGE>
But so far no luck. Even when I try to add a field in the 'Layout' tab that already exists, then it still gives me that error. Anyone any idea what I can try to solve this error? | It looks like you're using Visual Studio Online (Since I can see that you have a Windows Live ID), Visual Studio Online doesn't support process template customization at all at the moment. This is due to the fact that they release new versions of the service every 3 weeks or so, and having to consolidate and test all customization across all projects would be a major pain. | |
31,377,019 | 1 | 31,546,891 | I am trying to run a Decision Tree using 'RPart' in R, on a data set with 26 variables to classify an outcome as 0 or 1. The model has a fair accuracy of 81% and when I go ahead and plot the tree, I get very gibberish variable splitting values. Ex: v10 contains a list of countries, say US, UK, India, etc. but the plot as shown here as some nonsensical values. v7 here was a list of URLs, v12 some quantitative numbers in my data set, but the tree values look screwed up.
<IMAGE> | The algorithm replaces the levels of each factor by lower and upper case letters in the alphabet. If there are more than 56 levels in a factor, the Z letter is repeated, so it is not recommended to use factors with more than 56 levels as input to a rpart model.
However, it is possible to avoid the unwanted "gibberish" output: if you are using plot() + text(), try using the "pretty" parameter in the text() function. Example:
'''
plot(tree)
text(tree, pretty=1)
'''
Other output functions have their specific parameter for that. "labels()" for instance, has the "minlength" parameter:
'''
labels(tree)
labels(tree,minlength=0)
'''
I hope that helps. | |
10,928,161 | 1 | 10,928,283 | I've been using SQL Server Management Studio (SSMS) for the last 8 years, and I keep on stumbling upon a problem. When I right click on a Table, and select SELECT TOP 2000 ROWS, the query editor opens up a new file with the query inside. This is nice and all for a quick review of the table.
The problem I have is the default database is changed from the actual database to the master database. I have sysadmin rights.
The query that gets generated by SSMS, then has the databse, schema, and table in brackets, i.e. [DB].[dbo].[TableName]
Is there a way to set the default database on the SELECT TOP 2000 ROWS command, to NOT go and set the default database to 'master' ?
The other workaround is to click on the table, and then do a 'New Query', which will keep the current database, and then I have to type in 'SELECT * FROM TableName'
<IMAGE> | In SSMS go to Security > Logins - choose your login, then right-click and choose Properties - at the bottom of the tab is an option called "Default Database" - this is what you want to change. | |
13,813,321 | 1 | 13,908,095 | Quite often when there are many other applications running, Tortoise SVN's unified diff viewer can fail to show up - . But after closed some other applications, this diff viewer act normally again. I suspect this is related to the available GDI resources left in system, according to my observation, though in fact any other applications (even heavy resource consumers like MSWord/Excel...) can start without problem.
Has anyone got any idea of solving this?
OS: Windows XP SP3
TortoiseSVN 1.6.16
<IMAGE> | Tried use TortoiseUDiff.exe from TortoiseSVN 1.7.10 and problem solved. Seems should be bug in 1.6.16. | |
3,784,147 | 1 | 3,784,505 | If you use <URL> which is the approximate percentage of physical memory in use. Is memory that SuperFetch has consumed added to dwMemoryLoad? I'm working on software which uses this statistic to manage its own caching, flushing cache when the percentage goes too high. I'm worried that SuperFetch causes false results.
Reading about SuperFetch, games users on Vista <URL> turning it off improves performance. That confirms my hypothesis that SuperFetch will cause an application to falsely believe more physical RAM is in use than is actually used by the apps being run.
Mark Russinovitch's <URL> has a nice explanation of SuperFetch.
In an interesting example of where the original Task Manager is more informative than Sysinternals Process Explorer, Jeff Atwood has pictures of the <URL> in Task Manager.
<IMAGE>
Note the 6MB free Physical Memory!
I'm not just being lazy - all our 32bit test machines are running XP and I only have access to 64 bit Vista or Windows 7 machines, so I'd still like to hear from people as to how it affects 32 bit systems. | Tentatively, the answer is it doesn't get included - the cached amount is accumulated separately.
I turned on SuperFetch on my Vista x64 machine (interesting to note it was off for some reason) and built the sample program in the <URL> docs. At a time with little happening on my machine, the sample was reporting but the Windows task manager showed Physical Memory stats of:
- - - | |
17,954,958 | 1 | 17,955,096 | I use Delphi since version 2 and now on the version XE3.
Since 'BSD2006' I've noticed this menu 'Languages' on the 'Project' main . Now that I am interested in build an application available in and , I searched for tutorials on the Internet but couldn't find anything about this function, only third party components and wizards. Since English is not my first language, I don't even know how to look for the right terms in order to get to this Delphi tool.
Does anyone already used this tool? Where Can I find a proper tutorial to get started? Thanks.
<IMAGE>
Since Remy answered correctly, but with a link, I will resume it so other can get to it quickly:
1. Save all your project files
2. Go to Menu > Project > Languages > Add
3. Add as many languages as you need
4. Go to Menu > View > Project Manager
5. You will see your project plus a project for each language you created
6. Expand one language project and you will see the DFM files to translate your forms
7. Right click and open one and you will see the Translation Editor
8. Translate all the needed strings and then save the file
9. Again in the Project manager expand .\Win32\Debug\ and see the RC resource files
10. Right click one and edit the constant strings of all the units files of your app
More Tips:
- In order to get the strings of your own units into the translation list file, you have to create them as constants, but using not the 'consts' reserved word, but the 'resourcestring' one, like: 'resourcestring Str1 = 'Test'; StrN = '%s strings found';'- Every time you create a new 'resourcestring' or add a visual component on a form, you have to update the languages metadata, and to do it, go to Menu > Project > Languages > Update Localized Projects- Every time you finish to translate the terms on your language files, you not just have to save those files, but you have to re-build the projects they belong. It's easier if you go to Menu > Project > Build All Projects | Start by reading the documentation:
<URL>
<URL> | |
24,861,692 | 1 | 24,888,109 | I am trying to change an ActiveX TreeView Node Background colour, using VBScript. I thought it would be as easy as this: 'Node.BackColor = vbBlue' But clearly it is not. I am struggling to find documentation on this control.
This is my code so far:
'''
Set Node = TreeView1.Nodes.Add("T" & CStr(ParentNodeID),4,"T" & CStr(NewNodeID),NodeText,CInt(ImageNumber),CInt(SelectedImageNumber))
Node.Tag = Tag
Node.BackColor = vbBlue
'''
This is the error I am getting when running this code:
<IMAGE>
Not sure what else I can do? | I found a useful documentation on this control here <URL>. And my code would have worked, only with a newer version of the control. I had an older version and that was my only problem. I used 'Microsoft TreeView Control 6.0', and my older version was 'Microsoft TreeView Control 5.0'. | |
9,413,184 | 1 | 9,430,927 | I"m using <URL> to try and implement webpages inside my windows form application.
I've used the the awesomium .NET samples but I just don't get the my tab with my homeurl.
When I run my project the status bar is floating inside my form and nothing else happens.
Anyone know where I can get a tut on how to do this or know what could be the problem?
'''
public Laboratory() {
WebCoreConfig webConfig = new WebCoreConfig() {
SaveCacheAndCookies = true,
HomeURL = "http://www.google.com",
LogLevel = LogLevel.Verbose
};
// Using our executable as a child rendering process, is not
// available when debugging in VS.
if (!Process.GetCurrentProcess().ProcessName.EndsWith("vshost")) {
// We demonstrate using our own executable as child rendering process.
// Also see the entry point (Main function) in Program.cs.
webConfig.ChildProcessPath = WebCoreConfig.CHILD_PROCESS_SELF;
}
WebCore.Initialize(webConfig);
InitializeComponent();
}
#region methodes
#region OpenTab
internal WebDocument OpenTab(string url = null, string title = null) {
WebDocument doc = String.IsNullOrEmpty(url) ? new WebDocument() :
String.IsNullOrEmpty(title) ? new WebDocument(url) : new WebDocument(url, title);
doc.Show(dockPanel);
return doc;
}
#endregion
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
this.OpenTab();
}
'''
<IMAGE> | I've redone the left panel completely and used the other example that was with the download, that works like a charm. It's very basic but that'll do for now. | |
9,108,138 | 1 | 9,112,324 | I want to change the default styling of the volume bar in Flex to <IMAGE>
I want to know if it is possible? Any clues would be really helpful.
Thanks. | Create custom skin for your 'VolumeBar'.
<URL>.
You can take default skin ('VolumeBarSkin.mxml') from your sdk, copy code to your custom skin file and change styling there. After that apply your skin to the component ('skinClass' style property). | |
58,840,955 | 1 | 58,841,312 | I'm trying to write a sub-query to retrieve values from one of the columns I already selected with the main query, but under different criteria.
<IMAGE>
<URL> | I believe this is what you're looking for:
'''
CREATE TABLE #temp (thedate date, customer VARCHAR(100), revenue INT, [type] VARCHAR(100))
INSERT INTO #temp values ('2019-01-01','Acme, Inc.',1000,'Charge')
,('2019-01-01','Amazon',500,'Charge')
,('2019-01-01','Acme, Inc.',100,'Credit')
SELECT [Date]
, [Customer]
, [Revenue] as [Charge]
, [Credit]
FROM #temp t1
OUTER APPLY (
SELECT sum(revenue) credit
FROM #temp t2
WHERE t1.customer = t2.customer
AND t2.[type] = 'credit'
) x
WHERE t1.[type] = 'charge'
'''
Judging solely based on your input data and expected result, the above query should suffice. However, the comments you posted on your question are slightly contradictory with what the image of the expected result shows.
This is the output of my query, based on your input data:
<URL> | |
12,140,558 | 1 | 12,140,684 | Now it's time to explore Android for me. I have designed one ui which is shown below, The thing is I am getting confused with what should I do in the first frame in order to get 9x9 grid. Actually the same thing I developed in core java by placing 81 JTextFields in each cell using for loops and with the help of gridbaglayout and I got my application perfectly working. But in android how can I define my 9x9 cells in xml, so that it should accept numbers and entered numbers should be retrieved too in order to validate the sudoku rules. Following is my code and diagram. Can anyone suggest how to make the frame 1 to have 9x9 cells? If I use TextEdit in my xml file, it would be 81 textfields, and if I use Canvas(I am thinking, don't know whether it is possible), it seems to me impossible to make it accept numbers and to retrieve from that canvas board. I really appreciate if anyone could help. Please go easy, if it seems silly question(which I hope not, as I tried 2 days for it), as I am new to android. Thanks in advance.
'''
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/fLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#0f0"
/>
<FrameLayout
android:id="@+id/fLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
android:background="#00f">
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keypad"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="*">
<TableRow >
<Button android:id="@+id/cancel"
android:text="cancel"
android:layout_span="3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</TableRow>
<TableRow>
<Button android:id="@+id/submit"
android:text="validate"
android:layout_span="3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</Button>
</TableRow>
</TableLayout>
</FrameLayout>
</LinearLayout>
'''
Here is the UI
<IMAGE>. | I suggest you to use <URL>
> is a ViewGroup that displays items in a two-dimensional, scrollable grid. The grid items are automatically inserted to the layout using a ListAdapter. | |
9,820,309 | 1 | 9,836,159 | <IMAGE>
I want to make a form like this in windows forms. To make a user choose to continue...
I use DevExpress and i want a control or a button or a way to make something like this. For example when the user clicks a choice to be hightlighted.
Is a control for doing this or i have to do something bad styled with buttons and labels? | It is possible to use the <URL> to organize such a cell layout within a row.
Hide indicators, bands, columns, etc. i.e. organize a simple list.
Handle the RowStyle event to emulate a <URL>.
Handle the Click event of the required entity to respond to end-user manipulations. | |
6,992,051 | 1 | 6,993,046 | I have a a design problem. I have a centered logo on a page, What I want is a div centered between the left side of the page and te left side of the logo.
how could I achieve this using only css ?
Here is the example:
<IMAGE> | Take a look at this demo...
<URL>
## HTML
'''
<div id="wrapper">
<div id="box-left">
<div id="left"></div>
</div>
<div id="box-center">
<div id="center"></div>
</div>
</div>
'''
## CSS
'''
html, body {
margin: 0 !important;
padding: 0 !important;
}
#wrapper {
width: 100%;
}
#box-center, #box-left {
width: 50%;
float: left;
}
#left {
border: 1px solid magenta;
height: 50px;
width: 50px;
position: relative;
left: 50%;
/* half of width of #left + half of margin-left of #center */
margin-left: -75px; /* 50/2 + 100/2 = 25 + 50 = 75 */
}
#center {
border: 1px solid magenta;
height: 50px;
width: 200px;
margin-left: -100px;
}
'''
I hope this helps. | |
19,892,682 | 1 | 19,896,224 | I have a website that runs on Wordpress. There is a call to action (CTA) on the front page with contact details for the website business. Within the backend one is prompted to enter an email address and phone number for the call to action.
This is then output in an anchor tag:
'''
<a class="front-button" href="mailto:[email protected]">
Tel: <PHONE> [email protected] </a>
'''
This creates a fairly large and intrusive big long button on the home page, where the email and phone number are displayed on one line.
Within the CMS I tried to add a break tag in the actual CTA button input box:
'''
[email protected] <br /> Tel: <PHONE>
'''
This just output the exact same html as above, the '<br />' tag was ignored.
I could hard edit the html within the CMS but have two questions:
1) Is there a way to add the break within the CMS input box for the call to action? I imagined something like the opposite of an escape backslash character that says "No, this is html don't ignore"
2) Does a '<br />' tag even work when nested within an anchor '<a>' tag?
<IMAGE> | Question 1 - can you get your CMS to accept the line break tag?
Depending on the specific CMS - if it has a visual editor, shift and enter can usually get you a line break. If it allows the HTML source to be edited, that should work although the CMS may be using a crude regex that doesn't understand self-closing tags, so try:
'''
<br>
'''
As well as the self-closing version.
Question 2 - is a line break allowed in an anchor?
In HTML5, a br element is allowed inside any "phrasing element" and an anchor is a phrasing element - so it is allowable to put a br tag inside an a tag.
<URL> | |
31,437,160 | 1 | 31,439,882 | I have a UIView I'm trying to put together which will be layered above another view. This new view needs to have a fully transparent hole in it. I've attached a screenshot of what it is I'm trying to accomplish (checkerboard pattern is the underlying UIView that will be adding this new UIView as a sublayer, red is a UIImage).
<IMAGE>
I have the following code that will render the black background with the hole in the center:
'''
- (void)
drawRect:(CGRect)rect
{
CGRect boxRect = CGRectMake(_location.x - (kPointRadius/2), _location.y - (kPointRadius/2), kPointRadius, kPointRadius);
UIBezierPath *path = [UIBezierPath
bezierPathWithRoundedRect:CGRectMake(0, 0, self.layer.frame.size.width, self.layer.frame.size.height)
cornerRadius:0];
UIBezierPath *circlePath = [UIBezierPath
bezierPathWithRoundedRect:boxRect
cornerRadius:kPointRadius];
[path appendPath:circlePath];
[path setUsesEvenOddFillRule:YES];
CAShapeLayer *fillLayer = [CAShapeLayer layer];
fillLayer.path = path.CGPath;
fillLayer.fillRule = kCAFillRuleEvenOdd;
fillLayer.fillColor = [UIColor blackColor].CGColor;
fillLayer.borderWidth = 5.0;
fillLayer.borderColor = [UIColor redColor].CGColor;
fillLayer.opacity = 0.7;
[self.layer addSublayer:fillLayer];
}
'''
However, when I add an image to that and use '[[UIImage imageNamed:@"testimg" drawAtPoint:CGPointMake(x, y)];' to add the image, the image covers the hole.
Can anyone point me in the right direction here? I'm stumped.
I'm now able to get it almost there. I can get everything I need EXCEPT the image layered on top of the black, 90% opaque background is also at 90% opacity.
'''
CGRect boxRect = CGRectMake(
_location.x - (kPointRadius/2),
_location.y - (kPointRadius/2),
kPointRadius,
kPointRadius);
UIBezierPath *path = [UIBezierPath
bezierPathWithRoundedRect:CGRectMake(0, 0, self.layer.frame.size.width, self.layer.frame.size.height) cornerRadius:0];
UIBezierPath *circlePath = [UIBezierPath
bezierPathWithRoundedRect:boxRect
cornerRadius:kPointRadius];
[path appendPath:circlePath];
[path setUsesEvenOddFillRule:YES];
UIImage *image = [UIImage imageNamed:@"testimg"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(13, 57, 350, 230)];
imageView.image = image;
CGRect r = CGRectMake(self.layer.frame.origin.x, self.layer.frame.origin.y, self.layer.frame.size.width, self.layer.frame.size.height);
UIGraphicsBeginImageContextWithOptions(r.size, NO, 0);
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextAddPath(c, CGPathCreateCopy(path.CGPath));
CGContextEOClip(c);
CGContextFillRect(c, r);
UIImage* maskim = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CALayer* mask = [CALayer layer];
mask.frame = r;
mask.contents = (id)maskim.CGImage;
imageView.layer.mask = mask;
self.layer.mask = mask;
self.layer.backgroundColor = [UIColor blackColor].CGColor;
self.layer.opacity = 0.8;
[self.layer addSublayer:imageView.layer];
''' | > EDIT: I'm now able to get it almost there. I can get everything I need EXCEPT the image layered on top of the black, 90% opaque background is also at 90% opacity.
Instead of setting its opacity, you could set the layer's background color to '[UIColor colorWithWhite:0.0 alpha:0.9]'. | |
22,310,081 | 1 | 22,312,682 | I've to design a database where I've a client entity and a client can place multiple type of orders (all differ with each other, but few fields are common among them like status, pricing, time etc).
For example, he can place Order-A, Order-C, Order-F (from different forms). I'm confused how to cater different type of Orders.
This is what I've created so far.
<IMAGE>
Now I'm confused how to cater the fields that aren't common among order types. Should I create separate tables for each order type to save all different values? and add foreign key of all those tables to order table? It would be so complex. Whats the best way to do this? | The purist would say that you should create a separate table for each type of order, with the fields relevant to that order type. If there are fields that are common to all order types, these should be in a separate, common table. Then the tables with type-specific data should point to the "main" order table.
The opposite alternative is to put all the fields in one table, and set the ones not applicable to a given order type to null.
Which method you choose really depends on your data. Frankly, if I have 30 fields in an order record, and then one or two fields that only apply to some orders, I just throw them in the order table and let them be null when not applicable.
If you have many different order types and many different fields in different order types, creating separate tables can be a real beast. Who wants to manage 30 order tables? It also gets tricky when some fields are in more than one order type but not all.
Personally, I generally create one big table with all the fields and let some be null. This is usually the most practical. But you have to look at the nature of your data and your entities. If there are a small number of different order types and there are a large number of fields peculiar to each, it starts to make sense to make separate tables to keep them separate. It might be less confusing if there aren't bunches of null fields. | |
58,730,046 | 1 | 58,730,305 | I have a school project where i need to make a exact copy of a website.
The background is a bit tricky because i need to (what i think) add a radial ellipse but then with no sides or bottom, only the top.
when i try to make a ellipse i get a oval which covers all four sides (obviously) but i dont know hot to apply it to the top only.
can anyone help me out?
this is what is is supposed to look like
PLease pay attention to the background only
<IMAGE>
I already tried a ellipse and a normal radial gradient but i does not function how i want it to be.
this is the code i have
'''
background-image: radial-gradient(ellipse, white, lightgrey, lightgrey,
#1b1b2e
#1b1b2e);
''' | adjust your code like below:
'''
html {
min-height:100%;
background-image: radial-gradient(150% 150% at bottom center, white, lightgrey, #1b1b2e, #1b1b2e);
}
''' | |
26,576,648 | 1 | 26,576,841 | I can't figure out why my elements (logo, menu, info box) are outside the light grey container. Could you help me? Many thanks
See: <URL>
<IMAGE>
HTML:
'''
<header class="header">
<div class="header-wrapper">
<img class="header-logo" src="http://lorempixel.com/output/fashion-q-g-284-119-5.jpg">
<nav class="header_nav">
<ul class="header_nav-wrapper">
<li class="header_nav-item"> <a id="aboutOpen" class="header_nav-item-a" href="jkk">l'Atelier</a>
</li>
<li class="header_nav-item"> <a class="header_nav-item-a header_nav-item-a--btn" href="jkjks" target="_blank">La Carte des soins</a>
</li>
<li class="header_nav-item"> <a class="header_nav-item-a header_nav-item-a--btn" href="jkjks" target="_blank">Contact</a>
</li>
</ul>
</nav>
</div>
<div class="infos-pratiques clearfix">
<p class="info-pratiques-tag">Informations pratiques</p>
<div class="info-pratiques-content">
<p>3 rue dfdsf
<br>sdsqdssdd</p>
<p>Lundi:
<br>Mardi:
<br>Mercredi:
<br>Jeudi</p>
</div>
</div>
</header>
<div class="slider">
<ul class="slider__wrapper">
<li class="slider__item">
<div class="box" style="background-image:url(images/test.jpg);background-size: cover;
background-repeat: no-repeat; background-position: 50% 50%;"></div>
</li>
<li class="slider__item">
<div class="box" style="background-image:url(images/test2.jpg);background-size: cover;
background-repeat: no-repeat; background-position: 50% 50%;"></div>
</li>
</ul>
</div>
'''
CSS:
'''
.slider {
position: relative;
margin-left: auto;
margin-right: auto;
width: 90%;
height: 550px;
background: #eee;
overflow: hidden;
box-shadow: 0 2px 5px rgba(0, 0, 0, .5);
max-width: 1200px;
}
.slider__wrapper {
height: 100%;
list-style: none;
overflow: hidden;
*zoom: 1;
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
}
.slider__item {
height: 100%;
float: left;
clear: none;
}
.slider__arrows-item {
position: absolute;
display: block;
margin-bottom: -20px;
padding: 20px;
}
.slider__arrows-item--right {
bottom: 50%;
right: 30px;
}
.slider__arrows-item--left {
bottom: 50%;
left: 30px;
}
.slider__nav {
position: absolute;
bottom: 30px;
}
.slider__nav-item {
width: 12px;
height: 12px;
float: left;
clear: none;
display: block;
margin: 0 5px;
background: #fff;
}
.slider__nav-item--current {
background: #ccc;
}
.slider__nav-item:hover {
background: #ccc;
}
.box {
width: 100%;
height: 100%;
}
.header {
z-index: 999;
width: 100%;
margin-left: auto;
margin-right: auto;
position: absolute;
}
.header-wrapper {
padding: 54px 60px;
}
.header-logo {
float: left;
clear: none;
}
.header_nav {
float: right;
clear: none;
font-family:'Maven Pro', sans-serif;
font-weight: normal;
}
.header_nav-wrapper {
list-style: none;
}
.header_nav-item {
margin-left: 22px;
float: left;
clear: none;
}
.header_nav-item-a {
color: #474032;
text-decoration: none;
}
.header_nav-item-a:hover {
color: #eee;
}
.header_nav-item-a--btn {
padding: 16px 18px;
border-radius: 5px;
border: 1px solid #474032;
background-color: transparent;
}
.header_nav-item-a--donate {
margin-top: -18px;
}
.header_nav-item-a--btn:hover {
border: 1px solid #eee;
}
.info-pratiques-content {
float: left;
clear: both;
margin-top: 14px;
margin-left: 4.52489%;
font-size: 13px;
line-height: 1.38;
color: #433d2b;
}
.info-pratiques-content p {
margin-bottom: 1em;
}
.info-pratiques-tag {
margin-top: 14px;
margin-right: auto;
margin-left: auto;
padding-top: 2px;
padding-right: 2px;
padding-bottom: 2px;
padding-left: 2px;
background-color: #9d926a;
font-size: 13px;
font-weight: 400;
line-height: 1.38;
text-align: center;
text-transform: uppercase;
color: rgb(65, 61, 45);
}
.infos-pratiques {
position: absolute;
top: 217px;
right: 5.<PHONE>%;
z-index: 26;
width: 221px;
height: 200px;
background-color: rgb(222, 222, 222);
opacity: 0.91;
}
''' | The 'max-width' and the 'background' are on '.slider', but your header is not inside of it. just add the background and max-width to body and everything should be fine.
Also keep in mind that absolutely positioned elements are always relative to the closest non-static element ('position: fixed, relative, absolute').
edit: I also agree with Paulie_D's comment, try to reduce absolute positioning | |
44,160,136 | 1 | 44,162,425 | I have been given a very complex issue that I may not have the expertise to solve. I have tried a lot of difference methods, but I have not come close to solving this problem.
We have a relational database using SQL Server within an application called Lansweeper. I am working with two tables. One table ('tblAssets') houses our computer inventory data, and the other table ('tblRegistry') houses registry data of these computers.
I have a requirement to query for the computer name , driver name, and driver version all into one row. However, the driver version and driver name are within two separate registry keys on a computer, and the only way to derive the version and driver is by the registry key value.
I have created a simple query below to start.
'''
Select Distinct Top <PHONE> tblAssets.AssetName,
tblRegistry.Valuename,
tblRegistry.Value,
tblRegistry.Regkey
From tblRegistry
Inner Join tblAssets On tblAssets.AssetID = tblRegistry.AssetID
Where tblRegistry.Valuename Like '%Driver%'
Order By tblRegistry.Regkey
'''
I have provided an image of the current output and the desired output.
<IMAGE>
I think the biggest road block for me right now is how to treat the value for derived key location values in order to do this. I have created variants of row_number, pivot and union, but I am really at a loss of what to do. | You can join tblRegistry twice and include the 'Valuename' in the join conditions. Something like this:
'''
SELECT DISCTINCT assets.AssetName ComputerName
, reg1.value Driver
, reg2.value DriverVersion
FROM tblAssets assets
JOIN tblRegistry reg1
ON reg1.AssetID = assets.AssetID
AND reg1.Valuename = 'DriverDesc'
JOIN tblRegistry reg2
ON reg2.AssetID = assets.AssetID
AND reg2.Valuename = 'DriverVersion'
''' | |
27,489,526 | 1 | 27,496,033 | I am getting this error "Ad is not visible. Not refreshing ad." However my ad is visible. There is more than enough room to display the ad (all the green area is ad area). Will I still get credit for displaying the ad?
<IMAGE> | You get credit when someone clicks on your add, not when the ad is displayed.
So the message is irrelevant. | |
59,630,985 | 1 | 59,631,146 | My understanding of the grammar is as follows:
'''
float p = 3.14;
++(int)p;
'''
But when I compile it with clang, it fails to compile. So how do understand and what is use for? '(int)p' is a so why doesn't it work?
<IMAGE>
<URL> | '++(int)p' fails to compile because '(int)p' is not an l-value. However, that's a semantic error, not a syntactic one. Syntactically it's valid and matches the '++ cast-expression' production.
An instance where '++' followed by a cast would be both syntactically and semantically valid would be when you cast to a reference (references being l-values). An example (albeit not a useful one) would be:
'''
int x = 42;
++(int&)x;
'''
In practice the 'cast-expression' in '++ cast-expression' will rarely be an actual cast. In most cases, 'cast-expression' will be further reduced to 'primary-expression', allowing you to match expressions like '++x'. | |
28,554,766 | 1 | 28,554,935 | Is it possible to make progress bar like following image.
<IMAGE>
Star have to be filled up by giving percentage. Any help will be highly appreciable. Thanks. | <IMAGE>
There is a library to get this above animation.
Find it <URL>.
It's not complicated to use. all you have to do is add the following custom view in layout
'''
<com.romainpiel.titanic.TitanicTextView
android:id="@+id/titanic_tv"
android:text="@string/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#212121"
android:textSize="70sp"/>
'''
and then start it like:
'''
titanic = new Titanic();
titanic.start(myTitanicTextView);
'''
Yes, you can use it instead of progressBar. All you have to do is override it's code according to your requirements. | |
28,515,976 | 1 | 28,541,812 | webdriverbackedselenium throwing unhandled exception when use WaitForPageToLoad(timeout);
Even i have try catch
'''
try
{
selenium.WaitForPageToLoad(timeout);
}
catch
{
}
'''
Catching its exception, but when it comes out of catch, showing this image<IMAGE>
Tried many solutions but didn't succeeded , please advise what should i Do.
Thank you. | You may configure the <URL> even you have the catch block in your code.
Please see more details and pictures <URL> | |
33,745,271 | 1 | 51,152,021 | I'm trying to get the center of my view by using the code below, the class being used is from the 'DTIActivityIndicatorView' which add a custom activity indicator to the view.
'''
var midX = CGRectGetMidX(self.view.bounds)
var midY = CGRectGetMidY(self.view.bounds)
let topStoriesActivityIndicator: DTIActivityIndicatorView = DTIActivityIndicatorView(frame: CGRect(x: midX, y: midY, width:80.0, height:80.0))
'''
But the code above is giving me the following result where the activity indicator isn't centered in the middle.
<IMAGE> | '''
extension CGRect {
var center: CGPoint { .init(x: midX, y: midY) }
}
let someRect = CGRect(x: 10, y: 10, width: 200, height: 40)
let theCenter = someRect.center // {x 110 y 30}
''' | |
18,033,117 | 1 | 18,033,443 | I am following the Stanford lectures on developing apps for iOS and I've run into a bit of a problem.
The lecturer says to click on a label from the Document Outline and then go to Editor > Size to fit contents in order to remove the fixed size constraints. However my problem is that "Size to fit contents" is disabled and I cannot click it (see image).
<IMAGE>
Any idea what I'm doing wrong? | I fixed the issue by dragging around the labels and resizing them (randomly) manually and then the option was enabled! | |
27,877,609 | 1 | 27,883,471 | I want to show a picture in javafx webview local html. here is my code, But I found the picture can not be shown.The image url is "file:/D:/a.jpg".
<IMAGE>
'''
//Main WebViewBrowser.java
public class WebViewBrowser extends Application {
@Override public void start(Stage stage) throws Exception {
WebView browser = new WebView();
browser.setContextMenuEnabled(false);
WebEngine webEngine = browser.getEngine();
String url = this.getClass().getResource("t.html").toExternalForm();
System.out.println(url);
//out put is "jar:file:/D:/data/netbeans/WebViewBrowser1/dist/run690102893/WebViewBrowser.jar!/webviewbrowser/t.html"
Scene scene = new Scene(browser);
webEngine.load(url);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
//t.html
//.............
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<div>TODO write content</div>
<img src="a.jpg" alt="aaa"/> <!-- the relative path works -->
<img src="file:/D:/a.jpg" alt="aaa"/> <!-- the absolute path dos not work.why ?-->
</body>
</html>
'''
I just want to know how i can load the image which url is like 'file:/D:/a.jpg'.
Thak you very much. | With the new description of your problem, I can reproduce it too: it seems 'WebView' can't access to local files if the web page is loaded from a jar file.
After searching for a while, I've just found this bug report on JIRA (you need to be registered to access to it):
- <URL>
As it is pointed out in the report, if you right-click over the alt description, you can load the image on a new window, what means it's not a problem of security restrictions (sandbox).
For the moment there's no easy solution. One that is proposed also <URL> is encoding the image as a base64 string:
'''
<img src="data:image/png;base64,(...)" />
public String pathToBase64(String path) throws IOException {
return Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get(path)));
}
'''
Other solution is using 'webEngine.loadContent()'. There's already an example <URL> that may work.
As the OP points out, there's another workaround to deal with local images loading, based on the use of a custom URL protocol. In this <URL> there's already a working solution. For the image loading this is a possible implementation:
'''
private void loadImage() throws IOException {
String imgPath = getURL().toExternalForm();
String ext = imgPath.substring(imgPath.lastIndexOf('.')+1);
imgPath = imgPath.startsWith(PROTOCOL+"://") ?
imgPath.substring((PROTOCOL+"://").length()) :
imgPath.substring((PROTOCOL+":").length());
try{
BufferedImage read = ImageIO.read(new File(imgPath));
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(read, ext, os);
data=os.toByteArray();
} catch(IOException ioe){
System.out.println("IO exception: "+ioe);
}
}
''' | |
3,792,039 | 1 | 3,792,059 | I signed up for an account for a free web hosting.
The site provides MySQL databases and I'm trying to access it using my windows application but I can't connect to the server. Please consider my code:
'''
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace MySql
{
public partial class Form1 : Form
{
BackgroundWorker bg = new BackgroundWorker();
string MyConString = "SERVER=209.51.195.117;" + // MySQL host: sql100.0fees.net
"DATABASE=mydb;" + // IP: 209.51.195.117
"UID=myusername;" + // not really my username
"PASSWORD=mypassword;"; // and password
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
bg.DoWork += new DoWorkEventHandler(bg_DoWork);
bg.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted);
}
void bg_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
button1.Enabled = true;
}
void bg_DoWork(object sender, DoWorkEventArgs e)
{
string status = String.Empty;
MySqlConnection connection = new MySqlConnection(MyConString);
try
{
connection.Open();
if (connection.State == ConnectionState.Open)
lblStatus.Text = "Connected";
else
lblStatus.Text = "No connection";
}
catch (Exception x)
{
lblStatus.Text = x.Message;
}
}
private void button1_Click(object sender, EventArgs e)
{
lblStatus.Text = "Connecting... please wait.";
button1.Enabled = false;
bg.RunWorkerAsync();
}
}
}
'''
Is it possible to connect my application to an online database? Or are there errors in my code?
By the way, this the error message being produced: 'Unable to connect to any of the specified MySQL hosts.'
<IMAGE> | Unless you have full control over the server, you can't expose the mysql service to the web. This restriction is imposed by (almost; there might be exceptions) all free hosters for security reasons. Unless you provide a webservice on the server to access data, you can't access the database remotely. | |
45,525,228 | 1 | 45,525,296 | I am using to draw an imported binary .stl file as a mesh like this:
'''
ToxiclibsSupport gfx;
TriangleMesh mesh;
void setup(){
mesh = (TriangleMesh)new STLReader().loadBinary(
sketchPath("/data/3dmodels/gun.stl"), STLReader.TRIANGLEMESH);
gfx = new ToxiclibsSupport(this);
}
void draw(){
translate(width/2, height/2, 300);
gfx.origin(new Vec3D(), 100);
noStroke();
fill(fxColor.getRed(), fxColor.getGreen(), fxColor.getBlue());
gfx.mesh(model, false, 0);
translate(-width/2, -height/2, -300);
}
'''
Toxiclibs shows the xyz-axes by default as shown here:
<IMAGE>
I want to disable the draw of those axes, but can't seem to find anything related.
Thank you. | Can't you just get rid of the call to 'gfx.origin()'? According to <URL>, that's what's drawing the axis lines. | |
26,098,772 | 1 | 26,098,868 | I have a problem optimizing a really slow prestashop SQL query .
'''
SELECT
SQL_CALC_FOUND_ROWS a.*, a.id_order AS id_pdf,
CONCAT(LEFT(c.'firstname', 1), '. ', c.'lastname') AS 'customer',
osl.'name' AS 'osname',
os.'color',
IF((SELECT COUNT(so.id_order) FROM 'ps_orders' so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new,
(SELECT COUNT(od.'id_order') FROM 'ps_order_detail' od WHERE od.'id_order' = a.'id_order' GROUP BY 'id_order') AS product_number
FROM 'ps_orders' a
LEFT JOIN 'ps_customer' c
ON (c.'id_customer' = a.'id_customer')
LEFT JOIN 'ps_order_history' oh
ON (oh.'id_order' = a.'id_order')
LEFT JOIN 'ps_order_state' os
ON (os.'id_order_state' = oh.'id_order_state')
LEFT JOIN 'ps_order_state_lang' osl
ON (os.'id_order_state' = osl.'id_order_state' AND osl.'id_lang' = 6)
WHERE 1
AND oh.'id_order_history' = (SELECT MAX('id_order_history') FROM 'ps_order_history' moh WHERE moh.'id_order' = a.'id_order' GROUP BY moh.'id_order')
ORDER BY 'date_add' DESC
LIMIT 0,50
'''
<IMAGE>
What should I do ?
Thanks in advance for the answers. | This is a bit long for a comment.
The 'explain' looks reasonable. Except. The final 'order by' is requiring a filesort on 204,480 rows, which is probably accounting for much of the time. It is unclear where the column 'date_add' is coming from. But, perhaps you know that all rows will come from the last week or so. If so, then an additional 'where' clause might help:
'''
where date_added >= now() - interval 7 day and . . .
''' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.