Tuesday, 20 August 2013

From within a javascript var, how do you change the font color for individual lines?

From within a javascript var, how do you change the font color for
individual lines?

I'm sure this is an easy question. I have some javascript that randomizes
quotes, but I want the quote and the author of the quote to be different
colors. I can of course use CSS to change the appearance of all the text,
but I am not having much luck separating the quote and the author and I am
not very proficient with javascript.
<script language="JavaScript">
var Quotation=new Array()
Quotation[0] = "Only two things are infinite, the universe and human
stupidity, and I'm not sure about the former.<br>Albert Einstein";
Quotation[1] = "Science is a way of thinking much more than it is a body
of knowledge. <br>Carl Sagan";
Quotation[2] = "Few tragedies can be more extensive than the stunting of
life, few injustices deeper than the denial of an opportunity to strive or
even to hope, by a limit imposed from without, but falsely identified as
lying within.<br>Stephen Jay Gould";
Quotation[3] = "I don't want to talk to you no more, you empty-headed
animal food trough wiper! I fart in your general direction! Your mother
was a hamster and your father smelt of elderberries!<br>Taunting
Frenchman";
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();
</script>

D3 mysterious json parsing error

D3 mysterious json parsing error

D3 json parser is generating mysterious error. The json is as follows and
the string is validated by an online parser but d3 generates the error
"Unexpected token ]".
I'm totally confused. Please tell me whether it is the Json string's fault
or the parser?
{
"3090": [
"59205",
"72521"
],
"3130": [
"189939"
],
"3150": [
"58710"
],
"3258": [
"21738"
],
"3717": [
"61363"
],
"3719": [
"63965"
],
"3989": [
"47636",
"47656",
"58571",
"58741",
"58745",
"59266",
"139954"
],
"3991": [
"186438"
],
"3992": [
"38062",
"41032"
],
"4038": [
"59198"
],
"5009": [
"189476"
],
"027936": [
"179047"
],
"P391": [
"13461",
"679516",
"978543"
],
"M492": [
"170321",
"199900",
"273415",
"348748",
"966475"
],
"1P04": [
"49027",
"173470",
"1029583"
],
"N624": [
"178491",
"182573",
"204070",
"213200",
"220640",
"689284"
],
"M187": [
"65486",
"162474",
"167984",
"210661",
"218076",
"224395",
"256049",
"295905",
"298012",
"301037",
"307361",
"318149",
"320015",
"327478",
"329620",
"334297",
"334557",
"634880",
"714124",
"788333",
"976785",
"1016630",
"1017012",
"1026645",
"1048217",
"1048218"
],
"N622": [
"51453",
"150260",
"230713",
"632383",
"806624"
],
"N626": [
"268476",
"268481",
"721098",
"817611",
"941123",
"943528",
"1033581"
],
"057139": [
"114172"
],
"1F75": [
"18520",
"60105",
"215892",
"231772",
"807606",
"918089",
"943877",
"1039530"
],
"V056": [
"199919",
"292498",
"333106"
],
"V275": [
"24796",
"28969",
"29209",
"40253",
"303970",
"326940",
"332927",
"334300",
"597799",
"780261"
],
"K293": [
"6956",
"178352"
],
"W415": [
"22526"
]
}
d3.json("data/ms_org_hierarchy.json", function(errHier, hier){
d3.json("data/ms_org_user.json", function(errUser, users){
console.log(errHier);
console.log(hier);
console.log(errUser);
console.log(users);
}
}

Count number of days by ignoring times

Count number of days by ignoring times

I am trying to calculate the number of days that an event category has
occurred in T-SQL in SSMS 2008. How do I write this expression? This value
is stored as a datetime, but I want to count the day portion only. For
example, if my values were:
2013-01-05 19:20:00.000
2013-01-06 17:20:00.000
2013-01-06 18:20:00.000
2013-01-06 19:20:00.000
2013-01-03 16:15:00.000
2013-01-04 12:55:00.000
Then although there are 6 unique records listed above, I would want to
count this as only 4, since there are 3 records on 1/6/2013. Make sense?
This is what I'm trying now that doesn't work:
select
count(s.date_value)
From
table_A s

setting up informatica repository service

setting up informatica repository service

I'm new to informatica. I ran into problems creating repository service (
i searched this forum and the internet, nothing seemed to work)
So here is my whole setup
Vsphere server 1: installed windows server 2008 (64 bit), 11g(64 bit)
Vsphere server 2: installed Windows Server 2003 (32 bit), informatica
server 8.6.0 (32 bit)
My laptop: installed Windows 7 (64 bit),
I created a user in 11g for informatica inno_informatica, grant connect,
dba, resource created another user in 11g for repository inno_repo, grant
connect, dba, resource
After I successfully installed informatica in server 2, I tried to setup
repository service, but I got an error, saying that It cann't connect to
database,
so now, the repository service is there on the left hand panel, but there
is a message in red indicating "The service did not start due to the
following error: unable to connect to the repository inno_repo on database
Orcl.132.1.123. Check the Log for more Information"
When I check the log, two messages got my attention
database driver event.... Error occurred loading library [pmora8.dll].
System error encountered is 126. Error text is The specified module could
not be found..
unable to connect to the repository inno_repo orcle.132.1.123
Also, just want to point out, the database for repository service and
informatica domain is the same one, but with different schemas. And no
informatica client, or oracle client is installed on Server 2
Do I have to install Oracle Client on Server 2?
Are certain environmental variables needed in order to problem this problem?
what about ports? what ports are needed for informatica?
if none of the above could solve the problem, then what should be done?
Can someone please help!!!
Thanks in advance.
Shawn

Custom ListView not populating

Custom ListView not populating

I've been dealing with this for a few weeks now. I've already seen all
other related questions and it does not help. I'm trying to populate a
custom ListView and can't for the life of me get it to work. I'll post all
the relevant information hoping someone will notice my mistake.
Activity Layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="#000000">
<ListView
android:id="@+id/deviceListView"
android:layout_width="400px"
android:layout_height="fill_parent"
android:textColor="#ffffff"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"/>
Custom Row layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#000000">
<TextView android:id="@+id/textId"
android:textSize="50sp"
android:text="ID"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<TextView android:id="@+id/textTimestamp"
android:textSize="16sp"
android:text="Timestamp"
android:textColor="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"/>
<TextView android:id="@+id/textCoordinates"
android:textSize="16sp"
android:text="Coordinates"
android:textColor="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/textDistance"
android:textSize="16sp"
android:text="Distance"
android:textColor="#FFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
Adapter model:
public class DeviceList {
public static ArrayList<Device> list;
public static void loadModel(int quantity) {
ArrayList<Device> listTmp = new ArrayList<Device>();
for (int i = 0; i < quantity; i++) {
listTmp.add(new Device(System.currentTimeMillis(), i, new
float[]{0, 0}, System.currentTimeMillis() / (i + 1)));
}
list = listTmp;
}
public static Device GetById(int id){
Device tmp = null;
for(Device device : list){
if (device.getID() == id){
tmp = device;
}
}
return tmp;
}
}
Adapter:
public class DeviceArrayAdapter extends ArrayAdapter<Device> {
private Context context;
private int rowResourceId;
private String[] ids;
public DeviceArrayAdapter(Context context, int rowResourceId, String[]
devices) {
super(context, rowResourceId);
this.context = context;
this.ids = devices;
this.rowResourceId = rowResourceId;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.device_row, parent, false);
TextView idTextview = (TextView) rowView.findViewById(R.id.textId);
TextView timeStampTextview = (TextView)
rowView.findViewById(R.id.textTimestamp);
TextView coordinatesTextview = (TextView)
rowView.findViewById(R.id.textCoordinates);
TextView distanceTextview = (TextView)
rowView.findViewById(R.id.textDistance);
int id = Integer.parseInt(ids[position]);
timeStampTextview.setText(Long.toString(DeviceList.GetById(id).getTimestamp()));
idTextview.setText(DeviceList.GetById(id).getID());
coordinatesTextview.setText(DeviceList.GetById(id).getCoordinates()[0]
+ "," + DeviceList.GetById(id).getCoordinates()[1]);
distanceTextview.setText(DeviceList.GetById(id).getDistance() + "");
return rowView;
}
}
And finally the Activity's onCreate method:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// setContentView(R.layout.activity_main);
// ArrayList<Device> list = createDummyDeviceList(5);
DeviceList.loadModel(5);
String[] ids = new String[DeviceList.list.size()];
for (int i= 0; i < ids.length; i++){
ids[i] = Integer.toString(i+1);
}
ListView listView = (ListView) findViewById(R.id.deviceListView);
DeviceArrayAdapter adapter = new DeviceArrayAdapter(this,
R.layout.device_row, ids);
listView.setAdapter(adapter);
}
Note: I'm sorry to post like this but I'm desperate. I've already debugged
it up to the last line and everything is loaded and there are no
Exceptions. But it just won't populate.

