Thursday, 3 October 2013

How to simulate dynamic requests per minute in JMeter where numbers come from file for each minute

How to simulate dynamic requests per minute in JMeter where numbers come
from file for each minute

After successfully using JMeter to profile our platform's performance I
got the request to simulate a 24h load based on minute-by-minute
transaction data extracted from the last year's logs.
At this point, having the static nature of thread creation in jmeter I am
wondering if this is easily achievable. I studied the usual plugins
together with those at jmeter-plugins.org but still I could not find a
straightforward way to do this kind of shaping.
I am looking at the alternative to write a groovy script that takes
control of thread creation but I am not sure if this is the proper way to
go.
Any suggestions?
Thanks, Dikran

Wednesday, 2 October 2013

AHK utilman script gives file not found error

AHK utilman script gives file not found error

I'm trying to create a simple backdoor for myself through utilman on my
computer using autohotkey. Basically I want to have the ease of access
button function normally in all cases on login screen Except when I hold
down the M key, where in this case it opens cmd instead. No batch or cmd
window should pop up, and one doesn't. The issue I'm having is that I get
a file not found error from the script, I compiled the script into
Utilman.exe and tested with a copy of the real utilman (renamed to lol.exe
which is specified in the script to run normally) and this works fine in
its own directory. However when I do this in the system32 folder it gives
an error that lol.exe is not found, also executing lol.exe on it's own
gives the exact same error, as if it reroutes to the script named Utilman
yet again. Here is the script, should be short and simple:
SetWorkingDir %A_ScriptDir%
Sleep 400
GetKeyState, state, m
if state = D
Run cmd.exe
else
Run lol.exe
Sleep 200
ExitApp
Thanks for any pointers, alternative suggestions or ideas. This would be
great to get working.
EDIT: Changing Run lol.exe to Run, "C:\Windows\System32\lol.exe" now gives
instead an exe corrupted error. This also happens if I run lol.exe on it's
own, I'm really not sure what's happening.

Error Serializing Observable Collection Windows Store

Error Serializing Observable Collection Windows Store

