Home » Web Development » Page 13485

I'm using C# .NET, WinForms 2.0



In my MatchCollection, I get matches of the same thing. Like
this:



string text = @"match match match";
Regex R = new Regex("match");
MatchCollection M = R.Matches(text);


So my question is, how to remove duplicate matches in the fastest
way possible? Assume duplicate here means that the match contains the
exact same string.

I use Artifactory Java client, and cant upload file to Artifactory.
My code is very simple, taken from Artifactory Java Client test
folder:



artifactoryClient =
ArtifactoryClient.create("localhost:8081", "admin", "admin");
InputStream content = new ByteArrayInputStream("I want to test my
upload!".getBytes());
UploadableArtifact apAtrifact =
artifactoryClient.repository("ext-snapshotlocal").upload("test/content.txt",
content);
File res = apAtrifact.doUpload();


I got error:



02:44:26.014 [main] DEBUG org.apache.http.headers -
>> Accept-Encoding: gzip,deflate
02:44:26.014 [main] DEBUG org.apache.http.wire - >> "I want to
test my upload!"
02:44:26.248 [main] DEBUG org.apache.http.wire - << "HTTP/1.1
403 Forbidden[
][
]"
02:44:26.250 [main] DEBUG org.apache.http.wire - << "Server:
Apache-Coyote/1.1[
][
]"
02:44:26.250 [main] DEBUG org.apache.http.wire - <<
"Content-Type: text/html;charset=utf-8[
][
]"
02:44:26.250 [main] DEBUG org.apache.http.wire - <<
"Content-Length: 961[
][
]"
02:44:26.250 [main] DEBUG org.apache.http.wire - << "Date: Sun,
24 Nov 2013 00:44:25 GMT[
][
]"
02:44:26.250 [main] DEBUG org.apache.http.wire - << "[
][
]"
02:44:26.250 [main] DEBUG o.a.h.i.conn.DefaultClientConnection -
Receiving response: HTTP/1.1 403 Forbidden
02:44:26.250 [main] DEBUG org.apache.http.headers - << HTTP/1.1
403 Forbidden
02:44:26.250 [main] DEBUG org.apache.http.headers - << Server:
Apache-Coyote/1.1
02:44:26.250 [main] DEBUG org.apache.http.headers - <<
Content-Type: text/html;charset=utf-8
02:44:26.250 [main] DEBUG org.apache.http.headers - <<
Content-Length: 961
02:44:26.250 [main] DEBUG org.apache.http.headers - << Date:
Sun, 24 Nov 2013 00:44:25 GMT
02:44:26.253 [main] DEBUG o.a.h.impl.client.DefaultHttpClient -
Connection can be kept alive indefinitely
02:44:26.254 [main] DEBUG groovyx.net.http.RESTClient - Response code:
403; found handler: org.codehaus.groovy.runtime.MethodClosure@41feeacb
02:44:26.254 [main] DEBUG groovyx.net.http.RESTClient - Parsing
response as: application/json
02:44:26.265 [main] DEBUG org.apache.http.wire - <<
"<html><head><title>Apache Tomcat/7.0.39 - Error
report</title><style><!--H1
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
BODY
{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}
B
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}
P
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
{color : black;}A.name {color : black;}HR {color :
#525D76;}--></style> </head><body><h1>HTTP
Status 403 - </h1><HR size="1"
noshade="noshade"><p><b>type</b> Status
report</p><p><b>message</b>
<u></u></p><p><b>description</b>
<u>Access to the specified resource has been
forbidden.</u></p><HR size="1"
noshade="noshade"><h3>Apache
Tomcat/7.0.39</h3></body></html>"
02:44:26.272 [main] DEBUG o.a.h.i.c.BasicClientConnectionManager -
Releasing connection
org.apache.http.impl.conn.ManagedClientConnectionImpl@4349f1b6
02:44:26.272 [main] DEBUG o.a.h.i.c.BasicClientConnectionManager -
Connection can be kept alive indefinitely
02:44:26.278 [main] WARN groovyx.net.http.RESTClient - Error parsing
'text/html;charset=utf-8' response
com.fasterxml.jackson.core.JsonParseException: Unexpected character
('<' (code 60)): expected a valid value (number, String, array,
object, 'true', 'false' or 'null')
at [Source: org.apache.http.conn.EofSensorInputStream@494f0b41; line:
1, column: 2]
at
com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1284)
~[services-0.9-all.jar:na]
at
com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:588)
~[services-0.9-all.jar:na]


Could you help me with this issue?

I have a PHP script where I want to compare two numbers.



$usernumber = $_POST['usernumber'];

$sql = "SELECT password, isadmin, disabled FROM user WHERE usernumber
= " . $usernumber .";";


Everything is working fine but there is one more or less cosmetic
problem.



The usernumber is saved as a DECIMAL(5,0) with
ZEROFILL. If I compare 1 with 00001
it is true!



But is there also a possibility to compare these two with a SQL
command so it is only true if they are really the same, like
00001 and 00001?



In addition I do not have the possibilty to save it as a other
datatype because I use other functions that need a number.

I've created a ActionBar Style Using the tool ActionBar Style
Generator ( href="http://jgilfelt.github.io/android-actionbarstylegenerator"
rel="nofollow">http://jgilfelt.github.io/android-actionbarstylegenerator
);I selected appcombat at the style compatibility selection list,
because I need my app to be compatible with Android 2.3 devices; but
when I downloaded and implemented the theme,the styles are only shown
on my Android 2.3 emulated device; in newer devices it only shows the
deafault ones. This is the code:



/values/styles.xml



    <?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Theme.Iedecap"
parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item
name="actionBarItemBackground">@drawable/selectable_background_iedecap</item>
<item
name="popupMenuStyle">@style/PopupMenu.Iedecap</item>
<item
name="dropDownListViewStyle">@style/DropDownListView.Iedecap</item>
<item
name="actionBarTabStyle">@style/ActionBarTabStyle.Iedecap</item>
<item
name="actionDropDownStyle">@style/DropDownNav.Iedecap</item>
<item
name="actionBarStyle">@style/ActionBar.Solid.Iedecap</item>
<item
name="actionModeBackground">@drawable/cab_background_top_iedecap</item>
<item
name="actionModeSplitBackground">@drawable/cab_background_bottom_iedecap</item>
<item
name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Iedecap</item>

<!-- Light.DarkActionBar specific -->
<item
name="actionBarWidgetTheme">@style/Theme.Iedecap.Widget</item>

</style>

<style name="ActionBar.Solid.Iedecap"
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item
name="background">@drawable/ab_solid_iedecap</item>
<item
name="backgroundStacked">@drawable/ab_stacked_solid_iedecap</item>
<item
name="backgroundSplit">@drawable/ab_bottom_solid_iedecap</item>
<item
name="progressBarStyle">@style/ProgressBar.Iedecap</item>
</style>

<style name="ActionBar.Transparent.Iedecap"
parent="@style/Widget.AppCompat.ActionBar">
<item
name="background">@drawable/ab_transparent_iedecap</item>
<item
name="progressBarStyle">@style/ProgressBar.Iedecap</item>
</style>

<style name="PopupMenu.Iedecap"
parent="@style/Widget.AppCompat.PopupMenu">
<item
name="android:popupBackground">@drawable/menu_dropdown_panel_iedecap</item>

</style>

<style name="DropDownListView.Iedecap"
parent="@style/Widget.AppCompat.ListView.DropDown">
<item
name="android:listSelector">@drawable/selectable_background_iedecap</item>
</style>

<style name="ActionBarTabStyle.Iedecap"
parent="@style/Widget.AppCompat.ActionBar.TabView">
<item
name="android:background">@drawable/tab_indicator_ab_iedecap</item>
</style>

