How to create java beans dynamically?
How to create bean/s(retaining column datatype in bean) dynamically after
reading columns from table/s in java ?
Thursday, 3 October 2013
Wednesday, 2 October 2013
what is the purpose of the function annotation method in the Facebook JavaScript SDK?
what is the purpose of the function annotation method in the Facebook
JavaScript SDK?
I'm starting using facebook javscript SDK, and I found a interesting thing
when I read the source code.
The code example is as belowed:
/**
* Annotates a function with a meta object
*/
function annotate(fn, meta) {
meta.superClass = fn.__superConstructor__;
fn.__TCmeta = meta;
return fn;
}
// export to global
__w = annotate;
/**
* when using the annotate function
*/
function sprintf(format) {
// function body
}
__w(sprintf, {"signature":"function(string)"}); // <-- what is the
purpose of doing this?
So, my question is what is that used for? What is the benefit doing this?
JavaScript SDK?
I'm starting using facebook javscript SDK, and I found a interesting thing
when I read the source code.
The code example is as belowed:
/**
* Annotates a function with a meta object
*/
function annotate(fn, meta) {
meta.superClass = fn.__superConstructor__;
fn.__TCmeta = meta;
return fn;
}
// export to global
__w = annotate;
/**
* when using the annotate function
*/
function sprintf(format) {
// function body
}
__w(sprintf, {"signature":"function(string)"}); // <-- what is the
purpose of doing this?
So, my question is what is that used for? What is the benefit doing this?
How can i create a Thread that running on background on Android
How can i create a Thread that running on background on Android
I have a Thread with open socket connection in a activity, I like to use
the thread globaly so that I can get data from thread in other Activities.
Somethink like running on the background...
Does anyone have a solution or examples for me?
Thank u.
I have a Thread with open socket connection in a activity, I like to use
the thread globaly so that I can get data from thread in other Activities.
Somethink like running on the background...
Does anyone have a solution or examples for me?
Thank u.
R download and read many excel files, automatically
R download and read many excel files, automatically
I need to download a few hundred number of excel files and import them
into R each day. Each one should be their own data-frame. I have a csv.
file with all the adresses (the adresses remains static).
The csv. file looks like this:
http://www.www.somehomepage.com/chartserver/hometolotsoffiles%a
http://www.www.somehomepage.com/chartserver/hometolotsoffiles%b
http://www.www.somehomepage.com/chartserver/hometolotsoffiles%a0
http://www.www.somehomepage.com/chartserver/hometolotsoffiles%aa11
etc.....
I can do it with a single file like this:
library(XLConnect)
my.url <- "http://www.somehomepage.com/chartserver/hometolotsoffiles%a"
loc.download <- "C:/R/lotsofdata/" # each files probably needs to have
their own name here?
download.file(my.url, loc.download, mode="wb")
df.import.x1 = readWorksheetFromFile("loc.download", sheet=2))
# This kind of import works on all the files, if you ran them individually
But I have no idea how to download each file, and place it separately in a
folder, and then import them all into R as individual data frames.
I need to download a few hundred number of excel files and import them
into R each day. Each one should be their own data-frame. I have a csv.
file with all the adresses (the adresses remains static).
The csv. file looks like this:
http://www.www.somehomepage.com/chartserver/hometolotsoffiles%a
http://www.www.somehomepage.com/chartserver/hometolotsoffiles%b
http://www.www.somehomepage.com/chartserver/hometolotsoffiles%a0
http://www.www.somehomepage.com/chartserver/hometolotsoffiles%aa11
etc.....
I can do it with a single file like this:
library(XLConnect)
my.url <- "http://www.somehomepage.com/chartserver/hometolotsoffiles%a"
loc.download <- "C:/R/lotsofdata/" # each files probably needs to have
their own name here?
download.file(my.url, loc.download, mode="wb")
df.import.x1 = readWorksheetFromFile("loc.download", sheet=2))
# This kind of import works on all the files, if you ran them individually
But I have no idea how to download each file, and place it separately in a
folder, and then import them all into R as individual data frames.
Unable to add properties to a object using $.each() function
Unable to add properties to a object using $.each() function
I have a object habits contain some values
var habits={
"Drinking":"No",
"Smoking":"No"
}
I need to add the values in this variable to another variable in this format
var NewHabits=new Object();
NewHabits.Drinking="No";
NewHabits.Smoking="No";
My habits variable is big so i decided to add values using jquery $.each()
function
var NewHabits=new Object();
$.each(habits,function(index, value)
{
NewHabits.index=value;
}
But after executing this code i am getting value in NewHabits variable as
below
"index":"No","index":"No"
the problem is giving variable like this NewHabits.index
Please help me to solve this
I have a object habits contain some values
var habits={
"Drinking":"No",
"Smoking":"No"
}
I need to add the values in this variable to another variable in this format
var NewHabits=new Object();
NewHabits.Drinking="No";
NewHabits.Smoking="No";
My habits variable is big so i decided to add values using jquery $.each()
function
var NewHabits=new Object();
$.each(habits,function(index, value)
{
NewHabits.index=value;
}
But after executing this code i am getting value in NewHabits variable as
below
"index":"No","index":"No"
the problem is giving variable like this NewHabits.index
Please help me to solve this
Tuesday, 1 October 2013
gVim can't view file created with Notepad in System32 folder
gVim can't view file created with Notepad in System32 folder
When I create a file called hello.txt in C:\Windows\System32 with the text
"hello" in it, gVim for some reason will not find this file. Can someone
explain why this happens?
Here you can see I created the file in Notepad.
Now I'm trying to find the same file in gVim using :E. hello.txt is
nowhere to be found. :e hello.txt opens up a new file. I feel like I'm
getting trolled by my computer.
When I create a file called hello.txt in C:\Windows\System32 with the text
"hello" in it, gVim for some reason will not find this file. Can someone
explain why this happens?
Here you can see I created the file in Notepad.
Now I'm trying to find the same file in gVim using :E. hello.txt is
nowhere to be found. :e hello.txt opens up a new file. I feel like I'm
getting trolled by my computer.
Modifying an apk causes NoSuchFieldError
Modifying an apk causes NoSuchFieldError
I have decoded an apk via apktool and modified it like below finally
rebuilt it succesfully. However, when I run it on an emulator I get
NoSuchFieldError. I have broken something but I can't see what. Please
help.
Original:
...
.field private a_global_variable:Lsome/class;
...
new-instance v0, Lsome/class;
invoke-direct {v0} Lsome/class;-><init>()V
iput-object v0, p0, Lthis/main/class;->a_global_variable:Lsome/class;
Modified:
...
.field private a_global_variable:Lsome/class;
...
invoke-static {} Lsome/class;-><init>()Lsome/class;
move-result-object v0
iput-object v0, p0, Lthis/main/class;->a_global_variable:Lsome/class;
I have decoded an apk via apktool and modified it like below finally
rebuilt it succesfully. However, when I run it on an emulator I get
NoSuchFieldError. I have broken something but I can't see what. Please
help.
Original:
...
.field private a_global_variable:Lsome/class;
...
new-instance v0, Lsome/class;
invoke-direct {v0} Lsome/class;-><init>()V
iput-object v0, p0, Lthis/main/class;->a_global_variable:Lsome/class;
Modified:
...
.field private a_global_variable:Lsome/class;
...
invoke-static {} Lsome/class;-><init>()Lsome/class;
move-result-object v0
iput-object v0, p0, Lthis/main/class;->a_global_variable:Lsome/class;
xorg, jetty, and lightdm all crash my system when run
xorg, jetty, and lightdm all crash my system when run
Whenever I start xorg my computer crashes. I am brought out to a black
screen much like the one that it shows when I shut down my computer. After
displaying this screen for awhile it kicks me out to the login screen. The
same thing happens whenever I try to run Jetty or lightdm. Could it be a
problem with my really really old crappy ati drivers? I know it's not a
problem because of corrupted xubuntu files, because I just did a fresh
install of xubuntu 13.04 about a month ago, and haven't tampered with it
at all.
Whenever I start xorg my computer crashes. I am brought out to a black
screen much like the one that it shows when I shut down my computer. After
displaying this screen for awhile it kicks me out to the login screen. The
same thing happens whenever I try to run Jetty or lightdm. Could it be a
problem with my really really old crappy ati drivers? I know it's not a
problem because of corrupted xubuntu files, because I just did a fresh
install of xubuntu 13.04 about a month ago, and haven't tampered with it
at all.
Switch keyboard layout on left control while pressed
Switch keyboard layout on left control while pressed
I'm using dworak, and I'd like to switch to qwerty layout when I'm using
shortcuts (like ctrl+c etc). The problem is that I press the shortcuts
with my left hand (e.g. left Ctrl), and in ubuntu keyboard switching menu,
the only combination which seems absent is Left Ctrl (while pressed).
I've seen that it's possible to change the settings with a command line,
but apparently, I'm not advanced enough to understand how to do it
properly for the left Ctrl.
Can anyone suggest to me how I can do it with setxkbmap or any other tool?
UPDATE
this is not exactly what I wanted, but it answers my question:
Is there any way to use QWERTY's keyboard shortcut position while the
Dvorak layout is active?
I'm using dworak, and I'd like to switch to qwerty layout when I'm using
shortcuts (like ctrl+c etc). The problem is that I press the shortcuts
with my left hand (e.g. left Ctrl), and in ubuntu keyboard switching menu,
the only combination which seems absent is Left Ctrl (while pressed).
I've seen that it's possible to change the settings with a command line,
but apparently, I'm not advanced enough to understand how to do it
properly for the left Ctrl.
Can anyone suggest to me how I can do it with setxkbmap or any other tool?
UPDATE
this is not exactly what I wanted, but it answers my question:
Is there any way to use QWERTY's keyboard shortcut position while the
Dvorak layout is active?
Monday, 30 September 2013
Difference between a joint probability and the probability of an intersection
Difference between a joint probability and the probability of an intersection
Is the joint probability $p(X=x,Y=y)$ equivalent to $p(X=x \cap Y=y )$? If
it is, why do we use two different notations?
Is the joint probability $p(X=x,Y=y)$ equivalent to $p(X=x \cap Y=y )$? If
it is, why do we use two different notations?
Simple statements to prove or disprove
Simple statements to prove or disprove
I am supposed to teach undergraduate students who do not major in
mathematics and I would like to give them a short introduction to
mathematical reasoning and to the concept of proof. I am looking for very
simple mathematical statements (true or false) to help them get familiar
with logic and proof writing.
I am not sure if what I ask is clear, so here are some ideas I came up with:
Let $n$ be an integer. If $n$ is a multiple of $42$, then $n$ is even.
Let $n$ be an integer. If $n$ is a multiple of $43$, then $n$ is odd.
If $x$ is a positive real number, then $x^2 \geq x$.
For all $n \in \Bbb Z$, $n$ is even iff $n^2$ is even.
There is no $x \in \Bbb Q$ such that $x^2 = 2$.
There exist irrational numbers $\alpha,\beta > 0$ such that $\alpha^\beta$
is rational.
For all $x \in \Bbb R$, if [for all $\epsilon > 0$, $|x| < \epsilon$],
then $x = 0$.
There exists $m \in \Bbb Z$ such that, forall $n \in \Bbb Z$, one has $n
\leq m$.
It would be great to cover different type of statements.
I am supposed to teach undergraduate students who do not major in
mathematics and I would like to give them a short introduction to
mathematical reasoning and to the concept of proof. I am looking for very
simple mathematical statements (true or false) to help them get familiar
with logic and proof writing.
I am not sure if what I ask is clear, so here are some ideas I came up with:
Let $n$ be an integer. If $n$ is a multiple of $42$, then $n$ is even.
Let $n$ be an integer. If $n$ is a multiple of $43$, then $n$ is odd.
If $x$ is a positive real number, then $x^2 \geq x$.
For all $n \in \Bbb Z$, $n$ is even iff $n^2$ is even.
There is no $x \in \Bbb Q$ such that $x^2 = 2$.
There exist irrational numbers $\alpha,\beta > 0$ such that $\alpha^\beta$
is rational.
For all $x \in \Bbb R$, if [for all $\epsilon > 0$, $|x| < \epsilon$],
then $x = 0$.
There exists $m \in \Bbb Z$ such that, forall $n \in \Bbb Z$, one has $n
\leq m$.
It would be great to cover different type of statements.
Why does font ignore line-height in CSS while font-size doesn't?
Why does font ignore line-height in CSS while font-size doesn't?
pI experienced a very weird behavior. Why does test2 ignore line-height
while test1 works fine? (the background-color is just to identify the
containers better)/p precodebody { line-height:0.8; } .test1 {
background:#fdf; font-size:24px; font-family:Arial,sans-serif; } .test2 {
background:#ffd; font:24px Arial,sans-serif; } /code/pre plive demo: a
href=http://jsfiddle.net/tHUeg/4/
rel=nofollowhttp://jsfiddle.net/tHUeg/4//a/p
pI experienced a very weird behavior. Why does test2 ignore line-height
while test1 works fine? (the background-color is just to identify the
containers better)/p precodebody { line-height:0.8; } .test1 {
background:#fdf; font-size:24px; font-family:Arial,sans-serif; } .test2 {
background:#ffd; font:24px Arial,sans-serif; } /code/pre plive demo: a
href=http://jsfiddle.net/tHUeg/4/
rel=nofollowhttp://jsfiddle.net/tHUeg/4//a/p
Set default value for function parameter in scala
Set default value for function parameter in scala
I am trying to set a default value to an anonymous function in scala and
so for not able to find any solution. Hope some one would help me out in
SO.
I have the following structure,
case class A(id:Int = 0)
case class B(a:A)
object B {
def func1(f:Int = 0)={
........
}
def func2(f:A => B = (how to give default value ?))={
case Nothing => {
//do something....
}
case _ => {
//do some other thing......
}
}
}
Basically, I want to make passing the parameter as optional. How can I
achieve this?
I am trying to set a default value to an anonymous function in scala and
so for not able to find any solution. Hope some one would help me out in
SO.
I have the following structure,
case class A(id:Int = 0)
case class B(a:A)
object B {
def func1(f:Int = 0)={
........
}
def func2(f:A => B = (how to give default value ?))={
case Nothing => {
//do something....
}
case _ => {
//do some other thing......
}
}
}
Basically, I want to make passing the parameter as optional. How can I
achieve this?
Sunday, 29 September 2013
Using Python with the Twitter API to post tweets?
Using Python with the Twitter API to post tweets?
Anyone have any reccomendations as to what python library to use to post
tweets to twitter?
The ones I've found are
twython
PythonTwitter
TwitterAPI
Python Twitter Tools
Tweepy
TweetPony
twitter-gobject
Anyone else know of any good/better ones or can anyone give me a simple
example to post to twitter?
Thanks in advance - Hyflex
Anyone have any reccomendations as to what python library to use to post
tweets to twitter?
The ones I've found are
twython
PythonTwitter
TwitterAPI
Python Twitter Tools
Tweepy
TweetPony
twitter-gobject
Anyone else know of any good/better ones or can anyone give me a simple
example to post to twitter?
Thanks in advance - Hyflex
Div wiggles when overlay appears
Div wiggles when overlay appears
I have a div (the blue card with css3 logo) that wiggles when I hover the
I Icon, you can view the probleme here :
http://lab.stephenbe.ca/portfolio/portfoliov3/
I have no idea why this is happening, I tried recreating the problem in
codepen :
http://codepen.io/stephenbe/pen/FckrH
And the bug does not appear at all. I noticed that if your screen is
small, the bug does not appear. The screen has to be around 1600 in size.
The bug appears in the latest version of chrome
Thank you
I have a div (the blue card with css3 logo) that wiggles when I hover the
I Icon, you can view the probleme here :
http://lab.stephenbe.ca/portfolio/portfoliov3/
I have no idea why this is happening, I tried recreating the problem in
codepen :
http://codepen.io/stephenbe/pen/FckrH
And the bug does not appear at all. I noticed that if your screen is
small, the bug does not appear. The screen has to be around 1600 in size.
The bug appears in the latest version of chrome
Thank you
Is Byte implemented as Int anyway?
Is Byte implemented as Int anyway?
I had a java game book recommend implementing all data as Int when
possible, that that type runs the fastest. It said the Byte, Char, and
Boolean are implemented as Int anyway, so you don't save space and the
casting you end up having to do in the code because of the Byte data will
slow it down. For instance, a cast is needed for
a = (byte)(b+c);
since the addition result is an Int, even when a,b, and c are all declared
as Bytes.
I currently have a huge 2D array declared as Byte for my game, to save
space and for bitwise operations. Is it actually saving space? I've also
seen bitwise operations done on Ints in examples, do bitwise operations
work as expected on Ints?
I had a java game book recommend implementing all data as Int when
possible, that that type runs the fastest. It said the Byte, Char, and
Boolean are implemented as Int anyway, so you don't save space and the
casting you end up having to do in the code because of the Byte data will
slow it down. For instance, a cast is needed for
a = (byte)(b+c);
since the addition result is an Int, even when a,b, and c are all declared
as Bytes.
I currently have a huge 2D array declared as Byte for my game, to save
space and for bitwise operations. Is it actually saving space? I've also
seen bitwise operations done on Ints in examples, do bitwise operations
work as expected on Ints?
Unexpected Coffeescript transformation with if?
Unexpected Coffeescript transformation with if?
This CoffeeScript:
x = y > z ? 'a' : 'b'
Compiles to:
x = (_ref = y > z) != null ? _ref : {
'a': 'b'
};
I assume this is expected, just not intuitive.
This there a better way to do this in coffeescript?
This CoffeeScript:
x = y > z ? 'a' : 'b'
Compiles to:
x = (_ref = y > z) != null ? _ref : {
'a': 'b'
};
I assume this is expected, just not intuitive.
This there a better way to do this in coffeescript?
Saturday, 28 September 2013
What application are applications downloaded with from the software centre?
What application are applications downloaded with from the software centre?
How (What application) are applications downloaded with from the software
centre?
How (What application) are applications downloaded with from the software
centre?
hashchange function and jQuery mobile conflict
hashchange function and jQuery mobile conflict
I'm currently having some problems combining a hashchange function I have
set up and jQuery mobile. I've never used jQuery mobile before, but it
seemed the best solution to achieve a 'slideup' page transition, i.e.
sliding the whole page on transition.
I also have a hashchange function set up, in combination with the isotope
plugin to add content to the grid, attach a hash to it, thus allow you to
navigate to it via a url.
Here's an example page I've set up to demonstrate my problem:
http://nealfletcher.co.uk/transition/
Firstly click on the 'hash click' block, loads the relevant content in,
attaches a hash, BUT navigating to this hash url greets you with the
jquery mobile loading gif. Also clicking on the 'transition click' brings
in the new page correctly but clicking on the 'news hash click' attaches a
hash to the url as it should, but again navigating to this url greets you
with the jquery mobile spinning gif as /news is being replaced with
#news-01 instead of /news/#news-01.
Basically I'm trying to find a solution where both my hashchange function
and my jquery mobile page transitions can work in conjunction with each
other without conflict, if at all possible. I'm struggling with this one,
any suggestions would be greatly appreciated!
I'm currently having some problems combining a hashchange function I have
set up and jQuery mobile. I've never used jQuery mobile before, but it
seemed the best solution to achieve a 'slideup' page transition, i.e.
sliding the whole page on transition.
I also have a hashchange function set up, in combination with the isotope
plugin to add content to the grid, attach a hash to it, thus allow you to
navigate to it via a url.
Here's an example page I've set up to demonstrate my problem:
http://nealfletcher.co.uk/transition/
Firstly click on the 'hash click' block, loads the relevant content in,
attaches a hash, BUT navigating to this hash url greets you with the
jquery mobile loading gif. Also clicking on the 'transition click' brings
in the new page correctly but clicking on the 'news hash click' attaches a
hash to the url as it should, but again navigating to this url greets you
with the jquery mobile spinning gif as /news is being replaced with
#news-01 instead of /news/#news-01.
Basically I'm trying to find a solution where both my hashchange function
and my jquery mobile page transitions can work in conjunction with each
other without conflict, if at all possible. I'm struggling with this one,
any suggestions would be greatly appreciated!
Center an image in a container scale it and crop the remaining
Center an image in a container scale it and crop the remaining
I have this scenario. So the image is larger than the container
I want it to scale down or scale up depending on the container size but at
the same time put it on the center and crop the remaining (horizontally).
So I did something like this.
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/header_long"
android:gravity="center"
android:antialias="true"
android:dither="true"/>
However it looks like this now. The top, bottom, left and right is cropped.
I want it to be something like this.
I have this scenario. So the image is larger than the container
I want it to scale down or scale up depending on the container size but at
the same time put it on the center and crop the remaining (horizontally).
So I did something like this.
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/header_long"
android:gravity="center"
android:antialias="true"
android:dither="true"/>
However it looks like this now. The top, bottom, left and right is cropped.
I want it to be something like this.
Subscribe to:
Posts (Atom)