Hi Guys,
Bit of a general question here, i want to be able to make a line graph using GTK but im unsure how to approach this...
Has anyone got any hints or tips?
Regards
Paul
I'm writing a Bourne Shell script that may or may not receive input from stdin (as in foo.sh < test.txt, non-interactively). How do I check whether there is anything on stdin, to avoid halting on while read -r line...?
I'm trying to integrate facebook into my application so that users can use their FB login to login to my site. I've got everything up and running and there are no issues when I run my site using the command line
python manage.py runserver
But this same code refuses to run when I try and run it through Apache.
I get the following error:
Environment:
Request Method: GET
Request URL: http://helvetica/foodfolio/login
Django Version: 1.1.1
Python Version: 2.6.4
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'foodfolio.app',
'foodfolio.facebookconnect']
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'facebook.djangofb.FacebookMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'facebookconnect.middleware.FacebookConnectMiddleware')
Template error:
In template /home/swat/website-apps/foodfolio/facebookconnect/templates/facebook/js.html, error at line 2
Caught an exception while rendering: No module named app.models
1 : <script type="text/javascript">
2 : FB_RequireFeatures(["XFBML"], function() {FB.Facebook.init("{{ facebook_api_key }}", " {% url facebook_xd_receiver %} ")});
3 :
4 : function facebookConnect(loginForm) {
5 : FB.Connect.requireSession();
6 : FB.Facebook.get_sessionState().waitUntilReady(function(){loginForm.submit();});
7 : }
8 : function pushToFacebookFeed(data){
9 : if(data['success']){
10 : var template_data = data['template_data'];
11 : var template_bundle_id = data['template_bundle_id'];
12 : feedTheFacebook(template_data,template_bundle_id,function(){});
Traceback:
File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response
92. response = callback(request, *callback_args, **callback_kwargs)
File "/home/swat/website-apps/foodfolio/app/controller.py" in __showLogin__
238. context_instance = RequestContext(request))
File "/usr/lib/pymodules/python2.6/django/shortcuts/__init__.py" in render_to_response
20. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/lib/pymodules/python2.6/django/template/loader.py" in render_to_string
108. return t.render(context_instance)
File "/usr/lib/pymodules/python2.6/django/template/__init__.py" in render
178. return self.nodelist.render(context)
File "/usr/lib/pymodules/python2.6/django/template/__init__.py" in render
779. bits.append(self.render_node(node, context))
File "/usr/lib/pymodules/python2.6/django/template/debug.py" in render_node
71. result = node.render(context)
File "/usr/lib/pymodules/python2.6/django/template/__init__.py" in render
946. autoescape=context.autoescape))
File "/usr/lib/pymodules/python2.6/django/template/__init__.py" in render
779. bits.append(self.render_node(node, context))
File "/usr/lib/pymodules/python2.6/django/template/debug.py" in render_node
81. raise wrapped
Exception Type: TemplateSyntaxError at /foodfolio/login
Exception Value: Caught an exception while rendering: No module named app.models
I'm working on a project in Unity3D with Javascript, and I'm trying to implement the SmartFoxServer API (http://smartfoxserver.com) in Javascript instead of their example C# code. I've gotten most of it converted correctly, but I am still getting an error at runtime with the following line involving delegation to a C# file that is in the API (SFSEvent.cs).
C# original:
SFSEvent.onConnection += HandleConnection;
Javascript (or whatever I've turned it into):
SFSEvent.onConnection = Delegate.Combine(HandleConnection);
Error: InvalidCastException: Cannot cast from source type to destination type.
I'm an Objective-C newbie and am enjoying reading/learning Objective-C in order to do iPhone development but I'm struggling to understand some of the code, especially the code that comes with the UIKit framework.
For example, take this line:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSelection:(NSInteger)section {
...
I understand the parameters passed in but am struggling to understand the return parameter. Any help appreciated.
I've inherited code where BeginInvoke is called from the main thread (not a background thread, which is usually the pattern). I am trying to understand what it actually does in this scenario.
Does the method being called in the BeginInvoke get in line of messages that come down to the window? The docs say asynchronously, so that is my assumption.
How does the framework prioritize when to kick off the method called by BeginInvoke?
Question
Given a maximum sliding window size of 40 (i.e., the set of numbers in the list cannot exceed 40), what is the calculation to ensure a smooth averaging transition as the set size grows from 1 to 40?
Problem Description
Creating a trend line for a set of data has skewed initial values. The complete set of values is unknown at runtime: they are provided one at a time. It seems like a reverse-weighted average is required so that the initial values are averaged differently.
In the image below the leftmost data for the trend line are incorrectly averaged.
Current Solution
Created a new type of ArrayList subclass that calculates the appropriate values and ensures its size never goes beyond the bounds of the sliding window:
/**
* A list of Double values that has a maximum capacity enforced by a sliding
* window. Can calculate the average of its values.
*/
public class AveragingList
extends ArrayList<Double> {
private float slidingWindowSize = 0.0f;
/**
* The initial capacity is used for the sliding window size.
* @param slidingWindowSize
*/
public AveragingList( int slidingWindowSize ) {
super( slidingWindowSize );
setSlidingWindowSize( ( float )slidingWindowSize );
}
public boolean add( Double d ) {
boolean result = super.add( d );
// Prevent the list from exceeding the maximum sliding window size.
//
if( size() > getSlidingWindowSize() ) {
remove( 0 );
}
return result;
}
/**
* Calculate the average.
*
* @return The average of the values stored in this list.
*/
public double average() {
double result = 0.0;
int size = size();
for( Double d: this ) {
result += d.doubleValue();
}
return (double)result / (double)size;
}
/**
* Changes the maximum number of numbers stored in this list.
*
* @param slidingWindowSize New maximum number of values to remember.
*/
public void setSlidingWindowSize( float slidingWindowSize ) {
this.slidingWindowSize = slidingWindowSize;
}
/**
* Returns the number used to determine the maximum values this list can
* store before it removes the first entry upon adding another value.
* @return The maximum number of numbers stored in this list.
*/
public float getSlidingWindowSize() {
return slidingWindowSize;
}
}
Resulting Image
Example Input
The data comes into the function one value at a time. For example, data points (Data) and calculated averages (Avg) typically look as follows:
Data: 17.0
Avg : 17.0
Data: 17.0
Avg : 17.0
Data: 5.0
Avg : 13.0
Data: 5.0
Avg : 11.0
Related Sites
The following pages describe moving averages, but typically when all (or sufficient) data is known:
http://www.cs.princeton.edu/introcs/15inout/MovingAverage.java.html
http://stackoverflow.com/questions/2161815/r-zoo-series-sliding-window-calculation
http://taragana.blogspot.com/
http://www.dreamincode.net/forums/index.php?showtopic=92508
http://blogs.sun.com/nickstephen/entry/dtrace_and_moving_rolling_averages
This is my code:
/**********************************************************
* remove non-standard characters to give a valid html id *
**********************************************************/
function htmlid(s) {
return s.gsub(/[^A-Z^a-z^0-9^\-^_^:^\.]/, ".");
}
Why does jslint throw this error?
Lint at line 5 character 25: Unescaped '^'.
return s.gsub(/[^A-Z^a-z^0-9^\-^_^:^\.]/, ".");
I have a Visual Studio 2008 solution that when I build, returns the following error:
Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. Parameter name: ticks
There is no reference file/line/column in the error. Becoming quite frustrating as the solution builds in the end, however I cannot debug.
In the solution, there is no reference/using to DateTime.MinValue.Ticks at all...
I have the below line in the unix shell script. I want to exclude test.jar in WEB-INF/lib being added to the CLASSPATH. How can i do it?
for file in WEB-INF/lib/*jar ;
do
CLASSPATH=$CLASSPATH:$PWD/$file
done
I'm trying to visit a page with cucumber, with:
visit new_video_path
but I get this error:
undefined method `episode_id' for #<Video:0x22df8dc> (ActionView::TemplateError)
On line #19 of app/views/videos/_form.html.erb
...
19: <%= select(:video, :episode_id, @episodes.collect {|e| [ e.title, e.id ] }, { :include_blank => true }) %>
It loads fine in the browser, and the form processes fine too.
What did I do wrong?
Hello, I'm writing a makefile and I can't figure out how to include all my source files without having to write all source file I want to use. Here is the makefile I'm currently using:
GCC= $(GNUARM_HOME)\bin\arm-elf-gcc.exe
SOURCES=ShapeApp.cpp Square.cpp Circle.cpp Shape.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
#$(CC) $(LDFLAGS) $(OBJECTS) -o $@
.cpp.o:
$(GCC) -c $< -o $@
How do I automatically add new source file without having to add it to the sources line?
Thanks,
Mike.
Hi there!
Does anybody know how to deal with the effect at http://2crossmedia.com/liv-multicolor/
If you click into the text field, its surrounded by a color-changing line.
The code says it's jquery. But how :) ?
A lot of thanks!
I have this warning every time I run my CGI-script (output is rendered by Template::Toolkit):
Wide character in print at /usr/local/lib/perl5/site_perl/5.8.9/mach/Template.pm line 163.
What's the right way to eliminate it?
I create the tt object using this config:
my %config = (
ENCODING => 'utf8',
INCLUDE_PATH => $ENV{TEMPLATES_DIR},
EVAL_PERL => 1,
}
my $tt = Template->new(\%config);
Why is my shellcode is truncated after \x20 opcode, when it is copied by string to stack on a second vulnerable program?
--cmd.exe--
char shell[]=
"\xc7\x44\x24\x0c\x65\x78\x65\x20" ← only this line is put in stack, though hv a enough space
"\xc7\x44\x24\x08\x63\x6d\x64\x2e"
"\x31\xc0"
"\x89\x44\x24\x04"
"\x8d\x44\x24\x08"
"\x89\x04\x24"
"\x8d\x05\xad\x23\x86\x7c"
"\xff\xd0";
--end shell--
What is a regex I can write in bash for parsing a line and extracting text that can be found between two | (so that would be ex: 1: |hey| 2: |boy|) and keeping those words in some sort of array?
Hi,
I am (newbie) using Kohana V 3.0.3 and my directory structure is:
pojectsys (kohana's system directory) parallel to htdocs directory
C:\xampp\pojectsys
and my application directory is in htdocs
C:\xampp\htdocs\examples
Inside C:\xampp\htdocs\examples\index.php, following variables have been set:
$application = 'C:\xampp\htdocs\examples\application';
$system = 'C:\xampp\pojectsys';
Now when I am trying to execute http://lc.examples.com/ then Kohana returns error:
ErrorException [ Fatal Error ]: Class 'Controller' not found for line 3
class Controller_Welcome extends Controller {
Please help me to resolve this issue.
Possible Duplicate:
C++ Virtual/Pure Virtual Explained
Hi,
Need to know what is the difference between a pure virtual function and a virtual function?
I know "Pure Virtual Function is a Virtual function with no body" but what does this mean and what is actually done by the line below
virtual void virtualfunctioname() = 0
Whats wrong with my query?
ALTER TABLE test_posts ADD sticky boolean NOT NULL default = false
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=false' at line 2
How can I execute two consecutive commands on the command line with the help of wshshell.exec or wshshell.run in vbscript? For example I need to execute cd C:\a and then winzip32.exe -min -a D:\a.
I'd like to be able to raise another application's Window using Python.
I did see this, which I suppose I could try:
http://stackoverflow.com/questions/1028972/x11-raise-an-existing-window-via-command-line
However, I'd prefer to do it in Python if at all possible.
I need to read binary PGM image files. Its format:
P5
# comments
nrows ncolumns
max-value
binary values start at this line. (totally nrows*ncolumns bytes/unsigned char)
I know how to do it in C or C++ using FILE handler by reading several lines first and read the binary block. But don't know how to do it in .Net.
I have inheritted some code in which the MVC Controller classes all get their constructors called by Castle....DefaultProxyFactory.Create() somewhere along the line (the call stack drops out to the , which isn't helping.)
So, basically, how would I go about finding out where Castle is being told how to call the constructors of my Controllers?
I am very new to Castle, Windsor and MicroKernel, etc, and not a master of ASP's MVC.
Many thanks for any pointers - sorry about the vagueness,
Matt.
I am looking for a library to generate svg diagrams in python (I fetch data from a sql database). I have found python-gd, but it has not much documentation and last update was in 2005 so I wonder if there are any other libraries that are good for this purpose.
I am mostly thinking about simple line graphs, something like this: