Saturday, 31 August 2013

Read from word document line by line

Read from word document line by line


I'm trying to read a word document using C#. I am able to get all text but
I want to be able to read line by line and s*tore in a list and bind to a
gridview*. Currently my code returns a list of one item only with all text
(not line by line as desired). I'm using the Microsoft.Office.Interop.Word
library to read the file. Below is my code till now:
Application word = new Application();
Document doc = new Document();
object fileName = path;
// Define an object to pass to the API for missing parameters
object missing = System.Type.Missing;
doc = word.Documents.Open(ref fileName,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
String read = string.Empty;
List<string> data = new List<string>();
foreach (Range tmpRange in doc.StoryRanges)
{
//read += tmpRange.Text + "<br>";
data.Add(tmpRange.Text);
}
((_Document)doc).Close();
((_Application)word).Quit();
GridView1.DataSource = data;
GridView1.DataBind();
Any help would be highly appreciated. Thanks.

How to fix scrolling issues with liquid layout image 100% width and height?

How to fix scrolling issues with liquid layout image 100% width and height?

I am using a liquid layout on my site. The background is a an image (
slideshow ) and it works how I want. The photo stretches and resizes with
the size of the browser.
However, I just noticed that when I move my browser window as thin or
narrow as it goes, the image is still there but when I scroll to the right
the image cuts off into the background. But full size works fine.
basically I want it to be 100% width and height at all times and never
scroll horizontally or ever exposing the body.
Please let me know what else you need to know to help. Here is the html
and css. thanks
#revolver {
background-color:#ccc;
width:100%;
min-height:100%;
z-index:10001;
}
.revolver-slide {
width:100%;
min-height:100%;
background-position:center center;
-webkit-background-size:cover;
-moz-background-size:cover;
-o-background-size:cover;
background-size:cover;
}
.revolver-slide img {
width:100%;
min-height:100%;
}
.page-section {
width:100%;
height:100%;
margin:0px auto 0px auto;
}
html,body {
height:100%;
}
<div class="page-section clear">
<!-- 100% width -->
<div id="revolver">
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-6.jpg');"></div>
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-2.jpg');"></div>
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-8.jpg');"></div>
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-11.jpg');"></div>
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-7.jpg');"></div>
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-4.jpg');"></div>
<div class="revolver-slide" style="background-image:url('<?php
bloginfo('template_directory');?>/img/slides/slide-9.jpg');"></div>
</div>
</div>

URGENT SOLUTION NEEDED !!! DECIMAL are left forgotten in calculation !!!! PLZ HELP ME

URGENT SOLUTION NEEDED !!! DECIMAL are left forgotten in calculation !!!!
PLZ HELP ME

I'm stuck for some hours now on the following problem:
1)Got a textfield for a number that has to be divided through 100 and
multiplied by a second number after hitting a calculate box 2)I can add A
Decimal number in the textfield... 3)The result comes out as a number with
decimals but does not seem to use all the decimals from the first number
in the calculation.
Example : 2033,33 /100 * 21 becomes : 426,93 (it only looked at 2033 tot
preform the calculation and forgot the remaining 0,33)
Im kinda new to scripting in xcode and have looked everywhere. I guess
there is a simple solution im not seeing anymore after neary 8 hours of
trying??? I need to get this fixed for my brother tomorrow if possible
This is part of my viewcontroller h script:
{
IBOutlet UITextField *numOne; // First number
IBOutlet UITextField *numTwo; // Second number
IBOutlet UITextField *answer; // First number divided by 100 and
multiplied by second number
}
-(IBAction)Calculate:(id)sender; //Calculationbox
And this is the part of my view controller m script :
-(IBAction)Calculate:(id)sender{
float x = ([numOne.text floatValue]/100.00);
float c = x*([numTwo.text floatValue]);
answer.text = [[NSString alloc] initWithFormat:@"%.2f", c];

How do I write Ruby's each_cons in Clojure?

How do I write Ruby's each_cons in Clojure?

How can I rewrite this Ruby code in Clojure?
seq = [1, 2, 3, 4, 5].each_cons(2)
#=> lazy Enumerable of pairs
seq.to_a
=> [[1, 2], [2, 3], [3, 4], [4, 5]]
Clojure:
(??? 2 [1 2 3 4 5])
;=> lazy seq of [1 2] [2 3] [3 4] [4 5]

MySQL Precison Issues in DECIMAL NUMERIC data type

MySQL Precison Issues in DECIMAL NUMERIC data type

In writing a function for scientific application, I ran into issues. I
traced it back to MySQL's lack of precison.
Here is the page from the official documentation which claims that The
maximum number of digits for DECIMAL is 65 -
http://dev.mysql.com/doc/refman/5.6/en/fixed-point-types.html . It also
describes how the value will be rounded if it exceeds the specified
precison.
Here is reproducible code (a mysql stored function) to test it -
DELIMITER $$
DROP FUNCTION IF EXISTS test$$
CREATE FUNCTION test
(xx DECIMAL(30,25)
)
RETURNS DECIMAL(30,25)
DETERMINISTIC
BEGIN
DECLARE result DECIMAL(30,25);
SET result = 0.339946499848118887e-4;
RETURN(result);
END$$
DELIMITER ;
If you save the code above in a file called test.sql, you can run it by
executing the following in mysql prompt -
source test.sql;
select test(0);
It produces the output -
+-----------------------------+
| test(0) |
+-----------------------------+
| 0.0000339946499848118900000 |
+-----------------------------+
1 row in set (0.00 sec)
As you can see, the number is getting rounded at the 20th digit, and then
five zeroes are being added to it to get to the required/specified
precison. That is cheating.
Am I mistaken, or is the documentation wrong?

Timer not starting in vb.net

Timer not starting in vb.net

net program that uses excel as a datasource. I then fill a datagridview
with this datasource and make changes to the dataset via the datagridview.
I'm trying to find a way to refresh this dataset via a button that will
update the values after a change. My only problem is that I'm trying to
set up a timer in my refresh method but it never initializes/starts. I
can't figure out why, from what I've found online the way to start a timer
in vb.net is to set the timer variable to enabled = true. I've stepped
into my debugger and found that the timer never starts. Here is my code
below, if there is anyone who can figure out why this timer isn't starting
I would greatly appreciate your help!
Dim mytimer As New System.Timers.Timer
Sub refresh()
write2Size()
mytimer.timer = New System.Timers.Timer(20000)
'Starting Timer
mytimer.Enabled = True
Cursor.Current = Cursors.WaitCursor
AddHandler mytimer.Elapsed, AddressOf OnTimedEvent
'Setting the cursor back to normal here
Cursor.Current = Cursors.Default
mytimer.Enabled = False
objworkbook.Save()
objExcel.ActiveWorkbook.Save()
myDS.Clear()
retrieveUpdate()
End Sub
Private Shared Sub OnTimedEvent(source As Object, e As ElapsedEventArgs)
Console.WriteLine(&quot;The Elapsed event was raised at {0}, e.SignalTime)
End Sub

.htaccess 403 redirects not working

.htaccess 403 redirects not working

I have this code in my .htaccess file:
Options All -Indexes
order deny,allow
deny from all
ErrorDocument 403 /www/landing.html
<Files landing.html>
allow from all
</Files>
<Files styles.css>
allow from all
</Files>
<Files prefixfree.min.js>
allow from all
</Files>
which is located on my server at /www. There is an index.html,
loading.html, and a .htaccess in this folder, then the css and js files
are in their respective subfolders. The site is hosted on Hostgator.
When I load up my site, I get this error:
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an
ErrorDocument to handle the request.
So it's not finding the document. If I change my code to ErrorDocument 403
/loading.html then my site goes down entirely and the loading icon just
spins without loading anything. downforeveryoneorjustme.com also reports
that it is down. Is there something I'm doing wrong?

Friday, 30 August 2013

Surafce Has been Released Error

Surafce Has been Released Error

Am creating one media player for online videos, but when am trying to run
it is showing an error that surface has released. Here is my coding:
public class VideoSample1 extends Activity implements Callback,
OnPreparedListener, OnCompletionListener,
OnClickListener, OnSeekCompleteListener,
android.view.SurfaceHolder.Callback
{
public String video_path = "My video URL";
private SurfaceView surfaceViewFrame;
private MediaPlayer player;
private SurfaceHolder holder;
private Bundle extras;
private static final String TAG = "log_tag";
private boolean b =false;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.customvideoview);
extras = getIntent().getExtras();
surfaceViewFrame = (SurfaceView)
findViewById(R.id.surfaceViewFrame);
surfaceViewFrame.setOnClickListener(this);
surfaceViewFrame.setClickable(false);
holder = surfaceViewFrame.getHolder();
holder.addCallback(this);
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
player = new MediaPlayer();
player.setOnPreparedListener(this);
player.setOnCompletionListener(this);
player.setOnSeekCompleteListener(this);
player.setScreenOnWhilePlaying(true);
player.setDisplay(holder);
}
@Override
protected void onDestroy()
{
super.onDestroy();
player.stop();
player.release();
player = null;
Toast.makeText(VideoSample1.this,
"back",Toast.LENGTH_SHORT).show();
finish();
}
private void playVideo()
{
new Thread(new Runnable()
{
public void run()
{
try
{
player.setDataSource(VideoSample1.this,
Uri.parse(extras.getString("Video URL")));
player.prepareAsync();
}
catch (IllegalArgumentException e)
{
Log.d("admin","Error while playing video");
e.printStackTrace();
Log.i(TAG,"tag"+ e.getMessage());
}
catch (IllegalStateException e)
{
Log.d("admin","Error1 while playing video");
e.printStackTrace();
Log.i(TAG, "tag"+e.getMessage());
}
catch (IOException e)
{
e.printStackTrace();
Log.d("admin","Error while playing video.Please,
check your network connection");
Log.i(TAG, "tag"+e.getLocalizedMessage());
}
}
}).start();
}
public void surfaceChanged(SurfaceHolder holder, int format, int
width, int height)
{
}
public void surfaceCreated(SurfaceHolder holder)
{
playVideo();
}
public void surfaceDestroyed(SurfaceHolder holder)
{
}
public void onPrepared(MediaPlayer mp)
{
if (!player.isPlaying())
{
b = true;
player.start();
}
}
public void onCompletion(MediaPlayer mp)
{
mp.stop();
finish();
}
public void onSeekComplete(MediaPlayer mp)
{
}
@Override
public void invalidateDrawable(Drawable who)
{
}
@Override
public void scheduleDrawable(Drawable who, Runnable what, long when)
{
// TODO Auto-generated method stub
}
@Override
public void unscheduleDrawable(Drawable who, Runnable what)
{
// TODO Auto-generated method stub
}
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
}
}
I referred this , and other stack overflow sites but nothing worked with
me :-(. Error is near setdisplay(holder). And here is my Logcat messages:
08-31 10:18:01.512: E/AndroidRuntime(1162): FATAL EXCEPTION: main
08-31 10:18:01.512: E/AndroidRuntime(1162): java.lang.RuntimeException:
Unable to start activity
ComponentInfo{com.msense.msenseplayer/com.msense.msenseplayer.VideoSample1}:
java.lang.IllegalArgumentException: The surface has been released
08-31 10:18:01.512: E/AndroidRuntime(1162): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
android.app.ActivityThread.access$600(ActivityThread.java:123)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
android.os.Handler.dispatchMessage(Handler.java:99)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
android.os.Looper.loop(Looper.java:137)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
android.app.ActivityThread.main(ActivityThread.java:4429)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
java.lang.reflect.Method.invokeNative(Native Method)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
java.lang.reflect.Method.invoke(Method.java:511)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
dalvik.system.NativeStart.main(Native Method)
08-31 10:18:01.512: E/AndroidRuntime(1162): Caused by:
java.lang.IllegalArgumentException: The surface has been released
08-31 10:18:01.512: E/AndroidRuntime(1162): at
android.media.MediaPlayer._setVideoSurface(Native Method)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
android.media.MediaPlayer.setDisplay(MediaPlayer.java:641)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
com.msense.msenseplayer.VideoSample1.onCreate(VideoSample1.java:53)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
android.app.Activity.performCreate(Activity.java:4578)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-31 10:18:01.512: E/AndroidRuntime(1162): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
08-31 10:18:01.512: E/AndroidRuntime(1162): ... 11 more

Thursday, 29 August 2013

Next Line for text area in php

Next Line for text area in php

I am storing a some text from a text area into php.
When I press Enter in text area,The text do come into next line(looks good
for formatting), but when submitted to database and retrieved, it appears
that all text comes in a single line.
Example:Entered Text is
This is first line. This is second line.
And Retrieved output is:
This is first line.This is second line.
In stack overflow,double space is treated as \n. it can be done by
replacing double space by \n using preg_replace or through javascript, but
can it be done direclty if user press enter ?
So how to enable next line character(\n) for the text area so that it
displays the format in which it was entered.Similarly I want to enable ,
and tag as well to enhance formatting in entered data.

NFC API for Android NDK

NFC API for Android NDK

I'm working on a multi-platform project that need support for NFC. The
project is written in C++ so it would be nice to have access to C++
Android NFC API.
Is there a way to interact with the NFC using the NDK ?
I know that from NDK is possible to call SDK Java methods. In this case i
could create a Java class to handle the NFC interaction and then call
those methods from C++.
Do you think is possible to develop such mechanism ?

Wednesday, 28 August 2013

How to edit a database in Python?

How to edit a database in Python?

I am an absolute beginner in Python (3.3.2). I know the basic functions
like writing text files, variables, loops ,etc but have never written
complex code.
My research project requires applying a moving average filter on three
columns of a large text file (150 MB in size, having more than 1 million
rows). My question is: What should I study in order to develop a
methodology to apply the moving average formula within Python?. Excel is
not an option because doing so is very tedious in Excel and sometimes it
crashes due to longer periods of loading.
Kindly direct me to the 'right' resources/ examples relevant to my
problem. I have gone through several python tutorials but didn't find
anything relevant.

Popup Window After AddThis Window Closes

Popup Window After AddThis Window Closes

I would like to check to see if the AddThis popup window is closed, then
create a popup window after it is closed. I am not sure if it is not
working because of incorrect code or because of cross-domain policy. I
also looked into endpoint documentation for AddThis
(http://support.addthis.com/customer/portal/articles/381265-addthis-sharing-endpoints#.Uh4SreL3PBj),
which as far as I understand is for extending the ability of AddThis.
Thanks for any help.
var PopUpCloses = function(){
alert("This is a popup");
};
var win = location.href("http://api.addthis.com/oexchange/0.8/");
var pollTimer = window.setInterval(function() {
if (win.closed !== false) { // !== is required for compatibility with Opera
window.clearInterval(pollTimer);
PopUpCloses();
}
}, 200);

Struts make a link with wildcard parameter

Struts make a link with wildcard parameter

So say I have the following action mapping:
<action path="/admin/nst-*/manage/"
type="com.company.backend.actions.admin.nstManageAction"
name="nstMgmtForm" attribute="form"
validate="false" scope="request"
parameter="{1}"
input="/WEB-INF/company/pages/nstMgmt.jsp">
<forward name="view" path="/WEB-INF/company/pages/nstMgmt.jsp"/>
</action>
As you can see, it has a wildcard for institution which is passed in with
the parameter attribute.
Say on another JSP page I wanted to link to this action with a struts html
tag. How would I automagically insert the institution id into the the link
with the struts link tag? For instance /admin/nst-22/manage/ or
/admin/nst-99/manage. Is it possible to do this with the the link tag?

PHP and SQL maths

PHP and SQL maths

This part of PHP and SQL is totally new to me where I need to use maths to
update a table.
I currently have a table avis_credits with one row only in this table
The table deducts credits as the user uses the system from qty_credits,
but i want to be able to add additional credits to his account as per
example:
Client has currently 10 credits left he purchases 100 credits so the
system must take the current credits and add the 100 to it giving me the
110 credits. I am doing this currently manual adding it my side and
updating the table with this expresion.
"UPDATE avis_credits SET credits='$qty_credit'";
What I would like is that the system looks up the current credits and adds
the new credits to the row.
I have tried this
"UPDATE avis_credits SET credits='<?php echo qty_credit?> + $qty_credit'";
But it is not working at all. Is it because I am trying to do too many
functions in the one string? Or is it because The maths equation is wrong
as I have no idea how to write it?

Tuesday, 27 August 2013

How to change port number of Jboss 7 dynamically

How to change port number of Jboss 7 dynamically

I have grouped my Jboss 7 server, Postgres database and test.bat into a
demo.exe file using Advanced Installer. When file i.e demo.exe file double
clicked on the client side then test.bat file runs and it deploys JBoss
and postgres at the predefined location and the service starts and my
application runs at the port number 8080 .All the script has been writeen
to test.bat file .This demo.exe file has to used by different users . It
may be possible that 8080 might be used or engaged by different
application on client side.
So how can i change port number of jboss dynamically on the client side as
per port usage? Do i have to use any Jboss installer or write scipt on
batch file i.e test.bat ? Not able to click things or right approach :(
Any help will be highly appreciated and will be thankful .

How to Identify Actor Where Interface is doing the usecae

How to Identify Actor Where Interface is doing the usecae

i am modeling a system of ware house management system(Assignment).In this
system Most of the things are done by automated crane. ok, being specific
crane will read the barcode on it, its aso called licence plate. so, read
licence plate is a USE CASE but who is the ACTOR here? Can Crane be the
ACTOR or who else. Help is really Appreciated...

Is there a way to check iphone signals and display it on map kit?

Is there a way to check iphone signals and display it on map kit?

Would something like this require a database or a backend to make this
happen?

How to know if a user follows me on Twitter?

How to know if a user follows me on Twitter?

Obviously before writing this I have been reading everything I could, but
I have not found anything that works.
I need to know if a user (X) follows a user (Y) on twitter. Is it possible?
Eg.
@CarlosBeneyto follow @Demo I return a "true". Or something similar.
In PHP and as simple as possible, I've proven with the API but no way. Any
updated documentation or similar?
Thank you very much.

How to setup SSL in MSSQL Server 2012 with own certificate?

How to setup SSL in MSSQL Server 2012 with own certificate?

Environment:
Windows 7 Professional x64 in a domain, running MS SQL Server 2012. I have
lokal Admin rights, so messing up the system is easy. My SQL Server
'names' are 'SQLEXPRESS' and 'MSSQLSERVER'. FQDN should be for example
'my-pc.mydomain.local'.
Problem:
I dont know the right way to setup SSL on this MS SQL Server. I actually
only want to setup SSL with a certificate created of my own. Can anybody
help me out here? Most of the documentation online only describes the way
of going through a CA and have different knowleadge as a prerequirement.

adding json object name in asp.net web api

adding json object name in asp.net web api

created an web api that outputs json, trying to use it with backbone.js
pagination plugin to ouput the results to the backbone.js infinite-paging
plugin
this is my outputed json
[{"id":1,"title":"test1""desc":"book1"},
{"id":2,"title":"test2","desc":"book2"},
{"id":3,"title":"test3", "desc":"book3"},
{"id":4,"title":"test4","desc":"book4"},
{"id":5,"title":"test5","desc":"book5"},
{"id":6,"title":"test6","desc":"book6"}]
but i need to have the name of object included as the backbone.js
paginator requires to return the response object. think im almost there
but cant seem to get it to show or work out how i add the object name to
it ?
{"object name:"[{"id":1,"title":"test1","desc":"book1"},
{"id":2,"title":"test2","desc":"book2"},
{"id":3,"title":"test3","desc":"book3"},
{"id":4,"title":"test4","desc":"book4"},
{"id":5,"title":"test5","desc":"book5"},
{"id":6,"title":"test6","desc":"book6"}]}
public class latestnewsController : EntitySetController<news, int>
{
onlinepressEntities _context = new onlinepressEntities();
latestnewsController()
{
_context.Configuration.LazyLoadingEnabled = false;
}
[Queryable]
public override IQueryable<news> Get()
{
return _context.news;
}
protected override news GetEntityByKey(int key)
{
return _context.news.FirstOrDefault(c => c.ID == key);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_context.Dispose();
}
}

Monday, 26 August 2013

Video texture on a curve surface

Video texture on a curve surface

I want to implement a curve surface in WebGL, and map a video texture to
the surface, is it possible?
Sth like this: https://dl.dropboxusercontent.com/u/73906326/img.png
Thank you!

IOS Parse implementation Error

IOS Parse implementation Error

I am trying to implement Parse and when I add it to the framework through
the build phrase into my linked libraries, I get errors. I get
Undefined symbols for architecture i386: "_OBJC_CLASS_$_Parse", referenced
from: objc-class-ref in AppDelegate.o ld: symbol(s) not found for
architecture i386 clang: error: linker command failed with exit code 1
(use -v to see invocation)
When I try to implement
[Parse setApplicationId:@"XXXXXXXXX" clientKey:@"XXXXXXXX"];
In my app delegate.
I am using JTRevealSideBarDemoV2 and I am not 100% familiar with how
targets work. There are multiple targets available however I usually set
the target to the the one that I am using.
http://i44.tinypic.com/2v9q1rq.png
I have done a lot of research on this issue and I think it has something
to do with my targets so if you could explain what you think may be wrong,
it would be awesome!
Thanks.

javascript setattribute to multiple element

javascript setattribute to multiple element

I have many div with the class publish_0 that I would like to change to
publish_1 on click of a button.
Right now I use this but it only change one item. How to I apply the
setattribute to all item that have the publish_0.
document.querySelector('.publish_0').setAttribute("class", "publish_1");

how do I split database models based on a single spreadsheet table (beginner)?

how do I split database models based on a single spreadsheet table
(beginner)?

My question is conceptual, I suppose, rather than practical (though I
don't mind if the practical makes an appearance).
I'm a graphic designer that is now building a web application at my
workplace (a business firm) with Rails + postgresql, in which the premise
is to display a list of services stored in a database. I've been requested
to design a spreadsheet table for use by data-entry folk to do the grunt
work of copying hard-copy into data, that I can then, in turn, transfer to
the database.
The data is to be displayed, sorted, and filtered with JQuery - so the
point of the table structure is to lend itself well to that process. My
question is, is it better to split an incoming table of data (from
spreadsheets or .csv's) into two in order to separate the data displayed
explicitly (i.e., name, description, link, image) from the data that will
be used for sorting and filtering (i.e., tags like "location" and
"category of service") or best to keep the database table single and the
same as the incoming spreadsheet?
Or have I gone wrong already in the way I've begun to think about it?

Rails 4: How to use includes() with where() to retrieve associated objects

Rails 4: How to use includes() with where() to retrieve associated objects

I can't figure out how to user the .where() method to retrieve associated
model data. In this example, Projects belongs_to Users...
class Project < ActiveRecord::Base
belongs_to :user
has_many :videos
end
class User < ActiveRecord::Base
has_many :projects
end
class ProjectsController < ApplicationController
def invite
@project = Project.includes([:user]).where( {:hashed_id=>params[:id]}
).first
end
In App/views/projects/invite.html.erg <%= debug( @project ) %> returns:
--- !ruby/object:Project
attributes:
id: 22
name: Some Project Name
belongs_to: 1
instructions: Bla bla bla
active: true
max_duration: 2
max_videos:
created_at: 2013-08-26 15:56:50.000000000 Z
updated_at: 2013-08-26 15:56:50.000000000 Z
hashed_id: '1377532589'
Shouldn't the associated User hash/array be included in this? I know I
could manually add it by calling a second find/where ( @project.user =
User.where( {:id=>@project.belongs_to} ) but this doesn't feel like "The
Rails Way". What is?
Solution My initial question was formulated under the incorrect assumption
that debug() would return associated objects (this works in cakePHP
because it bundles everything into arrays).
So my original code should work. However, I had incorrectly named the
foreign key filed in the table. I got confused by looking at the migration
method t.belongs_to (which automatically creates the correctly named
foreign_key field, not a field named "belongs_to"). So I also had to
rename that column to user_id and now it works just as described in
@Veraticus's answer below.

Javafx slider: text as tick label

Javafx slider: text as tick label

I just started to learn Javafx, and I really like it so far. However in my
current project I would need to use text as the tick labels for the javafx
slider. I googled it a lot, but couldn't find any help. So for example I
would like a slider with 4-5 positions, and them being "bad", "good", etc.
instead of 1,2,3,...
I know I could build a custom UI manually with labels placed at the
correct places, but I need to generate the sliders with custom text, and
diofferent length every time, so it wouldn't work. In swing it is possible
to change the labels with a hashtable for example, so my question is, is
it possible to do it in Javafx?

Reformatting source code with Text I/O

Reformatting source code with Text I/O

I am teaching myself programming with Java through a textbook. An exercise
asks you to write a program that reformats an entire source code file
(using the command line):
from this format (next-line brace style):
public class Test
{
public static void main(String[] args)
{
// Some statements
}
}
to this format (end-of-line brace style):
public class Test {
public static void main(String[] args) {
// Some statements
}
}
Here's the code I have so far:
import java.io.*;
import java.util.*;
public class FOURTEENpoint12 {
public static void main(String[] args) throws IOException {
if (args.length != 2) {
System.out.println
("Usage: java FOURTEENpoint12 sourceFile targetFile");
System.exit(1);
}
File sourceFile = new File(args[0]);
File targetFile = new File(args[1]);
if (!sourceFile.exists()) {
System.out.println("File does not exist");
System.exit(2);
}
Scanner input = new Scanner(sourceFile);
PrintWriter output = new PrintWriter(targetFile);
String token;
while (input.hasNext()) {
token = input.next();
if (token.equals("{"))
output.println("\n{\n");
else
output.print(token + " ");
}
input.close();
output.close();
}
}
I have two problems:
I have tried many different while blocks, but can't get anything close to
what the book is asking. I've tried different combinations of regular
expressions, delimeters, token arrays, but still way off.
The book asks you to reformat a single file, but the chapter never
explained how to do that. It only explains how to rewrite the text into a
new file. So I just wrote the program to create a new file. But I would
really like to do it the way the problem asks.
If someone could help me with these two problems, it would actually solve
many of the problems I'm having with alot of the exercises. Thanks in
advance.

Not able to print GC details

Not able to print GC details

I am trying to print the GC details for a test program in eclipse.I want
to set it only for my program so I went to Run>Run Configurations and in
VM arguments gave this:
-Xms1024M -Xmx1024M –XX:+PrintGCDetails –XX:+PrintGCTimeStamps
However when I do this and run my program I get the following error:
java.lang.NoClassDefFoundError: –XX:+PrintGCDetails
Caused by: java.lang.ClassNotFoundException: –XX:+PrintGCDetails
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
What am I doing wrong in passing the arguments.

the process cannot access the file as its being used by another process

the process cannot access the file as its being used by another process

have been struggling with this error for ages. Below is the code is question
for ( Int32 Counter = 0; Counter < x.Rows.Count; Counter++)
{
using (FileStream bitmapFile = new
FileStream(@"c:/someOlddir/file1.txt", FileMode.Open,
FileAccess.Read, FileShare.ReadWrite))
{
using (Bitmap uploadedbitmap = new Bitmap(bitmapFile))
{
using (System.Drawing.Image uploadedbitmapResized =
ExtensionHelpers.Resize(uploadedbitmap, 800, 600,
RotateFlipType.RotateNoneFlipNone))
{
uploadedbitmapResized.Save(@"c:/someNewdir/file1.txt",System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
}
/*errror occurss on this line */
File.SetCreationTime(@"c:/someNewdir/file1.txt",someDateTimeVariable);
}
The problem I am having with this code is that It works just fine for the
first 30 or 40 images in the collection but when i get to 50 or 60 I get
an error saying that the file I am trying to set the date-time to is being
used by another process. but this error only occurs when I am iterating
through a large collection and at the 40 or 50th position in the iteration
how can this be that the first 30 images work just fine and then all of a
sudden a file is now lock by a process. I have everything in using
statements but this error still persists.
Do I Have to some how wait until the file is saved before accessing it but
this shouldn't be the case since i am saving the file first and then
trying access it. what is wrong with code?

Sunday, 25 August 2013

Eventing framework mbassador (bennidi) android compatibility

Eventing framework mbassador (bennidi) android compatibility

Is the Java Eventing framework mbassador (by bennidi) is compatible with
android 4.0 (Ice Cream sandwich) or Guava EventBus is better option. My
requirement is that I am looking for an eventing framework which is
compatible in Android and Java Fx( Windows and Linux platform) so that it
runs seamless in both the platform.

MySQL performance for 10M record

MySQL performance for 10M record

I developing ecommerce website, that support following this requirement:
max 10 million records.
300,000 page view per day.
Support listing, search by category, product detail and shopping card.
The question is:
If I use Mysql 5.6 with InnoDB (1G memcache + 2 replicate database
server), is this spec support for above requirement.
If not, which is the proper database design solution that support the
requirement above.

Symfony2 Variable "name" does not exist

Symfony2 Variable "name" does not exist

I'm new to Symfony, so this is most certain a simple mistake from my side.
I get the following error: Variable "worker" does not exist.
The template looks like this:
{% extends "NTSBSServiceBundle::layout.html.twig" %}
{% block body %}
<h1>Rapportera</h1>
{% for worker in workers if workers %}
{{ worker.name }}
{% else %}
<em>Det finns inga öppna protokoll för närvarande...</em>
{% endfor %}
{% endblock %}
And the controller method look like this:
/**
* List all open protocols, grouped by worker.
*
* @Route("/", name="report")
* @Method("GET")
* @Template()
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$workers = $em->getRepository('NTSBSServiceBundle:Worker')->findAll();
return array(
'workers' => $workers,
);
}
I have checked, and $workers does contain entities from the database. The
twig gets rendered. If I remove the for-loop, naturally the error message
disappears.
Hoping that someone can explain to me what I'm doing wrong.

conversion constructor or copy constructor

conversion constructor or copy constructor

I am trying to understand conversion constructors. I am using the
following piece of code
class cls
{
public:
cls()
{
std::cout << "Regular constructor \n"; ---> Line A
}
cls (int a) //Constructing converter
{
std::cout << "Int constructor \n"; ---> Line B
}
cls (der& d) //Copy constructor
{
std::cout << "Copy constructor \n"; ---> Line C
}
};
int main()
{
cls d;
std::cout << "-----------------------\n";
cls e = 15; //int constructor then copy constructor
return;
}
Now I am confused at the statement cls e = 15 my understanding was that
this statement was suppose to call Line B(Conversion Cont) and then Line C
(Copy constructor) however it only called Line B. I though cls e = 15 was
equivalent to cls e = cls(15). So I tried cls e = cls(15) which also only
gives the Line B. I would appreciate it if someone could explain what
happens when we use the following
cls e = cls(15) //I was expecting a conversion constructor followed by
copy constructor but apparently i was wrong. Any explanation on what is
happening would be appreciated

When is passing a pointer to another thrad in C++11 race condition?

When is passing a pointer to another thrad in C++11 race condition?

title isnt really descriptive so my question is the following. Is the
following code RC free?
auto x = make_shared<Fun>(1984);
auto t = thread(func, x);
Also Herb Sutter in his talk on Cpp and Beyond used concurrent q.
So if I have
auto x = new Fun(1984);
q.push(x);
//other thread
auto ptr = q.pop();
Is this race condition? Aka is it possible for other thread to pop ptr and
still see stale values of mem location where ptr points to? Since
concurrent q is not in the standard lets presume Im using PPL/TBB one.

Calculating PDF Table Height when cell text overruns. iTextSharp

Calculating PDF Table Height when cell text overruns. iTextSharp

I am writing a PDF invoice, various tables are being created and
specifically positioned depending on the total content of the invoice.
I have a part exchange window and a "Connect" window, which I am having
issues avoid a collision.
The "connect" box is generated first as this is part of a separate
template script. This template script returns a series of co-ordinates of
template content so I can position other content around them.
To calculate the top Y position of the Part Exchange window I am returning
the top Y position of the Connect box, then calculating the height of the
intended part exchange window and simply adding them.
This works if none of the text in any individual cell overruns and wraps,
thus making the cell larger. It would appear that the height calculation
which I am using doesn't cater for this.
I am using code inspired by the answer given here:
Itextsharp: Adjust 2 elements on exactly one page
to calculate the table height, and have also tried a variation which loops
the table rows and calculates individual row height, both have the same
outcome.

I could try this route:
How To Adjust Font Size To Fill A Fixed Height Table Cell In iTextSharp
And resize text, so wrapping does not occur, but it could create
unreadable lines.
Can anyone help me to identify a means of calculating table heights
Including catering for wrapping text?

Saturday, 24 August 2013

Error message in the terminal

Error message in the terminal

I used to get the error message :
bash: /home/amith/.bashrc: line 103: unexpected EOF while looking for
matching `'' bash: /home/amith/.bashrc: line 109: syntax error: unexpected
end of file each time i open the teminal.Recently one of my friend had
tried to edit the bash file.Anyone,please help me to point out the correct
problem and thereby rectify the error.

Stripping parts of a directory path using php

Stripping parts of a directory path using php

I am looking to strip away a part of the following url yet have no
experience with regex or if that's even what I would use.
I have this url:
/var/www/wordpress/wp-content/themes/Aisis-Framework/CoreTheme/AdminPanel/Template/Form/Update.php
I would like to strip away everything to form:
CoreTheme/AdminPanel/Template/Form/Update.php
Is there an easy way to do this, and one that is done such that the amount
of content before "CoreTheme" could be x characters long, where x is any
number.
It should also not match on the word CoreTheme as it might be any name, it
should also not match on Aisis-Framework as that could also be any name...
how ever it is safe to assume that anything after CoreTheme is static. The
above string will be turned into, using string replace:
CoreTheme_AdminPanel_Template_Form_Update.php
As I have done in this piece of code:
$class_name = str_replace('/', '_', $path . $name);
where path is, in my solution,
CoreTheme/AdminPanel/Template/Form/Update.php and $name is Update

Jquery variable within quotes returning Syntax Error

Jquery variable within quotes returning Syntax Error

I am really confused with the simplest thing. Can anyone please help me on
this one?
I've got the following code:
$('#nav a').click(function(){
var $href = $(this).attr('href');
if(!$($href).hasClass('top')){
console.log("'#" + $href + "'");
}
});
And it logs this every time I "click" on an link within "#nav":
Uncaught Error: Syntax error, unrecognized expression
Any clues?
Thanks ;)

Error trying to get data from MYSQL to XML

Error trying to get data from MYSQL to XML

I am having a issue with getting some MYSQL data to a XML output. I have
done some research and i am not trying to invoke the header before a echo.
The below code is from my example_xml.php file Below is the exact error as
well. Any help is much appreciated.
Warning: Cannot modify header information - headers already sent by
(output started at
/home/content/59/11513559/html/bg/example_xml.php:2) in
/home/content/59/11513559/html/bg/example_xml.php on line 65
line 65 is
header ("Content-Type:text/xml");
<?php
//database configuration
$config['mysql_host'] = "localhost";
$config['mysql_user'] = "placeholder";
$config['mysql_pass'] = "placeholder";
$config['db_name'] = "placeholder";
$config['table_name'] = "placeholder";
//connect to host
mysql_connect($config['mysql_host'],$config['mysql_user'],$config['mysql_pass']);
//select database
@mysql_select_db($config['db_name']) or die( "Unable to select database");
// start creating xml document
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
$root_element = $config['table_name']."s"; //fruits
$xml .= "<$root_element>";
//select all items in table
$sql = "SELECT * FROM ".$config['table_name'];
$result = mysql_query($sql);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
if(mysql_num_rows($result)>0)
{
while($result_array = mysql_fetch_assoc($result))
{
$xml .= "<".$config['table_name'].">";
//loop through each key,value pair in row
foreach($result_array as $key => $value)
{
//$key holds the table column name
$xml .= "<$key>";
//embed the SQL data in a CDATA element to avoid XML entity issues
$xml .= "<![CDATA[$value]]>";
//and close the element
$xml .= "</$key>";
}
$xml.="</".$config['table_name'].">";
}
}
//close the root element
$xml .= "</$root_element>";
//send the xml header to the browser
header ("Content-Type:text/xml");
//output the XML data
echo $xml;
?>

Simple JavaScript Login, Redirects to the user's page (Multiple Users)

Simple JavaScript Login, Redirects to the user's page (Multiple Users)

my school is doing a 5 day html challenge next week and i'm practicing my
idea,
To get to the point,
I want to make a login system using an external javascript script that
supports multiple users and when the two login forms are valid from the
certain part of the code it will redirect to the users page: I have the
two inputs set up:
<center> <h1> Join now! </h1> </center>
</header>
<p> Username </p> <input> </input><p> Password </p> <input> </input>
<button> Submit </button>
Feel free to make any adjustments needed to this code and I'd prefer not
to use database's for this project
Thanks for the help guys :)
Oh P.S, I only need a three user system
And you may user jquery aswell if necessary
Thanks Again

How to generate a random operator, put it in string, and evaluate the string

How to generate a random operator, put it in string, and evaluate the string

I'm trying to build an equation that takes random operators.
3 x 5 x 8 x 2
where x represents either a +, -, / * operator.
2nd question: if the equation is a string, can golang evaluate the answer?
(this question is for this problem
http://www.reddit.com/r/dailyprogrammer/comments/1k7s7p/081313_challenge_135_easy_arithmetic_equations/
)

Magento - How to get pricing_value for Super Attribute Option

Magento - How to get pricing_value for Super Attribute Option

Somehow I can't figure out how to get the pricing values for a
configurable product's super attribute options.
Currently I have an array of attribute id and attribute option id which
looks like this:
2013-08-24T15:35:01+00:00 DEBUG (7): Array Combination :Array
(
[135] => 3
[139] => 19
[138] => 6
[140] => 20
[141] => 22
[142] => 24
[143] => 26
[144] => 28
[145] => 34
)
Now I want to calculate the total price for the configurable product with
all the super attributes additional prices added.
I spend hours looking through the configurable product templates and
javascript and still haven't figured out how the new price is calculated.
Through this link
http://www.ayasoftware.com/content/magento-update-fly-super-product-attributes-configuration
I figured out how to get the configurable options for my product. The data
also contains a field "price_value" for each attribute option, but I
totally don't know how to simply access the right object values.
I would love to just do something like:
$price = $configurableProductBasePrice;
foreach ($attributeCombination as $attribute => attributeOption)
{
$attributeOptionPrice =
$attribute->getAttributeOption($attributeOption)->getPrice();
$price = $price + $attributeOptionPrice;
}
Thanks in advance for every hint :)

#@@#@!#@#Everton vs West Brom Live Stream Online@!@!#@!#@#@#

#@@#@!#@#Everton vs West Brom Live Stream Online@!@!#@!#@#@#

Watch Live Streaming Link
Welcome to watch Everton Live Stream, you'll find everything Everton FC
live matches with our streaming links we get from internet for the season
2013/2014. We'll try to discover all links the toffees games of the
Barclays Premier League, FA Cup, Carling Cup and other tournament where
everton participate. Watch Soccer Live Everton FC is an English football
club based in Liverpool with nine English championships, five FA Cup wins
and a success in the European Cup Winners' Cup.The first "Golden Era" of
Everton fell in the time of Dixie Dean, the most renowned player of
Everton FC, and brought 1928-1939 three English titles and a Cup triumph.
According to a recent high point during the mid-1980s, including two
English league titles and the 1985 European Cup Winners' Cup trophy
included, the FA Cup victory from the year 1995 to today is the last great
success of the club.
Watch Live Streaming Link

how to change eclipse html formatting

how to change eclipse html formatting

When i open an html file in eclipse, after i format it, it looks like this:
<form>
<fieldset>
<label for="memberName">Login Name:</label> <input
type="text"
name="memberName" id="memberName" value=""
class="text ui-widget-content ui-corner-all" /> <label
for="memberPass">Password:</label> <input type="password"
name="memberPass" id="memberPass" value=""
class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>
but i want each tag with all of its attributes on the same line
how do i make eclipse understand that?

Deducing a.s. finiteness from a.s. finiteness of conditioned variable

Deducing a.s. finiteness from a.s. finiteness of conditioned variable

Consider a sequence of non-negative random variables $X_n$ and the natural
filtration $\mathcal{G}=\sigma(X_1,X_2,...)$
Suppose that $\lim_{n\rightarrow \infty} X_n$ exists and is finite
$\mathbb{P}(\cdot \vert \mathcal{G})-a.s.$.
Why is it true that then also $\lim_{n\rightarrow \infty} X_n$ exists and
is finite $\mathbb{P}-a.s.?$

Friday, 23 August 2013

ASP.Net MVC 4 - How to dynamically add row to html table

ASP.Net MVC 4 - How to dynamically add row to html table

I got a ASP.net MVC 4.0 web application which enable user to dynamically
add rows to html table.
In my view:
$('.del').live('click', function () {
id--;
var rowCount = $('#options-table tr').length;
if (rowCount > 2) {
$(this).parent().parent().remove();
}
});
$('.add').live('click', function () {
id++;
var master = $(this).parents("table.dynatable");
// Get a new row based on the prototype row
var prot = master.find(".prototype").clone();
prot.attr("class", "")
prot.find(".id").attr("value", id);
master.find("tbody").append(prot);
});


Model.ChillerDetails)%> //referring to the template



**In my template:**
" %>
m.ChillerAge) %>
m.ChillerBrand) %>
m.ChillerCapacity) %>
m.ChillerRefrigerant) %>

"/> "/>

**In my Model:**
public class AddHealthCheckFormModel{
public List ChillerDetails { get; set; }
}
public class ChillerPlantDetails
{
//[Required(ErrorMessage = "Please enter Chiller Capacity.")]
[Display(Name = "Chiller Capacity")]
public string ChillerCapacity { get; set; }
//[Required(ErrorMessage = "Please enter Age of Chiller.")]
[Display(Name = "Age of Chiller")]
public string ChillerAge { get; set; }
//[Required(ErrorMessage = "Please enter Chiller Brand.")]
[Display(Name = "Chiller Brand")]
public string ChillerBrand { get; set; }
//[Required(ErrorMessage = "Please enter Chiller Refrigerant.")]
[Display(Name = "Chiller Refrigerant")]
public string ChillerRefrigerant { get; set; }
}
Now the question comes to how can I capture the data in the dynamically
added rows into my controller and save into database?
Thanks.

maintain multiple socket connections while putting the recv through a single handler in python

maintain multiple socket connections while putting the recv through a
single handler in python

i have a function that returns a host for a specific site. and using these
two functions
def connect(self, rooms):
print('')
i = [x for x in rooms]
for x in i:
self.room_connect(x)
running = True
while running:
self.event_data()`
def room_connect(self, rooms):
host = getServer(rooms)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, 443))
sock.send(self.room_auth(rooms).encode())
self.sockets = sock
print(self.sockets)
print('connected to '+ rooms)
self.postbyte = True
i am able to connect to a different socket for each host. the problem is,
i need it to maintain a connection with each socket it connects to. in the
end, only the last socket that is created in the for loop is maintained.
the socket recv data from that socket is passed in to a handler to parse
the info. basically what i am asking is how to keep a connection from each
of the sockets created in the for loop going while passing its recv info
in to the handler. the handler is the event_data() and in the event_data
function the data to parse is defined by data = self.sockets.recv(1024).
the problem is that the only the last socket from the for loop is left
over to be handled.

How do I re-render a chart in d3.js using an on click event (dashboard building)?

How do I re-render a chart in d3.js using an on click event (dashboard
building)?

I'm developing an interactive school report card for a local nonprofit
using Bootstrap, PHP, MySQL and d3.js.
I have no problem getting the d3 charts to render (example) once the user
has selected a school (3 separate bar charts render onscreen when the user
submits the school selection form). I do this by executing queries,
encoding them as JSON in PHP/MySQL, then using the PHP include function
(on three separate occasions) to reference 3 separate JavaScript files
that contain the d3 code that renders the charts. The reference to the
data that the d3 is pulling in to populate the graphs is nested inside of
PHP tags inside each of these JavaScript files. Again, no issues here, the
charts render exactly where they're supposed to and they look good.
The issue is that I'd like users to be able to be able to change the
options on one of the charts and then have that chart re-render with the
new data when a button in that form is clicked.
One of the charts that is initially rendered is of 4th grade math test
score data from the state standardized test for the selected school. There
are other test subjects (English, Science and Social Studies) within the
4th grade that I'd like users to be able to view; additionally, the same 4
subjects are tested in grades 3 and grades 5 – 8. These options for other
tests and subjects appear in 2 select boxes that appear in a form located
in a div that appears just above the test score graph's div.
I use Ajax on change event handlers (raw JavaScript) to trigger a MySQL
query with the selected options (subject and grade level; school is pulled
from a hidden form element which contains the school id for the currently
selected school) every time the user's subject/grade level selection
changes. The JSON from the last query is then written into the value of
another element that appears in the same form as the subject/grade level
select boxes. PHP/html for the form (I'm only using one on change handler
in the code below):
echo "<form name='testselect' method=get>";
echo "<table>
<tbody>
<tr>
<td>";
echo "<select name='testtype' id='ttype'
onChange='javascript:ajaxFunction();'>";
$dboxquery1 = "SELECT distinct subject FROM leapfile2012
WHERE site_code='$_POST[school]' ORDER BY subject;";
$resultdbq1 = mysql_query($dboxquery1,$con) or die("SQL
Error 1: " . mysql_error());
while($dbqr1 = mysql_fetch_array($resultdbq1))
{
echo '<option value="'. $dbqr1['subject'] . '">' .
$testType[$dbqr1['subject']] . '</option>';
}
echo "</select>";
echo "</td>
<td>";
echo "<select name='testsub' id='tsub'>";
echo "<option value='ELA' selected='selected'>English</option>";
echo "</select>";
echo "</td>";
echo "<td>" . "<input type='hidden' name='hidden'
id='hidename' value='" . $_POST['school'] . "'></input></td>";
echo" <td>";
echo '<input type="button" id="data-submit" value="Get"
onClick="javascript:doofus();"></input>';
echo "</td>
<td>
<input type='hidden' name='hidden2' id='hidename2'
value=''></input>
</td>
</tr>
</tbody>
</table>";
echo '</form>';
An on click event (user clicks 'Get' in the subject/grade level form) then
triggers the d3 code that is supposed to repopulate the graph with the
test data for the newly selected grade and subject. The JSON for that
new/updated graph is pulled from the value of that second hidden element.
This is where everything breaks down, I get an error running the following
JavaScript/d3:
function doofus() {
var birdmanbirdman = document.getElementById('hidename2').value;
var whutitdo = birdmanbirdman.length;
var quote_be_gone = birdmanbirdman.substring(0,whutitdo);
//var i_hope_this_works = new Array(quote_be_gone);
//alert(i_hope_this_works);
//alert(typeof(i_hope_this_works));
//alert(typeof(birdmanbirdman));
var margin = {top: 35, right: 105, bottom: 30, left: 40},
width = 370 - margin.left - margin.right,
height = 289 - margin.top - margin.bottom;
var data = new Array(quote_be_gone);
//var dontwant = ["site_name","site_code","subject","testsub"];
var formatAsPercentage = d3.format(".1%");
var x = d3.scale.ordinal()
.rangeRoundBands([0, width], .1);
var y = d3.scale.linear()
.rangeRound([height, 0]);
var color = d3.scale.ordinal()
.range(["#3366cc", "#dc3912", "#ff9900", "#109618", "#990099"]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom")
.tickSize(1);
var yAxis = d3.svg.axis()
.scale(y)
.orient("left")
.tickFormat(d3.format(".0%"))
.tickSize(1);
var svg = d3.select("#area3").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
color.domain(d3.keys(data[0]).filter(function(key)
{ return key !== "year"; }));
data.forEach(function(d) {
var y0 = 0;
d.ages = color.domain().map(function(name) { return {name: name, y0:
y0, y1: y0 += +d[name]}; });
d.total = d.ages[d.ages.length - 1].y1;
});
x.domain(data.map(function(d) { return d.year; }));
y.domain([0, d3.max(data, function(d) { return d.total; })]);
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.attr("font-size", "1.0em")
.style("text-anchor", "end")
/*.text("Population")*/;
var state = svg.selectAll(".state")
.data(data)
.enter().append("g")
.attr("class", "g")
.attr("transform", function(d) { return "translate(" + x(d.year) +
",0)"; });
state.selectAll("rect")
.data(function(d) { return d.ages; })
.enter().append("rect")
.attr("width", x.rangeBand())
.attr("y", function(d) { return y(d.y1); })
.attr("stroke","black")
.attr("stroke-width",0.5)
.attr("height", function(d) { return y(d.y0) - y(d.y1); })
.style("fill", function(d) { return color(d.name); });
state.selectAll("text.one")
.data(function(d) { return d.ages; })
.enter().append("text")
.attr("x", function(d,i) { return x.rangeBand()/2;})
.attr("y", function(d) { /*if ((y(d.y0) - y(d.y1))>=0.05) */ return
y(d.y1) + (y(d.y0) - y(d.y1))/2 + 6; })
.text(function (d) { if ((y(d.y0) - y(d.y1))>=0.05) return
formatAsPercentage(d.y1 - d.y0);})
.attr("fill", "white")
.attr("font-family", "sans-serif")
.attr("font-weight", "normal")
.attr("text-anchor", "middle")
.attr("font-size", "0.9em");
var legend = svg.selectAll(".legend")
.data(color.domain().slice().reverse())
.enter().append("g")
.attr("class", "legend")
.attr("transform", function(d, i) { return "translate(0," + i * 20 +
")"; });
legend.append("rect")
.attr("x", width + 6)
.attr("width", 12)
.attr("height", 12)
.attr("stroke","black")
.attr("stroke-width", 0.5)
.style("fill", color);
legend.append("text")
.attr("x", width + 100)
.attr("y", 5)
.attr("dy", ".35em")
.style("text-anchor", "end")
.style("font-size", "9px")
.text(function(d) { return d; });
svg.append("text")
.attr("x", (width / 2))
.attr("y", 0 - (margin.top / 2))
.attr("text-anchor", "middle")
.style("font-size", "11px")
.style("font-weight", "normal")
/*.text(gtitle)*/;
}
When I inspect in Chrome, I get "Uncaught TypeError: Cannot read property
'length' of undefined" around this piece of code.
data.forEach(function(d) {
var y0 = 0;
d.ages = color.domain().map(function(name) { return {name: name, y0:
y0, y1: y0 += +d[name]}; });
d.total = d.ages[d.ages.length - 1].y1;
});
In the debugging process, I'm able to alert out the JSON that's supposed
to populate the graph. I'm then able to strip off opening and closing
quotes using native JavaScript functions (the native data type is string),
then successfully verify that the new data is indeed an object. The d3
code in the on click script doesn't seem to be recognizing the new
data/Object that I'm attempting to pass in.
I'm not sure what to do at this point. I haven't been able to find a
parallel example online.
Any help you could offer would be greatly appreciated. Forgive my
wordiness, I wanted to make sure you all understood my issue in detail. If
this is an elementary error, please go easy on me. I only started using
JavaScript in March, PHP in April, and d3 six weeks ago.

Web page already open (in source format); just need to read that text, using Selenium

Web page already open (in source format); just need to read that text,
using Selenium

Let's say I have a tab already open in the browswer. Its URL is:
view-source:http://www.google.com/webhp?source=search_app
Now that it's already open and displayed, I just want to read the text
that's in the client window. (Get a context to the page, or obtain its
object (as opposed to creating a new browser object), or whatever. Then
just read the page.)
Is there any methodology in Selenium, Splinter that allows for that?
Thanks for any help.

Prevent bad-optimization in Multithreading

Prevent bad-optimization in Multithreading

The following code:
while (x == 0) { ... }
might be optimized to
while (true) { ... }
if x gets assigned in another thread only. See Illustrating usage of the
volatile keyword in C# . The answer there solves this by setting x as
volatile.
However, it looks like that is not reliable according to these three
contributors (with a combined reputation of over 1 million :) )
Hans Passant A reproducable example of volatile usage : "never assume that
it is useful in a multi-threading scenario."
Marc Gravell Value of volatile variable doesn't change in multi-thread :
"volatile is not the semantic I usually use to guarantee the behavior"
Eric Lippert Atomicity, volatility and immutability are different, part
three : "I discourage you from ever making a volatile field."
Assuming code that uses a Backgroundworker and doesn't have two threads
writing to the same object - How can bad-optimization be prevented?

Getting images from CBZ archive

Getting images from CBZ archive

I need to get images from CBZ archives and display them in my PageViewer.
At the moment I'm unzipping the CBZ archive and placing the images on the
SD-Card which is so slow... It takes 8 seconds to unzip one image. Is
there any other way to do this? I don't need to unzip the CBZ archive, but
just get the images to display them. Any suggestions would be great to
speed this up.
Code to unzip the archive:
package nl.MarcVale.ComicViewer;
/**
* Created by Marc on 23-8-13.
*/
import android.util.Log;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class DecompressZip {
private String _zipFile;
private String _location;
public DecompressZip(String zipFile, String location) {
_zipFile = zipFile;
_location = location;
_dirChecker("");
}
public void unzip() {
try {
FileInputStream fin = new FileInputStream(_zipFile);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
Log.v("Decompress", "Unzipping " + ze.getName());
if(ze.isDirectory()) {
_dirChecker(ze.getName());
} else {
FileOutputStream fout = new FileOutputStream(_location +
ze.getName());
for (int c = zin.read(); c != -1; c = zin.read()) {
fout.write(c);
}
zin.closeEntry();
fout.close();
}
}
zin.close();
} catch(Exception e) {
Log.e("Decompress", "unzip", e);
}
}
private void _dirChecker(String dir) {
File f = new File(_location + dir);
if(!f.isDirectory()) {
f.mkdirs();
}
}
}

Thursday, 22 August 2013

Timepicker save 12h to 24 hours Format

Timepicker save 12h to 24 hours Format

I'm having problem on saving the value of the Time Picker of Kendo to 24
Hours Format , Timepicker shows "HH:mm tt" format but i want to convert it
to "HH:mm:ss" , I use Time Span for my drowdown list
Sample Codes
//having error because Endtime's value is "HH:mm tt"
client.EndTime = TimeSpan.Parse(endTime.Trim());
client.EndTime = new DateTime(endTime).ToString("HH:mm");
client.EndTime
=TimeSpan.ParseExact(endTime,"hh\\:mm\\:ss",CultureInfo.InvariantCulture);

Python : the art of importing bla from bla using bla bla bla & Beautiful Soup?

Python : the art of importing bla from bla using bla bla bla & Beautiful
Soup?

You are about to be provided with information to
start your own Google.
Some people posted comments and said this can not
be done because google has 1 million servers and we do not.
The truth is, google has those many servers for trolling
purposes (e.g. google +, google finance, youtube the bandwidth consuming
no-profit making web site, etc ).
all for trolling purposes.
if you wanted to start your own search engine...
you need to know few things.
1 : you need to know how beautiful mysql is.
2: you need to not listen to people that tell you to use a framework
with python, and simply use mod-wsgi.
3: you need to cache popular searches when your search engine is running.
3: you need to connect numbers to words. maybe even something like..
numbers to numbers to words.
in other words let's say in the past 24 hours people searched for
some phrases over and over again.. you cache those and assign numbers
to them, this way you are matching numbers with numbers in mysql.
not words with words.
in other words let's say google uses 1/2 their servers for trolling
and 1/2 for search engine.
we need technology and ideas so that you can run a search engine
on 1 or 2 dedicated servers that cost no more than $100/month each.
once you make money, you can begin buying more and more servers.
after you make lots of money.. you probably gonna turn into a troll
too like google inc.
because god is brutal.
god is void-state
it keeps singing you songs when you are sleeping and says
"nothing matters, there is simply no meaning"
but of course to start this search engine, you need a jump start.
if you notice google constantly links to other web sites with a
trackable way when people click on search results.
this means google knows which web sites are becoming popular
are popular, etc. they can see what is rising before it rises.
it's like being able to see the future.
the computer tells them " you better get in touch with this guy
before he becomes rich and becomes un-stopable "
sometimes they send cops onto people. etc.
AMAZON INC however..

will provide you with the top 1 million web sites in the world.
updated daily in a cvs file.
downloadable at alexa.com
simply click on 'top sites' and then you will see the downloadable
file on the right side.
everyday they update it. and it is being given away for free.
google would never do this.
amazon does this.
this list you can use to ensure you show the top sites first in your
search engine .
this makes your search engine look 'credible'
in other words as you start making money, you first display things
in a "Generic" way but at the same time not in a "questionable" way
by displaying them based on "rank"
of course amazon only gives you URLS of the web sites.
you need to grab the title and etc from the web sites.
the truth is, to get started you do not need everything from web sites.
a title and some tags is all you need.
simple.
basic.
functional
will get peoples attention.
i always ask questions on SO but most questions get deleted. here's
something that did not get deleted..
How do I ensure that re.findall() stops at the right place?
use python, skrew php, php is no good.
do not use python frameworks, it's all lies and b.s. use mod-wsgi
use memcache to cache the templates and thus no need for a template engine.

always look at russian dedicated servers, and so on.
do not put your trust in america.
it has all turned into a mafia.

google can file a report, fbi can send cops onto you, and next thing you know
they frame you as a criminal, thug, mentally ill, bipolar, peadophile, and
so on.
all you can do is bleed to death behind bars.
do not give into the lies of AMERICA.
find russian dedicated servers.
i tried signing up with pw-service.com but i couldn't do it due to
restrictions with their russian payment systems and so on..
again, amazon's web site alexa.com provides you with downloadable
top 1 mil web sites in the form of a cvs file.
use it.
again, do not give into python programmers suggesting frameworks for python.
it's all b.s. use mod_wsgi with memcache.
again, american corporations can ruin you with lies and all you can do is
bleed to death behind bars
again, a basic search engine needs : url, title, tags, and popular searches
can be "cached" and words can be connected to "numbers" within the mysql.
mysql has capabilities to cache things as well.
cache once, cache twice, and you will not need 1 million servers in order
to troll.
if you need some xdotool commands to deal with people calling you a troll
here it is;
xdotool key ctrl+c
xdotool key Tab Tab Tab Return
xdotool type '@'
xdotool key ctrl+v
xdotool type --clearmodifiers ', there can not be such thing as a `troll`
unless compared to a stationary point, if you are complaining, you are not
stationary. which means you are the one that is trolling.'
xdotool key Tab Return
create an application launcher on your gnome-panel, and then select the
username in the comments section that called you a 'troll' and click the
shortcut on the gnome-panel.
it will copy the selected username to the clipboard and then hit TAB TAB
TAB RETURN
which opens the comment typing box. and then it will type @ + username +
comma, and then the rest.
......................................................................................................

get current time in a specific country via jquery

get current time in a specific country via jquery

pI want to show the current time in New Zealand using JQuery. My client
has got customers calling from outside New Zealand. However, he sometimes
felt very annoy that customers gave them a call at 3 am because they did
not think of the time difference. He wants to add a label saying Current
time in New Zealand is: 3.00 am. Can it be achieved via JQuery? Cheers./p

Whys to improve Select query

Whys to improve Select query

How can I improve my select query? currently the following select query
takes around 2 minutes to execute.
SELECT COUNT( * ) AS count
FROM post
WHERE category REGEXP
'[[:<:]](5|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|234|235|236|237)[[:>:]]'
AND approve =1
+-------+
| count |
+-------+
| 12718 |
+-------+
1 row in set (2 min 12.68 sec)
mysql> explain SELECT COUNT( * ) AS count FROM post WHERE category
REGEXP
'[[:<:]](5|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|134|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|234|235|236|237)[[:>:]]'
AND approve =1;
+----+-------------+----------+------+---------------+---------+---------+-------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len |
ref | rows | Extra |
+----+-------------+----------+------+---------------+---------+---------+-------+--------+-------------+
| 1 | SIMPLE | post | ref | approve | approve | 1 |
const | 844258 | Using where |
+----+-------------+----------+------+---------------+---------+---------+-------+--------+-------------+
i'm using mysql5.6. query cache is enabled.

Module isomorphism and trace

Module isomorphism and trace

I was reading the document "The Different Ideal"
http://www.math.uconn.edu/~kconrad/blurbs/gradnumthy/different.pdf and
there is a part on page 9, which I don't quite get.
We have a number field $K$ and its ring of algebraic integers $O_K$. Say
$\mathcal{P}$ is a prime ideal of $O_K.$ Take an element $\pi \in
\mathcal{P} \backslash\mathcal{P}^2 $. Then, $(\pi^i)$ is divisible by
$\mathcal{P}^i$, but not by $\mathcal{P}^{i+1}$, so $\mathcal{P}^{i} =
(\pi^i) + \mathcal{P}^{i+1}$. Therefore, $O_K/ \mathcal{P}$ is isomorphic
to $\mathcal{P}^i / \mathcal{P}^{i+1}$ as $O_K$-module isomorphism by $x
\mod \mathcal{P} \rightarrow \pi^i x \mod \mathcal{P}^{i+1}$.
I understand until here and the following part is where I am stuck on..
This $O_K$ module isomorphism comments with multiplication by $y$ on both
sides, so
$$ Tr (m_y: \mathcal{P}^i / \mathcal{P}^{i+1} \rightarrow \mathcal{P}^i /
\mathcal{P}^{i+1} ) = Tr (m_y: O_K / \mathcal{P} \rightarrow O_K /
\mathcal{P}). $$
I would greatly appreciate an explanation! Thank you very much!

Python : using python with memcache and mod-wsgi

Python : using python with memcache and mod-wsgi

You are about to be provided with information to
start your own Google.
Some people posted comments and said this can not
be done because google has 1 million servers and we do not.
The truth is, google has those many servers for trolling
purposes (e.g. google +, google finance, youtube the bandwidth consuming
no-profit making web site, etc ).
all for trolling purposes.
if you wanted to start your own search engine...
you need to know few things.
1 : you need to know how beautiful mysql is.
2: you need to not listen to people that tell you to use a framework
with python, and simply use mod-wsgi.
3: you need to cache popular searches when your search engine is running.
3: you need to connect numbers to words. maybe even something like..
numbers to numbers to words.
in other words let's say in the past 24 hours people searched for
some phrases over and over again.. you cache those and assign numbers
to them, this way you are matching numbers with numbers in mysql.
not words with words.
in other words let's say google uses 1/2 their servers for trolling
and 1/2 for search engine.
we need technology and ideas so that you can run a search engine
on 1 or 2 dedicated servers that cost no more than $100/month each.
once you make money, you can begin buying more and more servers.
after you make lots of money.. you probably gonna turn into a troll
too like google inc.
because god is brutal.
god is void-state
it keeps singing you songs when you are sleeping and says
"nothing matters, there is simply no meaning"
but of course to start this search engine, you need a jump start.
if you notice google constantly links to other web sites with a
trackable way when people click on search results.
this means google knows which web sites are becoming popular
are popular, etc. they can see what is rising before it rises.
it's like being able to see the future.
the computer tells them " you better get in touch with this guy
before he becomes rich and becomes un-stopable "
sometimes they send cops onto people. etc.
AMAZON INC however..

will provide you with the top 1 million web sites in the world.
updated daily in a cvs file.
downloadable at alexa.com
simply click on 'top sites' and then you will see the downloadable
file on the right side.
everyday they update it. and it is being given away for free.
google would never do this.
amazon does this.
this list you can use to ensure you show the top sites first in your
search engine .
this makes your search engine look 'credible'
in other words as you start making money, you first display things
in a "Generic" way but at the same time not in a "questionable" way
by displaying them based on "rank"
of course amazon only gives you URLS of the web sites.
you need to grab the title and etc from the web sites.
the truth is, to get started you do not need everything from web sites.
a title and some tags is all you need.
simple.
basic.
functional
will get peoples attention.
i always ask questions on SO but most questions get deleted. here's
something that did not get deleted..
How do I ensure that re.findall() stops at the right place?
use python, skrew php, php is no good.
do not use python frameworks, it's all lies and b.s. use mod-wsgi
use memcache to cache the templates and thus no need for a template engine.

always look at russian dedicated servers, and so on.
do not put your trust in america.
it has all turned into a mafia.

google can file a report, fbi can send cops onto you, and next thing you know
they frame you as a criminal, thug, mentally ill, bipolar, peadophile, and
so on.
all you can do is bleed to death behind bars.
do not give into the lies of AMERICA.
find russian dedicated servers.
i tried signing up with pw-service.com but i couldn't do it due to
restrictions with their russian payment systems and so on..
again, amazon's web site alexa.com provides you with downloadable
top 1 mil web sites in the form of a cvs file.
use it.
again, do not give into python programmers suggesting frameworks for python.
it's all b.s. use mod_wsgi with memcache.
again, american corporations can ruin you with lies and all you can do is
bleed to death behind bars
again, a basic search engine needs : url, title, tags, and popular searches
can be "cached" and words can be connected to "numbers" within the mysql.
mysql has capabilities to cache things as well.
cache once, cache twice, and you will not need 1 million servers in order
to troll.
if you need some xdotool commands to deal with people calling you a troll
here it is;
xdotool key ctrl+c
xdotool key Tab Tab Tab Return
xdotool type '@'
xdotool key ctrl+v
xdotool type --clearmodifiers ', there can not be such thing as a `troll`
unless compared to a stationary point, if you are complaining, you are not
stationary. which means you are the one that is trolling.'
xdotool key Tab Return
create an application launcher on your gnome-panel, and then select the
username in the comments section that called you a 'troll' and click the
shortcut on the gnome-panel.
it will copy the selected username to the clipboard and then hit TAB TAB
TAB RETURN
which opens the comment typing box. and then it will type @ + username +
comma, and then the rest.

Distributed locking mechanism .NET

Distributed locking mechanism .NET

We have a requirement to manage concurrent operations of a task. In short
only one version of this task can be running at any one time.
The issue is we will be running in a multi-server environment.
Requirements:
Allow once instance of a method to run at any one time. (OS mutex).
Must work in a multi server environment.
Mutex must be dropped if process dies.
Must be a robust and mature solution.
Environment:
Windows Server (on premise)
.Net
Azure
Things I have considered so far:
OS mutex: Works for on premise, unsure if it will release the lock on
process death. Also unsure if windows supports a robust mutex.
DB Flag: Works for on premis, works in multi-server. Won't unlock on
process death.
AppFabric: Works on premise though an extra setup step is undesirable.
Works multi-server. Won't unlock on process death though locks can be set
to time out when acquired. (best so far)
CIFS File lock: Works on premise, works multi-server, should unlock on
process death. Fails the robust test though this may be personal bias.
I imagine this is a fairly common problem and I'm interested to hear how
the community commonly solves it.

Wednesday, 21 August 2013

How can I extract URLs containing dashes from HTML using R?

How can I extract URLs containing dashes from HTML using R?

I have some HTML that looks like this:
<ul><li><a href="http://www.website.com/index.aspx"
target="_blank">Website</a></li>
<li><a href="http://website.com/index.html" target="_blank">Website</a></li>
<li><a href="http://www.website-with-dashes.org" target="_blank">Website
With Dashes</a></li>
<li><a href="http://website2.org/index.htm" target="_blank">Website
2</a></li>
<li><a href="http://www.another-site.com/">Another Site</a></li>
using
m<-regexpr("http://\\S*/?", links, perl=T)
links<-regmatches(links, m)
gets me the links, except the ones with dashes in them are truncated like
this:
http://www.website.com/index.aspx
http://website.com/index.html
http://www.website
http://website2.org/index.htm
http://www.another-site.com/
I thought /S matched any non-whitespace. What's going on?

New popup windows on Google Chrome for Windows are always the full screen width

New popup windows on Google Chrome for Windows are always the full screen
width

I have a site http://bizfriend.ly/lesson.html?1 which requires several
popups of specific widths. I cannot get the predefined widths to work for
Windows versions of Chrome. It works fine in IE, Safari, and Chrome on
Mac.
After step two in the instructions, your screen should have two popup
windows next to each other.
The following function is called by a jQuery click function. Again it
works fine all browsers except Chrome on Windows.
function _instructionsLinkClicked(evt){
var url = 'instructions.html?'+lessonId;
var width = 340;
var height = window.screen.height;
var left = window.screen.width - 340;
instructionOptions = "height="+height+",width="+width+",left="+left;
window.open(url,"instructions",instructionOptions);
}
An interesting clue, when the 'Restore Down' button is clicked, the window
reduces to the correct size I want, yet at the wrong location.

IFrame Issue in Chrome

IFrame Issue in Chrome

<iframe width="100%" src="http://www.youtube.com/embed/source"
frameborder="0" allowfullscreen></iframe>
I have the above code on one of my website pages. When working with google
chrome the page loads fine and the embedded video works fine. However I
receive
Blocked a frame with origin "http://www.youtube.com" from accessing a
frame with origin "http://mysite.com". Protocols, domains, and ports must
match.
I am not as savvy in Firefox so am unable to see if I am receiving this
error as well.
The main issue is that all of my navigation menus stop working on this
error. The dropdowns when hovering over the menu items in the nav bar
never appear. When loading any page without IFrames the issue is
irrelavent.
Is there a way to confront this error so it behaves on all browsers? I
have dug around the apache2 configuration as well as tried other things I
have found such as removing the http from the youtube link.

Unable to fix steps in Stored Procedure after queries?

Unable to fix steps in Stored Procedure after queries?

I Have Tables TABLE_TEXAS_2013
TABLE_DALLAS_2013,
Mapping_Table,
Summary_Table,
Area_Factor..
TABLE_TEXAS_2013 Looks Like
market_id texas_id year month value realvalue
4 1211 2013 1 36 36
6 1231 2013 1 43 99
TABLE_TEXAS_2013 Looks Like
market_id texas_id year month value realvalue
9 1218 2013 1 36 78
10 1238 2013 1 43 99
Mapping_Table
Texas_id role
1211 jr
1231 dr
1245 sr
1346 hr
Summary_Table
area year month total_value
texas 2013 1 777777
dallas 2013 1 989889
Factor_Table
area_id area year month factor
1 TEXAS 2000 1 2.38
480 DALLAS 2020 12 1
These is My code :
Begin Try Drop Table #TEMP1 End Try
Begin Catch End catch
SELECT sum(VALUE) as Strategy,a.Year,a.Month
INTO #TEMP1
FROM TABLE_TEXAS_2013 a
INNER JOIN Mapping_table B
ON a.Carline_id=b.CARLINE_ID
WHERE Role IN ('hr','sr')
GROUP BY A.Year,A.Month
ALTER TABLE #TEMP1 ADD AREA varchar(50)
UPDATE #TEMP1 SET AREA ='TEXAS'
Begin Try Drop Table #TEMP3 End Try
Begin Catch End catch
SELECT O.Total_Value,C.Year,C.Month,C.Strategy,C.AREA
INTO #TEMP3
FROM Factor_Table C
INNER JOIN #TEMP2 O
on C.Year=O.Year
AND C.Month=O.Month
and C.AREA=AREA.Media
UPDATE A
SET
A.Factor=B.Total_Value/B.Strategy,A.Total_Value=B.Total_Value,A.LastModified=sysDatetime(),A.LastModifiedBy=suser_name()
FROM AREA_fACTOR A
INNER JOIN #TEMP3 B ON
A.Year=B.Year and
A.Month=B.Month and
A.AREA=AREA.Media
UPDATE R
SET Real_Value=Value*S.Factor
FROM TABLE_TEXAS_2013 R
INNER JOIN AREA_fACTOR S
ON R.Year=S.Year
and R.Month=S.Month
The problem is i have succesfully created temp tables and generated the
steps but iam unable to fix all steps in one stored procedure.
Note: if i gives input to stores proc TABLE_TEXAS_2013 or
TABLE_DALLAS_2013 it should must and should go through every step because
FACTOR_Table consists of 2013 data or else if i give TABLE_TEXAS_2012 or
2011 it want to skip all steps and should goes to last step and want to
find update real value by using the factor in AREA_fACTOR table.. -->if
iam using TEXAS iam adding area TEXAS to one TEMP TABLE same fallows if i
use DALLAS.
-->iam mapping for hr,sr for dallas and texas..
Can anyone help me on this problem?

The calling thread must be STA, because many UI components require this (with a strage senerio)

The calling thread must be STA, because many UI components require this
(with a strage senerio)

I am working on a web project. The server of the project uses SignalR. I
am getting this error "The calling thread must be STA, because many UI
components require this" only in release version and at time when user
attempts to login. When login button is pressed again this error doesn't
come up. I'm not sure what could be reason and how to resolve it. Any help
would be greatly appreciated.
Thanks.