Saturday, August 31, 2013

Tinymce url needs to be versatile

Tinymce url needs to be versatile

I need relative path in links which don't have full url and i don't need
relative path in url which have full url.
When i insert in tinymce:
1. I need full url(non-relative path) in:
"http://dignepal.com/images/logo.png"
2. But i don't need full url (relative path) in: "javascript:"
While initializing tinymce i am currently using relative_urls as false and
it is causing problem in number 2 problem as mentioned above. And main
problem is i need it in same page and in same textarea.

phpmyadmin, import CSV-load date with line breaks?

phpmyadmin, import CSV-load date with line breaks?

I have the following problem.
I have a CSV file with articles (for joomla) that I want to import to my
server through phpmyadmin. Now after figuring out how to import date
format i came across my second problem, and that is how to import the
articles that is stored in a cell that is in a csv-load date file????
The problem is that when importing it, I don't see any line breaks in the
articles, not in joomla and not in the html code that sould be stored in
phpmyadmin
So I hope that somebody can help me with that Thanks in advance

Same column for two different relational entities with doctrine

Same column for two different relational entities with doctrine

Well, I have these three tables:
likes
id_like | post | post_type
post: it has the post id where the "like button" was triggered.
post_type: it has the type of the post, it could "article" or "comment".
Comment
id_comment | body
Article
id_article | body
I am trying to create the models "Article" and "Comment" where each one
can has an array of its likes. For example, I have tried this with:
Model Like
/**
* @Entity
* @Table(name="likes")
*/
class Like
{
/**
* @Id @Column(type="integer", nullable=false, name="id_like")
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Column(type="integer", nullable=false, name="like_type")
*/
protected $type;
Model Article
namespace models;
use \Doctrine\Common\Collections\ArrayCollection;
/** * @Entity * @Table(name="article") */ class Article {
/**
* @Id @Column(type="integer", nullable=false, name="id_article")
* @GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @OneToMany(targetEntity="Vote", mappedBy="article")
* @JoinColumn(name="id_article", referencedColumnName="post")
*/
protected $likes;
My first problem comes when I try to get the "likes" from the article. If
I do:
$likes = $article->getLikes();
I get this error:
Severity: Notice
Message: Undefined index: article
Filename: Persisters/BasicEntityPersister.php
Line Number: 1574
Now, the second problem (or question) that eventually will come is about
the "Comment" model. Is be possible do a OneToMany from Comment to Likes
using as the same way as Article do?

How to show properly display generated TinyMCE content

How to show properly display generated TinyMCE content

I would like to display in a box the saved content of a TinyMCE generated
bit of text. The text does not appear formatted like I'd like the HTML to
appear. The database has the following saved:
<p><strong>test</strong></p>
Do I need to convert this back to HTML encoding? I would like the content
to actually appear like it was formatted in TinyMCE. Is this possible?

twisted: test my service's stop sequence

twisted: test my service's stop sequence

We have a complex multiservice that needs to do some fairly intricate
accounting when shutting down in order to implement a "graceful" shutdown.
I'm trying to write tests for this under trial. The issue is that the
reactor is effectively a process-global resource, and shutting down my
service means that trial's reactor is also stopped, which (of course)
makes it explode.
This is documented to be a no-no in trial, but I need some kind of
workaround that allows me to write my tests. My first thought was to use a
mock.Mock, but this means we're not really using a reactor that's shutting
down, which isn't going to give me behavior that's faithful to the actual
shutdown process.
I believe what I need is a way to separate trial's reactor from the
reactor of my service-under-test. Sharing a mutable resource between the
test system and the system under test is surely an anti-pattern.

Trouble using cuechange event and track metadata (HTML5 video)

Trouble using cuechange event and track metadata (HTML5 video)

I've Googled and search for a few days, but I can only find HTML5 video
track examples that talk about subtitles, and the ones I've found aren't
really complete. Basically, what I would like to do is the following:
-When I enter a cue, I need to access the data for the cue.
-The text data (at least I think it's the text...) contains a number. That
number corresponds to an img id elsewhere in my document. I do something
to the image then.
This seems like it should be really simple, but I'm not exactly sure where
to start. I'm using Jquery.
Here are some snippets of my code:
In my $(document).ready function, I have the following...
var t = $("#track1")[0];
t.addEventListener("cuechange", function () {
var mycue = this.track.cues[0];
var imgnum = mycue.text;
var image = $("img#" + txt);//I'm not worried about this part yet...I
never get here
//perform actions on image...
});
My html video tag looks like this:
<video id="Video1" controls='controls' width="100%" autoplay>
<source src="videos/video-part1.mp4" type="video/mp4" >
<track id="track1" kind="metadata" src="test.vtt" srclang="en-us" />
HTML5 Video is required for this example. </video>
And my Webvtt file looks like this (The numbers below the time ranges are
the slide numbers I need to use)
WEBVTT
Test1
00:00:00.000 --> 00:00:23.999
00001
Test2
00:00:24.000 --> 00:01:19.999
00121
Test3
00:01:20.000 --> 00:01:39.999
00793
When I debugged my code in Chrome the first few times, there didn't appear
to be any cue data associated with the track (I checked the cues elsewhere
in the code and they were empty). The cuechange event is also not being
hooked. After a while, Chrome started giving me the error about
referencing text tracks across domains. I don't know why it suddenly
started doing that.
But anyway, in short...
-I don't know how to bind something to the cuechange event correctly
(apparently), or the event where you enter a cue either for that matter.
-I don't know how to access the data I need to use.
Just so you know, I also tried kind="captions" and kind="subtitles".
Neither one of those worked for me either. Some help would be lovely. :)

Is there a way to do USB debugging on the Kindle Fire?

Is there a way to do USB debugging on the Kindle Fire?

I use to email my apps to my kindle and then run them. My app is now to
big to email. Is there a way to debug your app (usb port from eclipse) on
the kindle????

Phone number list manipulation Nested SED

Phone number list manipulation Nested SED

Still about phone manipulation. I have a list of phone numbers as per below:
(855) 422-6932
(899) 991-9054
(855) 912-7326
(833) 390-8072
(867) 934 2368
(898) 731 7056
(899) 251 5372
(855) 137-6285
(855) 294-5537
(844) 680-7479
If you notice the phone number pattern on line number 5 to 7 it has no "-"
how can I insert "-" using sed or awk?
It feels like i will have to do some sort of nested sed conditional
substitution if it is possible at all.
can anyone help?

Friday, August 30, 2013

Perl Expresion for negate a group

Perl Expresion for negate a group

I have this log:
The Foo bar, and Bar foo needs to Foo
The Bar of Bar foo Bar Foo Foo
Bar bar The Bar of Foo other Foo Bar
And I want to create a perl expresion that only select words that are not
Foo nor Bar. The result log must be:
The bar, and foo needs to
The of foo
The of other
I have this one:
^(Foo|Bar)
But it doesn't work.

Thursday, August 29, 2013

Android use namespace as prefix for attributes in library

Android use namespace as prefix for attributes in library

I am trying to implement the ActionBar through the support library, v7.
Because I want to support the app for Android 2.1 (API level 7) and above.
I read in http://developer.android.com/guide/topics/ui/actionbar.html
following: "Using XML attributes from the support library Notice that the
showAsAction attribute above uses a custom namespace defined in the tag.
This is necessary when using any XML attributes defined by the support
library, because these attributes do not exist in the Android framework on
older devices. So you must use your own namespace as a prefix for all
attributes defined by the support library."
My question is how do I use my own namespace as a prefix for all
attributes defined by the support library?
Step by step explanation please! //Thanks.

Why does the .net SSLStream not show TLS in Wireshark?

Why does the .net SSLStream not show TLS in Wireshark?

So, I was curious about how the traffic through a .net SSLStream would
look like and I set up a small client/server application you can find
here.
It establishes a TLSv1 connection between the two hosts, with the
following parameters:
Cipher: Aes128 strength 128
Hash: Sha1 strength 160
Key exchange: RsaKeyX strength 2048
Protocol: Tls
Is authenticated: True as server? True
IsSigned: True
Is Encrypted: True
So I expected to see some TLSv1 in my wireshark traces between the two
hosts, but there was not a single one.. I had some SSL and TLSv1.2 in the
protocol-field, between my computer and some other hosts, but not between
the hosts communicating through the .net SSLStream

Is this how it is supposed to look?
I expected something like this: (found on google)..

What is the best way to organize my active directory structure

What is the best way to organize my active directory structure

i would like to adopt the best structure for my active directory domain,
in order to be able to apply GPO efficiently. Here is my schema :
CompanyName\ServiceName{Users, Groups, Workstations, Laptops}
My first question is about geographical sites : we have two geographical
sites, is it better to create this sort of hierarchy :
CompanyName\GeographicalSiteName\ServiceName{Users, Groups, Workstations,
Laptops} or handling geographical sites GPO using Sites policy ? Indeed,
this organization can lead to have to duplicate some services, if they are
split on 2 sites.
My second question is about the {Users, Groups, Workstations, Laptops}, do
you think there is better organization ?
Thanks very much

Wednesday, August 28, 2013

how to go from String to method

how to go from String to method

I hope the title was understandable .
I have 4 functions :
public void seta1(...);
public void seta2(...);
public void seta3(...);
public void seta4(...);
Now the user gives me a String with the methods partial name ( say String
input = "a1"). Is there a way ( without using case option) to activate the
correct method ?
something like : (set+input)();

Textbox border property for a Textbox in .net 2.0

Textbox border property for a Textbox in .net 2.0

In VB.net a textbox does not have border color property. But i want a
control with border color property. I have tried the code mentioned in
this link. By using it i was able to create a control which can be added
to visual studio and can be used. It works fine for me for .net 3.5 target
projects. But it does not work for .net 2.0 targeted project. The border
color does not change.i have even tried building the control(dll) using
.net 2.0 target and adding it to project but it didn't work. So please
help me on it or any alternative for it

Ada enumerations with duplicate values

Ada enumerations with duplicate values

I'm trying to have a device register as an enumeration. Reading from the
register has 2 values -> 0 means Done, 1 means Pending. Likewise, writing
into the register has 2 values -> 0 has no action and 1 does a reset. So,
I wrote the following code
type Soft_Reset is (Done, Pending, No_Action, Reset);
for Soft_Reset use
(Done => 0,
Pending => 1,
No_Action => 0,
Reset => 1);
But this throws an error
gcc-4.6 -c -g -gnatg -ggdb -I- -gnatA /home/sid/tmp/device.adb
device.ads:93:20: enumeration value for "No_Action" not ordered
gnatmake: "/home/sid/tmp/device.adb" compilation error
Is it possible for a enumeration to have duplicate values?

Can StyleCop warnings / errors create Visual Studio todo tasks

Can StyleCop warnings / errors create Visual Studio todo tasks

To keep my question as simple as possible, is there any way for my
StyleCop violations being shown in the Visual Studio To-Do Explorer (or
some similar window, I appreciate To-Do tasks are generated from actual
content in comments) so I can keep it pinned and track.
I am using Visual Studio 2010 with Resharper and StyleCop for Resharper
plugin.
Thanks in advance.

Tuesday, August 27, 2013

HTML script injection via javascript

HTML script injection via javascript

I have a text field where user can fill href tag script which I have to
show as a link later on. But your can enter some malicious script like
alert message and more like that which will cause execution on unwanted
script at the point where I use that text field value to display. My
question is that how can I restrict user to only enter href tag releated
entry in text field and restrict other script to enter. Thanks In advance.

NullPointerException while trying to invoke method on private field using Reflection

NullPointerException while trying to invoke method on private field using
Reflection

The original issue is described How to run method on private field using
reflection?
The class is
public class SecureResource {
private HttpServletRequest request;
// more things
}
Based on @Jon answer
(Where resource is a reference to the relevant instance of SecureResource.)
I did the following
Class cls = response.getResourceClass();
Object obj = cls.newInstance();
Field f = cls.getDeclaredField("request");
f.setAccessible(true);
HttpServletRequest request = (HttpServletRequest) f.get(obj);
String auth = request.getHeader("X-AUTH");
and I get request as null
and the Field f is not null
private javax.servlet.http.HttpServletRequest
com.sunrunhome.blackbird.service.SecureResource.request
Please let me know where I am making mistakes here?

c++ STL Child Class doesnt see the father class menber

c++ STL Child Class doesnt see the father class menber

iam developing a class that derives from another , but i am getting stuck
, with this code:
template <class A, class B, class C>
class BaseClass
{
public:
BaseClass(){}
virtual void amethod( A* aPtr=0)
{
mAPtr=aPtr;
}
virtual void init()=0;
protected:
A * mAPtr;
B* mBPtr;
C * mCPtr;
};
template <class A,class B,class C>
class ChildClass: public BaseClass<A,B,C>
{
public:
ChildClass( A* aAptr =0, B * aBPtr= 0, C* aCPtr= 0):mAPtr(aAptr)
,mBPtr(aBPtr)
,mCPtr(aCPtr)
{}
};
int main()
{
return 0;
}
The compiler out says that the child class doesnt have any of the parent
field.
Compiler out:
In constructor 'ChildClass<A, B, C>::ChildClass(A*, B*, C*)'
In constructor 'ChildClass<A, B, C>::ChildClass(A*, B*, C*)'
error: class 'ChildClass<A, B, C>' does not have any field named 'mAPtr'
error: class 'ChildClass<A, B, C>' does not have any field named 'mBPtr'
error: class 'ChildClass<A, B, C>' does not have any field named 'mCPtr'
i have searching in google but i cannot find an answer: Thx in advance

Using g.applyLayout in controller breaks unit test

Using g.applyLayout in controller breaks unit test

I've got a controller method that needs to return a JSON map, one of the
items inside of which is html from a template. I'm using code like
map['html'] = g.applyLayout(name: 'layoutName', g.render(template:
'template', model: [...])
...
render(map as JSON)
And I've got at Controller unit test that calls this method. However when
I run the test, I get the following exception:
java.lang.IllegalStateException: Cannot return Sitemesh factory it has not
been set!
at org.springframework.util.Assert.state(Assert.java:384)
at
org.codehaus.groovy.grails.web.sitemesh.FactoryHolder.getFactory(FactoryHolder.java:39)
at
org.codehaus.groovy.grails.web.sitemesh.FactoryHolder$getFactory.call(Unknown
Source)
...
If I take out the g.applyLayout() and just use the g.render() the test
runs. What am I doing wrong?
Update
Here's my unit test class
@TestFor(ContactsController)
@Mock([Contact, User, Company])
class ContactsControllerTests {
@Test
void testSaveContact() {
defineBeans {
contactsManagerService(ContactsManagerService)
}
Company company = new Company(name: 'COMPANY 1')
company.save(validate: false)
Contact userContact = new Contact(name: 'user contact', email:
'foo@bar.com')
Contact companyContact = new Contact(name: 'company contact',
email: 'foo2@bar.com')
userContact.save(validate: false)
companyContact.save(validate: false)
new User(name: 'user 1', password: 'foo', contact: userContact,
company: company).save(validate: false, deepValidate: false)
controller.params.name = ''
controller.params.email = 'updated1@bar.com'
controller.saveContact(userContact.id)
assertNotNull(response.json.errors) // Name cannot be empty
response.reset()
controller.params.name = 'Updated Name'
controller.params.email = 'updated1@bar.com'
controller.saveContact(userContact.id)
assertTrue(response.json.success)
Contact contact = Contact.read(userContact.id)
assertEquals('Updated Name', contact.name)
assertEquals('foo@bar.com', contact.email)
}
}

Deserialize error with jackson json in case of list in java

Deserialize error with jackson json in case of list in java

I have create a JSON with Jackson based on this class:
public class One {
public long param;
public List<Two> two;
public static class Two{
public long param;
public List<Short> param2;
}
}
I have defined two constructor for each class and I use it for the
creation of the objects that later are written on the json file. The
outcome is (valid JSON):
[{"param":1,"Two":[{"param":4,"param2":[1,2,3]},{"param":5,"parma2":[4,5,6]}]},{"param":2,"Two":[{"param":6,"param2":[1,2,3]}]}]
Now I would like to read and load the parameters and I define:
mapper.configure(Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); //tried
with and without
JsonFactory f = new JsonFactory();
JsonParser jp;
jp = f.createJsonParser(FILE);
jp.nextToken();
while (jp.nextToken() == JsonToken.START_OBJECT) {
mapper.readValue(jp, One.class);
}
jp.close();
I have this error:
Can not deserialize instance of json.One$Two out of START_ARRAY

how to connect dots and draw a line in cocos2d

how to connect dots and draw a line in cocos2d

How to connect dots and draw a line in cocos2d like the below image? How
to to make flow line type of game for iOS?

Monday, August 26, 2013

Installing C compiler, JDK etc. in Ubuntu

Installing C compiler, JDK etc. in Ubuntu

I am a new to Ubuntu. I have used Windows before, but I am not able to
install new software in Ubuntu from the offline setup files, so I don't
know how to install software in Ubuntu. Please tell me how to install new
software, such as C Compiler, JDK, etc. in Ubuntu.

Wireless is hard blocked on Asus x75a can't unblock!

Wireless is hard blocked on Asus x75a can't unblock!

I have an Asus x75a laptop on which I have recently installed Ubuntu 13.04
alongside Windows 8. I everything seems to be running smoothly except for
the fact that I can't get the Wi-Fi to work! When I click in the Wi-Fi
widget in the upper right-hand corner of the desktop, Wi-Fi is greyed out
and says that it is disabled by hardware switch. This is odd because my
computer model doesn't HAVE a hardware switch for wireless; it's turned
off and on by the Fn+F2 combination in Windows, but that doesn't seem to
be working here. I don't have any Ethernet or anything else besides
wireless to hook up to so it's a real problem.
I am extremely new to Linux, and I haven't found any good answers for this
problem online.
My computer has an internal Quallcom Atheros AR9485 Wireless Network Adapter.
Here's what I get when I run rfkill list:
0: phy0: Wireless LAN Soft blocked: no Hard blocked: yes 1: asus-wlan:
Wireless LAN: Soft blocked: no Hard blocked: no
I have tried both rfkill unblock all and rfkill unblock 0, both to no avail.
When I go into the settings app and click on network, I see the word
Wireless next to a virtual switch in the off position, but when I flip it
to on it immediately flips back to off.
It's not a problem with the Wireless adapter cuz it works fine in Windows.
It makes no difference whether it's on our off when I exit Windows.
Yes, wireless is enabled in the BIOS (or UEFI, our whatever it's callled
nowadays...)
When I installed Ubuntu, I did not connect to the internet during
installation cuz the only network I have at home is only for wireless
printing etc and no internet so I figured it was useless to connect it to
a dead network. So when I realized that I had this problem, I figured I
should try reinstalling Ubuntu WITH it connected to my dead network to see
if that would get the Wireless working. But when I went to connect to a
network in the reinstallation process, I realized it didn't list my
network at all, but rather listed my ATHEROS AR9485 WIRELESS NETWORK
ADAPTER as an available "network"! But I couldn't connect to this
"network" cuz it insisted I needed a password, which I thought was weird.
Network Adapter don't have password do they? I've never found anything
saying mine has one and I've never created one for that matter. So I
realized it was pointless and cancelled the reinstallation.
That's all the background info I can think of to provide you at the moment.
please help!!!!!!
Thanks!!!!

Confused about BER (Basic Encoding Rules)

Confused about BER (Basic Encoding Rules)

I'm trying to study and understand BER (Basic Encoding Rules).
I've been using the website http://asn1-playground.oss.com/ to experiment
with different ASN.1 objects and encoding them using BER.
However, even the simplest encodings seem to confuse me.
Let's take a simple ASN.1 schema:
World-Schema DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
Human ::= SEQUENCE {
name UTF8String
}
END
So basically this is just a SEQUENCE with a single UTF8String type field
called name.
An example of a value that matches this sequence would be something like:
{ "Bob" }
So, using http://asn1-playground.oss.com/, I produce the BER encoding of
the following data:
some-guy Human ::=
{
name "Bob"
}
I would expect this to produce one sequence object, followed by a single
string object.
What I get is:
30 05 80 03 42 6F 62
Now, I understand some of this encoding. The first octet, 30, is the
identifier which tells us that a SEQUENCE type is the first object. The 30
is 00110000 in binary, which means that we have a class of 0, a PC
(primitive/constructed) bit of 1 (meaning constructed), and a tag number
of 10000 (16 in decimal) which means SEQUENCE
So far so good. The next value is the LENGTH in bytes of the SEQUENCE,
which is 05.
Okay, still so far so good.
But then... I'm totally confused by the next octet 80. What does that
mean??? I would have expected a value of 00001100 (for tag number 12,
meaning UTF8String.)
The bytes following the 80 are pretty straightforward: the 03 means Length
of 3, and the 42 6F 62 is just the UTF8String value itself, "Bob"

Modal transition via presentViewController:animated ignores the animation

Modal transition via presentViewController:animated ignores the animation

I am trying to display a QLpreviewcontroller on a UIVIewcontroller.
-(void)showPreview{
if(!_previewController){
_previewController = [[QLPreviewController alloc] init];
_previewController.dataSource = self;
_previewController.delegate = self;
}
// There will always be one item here
_previewController.currentPreviewItemIndex = 0;
[_previewController
setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:_previewController animated:YES
completion:nil];
}
the previecontroller is displayed but the transition is not animated. it
just appears without any animation.

Error after run heroku run rake db:migrate

Error after run heroku run rake db:migrate

I already ran "heroku pg:reset DATABASE".However,I still got this error.



Running rake db:migrate attached to terminal... up, run.8257 ==
AddPasswordDigestToUsers: migrating
======================================= -- add_column(:users,
:password_digest, :string) rake aborted! An error has occurred, this and
all later migrations canceled:
PG::Error: ERROR: relation "users" does not exist : ALTER TABLE "users"
ADD COLUMN "password_digest" character varying(255)/app/ve
ndor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connection_adap
ters/postgresql/database_statements.rb:128:in exec'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/postgresql/database_statements.rb:128:inblock in execute'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract_adapter.rb:425:in block in log'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-4.0.0/lib/active_support/notifi
cations/instrumenter.rb:20:ininstrument'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract_adapter.rb:420:in log'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/postgresql/database_statements.rb:127:inexecute'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract/schema_statements.rb:360:in add_column'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/postgresql/schema_statements.rb:379:inadd_column'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:625:in block in method_missing'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:597:inblock in say_with_time'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:597:in say_with_time'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:617:inmethod_missing'
/app/db/migrate/20130822145844_add_password_digest_to_users.rb:3:in
change'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:571:inexec_migration'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:555:in block (2 levels) in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:554:inblock in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract/connection_pool.rb:294:in with_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:553:inmigrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:709:in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:959:inblock in execute_migration_in_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:1005:in block in ddl_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract/database_statements.rb:202:inblock in transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract/database_statements.rb:210:in within_new_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/connecti
on_adapters/abstract/database_statements.rb:202:intransaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/transact
ions.rb:209:in transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:1005:inddl_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:958:in execute_migration_in_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:920:inblock in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:916:in each'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:916:inmigrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:764:in up'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/migratio
n.rb:742:inmigrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.0.0/lib/active_record/railties
/databases.rake:42:in `block (2 levels) in ' Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Any suggestion?

How to access data of nested objects in LinkedHashMap

How to access data of nested objects in LinkedHashMap

Data present in LinkedHashMap:-
{
contacts={
id={
version=6,
lastUpdatedTimeStamp=1377,
contactID=23,
firstName=B,
lastName=K
}
}
}
Here, "contacts" & "id" are objects.
I am able to get the values of "contacts" :
LinkedHashMap map = restClient.getLinkedHashMap();
Object contactObj = map.get("contacts");
But how to get the value of "firstName"?
Any help or guidance will be well appreciated.

VHDL: receive module randomly fails when counting bits – electronics.stackexchange.com

VHDL: receive module randomly fails when counting bits –
electronics.stackexchange.com

Background This is a personal project; it regards connecting an FPGA to a
N64, the byte values that the FPGA receives are then sent through UART to
my computer. It actually functions pretty well! At …

Help with formulating a linear programming problem

Help with formulating a linear programming problem

I have the following linear programming problem I would like to be verified:

I have sketched the problem in the following picture:

Here is my attempted solution:
I figured that I have ten variables (corresponding to the colored lines,
between each building): $x_1, x_2, ..., x_{10}$ which are the amounts (in
tons) of raw materials from Source 1 --> Plant A, Source 1 --> Plant B,
Source 2 --> Plant A, Source 2 --> Plant B, Plant A --> Market 1, Plant A
--> Market 2, ............, Plant B --> Market 3.
The formulation I get is the following:
$$\text{minimize}\;\;\; 1x_1 + 1.5x_2 + 2x_3 + 1.5x_4 + 4x_5 + 2x_6 + 1x_7
+ 3x_8 + 4x_9 + 2x_{10}$$ $$\text{subject to}\;\;\;x_1 + x_2 = 10$$
$$\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;x_3 + x_4 = 15$$
$$\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;x_5 + x_8 = 8$$
$$\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;x_6 + x_9 = 14$$
$$\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;x_7 + x_{10} = 3$$
$$\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;x_1 \ge 0, x_2 \ge 0, \cdots, x_{10}
\ge 0.$$
I would appreciate if someone could verify the correctness of my answer :)
Thank you for any help!

Sunday, August 25, 2013

What are valid places to put HTML comments?

What are valid places to put HTML comments?

I am only concerned about HTML5 in this question.
This does not seem to work:
<code><<!-- test -->span class="otherCode">Bar</span></code>
( http://jsfiddle.net/dYSeK/ )
However, this works for me when I have long URLs that I want to wrap in
source code.
<div>
<a href="https://www.google.co.in/search?q=test">https://<!--
-->www.google.co.in/search?q=test</a>
</div>
( http://jsfiddle.net/wMGdk/ )
What are all the valid places in an HTML code where I can place HTML
comments?

Application Pool is Automatically Stop in IIS 7

Application Pool is Automatically Stop in IIS 7

My Application pool is automatically stop after someday then I have create
separate application pool for sendemail services but database log is not
download so what to do? Please help me.

D3js map color keys?

D3js map color keys?

Background concept: Elevation maps and their color keys for human readers
require a more detailled coverage of lower elevation (<200m), where 80% of
the world population lives.
D3 project:
Given data elevations levels (m) such : 0, 50, 100, 200, 500, 1000, 2000,
3000, 4000, 5000m.
How to add a non linear color ramp key, with ticks at 0, 50, 100, 200,
500, 1000, 2000, 3000, 4000, 5000m.



Comment: I currently goes with an unsatisfying linear ramp code, see this,
which cut my 5000m into 10 equal spans of 500m :

I should actually have 4 differents greens standing for 0, 50, 100, and
200m and less browns/greys/whites.
Var color declaration. Set up the color ramp table by stating the points
where I have color shifts :
// Color-values equivalence var color_elev = d3.scale.linear() .domain([0,
200, 2000, 5000]) // values elevation (m) .range(["#ACD0A5", "#E1E4B5",
"#AA8753", "#FFFFFF"]) // colors .interpolate(d3.interpolateHcl)
each of these 3 spans should indeed have linear color changes.
Injection of my SVG polygons
// Data (getJSON: TopoJSON) d3.json("data/topo/final.json", showData); //
---------- FUNCTION ------------- // function showData(error, fra) { ...
// do my topojson to svg map injection }
Create, push my Color ramp box and key
/* START LEGEND_RAMP */ // Color ramp var x = d3.scale.linear()
.domain([0, 5000]) // legend elevation (m) .range([0, 280]); // width (px)
// Color ramp place ? ? ? var xAxis = d3.svg.axis() .scale(x)
.orient("bottom") .tickSize(13) .tickFormat(d3.format(".0f"));
// (JS shortcut) var legend_key = svg.append("g") .attr("class",
"legend_key") .attr("transform", "translate(" + (width - 300) + "," +
(height - 30) + ")");
// Color ramp: white background legend_key.append("rect") .attr("x", -10)
.attr("y", -10) .attr("width", 310) .attr("height", 40) .style("fill",
"white") .style("fill-opacity", 0.5)
// Color ramp: bricks legend_key.selectAll(".color_ramp")
.data(d3.pairs(x.ticks(10))) .enter().append("rect") .attr("class",
"elev_color_brick") // or "band" .attr("height", 8) .attr("x", function(d)
{ return x(d[0]); }) .attr("width", function(d) { return x(d1) - x(d[0]);
}) .style("fill", function(d) { return color_elev(d[0]); });
// ? legend_key.call(xAxis); /* END LEGEND */

C# How do I parse a text file of data of unknown row size to a 2D array?

C# How do I parse a text file of data of unknown row size to a 2D array?

I can easily pass a data file to a 2D array if I know the size of the data
file, but thats pretty pointless when you want to add and remove data.
How can I instantiate a 2D array of that Data rows length that is global
and not out of scope to the rest of the program?
Here is the usual code, for an array of 4 rows and 6 columns, but I want
to add/remove data to the data file making it of unknown length in rows.
string[,] allStudentData = new string[4, 6];
string[] allStudents = File.ReadAllLines("data.txt");
for (int i = 0; i < allStudents.Count(); i++)
{
for (int j = 0; j < 6; j++)
{
string[] DataIn = allStudents[i].Split(',');
allStudentData[i, j] = DataIn[j];
}
}
Thanks for your ideas :-)

Saturday, August 24, 2013

Harvad Business Review Typefaces

Harvad Business Review Typefaces

I am wondering if there are any references to the typefaces used by the
Harvard Business Review in their monthly publication. Does anyone have
some useful pointers?

Can you register multiple system events with one broadcast receiver in android

Can you register multiple system events with one broadcast receiver in
android

I can't find this in the online documentation, but this is what I would
like to do:
In the AndroidManifest.xml add the following receiver:
<receiver android:name="my.package.SystemBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BATTERY_LOW" />
<action android:name="android.intent.action.DEVICE_STORAGE_LOW" />
<action android:name="android.intent.action.LOCALE_CHANGED" />
<action android:name="android.intent.action.TIMEZONE_CHANGED" />
<action android:name="android.intent.action.DATE_CHANGED" />
<action android:name="android.intent.action.AIRPLANE_MODE" />
<action
android:name="android.intent.action.CONFIGURATION_CHANGED" />
</intent-filter>
</receiver>
In the SystemBroadcastReceiver.java add the following code:
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BATTERY_LOW)) {
// stop the app to save battery
}
if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BATTERY_OKAY)) {
// start the app again
}
// if (...) { // next action, etc}
}
I would like to add all system events the app uses in this one receiver.
Or is this bad practice? Also use this receiver to start a Service like
BluetoothService, WifiService, NFCService, etc.
I have seen many tutorials that only mention one system event, not more
than one. Is that for a specific reason?

how to send an email with anonymous ip [on hold]

how to send an email with anonymous ip [on hold]

how to send an email with anonymous ip, I know in the mail my ip also
passes with the letter but I do not like to pass my real ip and I need
another IP specially anonymous one pay attention it is not duplicate
question I wanna do that in windows and my ip must be anonymous

How to move objects with Window's C++ Graphics (GDI+) library?

How to move objects with Window's C++ Graphics (GDI+) library?

So far, I've only copy/pasted the example that Microsoft has here (but I
removed #include ).
I'm trying to figure out how OnPaint is continually called (as to have
moving objects), but it doesn't seem to be called more than once.
How do I use the standard Windows C++ graphics library (i.e. GDI+, or
another standard Windows API) to create a moving object? Must I call
OnPaint myself? Or is there an easy fix to make it continually be called?
Or is it just not possible?

Problems getting data from XML using Nokogiri and Rails

Problems getting data from XML using Nokogiri and Rails

I'm trying to get information from a XML file with Nokogiri. I can
retrieve file using
f = File.open("/my/path/file.xml")
cac=Nokogiri::XML(f)
And what a get is a fancy noko:file. My row tags are defined like
<z:row ...info..../>
like
<Nokogiri::XML::Element:0x217e7b8 name="z:row"
attributes=[#<Nokogiri::XML::Attr:0x217e754 name="ID_Poblacio" value="3">
and I cannot retrieve the rows using either:
s=cac.at_xpath("/*/z:row") or
s=cac.at_xpath("//z:row") or
s=cac.at_xpath("//row") or
s=cac.at_xpath("z:row")...
Probably I'm really fool but I cannot figure out which can be the issue.
Does anyone face this problem?
Thanks in advance.
P:S I tried to paste my cac file directly from bash but something wierd
happens with format so I remove it from question. If anyone can explain
how to do it I will appreciate it.

Import & Export Google Chrome flags

Import & Export Google Chrome flags

Inside of Google Chrome there is an external settings page chrome://flags.
Is there any way to export these settings to external file in order to
import them back to Chrome on other PC or after clean Chrome installation
on new Windows?

Upload many file to Many Model properties in a single page

Upload many file to Many Model properties in a single page

I have to fill out following model in a view:
IEnumerable<File> Photos
IEnumerable<File> Logos
IEnumerable<File> Videos
How can send multiple files with one POST to a controller action?

Change a variable value inside a Jquery .filter() function

Change a variable value inside a Jquery .filter() function

I have a table which has id 'myTable'. Now there is a textbox in which I
write down the item name to find whether it exists in the myTable cell or
not. To do this I have written the following code -
var retval=0;
var search = $("#searchitem").val().trim();
$("table#myTable tr td").filter(function() {
if($(this).text() == search){retval=1;alert('Same item found');}
else{retval=0;}
});
The problem is that, when it finds the same item in the table cell it
shows the alertbox. But the value of my variable retval never changes. It
always shows 0. How can I solve it?

Friday, August 23, 2013

PHP mysql bug query

PHP mysql bug query

Hi guys i've been working for straight 12 hours, i can't seem to find fix.
i'm trying to compare user-input to database result for example $username
== $result echo "Username is aldready taken, but the problem is it's
passing through 2 statements without a break, and if i put a break to exit
the loop, it always check for $email == $result2 despite of not entering
any email in the field.
if( isset($_POST['username']) or isset($_POST['email']) )
{
$extract= mysql_query("SELECT username, email FROM users where
username='$username' or email='$email'");
$resultq = mysql_num_rows($extract);
while($row= mysql_fetch_array($extract))
{
$result = $row['username'];
$result2 = $row['email'];
echo " ".$result;
echo " ".$result2;
if ($username == $result )
{
echo " Username is already Taken!";
// break; //whenever i put break, it always gives me the else if
statement echo, despite not entering any email in the field
}
//$pass = $_POST['pass'];
else if($email == $result2 )
{
echo "Email Address is already used!";
// break;
}
else
{
}
}
}

ClientRequestFactory RestEasy Deprecated... Any other RestEasy alternative ?

ClientRequestFactory RestEasy Deprecated... Any other RestEasy alternative ?

I need to create rest-easy client, using de interface of the RestService
created by others... That's work good, except by just one thing...
When i update from rest-easy 2.3.5.Final to rest-easy 3.0.x, the
ClientRequestFactory class appear like @Deprecated.
The actual code is:
ClientRequestFactory crf = new
ClientRequestFactory(UriBuilder.fromUri("http://url-of-service").build());
SomeRestInterface client = crf.createProxy(SomeRestInterface.class);
client.theMethod();
Any one, now what is the alternative of rest-easy for ClientRequestFactory
at version 3.0.x?

Character array Assignment

Character array Assignment

int main()
{
char s[]="stack";
s="overflow";
}
This is not allowed.Its gives an error.But below code works fine.
int main()
{
char s[]="stack";
strcpy(s,"overflow");
}
Why this happens?

SAML IDP and WS-Federation SP with ADFS 2.0

SAML IDP and WS-Federation SP with ADFS 2.0

I am very confused about my current ADFS setup. I have an identity
provider that issues a SAML 2.0 token to ADFS 2.0 in an IDP-Initiated
scenario. ADFS translates the token into WS-Federation, and forwards it on
to a claims aware (WIF) web application. The web application, however
doesn't recognize the user has having authenticated and redirects back to
Home Realm discovery. I've used SAML Tracer in Firefox and I can see the
SAML assertions going in and the WS-Federation claims in the parameters
being sent to the web application. Is there a step I am missing? I set up
custom claim rules to translate the SAML assertion into a WS-Federation
claim (e.g. http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name) If
I switch the SP application to a SAML 2 web app, then everything works
fine.

How to detect programmatically when other apps are closed / force stopped

How to detect programmatically when other apps are closed / force stopped

I am developing an android application in which i need to perform an
action when other apps are closed / force stopped. This detection has to
be made from a service which is been running in the background once
started. Making the service to run continuously is not a problem but
making detection when other apps are closed is the problem. Please do
anyone have any solution.....

agent-state-info: 'hook failed: "config-changed" deploy wordpress using juju

agent-state-info: 'hook failed: "config-changed" deploy wordpress using juju

I have one virtual machine on Windows Azure. I have installed juju inside
my virtual machine. I want to deploy wordpress on my vm.
I've read this blog about step by step how to deploy wordpress:
https://juju.ubuntu.com/get-started/local
But i got error on my juju status like bellow :
machines:
"0":
agent-state: started
agent-version: 1.12.0.1
dns-name: 10.0.3.1
instance-id: localhost
series: precise
"1":
agent-state: started
agent-version: 1.12.0.1
instance-id: azureuser-local-machine-1
instance-state: missing
series: precise
"2":
agent-state: started
agent-version: 1.12.0.1
instance-id: azureuser-local-machine-2
instance-state: missing
series: precise
services:
mysql:
charm: cs:precise/mysql-27
exposed: false
relations:
cluster:
- mysql
db:
- wordpress
units:
mysql/0:
agent-state: error
agent-state-info: 'hook failed: "config-changed"'
agent-version: 1.12.0.1
machine: "1"
public-address: 10.0.3.209
wordpress:
charm: cs:precise/wordpress-16
exposed: true
relations:
db:
- mysql
loadbalancer:
- wordpress
units:
wordpress/0:
agent-state: started
agent-version: 1.12.0.1
machine: "2"
public-address: 10.0.3.174
Then when i try to access public address which have ip 10.0.3.174 i got
bad gateway.
On juju status i founded :
units:
mysql/0:
agent-state: error
agent-state-info: 'hook failed: "config-changed"'
How to solve this error ?

Thursday, August 22, 2013

How can I simplify my "equation" to switch between 3 and 5?

How can I simplify my "equation" to switch between 3 and 5?

It is easy to "switch" between 0 and 1 in the following way:
int i = 0;
i = (++i) % 2; // i = 1
i = (++i) % 2; // i = 0
Similarly, I found that it is possible to "switch" between 3 and 5:
int i = 3;
i = (((i * 2) - 1) % 3) + 3; // i = 5
i = (((i * 2) - 1) % 3) + 3; // i = 3
Whereas this feels cumbersome, I am searching for a more concise way to do
it. Can it be simplified? If so, how? I am actually using this for
something, by the way.

How can I print the contents of an ArrayList in a specific way? [on hold]

How can I print the contents of an ArrayList in a specific way? [on hold]

How can I print the contents of an ArrayList in a specific way, in Java?
For example:
System.out.println("A B");
System.out.println("100 100");
System.out.println("200 200");
System.out.println("300 300");
How can I do this with an ArrayList?
I write the array list like this:
ArrayList mathChoices = new ArrayList(3);
mathChoices.add("100");
mathChoices.add("200");
mathChoices.add("300");
ArrayList historyChoices = new ArrayList(3);
historyChoices.add("100");
historyChoices.add("200");
historyChoices.add("300");
And it prints out like this:
Math History
[100, 200, 300] [100, 200, 300]
I want to print out "MATH" and then "HISTORY" with vertical columns of
100,200,300 under each word. It is supposed to be like the questions in
the game show Jeopardy.

Can I restore closed tabs after quitting Chrome?

Can I restore closed tabs after quitting Chrome?

I closed Chrome by accident. Now all the tabs I had open are presumably
gone. I don't want to risk anything by starting Chrome now before asking
for help. I fear that they will be permanently lost (overwritten files) if
I do that. I know from past experience with Firefox that restoring tabs
and browser sessions can be a tricky business.
What can I do at this point? Is there a file or something I need to copy
or rename? I know about the Ctrl+Shift+T command. But I normally use this
while browsing. Will this work AFTER closing Chrome?

How can I change the time trial ghost?

How can I change the time trial ghost?

I'm currently doing time trials, and I just learned that my best lap on
Ghost Valley 2 is 21 seconds. My ghost, however, uses a different record.
How can I change it to use my best time?

Facebook "Like" Button Dynamic URL Load using Javascript

Facebook "Like" Button Dynamic URL Load using Javascript

I have a asp.net page where i'm loading specific Facebook Url page from
hiddenfield in the same page. What i want to do is to generate a like
button using this specific url .
i tried this but it doesn't work , the like button keeps the default
href(which is coca cola) :
<div id="fb-root"></div>
<div id="fb-like" class="fb-like"
href="https://www.facebook.com/cocacola" data-width="450"
data-show-faces="true" data-send="false"></div>
<script>
var sUrl = document.getElementById('AdresseLike').value;
document.getElementById('fb-like').setAttribute('href', sUrl);
FB.XFBML.parse(document.getElementById("fb-like"));

Wednesday, August 21, 2013

Customising up Button in android

Customising up Button in android

I want to customize the up button, I am using appcompat library for my
actionbar. I don't want the default up button which android provides.
Because I am using actionbar that has produced by style generator. So that
up button looks pale with the color of actionbar that I selected. Can
someone please suggest me how to achieve it? I have searched lot but
couldn't find.

I believe it is possible. Because googleplay displays the actionbar with
up button in different color in the apps section.

Anyway to have Audio output come through 2 headsets?

Anyway to have Audio output come through 2 headsets?

So I have a pretty unique sound setup for my YouTube recording... I have
Virtual Audio Cable installed with 3 cables (PC Audio, Skype and an
Output), I don't use the Audio Repeaters, instead I use windows' own
"Listen to this device" which makes it 10x better as there is no delay in
the output...
To explain what I've done:
PC Audio
Skype Audio
Output
I use dxtory to record my PC gameplay, I then record 3 audio streams, 1 is
my microphone, 1 is (1) and the other is (2)... This is so I can remove
white noise from streams (1) and (2).
Both (1) and (2) are heard through (3) which is then "listened" through my
headphones via the "Listen to this device"... Sometimes I have a second
person in the room doing a dual commentary, and it is too much hassle to
change the cables... Is there any way, without using the Audio Repeaters
(they give me a tonne of static noise and choppiness) to output to both my
headsets, if it makes it easier, they are both the Microsoft LifeChat
LX-3000.

Configuring NSight (Eclipse) and ld

Configuring NSight (Eclipse) and ld

I'm trying to build a project in nsight using the cufft.so library, but
the linker (ld) can't find the library file, and I'm stumped.
The library is installed as /usr/local/cuda/lib64/libcufft.so
In the project properties I have gone to "General->Paths and
Symbols->Libraries" tab and added /usr/local/cuda/lib64/libcufft.so, and
for good measure went to the Libraries Paths tab and added
/usr/local/cuda/lib64
The exact error is
Finished building: ../main.cu
Building target: cufftTest2
Invoking: NVCC Linker
/usr/local/cuda-5.5/bin/nvcc --cudart static -L/usr/local/cuda/lib64 -link
-o "cufftTest2" ./main.o -l/usr/local/cuda/lib64/libcufft.so
/usr/bin/ld: cannot find -l/usr/local/cuda/lib64/libcufft.so
collect2: error: ld returned 1 exit status
make: *** [cufftTest2] Error 1
and the environment paths are configured as:
echo $LD_LIBRARY_PATH
/usr/local/cuda/lib64:
echo $PATH
/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
echo $MANPATH
/usr/local/cuda/man:
I'm sure I've done something dumb, but I have no idea why ld can't find
/usr/local/cuda/lib64/libcufft.so
Can anyone help with this?

Showing 4 planes in the 4D space are in a same 3D hyperplane

Showing 4 planes in the 4D space are in a same 3D hyperplane

Given four 2D planes in the 4D space, how can I specify if they lie on a
3D hyperplane or not. Assume $\langle x_i, y_i, z_i, w_i \rangle$ for
$i=1,\cdots,4$ be the normal vectors of the planes. Is that enough to show
that they are not linearly independent, i.e., the following determinant is
zero?
$$ \begin{vmatrix} x_1& y_1& z_1& w_1 \\ x_2& y_2& z_2& w_2 \\ x_3& y_3&
z_3& w_3 \\ x_4& y_4& z_4& w_4 \end{vmatrix} $$
What about more than 4 dimensions? If we want to show that in $n$
dimensional space, $n$ hyperplanes of dimension $n-2$ lie on a hyperplane
of dimension $n-1$, is that enough to show that the normal vectors of the
planes are not linearly independent?

Not validate with Zend_Auth_Adapter_Http_Resolver_File

Not validate with Zend_Auth_Adapter_Http_Resolver_File

When I run Zend_Auth_Adapter_Http_Resolver_File in localhost,browser
appear a box to validate with a line "port:80" ,I validate OK but when I
run my project on host,browser appear a box to validate with a line
"port:2082",I can't validate although username and password I input OK.I
use Zend Framework version 1.2 and uses the basic
Zend_Auth_Adapter_Http_Resolver_File.Help me.Thank you very much. `public
function authenAction(){ $auth=Zend_Auth::getInstance();
if(!$auth->hasIdentity()){ $authHttp= new Zend_Auth_Adapter_Http(array(
'accept_schemes'=>'basic', 'realm'=>'Access deny' )); $fileResolver= new
Zend_Auth_Adapter_Http_Resolver_File(APPLICATION_PATH.'/configs/http_pass.text');
$authHttp->setBasicResolver($fileResolver);
$authHttp->setRequest($this->getRequest());
$authHttp->setResponse($this->getResponse()); //Xác th&#7921;c
$result=$authHttp->authenticate(); if(!$result->isValid()){
$this->_helper->getHelper('layout')->disableLayout(TRUE); $messErr= 'Error
404 Not Found.You don\'t permit to access this web page.';
$messErr.='Click here to go Home.'; echo $messErr; } else{
$this->_redirect('/admin/index/login'); }
}
}
`

c# joining string in a shorter and efficient manner

c# joining string in a shorter and efficient manner

How can I join various strings into a string in shortest and efficient
method. Currently I am doing in the following way
string str1 = string.Format(BitConverter.ToString(pass_packet, local_index
+ 511, 1) +
BitConverter.ToString(pass_packet, local_index + 510, 1) +
BitConverter.ToString(pass_packet, local_index + 509, 1) +
BitConverter.ToString(pass_packet, local_index + 508, 1) +
... + BitConverter.ToString(pass_packet, local_index +
400, 1));

Tuesday, August 20, 2013

A Few Inches Open

A Few Inches Open

Let's say the context is a sliding window:
The window was open a few inches.
The window was opened a few inches.
The window was a few inches open.
The window was a few inches opened.
I have two questions. First, should I use the adjective "open" or the
verb-participle "opened"? Second, should "a few inches" come before or
after "open/opened"?

Visual Basic open program

Visual Basic open program

I want to put a zip file in my application. And i want to add a folder to
the application and have buttons that will extract some of the contents of
the folder to the current directory.
I do not know how to add files to it, Or get it to run them.

MySQL subtract two count columns

MySQL subtract two count columns

I have a table like this:
client msg_type msg_body
------ -------- --------
123 typeA success
123 typeB success
456 typeA success
456 typeB failure
123 typeA success
123 typeA success
etc.
I would like output like this:
client diff
------ ----
123 2
456 1
where diff is the count of typeA:success messages - typeB:success
messages. I can get the count of the typeA success using something like:
select client, count(*) from mytable where msg_type="typeA" and
msg_body="success"
However, I can't figure out how to put another count in there (for typeB)
and also subtract. I tried something like:
select client, count(*) from mytable where msg_type="typeA" and
msg_body="success" - count(*) from mytable where msg_type="typeB" and
msg_body="success"
But of course it didn't work, or I wouldn't be asking here. :) Any advice?

Regex to match blank line and comments in a file

Regex to match blank line and comments in a file

How do I ignore comments or blank/empty lines in a file when reading? I
thought /^[\s#]*$/ would do the job but it didn't:
irb(main):180:0> open(inFile, 'r').each { |ln| puts ln if ln !~ /^[\s#]*$/ }
....
....
# and ..... ThIs Is A cOmMeNt .....
....
....
=> #<File:/tmp/running-instances.txt>
irb(main):181:0>
What am I missing here? Any help would be highly appreciated. Cheers!!
PS.
I can do the separately in two steps though:
open(inFile, 'r').each { |ln| next if ln =~ /^\s*$/; puts ln if ln !~
/#[^#]*$/ }

Fancybox lightbox image group. Load images

Fancybox lightbox image group. Load images

I have an issue: I have some search output with different results. Each
result item has own image, where i call Fancybox. But when i call it -
fancybox go through all images, that are displayed at page. But i need to
load only image groups for specific result item.
Each result box has own attr data-json="{ "photos" :
["http://site.com/1.jpg", "http://site.com/2.jpg"]}" and inside of this
div - <a href="1.jpg" class='fancy'><img src="1.jpg" /></a>
How i can on calling Fancybox with certain image create small fancybox
gallery only with this images from data-json?
Thanks!

Why didnt wordpress include parameter in the save_post action refernce?

Why didnt wordpress include parameter in the save_post action refernce?

http://codex.wordpress.org/Plugin_API/Action_Reference/save_post
Why Wordpress didnt include $post and $post_ID parameter and their
function. I realise these parameter exist only when I checked the source
code, What these parameter actually do?? Don't you think that they need to
include every parameter in the action hook reference so that we can assign
action to the hook

Monday, August 19, 2013

I want to dynamically populate the tabs from an array using jquery

I want to dynamically populate the tabs from an array using jquery

I want to dynamically populate the tabs from an array. please help me out.
I tried the following code but it fails to work.
how do I hardcode the values to be generated in an array??
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<title>Dynamic Population</title>
<script>
$(document).ready(function() {
$("div#tabs").tabs();
$("button#add-tab").click(function() {
var num_tabs = $("div#tabs ul li").length + 1;
$("div#tabs ul").append(
"<li><a href='#tab" + num_tabs + "'>#" + num_tabs + "</a></li>"
);
$("div#tabs").append(
"<div id='tab" + num_tabs + "'>#" + num_tabs + "</div>"
);
$("div#tabs").tabs("refresh");
});
});
</script>
</head>
<body>
<div id='tabs'>
<ul>
<li><a href='#tab1'>#1</a></li>
</ul>
<div id='tab1'></div>
</div>
<button id='add-tab'>Add tab</button>
</body>
</html>

ExtJs 4.2 example build

ExtJs 4.2 example build

I am new to ExtJs.
When practicing in eclipse do we need to include the entire library(52 MB
approx) in the appropriate location?
Is there any shorter version of this library?
Can I delete some files in the library which are not important?
What are the necessary .js files to be included for building a sample MVC
pattern, CRUD operation support application in ExtJs 4.2?

Unreliable Compiling of Very Simple Java Program in Netbeans

Unreliable Compiling of Very Simple Java Program in Netbeans

I'm a few days into learning Java and I am trying to build a simple
calculator.
When I run the code in Netbeans, perhaps 30% of the time it works great.
The window pops up with my buttons. The other 70% of the time just a blank
JFrame pops up.
In both circumstances Netbeans' Output tab is telling me BUILD SUCCESSFUL
(total time: N seconds)
My code is below - I'm certain it contains a untold numbers of problems
and errors, but specifically I'm trying to understand why the outcome of
executing it is so unreliable.
Thanks in advance,
Ben
import java.awt.Color;
import java.awt.PopupMenu;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Try1 extends JFrame {
public static void main(String[] args) {
//JFrame
JFrame frame = new JFrame();
frame.setSize(400,600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Ben's Program");
frame.setVisible(true);
frame.setLocationRelativeTo(null);
frame.setResizable ( false );
//JPanel
JPanel panel = new JPanel();
panel.setSize(360,100);
panel.setLocation(20, 20);
panel.setBackground(Color.BLUE);
//JPanel 2
JPanel panel2 = new JPanel();
panel2.setSize(360,420);
panel2.setLocation(20, 140);
panel2.setBackground(Color.RED);
//Button
JButton but1= new JButton("1");
JButton but2= new JButton("2");
JButton but3= new JButton("3");
JButton but4= new JButton("4");
JButton but5= new JButton("5");
JButton but6= new JButton("6");
JButton but7= new JButton("7");
JButton but8= new JButton("8");
JButton but9= new JButton("9");
JButton but0= new JButton("0");
JButton butadd= new JButton("+");
JButton butsub= new JButton("-");
JButton butmulti= new JButton("*");
JButton butdiv= new JButton("/");
JButton buteq= new JButton("=");
JButton butclear= new JButton("C");
//Button Layout
but1.setBounds(10, 81, 89, 23);
but2.setBounds(126, 81, 89, 23);
but3.setBounds(225, 81, 89, 23);
but4.setBounds(10, 115, 89, 23);
but5.setBounds(126, 115, 89, 23);
but6.setBounds(225, 115, 89, 23);
but7.setBounds(10, 149, 89, 23);
but8.setBounds(126, 149, 89, 23);
but9.setBounds(225, 149, 89, 23);
but0.setBounds(126, 183, 89, 23);
butadd.setBounds(126, 215, 89, 23);
butsub.setBounds(10, 215, 89, 23);
butmulti.setBounds(225, 183, 89, 23);
butdiv.setBounds(225, 149, 89, 23);
buteq.setBounds(126, 183, 89, 23);
butclear.setBounds(10, 183, 89, 23);
//Add Panel to Frame
frame.add(panel);
frame.add(panel2);
//Add Buttons to Panel2
panel2.add(but1);
panel2.add(but2);
panel2.add(but3);
panel2.add(but4);
panel2.add(but5);
panel2.add(but6);
panel2.add(but7);
panel2.add(but8);
panel2.add(but9);
panel2.add(butadd);
panel2.add(butsub);
panel2.add(butmulti);
panel2.add(butdiv);
panel2.add(buteq);
panel2.add(butclear);
}
}

executable ruby1.8 missing

executable ruby1.8 missing

So I was trying to install redmine on an apache2 server on Ubuntu. Between
multiple atemps to install a plugin, I "accidentaly" deleted
/usr/bin/ruby1.8.
Now I get this error when I try to launch redmine with ruby2.0 (even after
a rvm install 1.8) : *** ERROR ***: Cannot execute /usr/bin/ruby1.8: No
such file or directory (2)
What should I do to have this executable back ?
Thanks for your help

Dispatcher in WPF ViewModel Class

Dispatcher in WPF ViewModel Class

I am using a dispatcher in one of my WPF code behind but now moving all
code behind to MVVM pattern with below code:
this.Dispatcher.BeginInvoke(new Action(() => CallEmployee()));
Thread.Sleep(100000);
but the same is not available from a ViewModel Class file. I tried
System.Windows.Threading.CurrentDispatcher.BeginInvoke(new Action(() =>
CallEmployee()));
Thread.Sleep(100000);
but its not calling CallEmployee method.

Sunday, August 18, 2013

FullGC happens every time when CMS work

FullGC happens every time when CMS work

I have a realtime web application with ~100-1000 request per second. I use
CMS GC and every time when CMS starts to work FGC counter increases by 2.
Why FullGC happens every time? I mean CMS have to work without FullGC. My
JMV options:
-Xms6g
-Xmx6g
-XX:PermSize=512m
-XX:MaxPermSize=512m
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:+UseCMSInitiatingOccupancyOnly
-XX:CMSInitiatingOccupancyFraction=70
-XX:+CMSClassUnloadingEnabled
-XX:+UseLargePages
-XX:LargePageSizeInBytes=2m
-verbose:gc
-Xloggc:gc.log
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-Dsun.rmi.dgc.client.gcInterval=3600000
-Dsun.rmi.dgc.server.gcInterval=3600000
Here is gc.log:
2013-08-19T10:21:33.072+0600: 123570.236: [GC 123570.237: [ParNew:
427534K->35446K(440896K), 0.1872440 secs] 4482285K->4091194K(6242496K),
0.1877660 secs] [Times: user=0.51 sys=0.01, real=0.19 secs]
2013-08-19T10:21:34.026+0600: 123571.191: [GC 123571.191: [ParNew:
427382K->34355K(440896K), 0.1993550 secs] 4483130K->4090615K(6242496K),
0.1998720 secs] [Times: user=0.53 sys=0.00, real=0.20 secs]
2013-08-19T10:21:34.724+0600: 123571.889: [GC 123571.889: [ParNew:
426291K->38786K(440896K), 0.2229880 secs] 4482551K->4095384K(6242496K),
0.2235130 secs] [Times: user=0.53 sys=0.00, real=0.23 secs]
2013-08-19T10:21:35.579+0600: 123572.744: [GC 123572.744: [ParNew:
430722K->34694K(440896K), 0.1812580 secs] 4487320K->4091801K(6242496K),
0.1817630 secs] [Times: user=0.49 sys=0.00, real=0.18 secs]
2013-08-19T10:21:36.429+0600: 123573.594: [GC 123573.594: [ParNew:
426630K->34091K(440896K), 0.1752240 secs] 4483737K->4092028K(6242496K),
0.1757390 secs] [Times: user=0.48 sys=0.00, real=0.17 secs]
2013-08-19T10:21:37.221+0600: 123574.386: [GC 123574.386: [ParNew:
426027K->36411K(440896K), 0.2047550 secs] 4483964K->4095856K(6242496K),
0.2052280 secs] [Times: user=0.50 sys=0.00, real=0.21 secs]
2013-08-19T10:21:38.059+0600: 123575.223: [GC 123575.223: [ParNew:
428347K->40113K(440896K), 0.1892000 secs] 4487792K->4100213K(6242496K),
0.1896180 secs] [Times: user=0.51 sys=0.01, real=0.19 secs]
2013-08-19T10:21:38.593+0600: 123575.757: [GC 123575.757: [ParNew:
432049K->39917K(440896K), 0.2193730 secs] 4492149K->4101831K(6242496K),
0.2198480 secs] [Times: user=0.50 sys=0.00, real=0.22 secs]
2013-08-19T10:21:38.817+0600: 123575.981: [GC [1 CMS-initial-mark:
4061914K(5801600K)] 4102165K(6242496K), 0.0901990 secs] [Times: user=0.09
sys=0.00, real=0.09 secs]
2013-08-19T10:21:38.908+0600: 123576.072: [CMS-concurrent-mark-start]
2013-08-19T10:21:39.305+0600: 123576.469: [CMS-concurrent-mark:
0.397/0.397 secs] [Times: user=4.16 sys=0.44, real=0.39 secs]
2013-08-19T10:21:39.305+0600: 123576.469: [CMS-concurrent-preclean-start]
2013-08-19T10:21:39.335+0600: 123576.499: [GC 123576.499: [ParNew:
431853K->39752K(440896K), 0.2246840 secs] 4493767K->4102434K(6242496K),
0.2251970 secs] [Times: user=0.54 sys=0.00, real=0.23 secs]
2013-08-19T10:21:39.576+0600: 123576.741: [CMS-concurrent-preclean:
0.039/0.271 secs] [Times: user=0.75 sys=0.05, real=0.27 secs]
2013-08-19T10:21:39.576+0600: 123576.741:
[CMS-concurrent-abortable-preclean-start]
2013-08-19T10:21:40.193+0600: 123577.357: [GC 123577.358: [ParNew:
431688K->39319K(440896K), 0.2158020 secs] 4494370K->4102833K(6242496K),
0.2162640 secs] [Times: user=0.53 sys=0.00, real=0.22 secs]
2013-08-19T10:21:40.474+0600: 123577.638:
[CMS-concurrent-abortable-preclean: 0.673/0.898 secs] [Times: user=3.19
sys=0.77, real=0.90 secs]
2013-08-19T10:21:40.479+0600: 123577.643: [GC[YG occupancy: 202771 K
(440896 K)]123577.643: [Rescan (parallel) , 0.0455840 secs]123577.689:
[weak refs processing, 2.2041640 secs]123579.893: [class unloading,
0.0445080 secs]123579.938: [scrub symbol & string tables, 0.0187100 secs]
[1 CMS-remark: 4063513K(5801600K)] 4266284K(6242496K), 2.3260510 secs]
[Times: user=3.24 sys=0.00, real=2.32 secs]
2013-08-19T10:21:42.806+0600: 123579.970: [CMS-concurrent-sweep-start]
2013-08-19T10:21:42.914+0600: 123580.079: [GC 123580.079: [ParNew:
431328K->45397K(440896K), 0.0902990 secs] 4494842K->4109425K(6242496K),
0.0908150 secs] [Times: user=0.50 sys=0.00, real=0.09 secs]
2013-08-19T10:21:43.012+0600: 123580.176: [GC 123580.176: [ParNew:
45767K->4894K(440896K), 0.1271260 secs] 4109795K->4114786K(6242496K),
0.1275320 secs] [Times: user=0.75 sys=0.04, real=0.13 secs]
2013-08-19T10:21:43.286+0600: 123580.451: [GC 123580.451: [ParNew:
396847K->48960K(440896K), 0.2152650 secs] 4506739K->4161825K(6242496K),
0.2157500 secs] [Times: user=0.59 sys=0.00, real=0.22 secs]
2013-08-19T10:21:43.509+0600: 123580.673: [GC 123580.674: [ParNew:
49831K->8172K(440896K), 0.0639450 secs] 4162696K->4159717K(6242496K),
0.0643790 secs] [Times: user=0.48 sys=0.00, real=0.06 secs]
2013-08-19T10:21:43.726+0600: 123580.890: [GC 123580.890: [ParNew:
400108K->48960K(440896K), 0.1256470 secs] 4551616K->4203961K(6242496K),
0.1261110 secs] [Times: user=0.50 sys=0.00, real=0.13 secs]
2013-08-19T10:21:43.999+0600: 123581.164: [GC 123581.164: [ParNew:
440896K->48960K(440896K), 0.1631010 secs] 4565558K->4184975K(6242496K),
0.1635960 secs] [Times: user=0.58 sys=0.01, real=0.16 secs]
2013-08-19T10:21:44.715+0600: 123581.880: [GC 123581.880: [ParNew:
440896K->39265K(440896K), 0.2020150 secs] 4374009K->3975902K(6242496K),
0.2025700 secs] [Times: user=0.53 sys=0.00, real=0.21 secs]
2013-08-19T10:21:44.924+0600: 123582.088: [GC 123582.088: [ParNew:
39857K->1876K(440896K), 0.0546600 secs] 3976335K->3973247K(6242496K),
0.0550670 secs] [Times: user=0.46 sys=0.02, real=0.06 secs]
2013-08-19T10:21:45.207+0600: 123582.371: [GC 123582.371: [ParNew:
393812K->42887K(440896K), 0.2367970 secs] 4280052K->3929127K(6242496K),
0.2372620 secs] [Times: user=0.57 sys=0.00, real=0.24 secs]
2013-08-19T10:21:46.048+0600: 123583.212: [GC 123583.213: [ParNew:
434823K->33908K(440896K), 0.1922750 secs] 4081263K->3683497K(6242496K),
0.1927880 secs] [Times: user=0.54 sys=0.00, real=0.19 secs]
Here is jstat log:
70.86 0.00 63.36 69.93 29.29 7110 1077.048 42 112.603 1189.651
unknown GCCause No GC
0.00 69.63 84.75 69.95 29.29 7111 1077.223 42 112.603 1189.826
unknown GCCause No GC
74.37 20.57 100.00 69.98 29.29 7113 1077.428 42 112.603 1190.031
unknown GCCause Allocation Failure
S0 S1 E O P YGC YGCT FGC FGCT GCT
LGCC GCC
81.53 0.00 80.03 70.01 29.29 7114 1077.837 43 112.693 1190.530
CMS Initial Mark No GC
0.00 81.19 92.05 70.03 29.29 7115 1078.061 **43** 112.693
1190.754 unknown GCCause No GC
80.31 0.00 41.70 70.04 29.29 7116 1078.277 **44** 112.693
1190.970 No GC CMS Final Remark
80.31 0.00 41.70 70.04 29.29 7116 1078.277 44 112.693 1190.970
No GC CMS Final Remark
10.00 92.72 0.09 70.85 29.30 7118 1078.368 44 115.019 1193.386
No GC GCLocker Initiated GC
S0 S1 E O P YGC YGCT FGC FGCT GCT
LGCC GCC
86.43 100.00 100.00 71.26 29.30 7122 1078.900 44 115.019 1193.918
unknown GCCause Allocation Failure
3.83 0.00 96.82 67.37 29.30 7124 1079.319 44 115.019 1194.338
GCLocker Initiated GC No GC
10.70 87.60 100.00 62.91 29.30 7126 1079.556 44 115.019 1194.575
unknown GCCause Allocation Failure
69.26 46.82 100.00 58.81 29.30 7127 1079.748 44 115.019 1194.767
unknown GCCause Allocation Failure
0.00 2.97 0.00 54.59 29.30 7129 1080.196 44 115.019 1195.215
GCLocker Initiated GC No GC
S0 S1 E O P YGC YGCT FGC FGCT GCT
LGCC GCC
77.12 0.00 72.64 46.93 29.30 7130 1080.391 44 115.019 1195.410
unknown GCCause No GC
1.21 0.00 92.31 40.78 29.30 7132 1080.656 44 115.019 1195.675
GCLocker Initiated GC No GC
70.43 0.00 0.14 33.51 29.30 7134 1080.874 44 115.019 1195.893
unknown GCCause No GC
0.00 62.56 33.67 25.89 29.30 7135 1080.974 44 115.019 1195.992
unknown GCCause No GC
71.90 0.00 85.91 23.61 29.30 7136 1081.153 44 115.019 1196.172
unknown GCCause No GC
S0 S1 E O P YGC YGCT FGC FGCT GCT
LGCC GCC
35.00 87.41 100.00 23.66 29.30 7138 1081.349 44 115.019 1196.368
unknown GCCause Allocation Failure
0.00 79.22 68.07 23.69 29.30 7139 1081.671 44 115.019 1196.690
unknown GCCause No GC
87.27 0.00 93.23 23.70 29.30 7140 1081.878 44 115.019 1196.897
unknown GCCause No GC
0.00 65.85 68.58 23.73 29.30 7141 1082.028 44 115.019 1197.047
unknown GCCause No GC
37.82 0.00 22.79 23.75 29.30 7142 1082.097 44 115.019 1197.116
unknown GCCause No GC
S0 S1 E O P YGC YGCT FGC FGCT GCT
LGCC GCC
0.00 65.38 91.55 23.75 29.30 7143 1082.223 44 115.019 1197.242
unknown GCCause No GC
5.66 97.48 100.00 23.80 29.30 7146 1082.490 44 115.019 1197.509
unknown GCCause Allocation Failure
91.30 0.00 93.29 24.44 29.30 7148 1082.807 44 115.019 1197.826
unknown GCCause No GC
64.91 76.26 100.00 24.48 29.30 7150 1082.925 44 115.019 1197.944
unknown GCCause Allocation Failure
0.00 75.64 43.14 24.51 29.30 7151 1083.267 44 115.019 1198.286
unknown GCCause No GC

Have you ever compared Klocwork with Findbugs?

Have you ever compared Klocwork with Findbugs?

pWe are using Klocwork as a static analysis tool./p pKlocwork is a
commercial tool and has many advantages but also has limitations like
false-positives./p pI wonder who has ever compared Klocwork with other
open source tools such as Findbugs./p pCan you say that Klocwork is
superior to other open source tools, especially Findbugs in aspects of
false positives and false negatives?/p

C copy char * to char[]

C copy char * to char[]

Hello I am trying to copy a char * pointer to a char [] array.
this is my code so far
char * string_add(char * base, char * toAdd)
{
char * string=malloc(strlen(base)+streln(toAdd)+1);
sprintf(string,"%s%s",base,toAdd);
char returnString[strlen(string)+1];
// here comes my problem:
memcpy(returnString,string,strlen(string)+1);
// want to add free(string) here
return returnString;
}
I want to use such a function to save code. I don't want to look after
every allocated memory. I also tried
memcpy(&returnString,string,strlen(string)+1);
and some variants with strcpy and strncpy. But following problem persists:
if I call the function twice like:
int main(int argc, char * argv[])
{
char * str1=string_add(argv[1],"-test1");
char * str2=string_add(argv[1],"-test2");
printf("%s, %s", str1,str2);
}
the output is like:
abc-test2, abc-test2
How can I realize this?
Thank you in advance!

Excel macro help needed

Excel macro help needed

im having excel columen key value (scrNo and taskName TeamMember and hours)
scrNo taskName Hours TeamMembers (groupedby)
6533 project 10.5 santosh 6533 project 10 santosh 1423 team work 23 rajesh
2343 work order 10.4 ganesh 2354 testing 21.1 ganesh
TeamMembers are grouped by. and i want to create excel report based on
individual member effort hours like below and respective graph based on
scr no and hours. can any one help me to do in excel macro.![pleace check
the attach image.][1]
**EXCEL REPORT**
GANESH
ScrNo Hours
2343 10.5
2354 21.5
Total 32
Santosh... xx xxx Rajesh.... like above

Remove 'X' from vim tab bar

Remove 'X' from vim tab bar

When using multiple tabs in vim, there is a bar at the top displaying the
tabs. At the far right of that bar there is an X. This is used to close
the current tab if use of the mouse is enabled; however, I don't use the
mouse in vim, so for me it is a bit of useless cruft taking up space.
With many tabs open, vim doesn't display the whole filename in each files,
only the last few characters. Getting rid of this X -- and the small
amount of empty space that seems to be reserved next to it -- would free
up a little bit of space. I would be interested in a method to simply turn
it invisible, but the ideal answer would give me a way to remove it
entirely and free up this space.

Echo HTML tags with attributes

Echo HTML tags with attributes

This code is fine :
<?php
echo "<div>Hello world!</div>";
?>
This code produces an error :
<?php
echo "<div id="test">Hello world!</div>";
?>
It says
Parse error: syntax error, unexpected 'test' (T_STRING), expecting ',' or ';'
Why is that?

how to use systemtap to log CPU scheduling events( sched.switch )

how to use systemtap to log CPU scheduling events( sched.switch )

I have never known systemtap before ,and I would like to log CPU
scheduling events( sched.switch ) using systemtap recently .dose anyone
tell me how to write the script for it .thanks in advance!

Saturday, August 17, 2013

Ruby soundcloud Gem : uninitialized constant SoundCloud (NameError)

Ruby soundcloud Gem : uninitialized constant SoundCloud (NameError)

I installed the SoundCloud ruby gem but when I tried running the example
'Print links of the 10 hottest tracks' on this page
https://github.com/soundcloud/soundcloud-ruby I kept getting an error
message "uninitialized constant SoundCloud (NameError)"
I did follow the instruction on the example, registered a client and got
my client_id (not sure how to get the access token, which is not required
in this example)
I followed the instruction on http://docs.rubygems.org/read/chapter/3 to
add require 'soundcloud' to the example code but i still keep getting the
same error message.
I am using OSX terminal.
sorry i'm new to ruby and soundcloud API so my question might be very
entry level.

Trying to make good looking comments to law in Russian

Trying to make good looking comments to law in Russian

Suppose, I have a Russian text: quotes from law and my comments. And I
want to put the comments in a such way, that:
the reader can easily distinguish comments from the text of the law
it won't distract the attention too much from the main text
Something like this:

What I achieved so far is this:
\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage[T2A]{fontenc}
\setlength{\parindent}{0cm}
\newcommand{\note}[1]{\\\hfill\begin{minipage}{\dimexpr\textwidth-0.5cm}
\begin{itemize}
\item \textbf{\textit{#1}}
\end{itemize}
\xdef\tpd{\the\prevdepth}
\end{minipage}\\
}
\begin{document}
Òåêñò òåêñò òåêñò
\note{Ìîå âàæíîå çàìå÷àíèå}
Òåêñò òåêñò òåêñò
\end{document}
Generating this:

I think, that bold italic it's too distracting.
So, I tried OpenSans font, suggested by egreg here: Why does
\usepackage[T2A]{fontenc} take over?:
\newcommand{\note}[1]{\\\hfill\begin{minipage}{\dimexpr\textwidth-0.5cm}
\begin{itemize}
\item {\fontfamily{fos}\selectfont \footnotesize #1}
\end{itemize}
\xdef\tpd{\the\prevdepth}
\end{minipage}\\
}

This is better, but when I tried to make it italic, it reverted to
computer modern:
\item {\fontfamily{fos}\selectfont \it #1}

How can I generate something, looking like the model text?

TextBox not displayed when rendering form with Html.BeginForm

TextBox not displayed when rendering form with Html.BeginForm

I've just begun learning ASP MVC 4, and I'm working on a basic exercise,
which is a book hosting website.
I'm currently working on a controller for adding a new book to the
repository. The view for the appropriate action is strongly-typed to the
Book class as its model. Book is a very simple model consisting of title,
author and so forth.
My AddBook controller currently looks like this: (I haven't implemented
any database insertion logic on POST, yet)
public class AddBookController : Controller
{
[HttpGet]
public ActionResult AddBook()
{
return View();
}
[HttpPost]
public ActionResult AddBook(Book book)
{
return View();
}
}
My view is also very simple:

@model Bookshare.Models.Book
@{
ViewBag.Title = "AddBook";
}
Add a new book
@using (Html.BeginForm())
{
Html.TextBoxFor(model => model.Title);
Html.TextBoxFor(model => model.Author);
Html.TextBoxFor(model => model.PublishingCompany);
Html.TextBoxFor(model => model.ReleaseYear);
Html.TextBoxFor(model => model.Summary);
}
And yet, when I call this action, all I can see is the "Add a new book"
header and the submit button for the form. No text boxes whatsoever. This
also happens if I use the plain old Html.TextBox syntax. Viewing the
page's source reveals just an empty form tag.
What am I doing wrong here?

URI routing in codeigniter

URI routing in codeigniter

As the title suggests, my issue is with codeIgniter.
I have used a code in an .htaccess file to remove index.php whcih works
all OK.
But I need to go further in changing the URI:
My main controller is page(), so when a user is in my homepage, the
URL-bar shows:
www.example.com/page/
(because homepage is index page, it does not show the page name as usual
the controller suffice),
but If I go to registration page, the URL-bar shows:
www.example.com/page/register
Up to here everything is OK, but I want the codeIgniter to show my domain
without the page() when the user is in my homepage, I don't want foolish
www.example.com/page/ to appear and I think when someone is visiting index
page, the URL-bar better to be www.example.com

Optimization: Algorthm to share 5 Apples with 3 people - compute all valid permutations

Optimization: Algorthm to share 5 Apples with 3 people - compute all valid
permutations

Stuck with a problem.
Given 5 apples and 3 people, compute all possible distribution permutations.
For example:
1) Peter gets 5 Apples, Paul None, Mary None
2) Peter gets 4 Apples, Paul 1, Mary None
etc...
Peter Paul Mary
5 0 0
4 1 0
4 0 1
3 2 0
3 1 1
3 0 2
2 3 0
2 2 1
2 1 2
2 0 3
1 4 0
1 3 1
1 2 2
1 1 3
1 0 4
0 0 5
0 1 4
0 2 3
0 3 2
0 4 1
0 5 0
All 5 apples must be distributed and no more than 5 apples may be
distributed.
Is there an algorithm that will allow me to calculate all permutations,
when when the parameters change.
e.g. 7 Apples and 4 people.
Probably simple for you maths wizards?
Thanks! Harry

Java bytecode manipulation?

Java bytecode manipulation?

So, I'm writing an AV, and I'm developing hooks for a sandbox thing, and I
have a problem: I can't edit the java.lang.* files, nor can I overwrite
them with a classloader. Whenever I try to edit the bytes of a class file,
no good happens. Say, I have a copy of the source code from Runtime(with
reflection for the restricted bits), works 100% the same as the one in
java.lang, I can't modify the bytes to change all references from the lang
one to my custom one. Look at this, I compile this class, which just opens
notepad.exe:
Êþº¾...3.(......Start......java/lang/Object...<init>...()V...Code.............LineNumberTable...LocalVariableTable...this...LStart;...main...([Ljava/lang/String;)V...........java/lang/Runtime........getRuntime...()Ljava/lang/Runtime;......notepad.exe.............exec..'(Ljava/lang/String;)Ljava/lang/Process;...........java/io/IOException..
.....printStackTrace...args...[Ljava/lang/String;...e...Ljava/io/IOException;...StackMapTable...SourceFile...Start.java.!......................./........*·..±...............................................g........¸....¶..W§..L+¶..±.................................................!.".......#.$...%......L.......&.....'
I got the text dump from HxD.
Then I replace all occurrences of java/lang/Runtime with
JavaProphet/JoustJAV/sandbox/Runtime and I get this:
Êþº¾...3.(......Start......java/lang/Object...<init>...()V...Code.............LineNumberTable...LocalVariableTable...this...LStart;...main...([Ljava/lang/String;)V...........JavaProphet/JoustJAV/sandbox/Runtime........getRuntime...()LJavaProphet/JoustJAV/sandbox/Runtime;......notepad.exe.............exec..'(Ljava/lang/String;)Ljava/lang/Process;...........java/io/IOException..
.....printStackTrace...args...[Ljava/lang/String;...e...Ljava/io/IOException;...StackMapTable...SourceFile...Start.java.!......................./........*·..±...............................................g........¸....¶..W§..L+¶..±.................................................!.".......#.$...%......L.......&.....'
Now, if I run the first file, notepad opens, if I open the second file, I
get this error:
Exception in thread "AWT-EventQueue-0" java.lang.ClassFormatError: Unknown
constant tag 74 in class file Start
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at JavaProphet.JoustJAV.SandboxCL.findClass(SandboxCL.java:152)
at JavaProphet.JoustJAV.SandboxCL.loadClass(SandboxCL.java:97)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at JavaProphet.JoustJAV.FileScanner.sandboxFile(FileScanner.java:335)
at JavaProphet.JoustJAV.FileScanner.sandboxFile(FileScanner.java:348)
at JavaProphet.JoustJAV.MainWindow$4.actionPerformed(MainWindow.java:120)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2713)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Now, I assume that those dots are integers or some sort of indexing for
the data in the class file, but what do I need to change to get this class
file to work? I've looked into ASM, but I didn't see a class replacement
mechanism. Suggestions, anyone?

Can't publish on Facebook using Facebook SDK for Android

Can't publish on Facebook using Facebook SDK for Android

I'm using com.facebook.widget.UserSettingsFragment to manage login/logout:
Fragment userSettingsFragment = new UserSettingsFragment();
fragmentTransaction.replace(R.id.content_container, userSettingsFragment,
"userSettingsFragment");
Then in another Fragment I want to publish a message on Facebook. I check
the doc and wrote MyFragment shown below.
The connection with com.facebook.widget.UserSettingsFragment seems to
works (I can login/logout), but when I want to publish in MyFragment, it
seems that session.requestNewPublishPermissions(newPermissionsRequest);
does not change the Session, because onSessionStateChange is never called.
Anybody can help?
public class MyFragment extends Fragment{
private Button mBtnShare;
private UiLifecycleHelper mUiHelper;
private Session.StatusCallback mCallback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception
exception) {
onSessionStateChange(session, state, exception);
}
};
private static final List<String> PERMISSIONS =
Arrays.asList("publish_actions");
private static final String PENDING_PUBLISH_KEY =
"pendingPublishReauthorization";
private boolean pendingPublishReauthorization = false;
private void onSessionStateChange(Session session, SessionState state,
Exception exception) {
if (state.isOpened()) {
if (pendingPublishReauthorization &&
state.equals(SessionState.OPENED_TOKEN_UPDATED)) {
pendingPublishReauthorization = false;
publish();
}
} else if (state.isClosed()) {
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (savedInstanceState != null) {
pendingPublishReauthorization =
savedInstanceState.getBoolean(PENDING_PUBLISH_KEY, false);
}
return inflater.inflate(R.layout.my_fragment, container, false);
}
@Override
public void onActivityCreated (Bundle savedInstanceState){
super.onActivityCreated(savedInstanceState);
mBtnShare = (Button) getActivity().findViewById(R.id.btn_share);
mBtnShare.setOnClickListener( new Button.OnClickListener() {
public void onClick(View v)
{
publish();
}
);
}
@Override
public void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
mUiHelper = new UiLifecycleHelper(getActivity(), mCallback);
mUiHelper.onCreate(savedInstanceState);
}
@Override
public void onResume() {
super.onResume();
mUiHelper.onResume();
}
@Override
public void onPause() {
mUiHelper.onPause();
super.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
mUiHelper.onDestroy();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(PENDING_PUBLISH_KEY,
pendingPublishReauthorization);
mUiHelper.onSaveInstanceState(outState);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent
intent) {
super.onActivityResult(requestCode, resultCode, intent);
mUiHelper.onActivityResult(requestCode, resultCode, intent);
}
private void publish() {
Session session = Session.getActiveSession();
if (session != null){
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new
Session
.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
Bundle postParams = new Bundle();
postParams.putString("name", "Facebook SDK for Android");
postParams.putString("caption", "Build great social apps and
get more installs.");
postParams.putString("description", "The Facebook SDK for
Android makes it easier and faster to develop Facebook
integrated Android apps.");
postParams.putString("link",
"https://developers.facebook.com/android");
postParams.putString("picture",
"https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
Request.Callback callback= new Request.Callback() {
public void onCompleted(Response response) {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i(this.getClass().getSimpleName(), "JSON error
"+ e.getMessage(), MyApplication.LOG_LEVEL);
}
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(getActivity()
.getApplicationContext(),
error.getErrorMessage(),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity()
.getApplicationContext(),
postId,
Toast.LENGTH_LONG).show();
}
}
};
Request request = new Request(session, "me/feed", postParams,
HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
}
}
private boolean isSubsetOf(Collection<String> subset,
Collection<String> superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}
}