I have an observable collection I am trying to serialize to disk. The
error that is received is :
Type 'VisuallySpeaking.Data.GrammarList' with data contract name
'GrammarList:http://schemas.datacontract.org/2004/07/VisuallySpeaking.Data'
is not expected. Consider using a DataContractResolver or add any types
not known statically to the list of known types - for example, by using
the KnownTypeAttribute attribute or by adding them to the list of known
types passed to DataContractSerializer."} System.Exception
{System.Runtime.Serialization.SerializationException}
Here is my data object:
namespace VisuallySpeaking.Data
{
[CollectionDataContract]
public class GrammarList : ObservableCollection<GrammarDataObject>
{
public GrammarList() : base()
{
Add(new GrammarDataObject("My Name", "My name
is","Assets/SampleAssets/MyName.png"));
Add(new GrammarDataObject("Where is", "Where is",""));
Add(new GrammarDataObject("Dog", "I have a
dog","/Assets/SampleAssets/westie.jpg"));
}
}
[DataContract]
public class GrammarDataObject : VisuallySpeaking.Common.BindableBase
{
private string _Name;
private string _SpeakingText;
private string _ImagePath;
public GrammarDataObject(string Name, string SpeakingText, string
ImagePath)
{
this.Name = Name;
this.SpeakingText = SpeakingText;
this.ImagePath = ImagePath;
}
[DataMember]
public string Name
{
get { return _Name; }
set
{
if (this._Name != value)
{
this._Name = value;
this.OnPropertyChanged("Name");
}
}
}
[DataMember]
public string SpeakingText
{
get { return _SpeakingText; }
set
{
if (this._SpeakingText != value)
{
this._SpeakingText = value;
this.OnPropertyChanged("SpeakingText");
}
}
}
[DataMember]
public string ImagePath
{
get { return _ImagePath; }
set
{
if (this._ImagePath != value)
{
this._ImagePath = value;
this.OnPropertyChanged("ImagePath");
}
}
}
}
I assume that I have somehow marked my GrammarList class incorrectly, but
it escapes me as to how to resolve.
Thanks!

Two vertical child elements need to fit 100% height of parent, both dynamic heights

Two vertical child elements need to fit 100% height of parent, both
dynamic heights

I have a feeling that this might not be possible, but I'm hoping someone
will prove me wrong.
I have a parent element of a non-fixed height (although it could be, I
don't think it helps). Within it are two children, stacked vertically. The
height of the first item is unknowable. I'd like the second item to take
up the remaining height.
HTML:
<div class="container">
<a class="snippet" href="#">
<img class="example-image" src="example-image.png">
<div class="snippet-text-section">
<div class="snippet-title">Title for the item - could be one or two
lines long</div>
<div class="snippet-text">Rest of the text, filling the remaining
space.</div>
</div>
</a>
</div>
CSS:
* {
padding: 0;
margin: 0;
}
.container{
position:relative;
}
.snippet {
display: block;
border-radius: 5px;
background-color: #ddd;
color:black;
overflow:hidden;
}
img {
max-width: 100%;
vertical-align: middle;
display: inline-block;
height:100px;
}
.example-image {
width: 100%;
background-color: #111;
}
.date {
position: absolute;
top: -20px;
background-color: #1b1f52;
font-weight: bold;
padding:0px 2px;
color: white;
}
.snippet-text-section {
padding: 0px 20px 20px 0px;
position: absolute;
top: 0;
width: 100%;
height: 100%;
}
.snippet-title {
margin-bottom: 0;
font-size: 14px;
font-weight: 700;
background-color: rgba(255,0,0,0.8);
color: white;
padding: 0 5px;
border-radius: 0px 5px 0px 0px;
}
.snippet-text {
font-size: 20px;
line-height: 25px;
background-color: rgba(0,0,255,0.8);
color: white;
height: 100%;
padding: 0 5px;
border-radius: 0px 0px 5px 5px;
}
Please note I've looked at a lot of posts on here. Most similar ones deal
with the child divs having a horizontal layout. The closest I've come to a
solution (and what I'm currently using) is Two vertical divs within a 100%
height div where I'm forcing the height of the first child, but it's not
ideal.
I'm currently wondering if there's a table-layout solution I've missed...

Taking ddms logs through an application

Taking ddms logs through an application

Thanks in Advance!!
My requirement is to take ddms logs on click of a button in an app, and
save the file in sdcard.
I am able to do this through following code:
logbtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
int ret = DoShellCmd("logcat -d > /sdcard/log_" +
sysdump_time + ".log");
Log.i(LOG_TAG, "returned value"+ret);
}
});
thread.start();
}
});
}
int DoShellCmd(String cmd) {
//isDumpstateRunning = true;
Log.i(LOG_TAG, "DoShellCmd : " + cmd);
Process p = null;
String[] shell_command = {
"/system/bin/sh", "-c",cmd
};
try {
Log.i(LOG_TAG, "exec command");
p = Runtime.getRuntime().exec(shell_command);
p.waitFor();
Log.i(LOG_TAG, "exec done");
} catch (IOException exception) {
Log.e(LOG_TAG, "DoShellCmd - IOException");
return -1;
} catch (SecurityException exception) {
Log.e(LOG_TAG, "DoShellCmd - SecurityException");
return -1;
} catch (InterruptedException e) {
e.printStackTrace();
return -1;
}
Log.i(LOG_TAG, "DoShellCmd done: " + cmd);
return 1;
}
Though the log file is generated , but complete logs are not appeared.
Only some logs appears. Any help will be appreciated.

Tuesday, 1 October 2013

Can I use different workflows simultaneously in F#?

Can I use different workflows simultaneously in F#?

I need my state to be passed along while being able to chain functions
with the maybe workflow. Is there a way for 2 workflows to be within the
same context? If no, what is the way of doing it?

Doctrine many to one relation with no additional key

Doctrine many to one relation with no additional key

I've made some projects with many-to-one/many relations, foreign keys etc
in doctrine and they all worked well. At least as long as I could join
them by id and some other index.
This time I have a table with invoices and another table with company
addresses etc. A simplified Invoice.orm.yml looks like this:
uniqueConstraints:
event_user_idx:
columns: seller,number
manyToOne:
companyData:
targetEntity: CompanyData
joinColumns:
seller:
referencedColumnName: vatNo
fields:
id:
type: integer
id: true
generator:
strategy: AUTO
seller:
type: string
length: '16'
number:
type: string
length: '32'
while CompanyData.orm.yml looks like this:
indexes:
nip:
columns: [ nip ]
fields:
id:
type: integer
id: true
generator:
strategy: AUTO
name:
type: string
length: '128'
vatNo:
type: string
length: '16'
Usually I would just add a new field to Invoices, like 'company_id' and
everything would (most likely) work well. However, as vatNo is a unique
number (as there are no two companies with the same vat number) I don't
want to create necessary artificial keys. So I've made a unidirectional
many-to-one mapping as above. Everything works well when I get data from
the database. I can make a query like this:
SELECT f, c
FROM MyBundle:Invoices i
LEFT JOIN i.companyData c
WHERE f.seller = :seller
and get all the invoices with companies related to it. However, there's a
problem with adding new entities to the database - after adding a foreign
key, I can no longer change the 'seller' field. I tried
$invoice->setSeller('some string')
and
$invoice->setCompanyData($companyData) //some CompanyData object fetched
from DB
it is set to null anyway. While 'seller' is not nullable, I get an exception.
I've tried to change the mapping to:
manyToOne:
companyData:
targetEntity: CompanyData
joinColumns:
seller_other_column:
referencedColumnName: vatNo
and then the query was successful, but the seller_other_column was set to
null anyway. Another strange thing is that when I call
echo $invoice->getSeller();
print_r($invoice->getCompanyData());
$em->persist($invoice);
$em->flush();
it displays the proper data (vat number and CompanyData object), but these
data are nulled anyway, before saving to the database.
Do you have any idea what's wrong?

I am trying to remove OpenOffice to go back to LibreOffice, but I keep getting an error message

I am trying to remove OpenOffice to go back to LibreOffice, but I keep
getting an error message

I am trying to remove OpenOffice and go back to LibreOffice but I keep
getting this error message:
The following packages have unmet dependencies:
libreoffice-core : Depends: libreoffice-common (> 1:4.0.2) but it is not
going to be installed
libreoffice-help-en-us : Depends: libreoffice-l10n-en-us
libreoffice-java-common : Depends: libreoffice-common but it is not going
to be installed
libreoffice-l10n-en-gb : Depends: libreoffice-common but it is not going
to be installed
libreoffice-l10n-en-za : Depends: libreoffice-common but it is not going
to be installed
E: Unmet dependencies. Try 'apt-get -f install with no packages (or
specify a solution).
And then when try running apt-get -f install I get this:
Errors were encountered while processing:
/var/cache/apt/archives/libreoffice-common_1%3a4.0.2-0ubuntu1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

How to configure DNS nameservers for Ubuntu cloud machines non-interactively?

How to configure DNS nameservers for Ubuntu cloud machines non-interactively?

I want to setup custom nameservers for my Ubuntu cloud instances (which
have static IPs). When I try to edit /etc/resolv.conf, I see that it gets
overwritten on reboot.
If I try to set it in /etc/network/interfaces it works, but this would is
not friendly to script. Is there a easier way to script this so that the
setting remains persistent across reboots?

Monday, 30 September 2013

Sufficient and necessary conditions to get an infinite fiber $g⁻©Ã¶(w)$

Sufficient and necessary conditions to get an infinite fiber $g&#8315;©ö(w)$

I want to verify the proof of this result and get some start ideas to
overcome the different steps of this proof.
Lemma: Let $g$ be a real analytic function. Then we have the equivalence
$((a)¡ü(b))¢¢(c)$, where the statements $(a),(b)$ and $(c)$ are given by:
(a) $g$ has infinitely many real zeros.
(b) $g$ assumes arbitrarily large and arbitrarily small values, i.e., for
all $K>0$, there are $s©û,s©ü$ with $g(s©û)<-K$ and $g(s©ü)>K$,
(c) The fiber $g&#8315;©ö(w)$ is infinite for all $w¡ô&#8477;$.
Proof: (1) To prove that $(a)¡ü(b)¢¡(c)$, assume by contraduction that the
equation $g(s)=w$ has only finitely many solutions $(b_{j})_{1¡Âj¡Âi}$.
That means there are $z©û<z©ü$ such that $g(s)¡Áw$ for $w<z©û$ or $w>z©ü$.
Let $z©ý$ be the largest zero of $g$ smaller than $z©û$, and $z©þ$ the
smallest zero larger than $z©ü$. The exitence of $z©ý$ and $z©þ$ is
guaranteed by the premises that $g$ has infinitely many zeros and the fact
that $g$ is analytic, so $g$ has only finitely many zeros in the compact
interval $[z©û,z©ü]$ (or $g$ is identically $0$, but that has been ruled
out by the premise that it take arbitrarily large values), hence there
must be infinitely many outside the interval. Let
$K=max({|g(s)|:z©ý¡Âs¡Âz©þ})+|w|$. By assumption, there are $s©û,s©ü$ with
$ g(s©û)<-K$ and $g(s©ü)>K$. By the intermediate value theorem, there is
an $s_{w}$ between $z©ý$ or $z©þ$ and $s©û$ or $s©ü$ with $g(s_{w})=w$.
Contradiction.
We note that if $g$ is not analytic then it satisfies conditions (a) and
(b) but does not satisfy (c).
(2) To prove that $(c)¢¡(a)¡ü(b)$, we note first that $g$ has infinitely
many zeros because the fiber $g&#8315;©ö(0)$ is infinite. This proves item
(a). To prove item (b), let $K>0$ and $w=K+¥å,¥å>0$. The fiber
$g&#8315;©ö(K+¥å)$ is nonempty because it is infinite, hence there is
$s©ü$ such that $g(s©ü)=w=K+¥å>K$. By the same method, $g&#8315;©ö(-K-¥å)$
is nonempty, so there is $s©û$ such that $g(s©û)=-K-¥å<-K$.