<style name="DropDownNav.Iedecap"
parent="@style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item
name="android:background">@drawable/spinner_background_ab_iedecap</item>
<item
name="android:popupBackground">@drawable/menu_dropdown_panel_iedecap</item>
<item
name="android:dropDownSelector">@drawable/selectable_background_iedecap</item>
</style>

<style name="ProgressBar.Iedecap"
parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
<item
name="android:progressDrawable">@drawable/progress_horizontal_iedecap</item>
</style>

<style name="ActionButton.CloseMode.Iedecap"
parent="@style/Widget.AppCompat.ActionButton.CloseMode">
<item
name="android:background">@drawable/btn_cab_done_iedecap</item>
</style>

<!-- this style is only referenced in a Light.DarkActionBar
based theme -->
<style name="Theme.Iedecap.Widget"
parent="@style/Theme.AppCompat">
<item
name="popupMenuStyle">@style/PopupMenu.Iedecap</item>
<item
name="dropDownListViewStyle">@style/DropDownListView.Iedecap</item>
</style>


AndroidManifest.xml



    <?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hipano.idecapmovil" >

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Iedecap" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN"
/>

<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:label="@string/app_name" >
</activity>

<activity
android:name=".Register"
android:label="@string/app_name" >
</activity>
<activity
android:name=".DashboardActivity"
android:label="@string/title_activity_dashboard" >
</activity>
</application>

</manifest>


I think this is pretty strange since my entire code was generated
by an automatic tool.
Thanks in advance

We are developing a Rails app, that has quite a few pages with data
reports. A typical reporting page is based on a relatively big SQL
query, usually involving 5–8 table joins.



The cornerstone question we've stumbled upon is – writing
integration tests reports pages. A common integration test of ours
looks like this:




  1. creating a bunch of records in the DB via href="https://github.com/thoughtbot/factory_girl"
    rel="nofollow">factory_girl in the test
    setup,


  2. fire up a rel="nofollow">capybara scenario, where a user logs
    in, advances to the page with report, and sees the right data in
    it.




As the app grows and we get to create more of such reports pages,
we've started to run into the following problem - the setup for each
individual test ends up being too big, complex and generally hard to
read and maintain.



Creating such a test significantly raises the bar for a developer
in delivering a feature, related to reporting, as it is very
time-consuming and not optimized for happiness. However, we still need
to make sure our reports are correct.



Therefore, my questions are:




  1. should or should we not test pages with
    reports?


  2. if we should test the reports, then what would be the
    least painful way to do that?


  3. where are we doing wrong?


I'm trying to make database for my program and I'm having a lot of
dumb problems...
It's fragment of main activity:



Database db = new
Database(this,editText.getText().toString());
String text = db.printRow();
textView.setText(text);


Now database class:



String nickname="EmptyNick";
public Database(Context context, String name) {
super(context, "database.db", null, 1);
nickname = name;
}

public void onCreate(SQLiteDatabase db) {
if(!nickname.equals("EmptyNick")) {
db.execSQL("create table player(id integer primary key
autoincrement,nick text);");
Users user = new Users();
user.setNick("Mariusz");
addPlayer(user);
}
else {
//not important
}
}

private void addPlayer(Users user) {
SQLiteDatabase db = getWritableDatabase();
ContentValues values = new ContentValues();
values.put("nick",user.getNick());
db.insertOrThrow("player",null,values);
}

public String printRow() {
String string=null;
if(!nickname.equals("EmptyNick")) {
String[] collumns = {"id","nick"};
SQLiteDatabase db = getReadableDatabase();
Cursor cursor =
db.query("player",collumns,null,null,null,null,null);
cursor.moveToFirst();
while (cursor.moveToNext()) {
string += cursor.getString(1);
}
}
else {
//not important
}
return string;
}


