Thursday, 3 October 2013

Source code of copy image and paste it in paint

Source code of copy image and paste it in paint

I want to copy the image from website and paste it in the paint and
Microsoft word. Pls help me to solve out this problem.

Wednesday, 2 October 2013

How To create a report using data from Excel in Word Template

How To create a report using data from Excel in Word Template

Summary: I have to fill in a report using data from Excel in Word
Template. Problem: I am trying to write a macro which will search some
variables in pre-defined template (doc) and replace these variables with
data from excel. The variables are nothing but some text like <-Date->,
<-Author-> (self-created). There are also some Tables and Sections that
needs to be duplicated from the Word Template depending on the Excel Data.
For Example
I'll need to make 3 more Sections for Dates. Because Word
1.<-Date->
Excel 03-10-2013 04-10-2013 05-10-2013
After Macro 1. 03-10-2013
04-10-2013
05-10-2013
Thanks in advance.

Displaying console output in jtextarea even when other actions occur

Displaying console output in jtextarea even when other actions occur

I found this code here: how to display console output in java JTextarea
one by one in a loop when button action is triggered and it displays
console output in a jtextarea. I have added this class as action in a
jmenuitem. So that it appears when I want and when I run other classes it
will show the output there. However when I launch it, it works properly,
but if I try and launch another class which will show output in console
and accept userinput, the jtextarea which is supposed to show console
output at the same time, it freezes. How could I make it so that it stays
tuned, despite invoking other classes/frames? Thanks in advance
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DynamicWrite implements ActionListener
{
JFrame frame = new JFrame("TextArea");
JTextArea tArea = new JTextArea(10,20);
JButton button = new JButton("Click");
JScrollPane pane = new JScrollPane(tArea);
SwingWorker worker;
String s= "Java is an Object Oriented Programming langauge...Java is
static typed language...asbfldfjsdj";//some random String
public void prepareAndShowGUI()
{
Container container = frame.getContentPane();
container.add(pane);container.add(button,BorderLayout.NORTH);
tArea.setLineWrap(true);
tArea.setWrapStyleWord(true) ;
button.addActionListener(this);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent evt)
{
if(evt.getSource()==button)
{
tArea.setText("");
if (worker!=null)
{
worker.cancel(true);
}
worker = new SwingWorker()
{
@Override
protected Integer doInBackground()//Perform the required
GUI update here.
{
try
{
for(int i = 0;i<s.length();i++)
{
tArea.append(String.valueOf(s.charAt(i)));
Thread.sleep(5);
}
}catch(Exception ex){}
return 0;
}
};
worker.execute();//Schedules this SwingWorker for execution on
a worker thread.
}
}
public static void main(String st[])
{
DynamicWrite dyna = new DynamicWrite();
dyna.prepareAndShowGUI();
}
}

If C# code is JIT compiled why do I have to choose a target platform in Visual Studio when building?

If C# code is JIT compiled why do I have to choose a target platform in
Visual Studio when building?

My assumption could be wrong, but I thought that the main advantage of JIT
compilation is that allows a single distributable that the JIT compiler
will compile for the target machines particular hardware.
If this is true, then why can a target platform be specified when
compiling C#?
Thanks.

Tuesday, 1 October 2013

Creating A new Route in MVC

Creating A new Route in MVC

In MVC, the default route url pattern is - url : "{controller}/{action}/{id}"
When I add a new route as shown below before the default route, the
default route does not work. I can I make them to co-exist
routes.MapRoute(
name: "Name",
url: "{controller}/{action}/{name}",
defaults: new { controller = "Home", action = "Browse", name =
UrlParameter.Optional }
);

I cant simply await GetStringAsync?

I cant simply await GetStringAsync?

I thought I could do i straight forward, but maybe there is something
wrong with my setup? I'm trying to download a string in my app for logging
in:
private async void DoLogin()
{
HttpClient client = new HttpClient();
string response = await
client.GetStringAsync(Config.SERVER_URL + "/Login/");
All logic is removed, im going to add headers and so on, but VS2012 will
no allow me to await that response.
I tried to follow the code from here, but in my case I only get Cannot
await 'System.Threading.Tasks.Task<string'.
Why is that? Should'nt GetStringAsync simply return me a string? It
returns a Task<string>, but do I have to wrap it in a method?

Conditional probability with and without replacement

Conditional probability with and without replacement

A sample of size $r$ is taken from a population of $n$ elements. Find the
probability that none
of the $N$ prescribed elements will be included in the sample, assuming
the sampling to be
a) without
b) with replacement
..


Compare the numerical value for the two methods, when
(i) n=100, r=N=3
and
(ii) n=100, r=N=10
..

How to draw a big red cross through large parts of a text=?iso-8859-1?Q?=3F_=96_tex.stackexchange.com?=

How to draw a big red cross through large parts of a text? –
tex.stackexchange.com

I am co-authoring a piece of text, and I would like to indicate that in my
opinion certain parts should be removed, by drawing a big red cross
through that specific section. I have tried to work with …

Monday, 30 September 2013

Ssh X11 forwarding very slow using Xshell

Ssh X11 forwarding very slow using Xshell

My server is Ubuntu 12.10
And my client is Windows 7 64bit
Now I am using Xshell to connect my server via ssh
But after I forwarding X11, it's take a long time!!
after I enter
$matlab -nodesktop
it's almost take 5~10 mins to ready for use
I have found some speed up issue on the web but it's work on MAC not on
windows(Xshell)!
following is solution for mac and it's worked perfect!
ssh -c arcfour,blowfish-cbc -XC username@host
But when I use Xshell it's always think -c arcfour,blowfish-cbc -XC
usernameis my username!
Is there any other way to make it faster?

What changes in Ubuntu 12.10 as a VM?

What changes in Ubuntu 12.10 as a VM?

I compiled a small "hello world" C program on Ubuntu 10.04 32 bit machine.
Then I put the executable(a.out) on Ubuntu 12.10(64 bit) VMWare virtual
machine and tried to execute it(./a.out). The OS does not identify the
file and says 'No such file or directory'. But when I put the same
executable on a Ubuntu 12.10(64 bit) running on a 64 bit laptop, it runs
fine and I get the desired output. The VM is running on IBM Blade Servers.
I wanted to know why the results for a VM?

Python tkiner grid_forget()

Python tkiner grid_forget()

I have a problem with grid_forget() ,because i want to appear and
disappear a Label, this is part of the code:
def creabackuno():
showinfo( "Wait..","I am creating the backup, please wait...")
vsl=Label(gui,text="Working, please
wait...",font=("arial",16)).grid(row=20,rowspan=1,column=0,columnspan=1,padx=10,sticky=N)
try:
copytree(path,r"backup\dirbackup1\.minecraft")
showinfo( "OK!","Backup (1) created!")
vsl.grid_forget()
except OSError:
showerror( "Nope!","There is already a backup to restore")
vsl.grid_forget()
And this is the error of the console:
AttributeError: 'NoneType' object has no attribute 'grid_forget'
I'm using python 2.7.5 thanks!

How is the position of an array pointer determined in a preg_replace_callback's callback function with an array of subjects?

How is the position of an array pointer determined in a
preg_replace_callback's callback function with an array of subjects?

e.g.
$array = preg_replace_callback("/pattern/", create_function( '$matches',
'[WHAT IS MY ARRAY POSITION? ($foo = ...)]; return $foo);' ), $array);

Sunday, 29 September 2013

Checking an array list of strings for substring

Checking an array list of strings for substring

I need to write a public method that takes an array of strings and checks
to see if there are any strings in the array that contain the substring or
string "nine". I wrote a method to check for "nine" but I'm stumped for
the substring.
public static boolean doesFive ( String [] input ) {
boolean rez = false;
String n = "nine";
for( int i = 0; i < inputArray.length - 1; i++ ) {
if( inputArray[i].equals(n) ) {
rez = true;
}
}
return rez;
}

Google Analytics: export every visitor

Google Analytics: export every visitor

I'm looking for a method to export every unique visitor from Google
Analytics. So, a visitor could open a website for multiple times, I would
like to export a single row with some information about the visits like
mean time on the website, number of purchases, mean order amount etc.
Thanks in advance.

jquery return only text from filtered results

jquery return only text from filtered results

my html filtered is giving me
$.get(myURL, function(data) {
$(data).find("td.Chats").filter(':gt(5)').appendTo('#regions');
}, 'html')
results:
<td class="Chats">Item 1</td>
<td class="Chats"></td>
<td class="Chats"></td>
<td class="Chats"></td>
<td class="Chats"></td>
<td class="Chats">Item 2</td>
<td class="Chats"></td>
<td class="Chats"></td>
<td class="Chats"></td>
<td class="Chats"></td>
<td class="Chats">Item 3</td>
<td class="Chats"></td>
<td class="Chats"></td>
<td class="Chats"></td>
<td class="Chats"></td>
How would I just get the elements with text? or every 5th ?

What the difference between SerialPort control and SerialPort class in .Net

What the difference between SerialPort control and SerialPort class in .Net

I am using c# serialPort to communication with inverter that is used in
solar power station.
Now I have a issue: when I use SerialPort control dragged from toolbox,
the DataReceived event will no be fired, but when trun to use SerialPort
class, it is working.
Can anybody please kindly tell me something about it, thank you very much!

Saturday, 28 September 2013

Cannot use alert() in a jQuery method

Cannot use alert() in a jQuery method

When using jQuery to make an AJAX call, for the time being I want to just
want to have a popup box (using alert()) showing me the response text.
$(document).ready(function() {
$(".jeobutton").mouseup(function() {
var $button = $(this);
$.ajax({ url: 'getdata.php',
data: // <parameters>
type: 'get',
dataType: 'json',
success: function(output) {
// do something
},
error: function(xhr) {
alert("<some error>");
console.error(xhr.responseText);
}
});
});
});
The response text prints out fine. However, the alert() dialog is nowhere
to be found.
Please help this poor noob.

Missing package in Google IO application code

Missing package in Google IO application code

I download the code of iosched(Google I/O App for Android) application and
tried to run it, but i can't find the
com.google.api.services.googledevelopers.model package nor
com.google.api.services.googledevelopers package in the first place,
neither on the website itself nor over the internet. can anyone please
point that out. thank you :)