What is the most elegant way to load a string array into a List=?iso-8859-1?Q?=3F_=96_stackoverflow.com?=

What is the most elegant way to load a string array into a List? –
stackoverflow.com

Say you have a array of strings containing numerical values: string[]
intArray = {"25", "65" , "0"}; What is the most elegant way to load the
numbers into a List<int> without using a for or …

mechanize: first form works, then "unknown GET form encoding type 'utf-8'"

mechanize: first form works, then "unknown GET form encoding type 'utf-8'"

I am trying to fill out 2 forms from the EUR-Lex website in order to
record some data from the generated webpage. I am stuck at form #2. I get
the feeling this should be easy and I've researched a bit, but no luck.
import mechanize
froot = '...'
f = open(froot + 'text.html', 'w')
br = mechanize.Browser()
br.open('http://eur-lex.europa.eu/RECH_legislation.do')
br.select_form(name='form2')
br['T1'] = ['V112']
br['T3'] = ['V2']
br['T2'] = ['V1']
first_page = br.submit()
f.write(first_page.get_data())
up until here everything seems to work, because I get the source of the
correct page saved to the file. But then...
br.select_form(name='form2')
br['typedate'] = ['PD']
br['startaaaa'] = '1960'
br['startmm'] = '01'
br['startjj'] = '01'
br['endaaaa'] = '1960'
br['endmm'] = '12'
br['startjj'] = '31'
next = br.submit()
here everything stops:
ValueError: unknown GET form encoding type 'utf-8'
I checked br.enctype before selecting the first and second forms. What I
get is:
after the first form: application/x-www-form-urlencoded
after the second form: utf-8
I don't know what is going on here.

out of memory exception when reading image from folder

out of memory exception when reading image from folder

i need to read all image files from folder ans save it to another folder
with compressed size.However my code compresses this images very well but
it give error after 695 image files "out of memory exception". This my
code.there are around 2000 images
List<string> files = new List<string>();
files = Directory.GetFiles(Server.MapPath("../imgres") + "\\products\\",
"*.jpg").ToList();
for (int k = 0; k < files.Count; k++)
{
if (File.Exists(files[k].ToString()))
{
string SaveLocation1 = "";
System.Drawing.Image thumbnail;
System.Drawing.Image smallsize;
System.Drawing.Image originalimg;
originalimg = System.Drawing.Image.FromFile(files[k].ToString());
thumbnail = originalimg.GetThumbnailImage(110, 110, new
System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback),
IntPtr.Zero);
smallsize = originalimg.GetThumbnailImage(47, 47, new
System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback),
IntPtr.Zero);
SaveLocation1 = Server.MapPath("../imgres/products") + "\\Thumbnail\\"
+ Path.GetFileName(files[k].ToString());
thumbnail.Save(SaveLocation1);
thumbnail.Dispose();
SaveLocation1 = Server.MapPath("../imgres/products") + "\\smallsize\\"
+ Path.GetFileName(files[k].ToString());
smallsize.Save(SaveLocation1);
smallsize.Dispose();
}
}

Sunday, 29 September 2013

I want to insert to database multiple data codeigniter

I want to insert to database multiple data codeigniter

This is my VIEW:
for ($i=1; $i < $loop_count ; $i++) {
echo $this->formbuilder->text( 'dates[]', 'Set Date '.$i);
}
This is my model:
function add_pm($data) {
$this->db->insert($this->table, $data);
$this->session->set_flashdata("message", "Contract record
successfully created.");
}
And now my question is what will i put in controller and how can i insert
it in database in loop? I wish someone will help me!

Is there a way to show max amount items in masonry?

Is there a way to show max amount items in masonry?

Is there a way to show a max amount of items in jQuery Masonry?
http://masonry.desandro.com/#jquery
We want to show max 12 items on http://denimjacket.nl/voorbeeld-pagina/,
so we would like to hide the rest. We can show max 12 items with a
Wordpress function, but ofcourse the Masonry will then only work on those
12 items, which is not correct. It has to work on all items, but still
show max 12 items.

In UCP, Is SCTS Field is really consistent between ot-51 ack and ot-53 request?

In UCP, Is SCTS Field is really consistent between ot-51 ack and ot-53
request?

I've been trying to implement a mechanism that communicates with smsc
using the ucp(emi) protocol. on top og that, i was trying to implement a
CDR mechanism, based on three steps: tcp ack, ot-51 ack message and ot-53
notification message. According to the EMI documentation, the SCTS field
should be consistent with the timestamp recieved in the ot-51 ack. i've
noticed that those values are not always consistent, did anyone else came
by this problem? can it be an smsc configuration problem?
thanx in advance :)