Errors:
no such table: player
Caused by: java.lang.reflect.InvocationTargetException
Caused by: android.database.sqlite.SQLiteException: no such table:
player (code 1): , while compiling: SELECT id, nick FROM player



I really can't see what's wrong. Error says there is no table
'player', but it is. On the beggining of onCreate methon in line:



db.execSQL("create table player(id integer primary key
autoincrement,nick text);");


Can somebody help me? If I make Toast instead of text.setText(...)
it shows me empty field, so yes, it can't create specific row. I
understand the error, but do not from where and why it comes.

I have this android program that would take a source images which
will be matched with a template image. Using ORB, I was able to detect
keypoints and extract descriptors as well. For matching, I used
Brute-force hamming as suggested by some OpenCV tutorials that would
fit for ORB descriptors. Based on the initial results, Brute-force
hamming was able to match descriptors between a source image and a
template image. However, I believe there is inaccuracy when it comes
to finding the good matches out of all the matches.



Example situation:



Source Image 1 and Source Image 2 are being matched with a Template
Image. Source Image 1 is 70-80% the same with Template Image if our
eyes and mind are to judge, while the Source Image 2 is of only
10-20%. Upon using the combination of ORB/Brute Force, Source Image 1
compared with Template Image produces 490 matches and a 23 good
matches. Whereas, Source Image 2 compared with Template Image produces
500 matches with 450 good matches.



Please see this sample images:



href="https://drive.google.com/folderview?id=0B4a02nUWN3pvaFFXT05Gc2lvRFU&usp=sharing"
rel="nofollow">https://drive.google.com/folderview?id=0B4a02nUWN3pvaFFXT05Gc2lvRFU&usp=sharing



From that, it seems as if Source Image 2 matches perfectly with
Template Image which should have been the Source Image 1. How does
that happen? Any solution?



Here's my code:



Note: srcImage - source image, tmpImage - template image



Mat srcImage = new Mat();
Mat tmpImage = new Mat();



    // convert bitmap to MAT
Utils.bitmapToMat(source, srcImage);
Utils.bitmapToMat(template, tmpImage);

//to Greyscale
Mat srcGreyscale = new Mat();
Mat tmpGreyscale = new Mat();

Imgproc.cvtColor(srcImage, srcGreyscale, Imgproc.COLOR_RGB2GRAY);
Imgproc.cvtColor(tmpImage, tmpGreyscale, Imgproc.COLOR_RGB2GRAY);

//Feature Detection
FeatureDetector orbDetector =
FeatureDetector.create(FeatureDetector.ORB);
DescriptorExtractor orbextractor =
DescriptorExtractor.create(DescriptorExtractor.ORB);

MatOfKeyPoint kpsrc = new MatOfKeyPoint();
MatOfKeyPoint kptmp = new MatOfKeyPoint();
Mat descriptors_src = new Mat();
Mat descriptors_tmp = new Mat();

//Getting the keypoints
orbDetector.detect(srcGreyscale, kpsrc);
orbDetector.detect(tmpGreyscale, kptmp);

//Compute descriptors
orbextractor.compute( srcGreyscale, kpsrc, descriptors_src );
orbextractor.compute( tmpGreyscale, kptmp, descriptors_tmp );

//Match with Brute Force
MatOfDMatch matches = new MatOfDMatch();
DescriptorMatcher matcher;
matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE);
matcher.match( descriptors_src, descriptors_tmp, matches);

double max_dist = 0;
double min_dist = 100;

List<DMatch> matchesList = matches.toList();

//-- Quick calculation of max and min distances between keypoints
for( int i = 0; i < descriptors_src.rows(); i++ )
{ double dist = matchesList.get(i).distance;
if( dist < min_dist ) min_dist = dist;
if( dist > max_dist ) max_dist = dist;
}

LinkedList<DMatch> good_matches = new
LinkedList<DMatch>();