Remove empty space from the end of a line in a richtextbox

Remove empty space from the end of a line in a richtextbox

How can I remove empty space from end of line in a richtextbox
Original string
ALTER TABLE "TBLCONCESSIONAIREOFFICES" ADD ("CNCO_IRISAUTOCONFIRMINVOICE"
NUMBER(2,0) DEFAULT 0 --0: No, 1: Yes;
);
Expected result:
ALTER TABLE "TBLCONCESSIONAIREOFFICES" ADD
("CNCO_IRISAUTOCONFIRMINVOICE" NUMBER(2,0) DEFAULT 0 --0: No, 1:
Yes);
My code:
string[] lines2 = comparedResultRTB1.Lines;
lines2.ToString().Replace("; );",");");

Cannot compile Mono.Addins

Cannot compile Mono.Addins

I've tried to compile the current version of Mono.Addins, but it failed
with the following error messages:
Building Mono.Addins.Gui.csproj
/usr/lib/mono/4.0/Microsoft.Common.targets: warning : Reference
'glib-sharp, Version=2.12.0.0, Culture=neutral,
PublicKeyToken=35e10195dab3c99f' not resolved
/usr/lib/mono/4.0/Microsoft.Common.targets: warning : Reference
'pango-sharp, Version=2.12.0.0, Culture=neutral,
PublicKeyToken=35e10195dab3c99f' not resolved
/usr/lib/mono/4.0/Microsoft.Common.targets: warning : Reference
'atk-sharp, Version=2.12.0.0, Culture=neutral,
PublicKeyToken=35e10195dab3c99f' not resolved
/usr/lib/mono/4.0/Microsoft.Common.targets: warning : Reference
'gdk-sharp, Version=2.12.0.0, Culture=neutral,
PublicKeyToken=35e10195dab3c99f' not resolved
/usr/lib/mono/4.0/Microsoft.Common.targets: warning : Reference
'gtk-sharp, Version=2.12.0.0, Culture=neutral,
PublicKeyToken=35e10195dab3c99f' not resolved
Mono.Addins.Gui/AddinManagerDialog.cs(30,7): error CS0246: The type or
namespace name Gtk' could not be found. Are you missing an assembly
reference?
Mono.Addins.Gui/AddinTreeWidget.cs(32,7): error CS0246: The type or
namespace nameGtk' could not be found. Are you missing an assembly
reference?
Mono.Addins.Gui/AddinTreeWidget.cs(33,7): error CS0246: The type or
namespace name Gdk' could not be found. Are you missing an assembly
reference?
Mono.Addins.Gui/ManageSitesDialog.cs(31,7): error CS0246: The type or
namespace nameGtk' could not be found. Are you missing an assembly
reference?
I've alread installed the current versions of Mono and Gtk# from sources.
Any idea what's going wrong?