fix the position of a div inside body

fix the position of a div inside body

<body>
<div id="container">
<div id="inside">
</div>
</div>
<div id="special-div">
</div>
<body>
I need to have my special-div outside container for some js considerations
#inside{
margin:auto;
width:760px;
}
#special-div{
position:relative;
top:200px;
left:300px
}
With the above CSS,the position of the special-div changes with change in
browser size change? So,how do i fix the position of the special-div
irrespective of the browser size?

Saturday, 28 September 2013

How should I communicate with a server?

How should I communicate with a server?

Imagine some fellow wants to query a pizza server for the list of pizzas.
This individual would do simply
GET /pizzas
;=> ["cheese", "extra cheese", "broccoli"]
With pedestal-app's data model and messages, I am not sure how to design
client-server communication. Here are the possibilities some minutes of
hammocking brought:
An effect-consumer that
transforms a message into an HTTP request
transforms back the results (to e.g. [{:type :add :topic [:pizzas] :value
"cheese"} ...])
puts the messages in the queue
A dedicated resource on the server (e.g. "/edn") that
accepts pedestal messages
dispatches to the right function
responds with the raw data (i.e. ["cheese", "extra cheese", "broccoli"])
has the effect-consumer transform back the results to messages
A dedicated resource that uses the routes. Just like #2, but
altering the request
forwarding it to another entry in route table
Messages on both sides, with
the server transforming messages into function calls
the server transforming results back into messages
the client just adding these messages to the queue
It seems to me that with approaches #2 and #4, I'd bypass and lose all the
benefit of the interceptors. With approach #2, I'd need to redouble the
routing logic. With approach #4, I'd also need to generate a lot of code
to accommodate the pedestal client.
Options #1 and #3 seem better, but #3 smells hacky and #1, misdirected.
How are you guys doing it?
Thanks!

java socket buffer and string

java socket buffer and string

For a homework i try to send a file and some parameter corresponding to
this file. So, i send my file and after my string. The problem is my
paramater go to my file and not in my variable. I understand the problem,
my loop while continue to write in the file as long as he receives
something, but i want to stop it and have my parameter outside from my
file.
Here my code client:
public static void transfert(InputStream in, OutputStream out) throws
IOException{
PrintWriter printOut;
byte buf[] = new byte[1024];
int n;
while((n=in.read(buf))!=-1)
out.write(buf,0,n);
printOut = new PrintWriter(out);
printOut.println("add");
System.out.println("envoie !!!");
printOut.println("1");
printOut.println("3");
// out.write(getBytes("add"),0,0);
printOut.flush();
}
and here my server code :
public static void transfert(InputStream in, OutputStream out, boolean
closeOnExit) throws IOException
{
byte buf[] = new byte[1024];
int n;
while((n=in.read(buf))!=-1)
out.write(buf,0,n);
buffIn = new BufferedReader (new InputStreamReader(in));
String nom_methode = buffIn.readLine();
String param1 = buffIn.readLine();
String param2 = buffIn.readLine();
System.out.println("methode:"+nom_methode+"param1:"+param1+"param2:"+param2);
if (closeOnExit)
{
in.close();
out.close();
}
}

Why double is not allowed in in-class intializer

Why double is not allowed in in-class intializer

I have been reading Exceptional C++ by Herb Shutter Item 1 : #define or
const and inlining..
Its said that the in-class initialization is allowed only for integral
types(integers,chars,bools) and only for constants..
I just want to know why double/float cannot be initialized in class
declaration .. Are there any specific reasons.
class EngineeringConstants { // this goes in the class
private: // header file
static const double FUDGE_FACTOR;
...
};
// this goes in the class implementation file
const double EngineeringConstants::FUDGE_FACTOR = 1.35;
I just want to know the reason why the below declaration is not allowed.:,,
class EngineeringConstants { // this goes in the class
private: // header file
static const double FUDGE_FACTOR = 1.35;
...
};