int count = 0;
for( int i = 0; i < descriptors_src.rows(); i++ )
{ if( matchesList.get(i).distance <= 2*min_dist )
{ good_matches.addLast( matchesList.get(i));
count++;}
}


I tried using findHomography function as advised by others but it
did not help. Please guys, really need your help here.

I apologize if I'm posting into the wrong community, I'm quite new
here.



I have multiple methods using the same foreach loop, changing only
the inner method I call:



    public void CalculationMethod1()
{
foreach (Order order in ordersList)
{
foreach (Detail obj_detail in order.Details)
{
CalculateDiscount(obj_detail);
}
}
}

public void CalculationMethod2()
{
foreach (Order order in ordersList)
{
foreach (Detail obj_detail in order.Details)
{
CalculateTax(obj_detail);
}
}
}


Each inner method has different logic, database search, math
calculations (not important here).



I'd like to call the methods above without repeating the foreach
loop everytime, so I throught about the solution below:



    public void CalculateMethod_3()
{
foreach (Order obj_order in ordersList)
{
foreach (Detail obj_detail in order.Details)
{
CalculateDiscount(obj_detail);
CalculateTax(obj_detail);
}
}
}


But I fall into a rule problem:



 class Program
{
static void Main(string[] args)
{
Calculation c = new Calculation();
c.CalculateMethod_3();
c.AnotherMethod_4(); //It doesn't use objDetail
c.AnotherMethod_5(); //It doesn't use objDetail
c.CalculateMethod_6(); //Method 6 needs objDetail but
respecting the order of the methods, so It must be after
AnotherMethod_4 and AnotherMethod_5
}
}


How can I create a method to achieve my objective (I don't want to
repeat code) respecting the rule above?

I have question about fprintf and fwrite.
How many bytes are written when this code runs (assuming fp has been
correctly set up).



int i = 10000;

fprintf(fp,"%d",i);

fwrite(fp,sizeof(int),1,&i);


When I checked then 5 bytes and 9 bytes respectively. Maybe I am
wrong. I thought it is 4 bytes since int. Can someone explain
please??? Thanks.

I have this really simple code in Microsoft Visual Studio C#
2013:



//all stuff I include
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient; //sql DB
using System.Media; //media player
using System.IO; //required for exceptions
using System.Globalization;

//start
namespace Programx
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
MessageBox.Show(DateTime.Now.ToString("MMMM yyyy")); //
this give error (or any other code that has DateTime)
}
}
//-----


and I get this error in error list:
"Error 1 The name 'dateTime' does not exist in the current
context"



I have found 2 possible answear to the problem:




  1. lack of: using System.Globalization; (but I have it
    in code)

  2. mscorlib.dll - included by defualt (I did not change
    it) but possible cause of the problem



Now I have checked my settings in MS Studio 2013
project -> Properties -> Build -> Advanced..." and I'd not chave
mentioned option "Do not reference mscorlib.dll" or
"Do not use stdlib" or anything similar. (but its only a
suspect, I have no proof this is the reason)



Could somebody tell me what I need to do in order to use
DateTime? Thx.


- Technology - Languages
+ Webmasters
+ Development
+ Development Tools
+ Internet
+ Mobile Programming
+ Linux
+ Unix
+ Apple
+ Ubuntu
+ Mobile & Tablets
+ Databases
+ Android
+ Network & Servers
+ Operating Systems
+ Coding
+ Design Software
+ Web Development
+ Game Development
+ Access
+ Excel
+ Web Design
+ Web Hosting
+ Web Site Reviews
+ Domain Name
+ Information Security
+ Software
+ Computers
+ Electronics
+ Hardware
+ Windows
+ PHP
+ ASP/ASP.Net
+ C/C++/C#
+ VB/VB.Net
+ JAVA
+ Javascript
+ Programming
Privacy Policy - Copyrights Notice - Feedback - Report Violation 2018 © BigHow