ormlite creates tables with columns in wrong order |
[[ Sorry for the late answer. ]]
I cannot retrieve rows by queryId without knowing which column index the
id field will be!
Why does this happen and how can I make the column order consistent?
ORMLite is using reflection (or the table configuration file) to determine
the field order. For some reason when it goes through your entities,
reflection is generating the field list in an order you aren't expecting.
"Don't ever rely on the defined order of fields in any database. This is
not just an Android tip, it's just good database practice in general."
This is a very good tip.
where queryForId(Integer.valueOf(resultArray[2]) requires me to have only
the id and know EXACTLY what index the id will be in.
Sure but since you are doing your own custom query, you can specify the
|
IntelliJ IDEA creates wrong maven snapshot depencies |
Build your project using maven
mvn clean install
now all the dependencies downloaded to your local Maven repository.(you can
define it.)
Then all the dependencies are in one location. Go to module(project)
properties in IntelliJ IDEA by right click on that project. set your local
repository as maven repository. Then re import dependencies. Now you solved
that issue. If you have more issues leave a comment here
|
recvmsg linux receive wrong data |
You don't update the iovecs in your send/recv loops, so you will repeatedly
send the same prefix / recv into the beginning of the data buffer if the
data is too large to transfer in a single network packet.
I would use a common function for both send and receive to update the
iovec:
/**
* Shrinks the iovec associated with a msg by a given number of bytes.
*
* @msg The message whose iovec needs updating.
* @bytes Number of bytes to remove from the beginning of the iovec.
*
* @return Returns 0 iff the updated iovec is empty.
*/
int update_buffer(struct msghdr* msg, size_t bytes) {
while (msg->msg_iovlen > 0) {
if (bytes < msg->msg_iov[0].iov_len) {
msg->msg_iov[0].iov_len -= bytes;
msg->msg_iov[0].iov_base += bytes;
return 1;
}
b
|
Python Smtp SSL wrong version on linux |
I bet the problem is on the other side of the wire. Hello, Microsoft!
I've tried logging in a number of times, and you won't believe me, but some
servers will let me in, while others won't.
Try doing smtp.ehlo() in order to find the server's hostname (by the way,
you must issue EHLO at the beginning of your session, and immediately after
STARTTLS).
All their servers have names BLU0-SMTP<somenumber>phx.gbl. Believe me
or not, but servers with two digits in their name are OK, but those with
three digits are not.
In [52]: s = smtplib.SMTP('smtp.live.com', port=587)
In [53]: s.ehlo()
Out[53]:
(250,
'BLU0-SMTP17.phx.gbl Hello [188.134.8.114]
TURN
SIZE 41943040
ETRN
PIPELINING
DSN
ENHANCEDSTATUSCODES
8bitmime
BINARYMIME
CHUNKING
VRFY
TLS
STARTTLS
OK')
In [54]: s.starttls()
Out[54]: (
|
Is that possible map an image with curves? |
In my opinoin your best option is to trace the guidelines using a polygon..
There are a lot of free tools on the internet that will help you do this
visually. I recomment using this one.
|
Best fit from a set of curves to data points |
You need two elements in order to have a fit, the data(which you already
have) and a model space(Linear Models, Gaussian Process, Support Vector
Regression). In your case your model has the additional constrain that some
data points should be weighted differently than others. May be something
like this works from you:
from scipy.interpolate import UnivariateSpline
temp = np.asarray([10, 9.6, 9.3, 9.0, 8.7])
height = np.asarray([129, 145, 167, 190, 213])
f = UnivariateSpline(height, temp)
Now you can evaluate f wherever you want:
test_points = np.arange(120, 213, 5)
plot(height, temp, 'o', regular_heights, f(test_points), 'x')
|
Overlaying many curves in ggplot2 |
Create a list of calls to stat_function using lapply
eg
library(ggplot2)
# the base plot (with x limits)
xlim <- c(-5,5)
baseplot <- ggplot(data.frame(x = xlim), aes(x=x))
# the function
testfn <- function(x,a){sin(x-a)}
# a list of 10 calls (a = 1,...10)
list_fn <- lapply(seq_len(10), function(a){
stat_function(fun = testfn, args = list(a=a))
})
# the plot
baseplot + list_fn
|
Wait on thread that creates an instance that creates a thread |
One solution could be to use Task class instead of explicitly creating the
Thread
//here instead of creating a Thread, create a Task and return it to the
caller
objClientThread = new Thread(start) { IsBackground = true };
objClientThread.Start();
Then you can do
Task task = objClientBase.Connect();
task.Wait();
|
linux checking number of files subdirectory - providing wrong variable result when subdirectory searching for does not exist |
You are getting error messages that you shoud fix. Cd is failing because
you are not allowed to change into a non-existent directory. Your shell
will just stay in the directory it was in. It looks like you know how to
test for directory existence, so you should just do that more to avoid
trying to go into non-existent directories.
|
How to Plot realistic curves using Scipy |
Use scipy.interpolate.interp1d: scipy.interpolate.interp1d
...
from scipy.interpolate import interp1d
import numpy
class Interface(ttk.Frame):
....
def Plot(self):
x_vals =
range(int(self.x_from_1_inp.get()),int(self.x_from_2_inp.get()))
eq = eval(self.equation.get())
self.prepare_table(x_vals,eq)
f = interp1d(x_vals, self.y_values, kind='cubic')
x_new = numpy.linspace(x_vals[0], x_vals[-1],
(x_vals[-1]-x_vals[0])*4)
plt.plot(x_new, f(x_new))
plt.grid(True)
plt.show()
|
Stacked curves in geom_area plot |
Indeed a bit unclear, but I think you want the graphs to be on top of each
other instead of next to each other. To do this just add nrow = 2 to the
facet_wrap
p<-p + facet_wrap( ~ order,scales="free_x", nrow = 2)
If this is not what you mean, please tell is what exactly you want.
|
Convert a B-Spline into Bezier curves |
I wrote a simple Javascript implementation of Boehm's algorithm for cubic
B-Splines a while back. It's a fairly straightforward implementation
involving polar values, described here in section 6.3: Computer Aided
Geometric Design- Sederberg
If you're just interested in the implementation, I've linked the classes I
wrote here: bsplines.js
|
Ways to animate bezier curves with AS3? |
Hmm. Perhaps you should post your used version of TweenMax to properly
debug the issue. There seem to be several of them, some use asynchronusly
dispatched "update" events, some employ an enterframe listener, thus making
sure each update routine is called each frame. So, graphics jittering can
occur in an asynchronus scenario.
On the other questions:
Yes, you have to redraw the graphics object in question, this involves
calling graphics.clear(). See, the Graphics object is a blackbox entity,
you can't directly reach a control point of a curve to tween it somehow.
So, in order to change a point on a curve, you have to redraw it.
A more efficient way would be emulating a tween on your Sprite directly,
via an enterframe listener and a function similar to Strong.easeOut used in
tweening t
|
point of intersection 2 normal curves |
You can use uniroot:
f <- function(x) dnorm(x, m=14, sd=0.9) * .6 - dnorm(x, m=16, sd=0.6) *
.4
uniroot(f, interval=c(12, 16))
$root
[1] 15.19999
$f.root
[1] 2.557858e-06
$iter
[1] 5
$estim.prec
[1] 6.103516e-05
ETA some exposition:
uniroot is a univariate root finder, ie given a function f of one variable
x, it finds the value of x that solves the equation f(x) = 0.
To use it, you supply the function f, along with an interval within which
the solution value is assumed to lie. In this case, f is just the
difference between the two densities; the point where they intersect will
be where f is zero. I got the interval (12, 16) in this example by making a
plot and seeing that they intersected around x=15.
|
Multiple curves with same Time x-axis in R |
The following solution uses ggplot2:
First create some sample data:
df = data.frame(id = rep(letters[1:5], each = 100),
time = rep(Sys.time() + 1:100, 5),
value = runif(500) + rep(1:5, each = 100))
> head(df)
id time value
1 a 2013-06-17 14:02:37 1.368671
2 a 2013-06-17 14:02:38 1.302188
3 a 2013-06-17 14:02:39 1.817873
4 a 2013-06-17 14:02:40 1.283439
5 a 2013-06-17 14:02:41 1.022949
6 a 2013-06-17 14:02:42 1.232590
And create a plot.
library(ggplot2)
ggplot(df, aes(x = time, y = value, color = id)) + geom_line()
|
Color scale for curves in ggplot2 |
This is fairly straightforward. You just need two things:
Specify the variable that colour changes with, in this case y
Add the colour palette.
So:
ggplot(dat, aes(x, y)) +
scale_y_continuous(limits = lim) +
geom_line(aes(colour=y)) +
scale_colour_gradientn(colours = topo.colors(256))
|
How to plot density curves for each column in R? |
ggplot needs your data in a long format, like so:
variable value
1 V1 0.24468840
2 V1 0.00000000
3 V1 8.42938930
4 V2 0.31737190
Once it's melted into a long data frame, you can group all the density
plots by variable. In the snippet below, ggplot uses the w.plot data frame
for plotting (which doesn't need to omit the final refseq variable). You
can modify it to use facets, different colors, fills, etc.
w <- as.data.frame(cbind(
c(0.2446884, 0.0000000, 8.4293893),
c(0.3173719, 0.0000000, 4.9985040),
c(0.74258410, 0.08592243, 2.22526463)))
w$refseq <- c("NM_000014", "NM_000015", "NM_000016")
library(ggplot2)
library(reshape2)
w.plot <- melt(w)
p <- ggplot(aes(x=value, colour=variable), data=w.plot)
p + geom_density()
|
SVG convert polygon to curves conversion in Javascript |
I assume, that while polygonizing, you sampled points on the curve, and
joined them with straight lines.
The reverse process is curve fitting.
You want to do a "Hermite fitting of curve through a set of points". A
little search will help you out.
There are more such fitting algorithms. This is maths based and the under
the hood solution to what you want. This is also how most such problems are
solved.
If you want a quick solution, you would have to find a library that does it
for you. i.e take a set of points, and fits a curve through them.
Note: I assume that fitting a curve through more than 4000 nodes is going
to be costly. You could try it and see the performance for yourself, as I
am not sure how costly would this be. But, I would suggest that if you
needed to maintain the accura
|
plotting diffrent curves in one plot in matlab |
Make some data:
x = 1:0.1:100;
y = 1:5;
for i = y
z(i,:) = sin(i*x);
end
Plot it:
figure
hold on
for i = y
plot3(x,i*ones(size(x)),z(i,:))
end
Modify the plot aspect and view:
daspect([100,2,2])
view(45,60)
Does that do roughly what you need?
|
core graphics create an oval border with curves |
Some clues
Draw two ellipse with same center,one large A and other small B
Get the points at regular intervals on an ellipse
These points will be the starting and ending point and draw small arc
,Mathematically calculate the values and implement it
This is an excellent tutorial to help you drawing arcs and some basic
calculation
|
Qt : Drawing Blended Transparent Lines/Curves/Paths |
I suspect the most visually satisfying solution will be to render the
strokes yourself. For example, the image you posted was rendered by drawing
a large number of partially-transparent circles over one another. This
could be optimized by rendering a large number of ellipses onto a QImage,
then later drawing the pre-rendered image to save time.
|
HTML5 canvas disable antialias on primitive (curves, ...) |
Unfortunately there is no portable way to disable antialiasing when drawing
on a canvas.
The only solution I found is reimplementing graphic primitives writing
directly on the image data.
|
Given two arbitrary interpolated curves, color them based on relative values |
Take a look at the Difference chart in their examples, it is quite similar
to what you want and may satisfy you're criteria. If not I imagine you can
adapt it quite easily to suit you're needs.
|
Plotting x-y plot with errors as Gaussian/normal curves (ideally in R) |
Do you want a contour plot of Age versus Value as a 2d kernel density?
require(MASS)
dens <- with(dat, MASS::kde2d(Age, Value))
str(dens)
#-------------
List of 3
$ x: num [1:25] 1657 1671 1686 1700 1715 ...
$ y: num [1:25] -0.267 -0.249 -0.232 -0.214 -0.197 ...
$ z: num [1:25, 1:25] 0.00152 0.00187 0.00226 0.00267 0.00312 ...
#--------------
# kde2d is designed for contour display: x-vector, y-vector, z-Matrix
contour(dens)
Added the data points so the connection between the contour plot and the
data was more visible:
points(dat$Age, dat$Value, cex=0.3, col="red")
|
haskell, combine bezier curves with points to fill in color |
Actually, as the az1..az10 are just curves, you can't fill them, so you can
delete the fc blue in the function example3, they do nothing. You can also
map scaleY (-1) and lw 0.5, as they are common to every diagrams in the
list, like that:
example3 = mconcat $ map (scale (-1) . lw 0.5)
[ az1 # lc black # translate (r2 (158.0767, -453.67502))
, az2 # lc red # translate (r2 (201.4019, -588.8238000000001))
, az3 # lc blue # translate (r2 (200.10862, -587.8538300000001))
, az4 # lc green # translate (r2 (198.00702, -584.4589500000002))
, az5 # lc red # translate (r2 (197.03705000000002,
-582.1956900000002))
, az6 # lc blue # translate (r2 (196.06708000000003,
-583.1656500000003))
, az7 # lc green # translate (r2 (194.77379000000002, -581.
|
Python: Pyplot in loop --> curves are cumulated per iteration, not separately plotted |
I think the confusion comes from the fact that you dont use the OO
interface. Pyplot is convenient but handles a lot of things in the
background making you unaware of whats really going on. In your example you
create a figure and axes on-the-fly and keep plotting in that same axes.
Clearing the axes before plotting would solve your issue, try adding
pyplot.cla() as the first line of your loop.
I would prefer making a figure and axes object:
all_Lists = [list(np.random.randn(30).cumsum()) for i in range(10)]
fig, ax = plt.subplots()
for n, curv in enumerate(all_Lists):
ax.cla()
ax.plot(curv)
fig.savefig()
|
Linux users', specifically Apache, permissions settings, [Linux noob :] |
usually any daemon will need to access a number of ressources.
it is therefore good practice to run each daemon under a special
user:group, rather than nobody:nogroup.
traditionally (e.g. on Debian systems) apache runs as www-data:www-data.
finally, user permissions take precedence over group permissions (which in
turn take precedence over other permissions).
this means that a directory where the user does not have write perms but
the user's group can write is effectively r/o for that user (but not for
other members of the group)
|
Exec(Linux). How it functions internally? Linux executable attributes(rlimit) |
The RLIMIT_CORE is used to place a limit on the amount of info that
coredump is allowed to produce, before it is aborted. Once this limit is
hit, no more info is logged and the message Aborting Core is logged to the
console.
From the man page of core :
A process can set its soft RLIMIT_CORE resource limit to place an upper
limit on the size of the core dump file that will be produced if it
receives a "core dump" signal.
Use setrlimit() to configure RLIMIT_CORE to a larger value to obtain
complete coredumps.
The most common format of executables/shared-objects is ELF. On Linux, the
dynamic loading and linking of these shared-objects is performed by ld.so
ld.so is loaded in the address space of a newly created process (by exec in
this case) and executed first. This is possible as
|
Purpose of Curly Brace Usage of C Code found in Linux (include/linux/list.h)? |
This is a GNU language extension known as a statement expression; it's not
standard C.
|
Write C++ on Windows but use Linux System calls through a Linux emulator |
You've already tagged your question with Cygwin. That seems like the best
solution for what you want. Cygwin is basically a collection of programs
which emulate a GNU/LInux environment through the use of a
DLL (cygwin1.dll) which acts as a Linux API layer providing
substantial Linux API functionality.
Here's the link to the documentation for its API
Edit: Most of the Cygwin source code that I've looked at is written in C++
and makes system calls using MS Windows API to do provide the *nix
emulation. The source is well written and very readable (even to to a
non-C++ programmer such as myself). I think using Cygwin would be a good
transition from programming on Windows to a GNU/Linux environment.
|
How to turn a Linux application in C/C++ into a Desktop Enviroment for a Linux distro? |
You either want to
create a boot loader, or
you want to replace the 'shell'.
This would be governed by per-user or global xinit and Xsession files.
|
What's a good way to set up Closure Compiler on Linux? Or, where should Java .jar's live on a Linux? |
If you using the java command directly, then you'll have to provide a path
to the jar in question. It's probably easier to place the jar in one place
and create a shell script that handles the invocation and jar path.
|
Do i need to install mono on every Linux PC to run .NET application on Linux platform? |
"can I run a mono application on a machine that doesn't have mono
installed": no; the same as you can't run a java application on a machine
that doesn't have java installed.
And at the same time (to both): yes. There are tools that attempt to make
this work, but they tend to be fiddly and a bit unreliable. However, it
should also be noted that several (not all, by any means) distros ship with
mono by default.
|
fedora linux --- compiling first linux module |
As guido said, you have to match your current kernel and the kernel-devel
package.
To get your kernel version run
uname -r
I get 3.6.10-4.fc18.x86_64, download that kernel-devel version
sudo yum install kernel-devel-3.6.10-4.fc18
Or update your system and boot with the new kernel, I believe those two
will automatically match.
|
Wordpress uploads files in a wrong path (wrong date) |
Are you uploading to a post from 2009?
If so, this may explain (it's a feature not a bug):
"Using WP 2.8.4, when uploading new media files to a page or post that has
already been published, the new file is added in the
/UPLOAD_DIR/year/month/ directory that corresponds to the original
page/post publication date, rather than the file upload date."
From: http://core.trac.wordpress.org/ticket/10752
|
GWT Generates the wrong classes in the wrong files (ClassNotFoundException) |
The problem was that a generator is instantiated once, and the generate
method is called again on the same instance each time, thus any properties
are effectively cached. I was using a cached ClassSourceFileComposerFactory
instance with a method called getComposer() which would check if null, if
it is, instantiate, otherwise return. This was leaving a cached
ClassSourceFileComposerFactory which would always have the same class in
mind.
|
Animation GUI with curves for iPhone animation |
Unity3d is usually a good place to start for people with a Maya background.
It will also allow you to import assets directly from Maya without having
to build your own graphics pipeline.
|
Changing an Entity creates a new one as well |
i think this is entity framework issue,you may use
"Context.context.Projekt.Find(id)" in your "izmjeniProjekt" instead of your
function "getProjektByID",maybe passing and getting types with the
functions is the problem, by the way your naming is awesome !
the problem is obvious, entity framework recognizes your "Projekt" as a new
entry, so the problem is the Key of your database table, you probably used
code first migrations to creating your database and you didn't specify the
key, but by the way, you have the id, in my opinion its not necessary to
get the "Projekt" from data context, just use it!
maybe what i'm trying to say is not clear so watch this video ( you will
see your problem there ) to have a better understanding of entity
framework.
Julie Lerman Speaks
|
Decorator that creates classes |
Not possible. Making 3 classes is easy. Assigning the results to 3
variables, though? That violates Python's scope rules.
@mc_me
class Test:
name = "Test"
is equivalent to
class Test:
name = "Test"
Test = mc_me(Test)
There's no way for the decorator to say that it wants to create some more
variables and assign to those too. Even if you somehow managed to get it to
work (probably only at module or class scope with inspect craziness),
Python would have no way to know that references to TestSuper or TestExtra
should refer to the variables created by the decorator when compiling the
bytecode.
|
wp_insert_post(), creates two pages? |
I got a similar error before, when i am running a custom php script to
insert posts into the Wordpress database, using the wp_insert_post
statement. Weirdly it created 2 records in wp_posts table for every post.
Not sure what is the issue, but i realized that when i ran the php code in
the same browser where i am logged in as administrator, i got this
duplicate posts issue. I resolved it by running my custom php code in a
separate browser.
So make sure that you are running your custom php code with SQL query in a
browser, that has no Wordpress login in it. Hope it helps someone.
|