C# deleget and event in UserControl

C# deleget and event in UserControl

I have UserControl similar to ListView. I want to create event machining
delete item from ListView.
I doing so. But I do not know how to go on.
namespace ImagesSetEditor
{ public partial class ImagesSetEditor : UserControl { public delegate
void ImageRemovedEventHandler(object sender, ImagesSetEditor e); public
event ImageRemovedEventHandler ImageRemovedEvent;

How to generate a memeber function with a deduced signature

How to generate a memeber function with a deduced signature

is it possible to produce method definition (with an exact number of
parameters and return value of known type), having:
method argument types "frozen" in a variadic arguments pack
deduced method return type
method name (passed to a macro?)
Details:
I have a simple reflection structure (partial specialisation stuff omited
for readability), which deduces member functions return type and argument
types:
template<typename RetType, typename ...ArgTypes>
struct reflect_method<RetType(HostClassType::*)(ArgTypes...)> {
using method_type = RetType;
using method_args = type_placeholder<ArgTypes...>;
using call_type = RetType(HostClassType::*)(ArgTypes...);
};
where method_type is a method return type, method_args are a method
argument types "frozen" in a helper template struct type_placeholder.
What I'm trying to do is to create a method in a generated class which
will reflect arguments and return type of another method of some other
class. The created method will provide a decoration for the reflected
method.
Pseudocode implementation:
#define RPCCLASS(class_name) class RPC##class_name : public class_name \
{ \
using SelfType = RPC##class_name; \
using ParentType = class_name;
#define RPCCLASS_END() };
#define RPCBIND(method_name) \
using method_name_##tag =
reflect_method<decltype(ParentType::method_name)>; \
method_name_##tag::method_type
method_name(method_name_##tag::method_args::at<0>::type arg0, \
method_name_##tag::method_args::at<1>::type arg1, \
/* ... */ \
/*don't know how to put correct number of arguments
here)*/) \
{
\
/* do some stuff */
\
/* ... */
\
/* invoke the reflected method */
\
return Invoke<method_name_##tag>::apply(this, method_name,
\
arg0,
\
arg1
\
/*again don't know how to put correct number of arguments
here)*/) \
}
// USAGE:
class MyOwnClass {
public:
virtual long long doFun(int a, char b, const std::string& c);
};
RPCCLASS(MyOwnClass)
RPCBIND(doFun)
RPCCLASS_END()