mercredi 30 avril 2014

Why Is 3D Visualization Used In Architectural Field?


Vote count:

0




3D Modeling 3D visualisation may be a generic term employed in CAD trade for 3D Rendering and Modeling services. visualisation normally suggests that ability to ascertain or imagine one thing even before it's created. it's going to be something a building or a product. 3D visualisation is conspicuously employed in the sector of design. 3D Modeling and Rendering Services fall into "3D Visualization". it helps same in Nursing exterior, interior or website} takes care of it's created Technique that offers a sensible look and feel to the building or site is termed "Rendering". Rendering commonly comes into image when the model is built. victimization 3D Modeling Associate in Nursingd 3D Rendering an designer or a 3D creator will showcase all parts of a specific building or web site. Not solely building parts however conjointly landscaping, water bodies etc. will be shown in 3D Renderings. There will be multiple views for one single building which might be show cased from completely different angles.


This technique has brought a revolution within the field of study trade. CAD Plans, hand-crafted drawings and sketches will all be regenerate simply into 3D Rendered pictures. It will provides a clear plan concerning the colours employed in the building interior likewise as exterior, interior style, furnishings varieties, wall color, lighting etc even before the building is built. Trees, Plants, Vegetation round the main building and web site can also be visualised with absolute realism.


The following will be achieved victimization 3D visualisation 1. Exterior Rendering 2. Interior Rendering 3. Photo-montage 4. Landscaping 5. Product Modeling 6. furnishings Modeling 3D Industrial Modeling Exterior Rendering refers to visualisation of the outside of any building or house. Exterior will be an ad Building, Residential House, Condominiums, Single Family Home, Villas, Resorts etc.Architectural firms or consultants use exterior rendering to form visualisation of a building that's getting ready to get created. this could be used as a wonderful tool to promote their services or buildings.


Landscaping and web site rendering conjointly add price to the whole package. beside this photo-montage helps North American country visualize a building or villa created with a back drop of Associate in Nursing existing web site. Our 3D Model Associate in Nursingd Rendered Model will be amalgamated to an existing website} or natural scenery to check however a building appearance against one specific site.


Interior Rendering allows one to ascertain however an internal of a building, house, villa or a resort goes to seem like. furnishings layouts, 3D floor plans, color of walls and floors, material texture, fixtures, room appliances, water closets etc will be designed to convey a transparent plan to Associate in Nursing user. this could be conjointly used as a wonderful promoting technique to draw in patrons for residences or villas. Associate in Nursing designer will offer you with Associate in Nursing exceptional interior pictures or models beside multiple choices for you to settle on from. 3D Product Modeling This is extraordinarily value effective and saves ample time. we are able to visualize the whole building at a look victimization 3D rendering before the building is complete. this protects time and helps North American country modify details that need to be modified before the particular construction. Some parts ar terribly troublesome to switch when actual construction takes place.


Contact :- The Cheesy Animation. Ahmadabad, India. Visit Us : - http://ift.tt/1iFZIUy



asked 16 secs ago






XMPPFramework Single User Chat in iOS


Vote count:

0




I am in the process of developing an chat app in iOS. The XMPP server is an ejabberd server which is up and running. I got to know from SO that there is no need to do any configuration in ejabberd.cfg for Single user chat.


I went ahead and started coding and created room (though I was kicked out after 60 seconds after the creation of room) using robbiehanson xmppframework.


Later I realized ( after breaking my head for 2 days and 2 sleepless nights) that room is not something which comes into picture for a single user chat.


When I was searching for an entry point to start with the single user chat I was not able to find a proper guide, sample code snippets to start with. But in many of the SO post, I got to know that it is something easy to accomplish. Could anyone please guide me an entry point as how to start a single user chat session


As of now, I have all the rosters as a list. Each row of the list has a link which is a friend's/contact's name. Clicking on the link should open a chat window ( I have created a chat client in story board ).What I need is clicking on a link, how do I initiate a single user chat session with the user. Any advice will be valuable for me to start up with. Thanks for your time and help.



asked 2 mins ago






Display my Android app along google+, facebook etc in connections (Contacts)


Vote count:

0




Can anyone help me get my app displayed along with google+, facebook, whatsapp etc to sync with contacts in the connections in the People app. I have already googled it but there seems to be no similar thing.



asked 55 secs ago






reading octal from sqlite - ios


Vote count:

0




I'm tring to Insert special characters into Sqlite and then trynig to read data from sqlite, but im facing some issue, i using follwing query to insert value to sqlite


INSERT INTO manufacturers VALUES(35,NULL,NULL,'KARTHICK\047'); in this query KARTHICK\047 has octal value, so when i try to read and displays the KARTHICK into my tableview, im getting (KARTHICK\047) instead of (KARTHICK'),


octal value \047 is special character ('),


please help me to sort out this issue




rmaddy

68.7k

asked 1 min ago






Showing Error Segmentation fault


Vote count:

0




This code is of Stack Using Double Linked list. This Code works fine except for one condition i.e whenever the last node is deleted it shows 'Segmentation fault' error!


typedef struct node_type{



int value;

struct node_type *next, *prev;


}node;



node *insert(int value, node *top){

node *p;

p = (node*)malloc(sizeof(node));

if(top == NULL){

top = p;

p -> value = value;

p -> next = NULL;

p -> prev = NULL;

return top;

}

else{

p -> value = value;

p -> next = top;

p -> prev = NULL;

top -> prev = p;

top = p;

return top;

}


}


node *del(node *top){



node *temp;

if(top == NULL){

printf("Stack is empty\n");


}



else{

temp = top;

top = top -> next;

top -> prev = NULL;

free(temp);

}

return top;


}


node *disp(node *top){



if(top == NULL){

printf("Stack is empty\n");

}

else{

while(top != NULL){

printf("The value is: %d\n", top -> value);

top = top->next;

}

}


}


int main(){



int value, ch = 0;

node *top = NULL;

while( ch != 4){

printf("------> 1. Insert <-------\n");

printf("------> 2. Delete <-------\n");

printf("------> 3. Display <-------\n");

printf("------> 4. Exit <-------\n");

printf("Enter the choice\n");

scanf("%d",&ch);

switch(ch){

case 1:

printf("Enter the value\n");
scanf("%d",&value);

top = insert(value, top);

break;

case 2:

printf("Removing the element\n");

top = del(top);

break;

case 3:

disp(top);

break;

case 4:

exit(0);

break;

default:

printf("Wrong Choice\n");

break;

}

}

return 0;


}



asked 1 min ago






Image recognition of well defined but changing angle image


Vote count:

0




PROBLEM


I have a picture that is taken from a swinging vehicle. For simplicity I have converted it into a black and white image. An example is shown below:


Figure 1


The image shows the high intensity returns and has a pattern in it that is found it all of the valid images is circled in red. This image can be taken from multiple angles depending on the rotation of the vehicle. Another example is here:


enter image description here


The intention here is to attempt to identify the picture cells in which this pattern exists.


CURRENT APPROACHES


I have tried a couple of methods so far, I am using Matlab to test but will eventually be implementing in c++. It is desirable for the algorithm to be time efficient, however, I am interested in any suggestions.


SURF (Speeded Up Robust Features) Feature Recognition


I tried the default matlab implementation of SURF to attempt to find features. Matlab SURF is able to identify features in 2 examples (not the same as above) however, it is not able to identify common ones:


enter image description here


I know that the points are different but the pattern is still somewhat identifiable. I have tried on multiple sets of pictures and there are almost never common points. From reading about SURF it seems like it is not robust to skewed images anyway. Perhaps some recommendations on pre-processing here?


Template Matching


So template matching was tried but is definitely not ideal for the application because it is not robust to scale or skew change. I am open to pre-processing ideas to fix the skew. This could be quite easy, some discussion on extra information on the picture is provided further down.


For now lets investigate template matching: Say we have the following two images as the template and the current image:


enter image description here


The template is chosen from one of the most forward facing images. And using it on a very similar image we can match the position:


enter image description here


But then (and somewhat obviously) if we change the picture to a different angle it won't work. Of course we expect this because the template no-longer looks like the pattern in the image:


enter image description here


So we obviously need some pre-processing work here as well.


Hough Lines and RANSAC


Hough lines and RANSAC might be able to identify the lines for us but then how do we get the pattern position?


Other that I don't know about yet


I am pretty new to the image processing scene so i would love to hear about any other techniques that would suit this simple yet difficult image rec problem.


The sensor and how it will help pre-processing


The sensor is a 3d laser, it has been turned into an image for this experiment but still retains its distance information. If we plot with distance scaled from 0 - 255 we get the following image:


enter image description here


Where lighter is further away. This could definitely help us to align the image, some thoughts on the best way? . So far I have thought of things like calculating the normal of the cells that are not 0, we could also do some sort of gradient descent or least squares fitting such that the difference in the distance is 0, that could align the image so that it is always straight. The problem with that is that the solid white stripe is further away? Maybe we could segment that out? We are sort of building algorithms on our algorithms then so we need to be careful so this doesn't become a monster.


Any help or ideas would be great, I am happy to look into any serious answer!



asked 53 secs ago

Ben

2,940





riak mapreduce with limit on response size in java


Vote count:

0




I'm trying to run a mapReduce query on Riak 1.4 that queries by secondary index, sorts the records by date, and then limits the results to the first record.


I've got the secondary index query working. The sort doesn't seem to do anything. No errors on the sort, just returns the results unsorted. The limit on the number of records returned yields a 'bad_json' error returned by the server.


Here's what I have. It is suppose to query the "cars" bucket for the most recent car owned by "john_doe". (some names have been changed to protect the innocent;) :



JSSourceFunction dateSortFunction = new JSSourceFunction(
"function(v) {" +
"return v.sort(function(a, b) {" +
"return a.issueDate - b.issueDate ;" +
"}" +
");" +
"}");

IndexQuery iq = new BinValueQuery(BinIndex.named("person"), "cars", "john_doe");

MapReduceResult response = session.mapReduce(iq)
.addMapPhase(NamedErlangFunction.MAP_OBJECT_VALUE)
.addReducePhase(dateSortFunction)
.addReducePhase(new NamedJSFunction("Riak.reduceLimit"), 1)
.execute();


I've seen a number of posts on sorting and am hoping to figure it out eventually. However, I haven't seen any help on how the LIMIT function might work.


Thanks in advance!



asked 1 min ago






What's idiom/best practice with UncheckedIOException and Stream API?


Vote count:

0




Java 8 officially introduce java.io.UncheckedIOException to JDK class libraries for lambda with Stream API, because lambda expressions can't declare its throws-clause and lambda body can't throw checked exception such as IOException.


What's idiom/best practice with UncheckedIOException and Stream API? What conditions do I explicitly throw new UncheckedIOException object, and when should I catch UncheckedIOException exception?



asked 1 min ago

yohjp

929





Error in opening a file through system() C++


Vote count:

0




I'm trying to run a file using system() function with C++. It opened up the command prompt but it says that 'C:\Program' is not recognised as internal or external command.


I tried to manually open the CMD and typing this into it and it can run.



"C:\Program Files\MATLAB\R2011a\bin\matlab.exe" -r "run('C:\Users\victor\Desktop\FYP MATLAB\MATLAB 29april\main.m');"


but when use MSVC++ with this function it failed.



system("\"C:\\Program Files\\MATLAB\\R2011a\\bin\\matlab.exe\\\" -r \"run('C:\\Users\\victor\\Desktop\\FYP MATLAB\\MATLAB 29april\\main.m');\"");


I already used \" for " and \ instead of \


Please help. thanks



asked 1 min ago






Bootstrap Dropdown Wrong Place


Vote count:

0




i tried a bootstrap but, why dropdown menu is in left middle?


this is link to the picture, http://ift.tt/1nKwsny


this is my code


<td><button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Action <span class="caret"></span></button> <ul class="dropdown-menu" role="menu" > <li class="dropdown"><a href="#">Edit</a></li> <li class="dropdown"><a href="warga/delete/<?php echo $a->id;?>">Delete</a></li> </ul> </td>


sorry for my bad english, thanks before



asked 2 mins ago






Modal dialog to show when link is clicked and button to point to window.location


Vote count:

0




I have a "Delete Account" link. I want to show a dialog box confirmation when this link is clicked.


See: http://ift.tt/PSrOFb


The problem is that in this code, the confirmation "Are you sure you want to delete your account?" is already showing.


I also want to show the dialog box with the Delete button linking to:



window.location = bender.base_url + '?page=user&action=delete&id=' + bender.user.id + '&secret=' + bender.user.secret;


and the Close button to simply close the dialog box.


I wanted to make it look like this: http://ift.tt/R25SZo


Would really appreciate any help. Thanks!



asked 2 mins ago






Where am I going wrong while matching the time?


Vote count:

0




How can I match time with what is in the database to the current time ?


This is how I have been doing till now but haven't succeeded. There is a column named stime in the table that has the datatype TIME. It has values in HH:mm:ss



String time = dateFormat.format(new java.sql.Time(new GregorianCalendar().getTimeInMillis()));
int timeattr[] = new int[2];
int i = 0;
for(String a : time.split(":")) {
timeattr[i] = Integer.parseInt(a);
i++;
}
GregorianCalendar gc = new GregorianCalendar(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), timeattr[0], timeattr[1], 0);

// QUERY
String hql = "from Scheduled where stime <= :now";

List list = session.createQuery(hql).setTime("now", new java.sql.Time(gc.getTimeInMillis())).list();
Iterator iterator = list.iterator();

while(iterator.hasNext()) { // never enters the loop }


asked 23 secs ago






AVFoundation - Why my image would fail on output?


Vote count:

0




I don't know why my capture raw data would return null. Input and Output of the capture seems to declared correctly. I am trying to have r,g,b color of specific pixel from live camera view. I am not sure which part of the function is not making it work.





#import "PCamViewController.h"

@interface PCamViewController ()

@end

@implementation PCamViewController

- (void)viewDidLoad
{
[super viewDidLoad];
[self startSession];
}

- (AVCaptureSession *)session
{
if (!_session) {
_session = [[AVCaptureSession alloc]init];
}
return _session;
}

- (AVCaptureDeviceInput *)deviceInput
{
if (!_deviceInput) {
_deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo] error:nil];
}
return _deviceInput;
}

- (void) startSession {

[self.session addInput:self.deviceInput];

AVCaptureVideoPreviewLayer *previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.session];
[previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];
CALayer *rootLayer = [self.captureView layer];
[rootLayer setMasksToBounds:YES];
CGRect boundCapture = self.captureView.bounds;
[previewLayer setFrame:boundCapture];
[rootLayer insertSublayer:previewLayer atIndex:0];

[self.session startRunning];

stillImageOutput = [AVCaptureStillImageOutput new];
if ([_session canAddOutput:stillImageOutput])
[_session addOutput:stillImageOutput];

NSLog(@"session activated");
}

- (IBAction)captureImage:(UIButton *)sender {
NSLog(@"captureImage button pushed");
AVCaptureConnection *stillImageConnection = [stillImageOutput connectionWithMediaType:AVMediaTypeVideo];

[stillImageOutput captureStillImageAsynchronouslyFromConnection:[[stillImageOutput connections] objectAtIndex:0] completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
CVImageBufferRef cameraFrame = CMSampleBufferGetImageBuffer(imageSampleBuffer);
CVPixelBufferLockBaseAddress(cameraFrame, 0);
GLubyte *rawImageBytes = CVPixelBufferGetBaseAddress(cameraFrame);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(cameraFrame);
NSData *dataForRawBytes = [NSData dataWithBytes:rawImageBytes length:bytesPerRow * CVPixelBufferGetHeight(cameraFrame)];
// Do whatever with your bytes
NSLog(@"%@", dataForRawBytes);
NSLog(@"%@", rawImageBytes);
//NSLog(@"%@", imageSampleBuffer);

CVPixelBufferUnlockBaseAddress(cameraFrame, 0);
}];
}
@end


asked 46 secs ago






Even-odd merge sort 64 inputs to 64 outputs sorted 32 bits words works partly


Vote count:

0




I have a module in vhdl that does what is state in the title. The thing is, this rowks flawless in a sorted set of numbers, in a decrescent sorted set, and a semi-mixed set of numbers , but with really random numbers this module , does work, any ideia why?


i'm using a 64 to 64 module , that uses two 32 to 32, this one uses two 16 to 16 and finaly this last one uses two 8 to 8 modules , i'm pretty sure the 8 to 8 and 16to16 modules are correct, were done by my teacher, but not so sure about the 64 to 64, please give me some feed back , on what could be wrong :)



library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

use work.set_of_data_items.all;

entity merge64to64 is
--generic ( M : integer := 4;
-- N : integer := 16 );
Port ( input_1items : in set_of_8items;
input_2items : in set_of_8items;
input_3items : in set_of_8items;
input_4items : in set_of_8items;

input_5items : in set_of_8items;
input_6items : in set_of_8items;
input_7items : in set_of_8items;
input_8items : in set_of_8items;

sorted : out set_of_64items);

end merge64to64;

architecture Behavioral of merge64to64 is

signal sorted1,sorted2 : set_of_32items;
signal out1_in2,out2_in3 : set_of_64items;
signal out3_in4,out4_in5 : set_of_64items;
signal out5_in6 : set_of_64items;

begin


sort32items1: entity work.merge32to32
port map(input_1items,input_2items,input_3items,input_4items,sorted1);

sort32items2: entity work.merge32to32
port map(input_5items,input_6items,input_7items,input_8items,sorted2);


stage6:
for i in 8*N/2-1 downto 0 generate
group1stage6: entity work.Comparator
port map(sorted1(i),sorted2(i),out1_in2(i),out1_in2(i+32));

check1stage6: if(i>=16) generate
group2stage6: entity work.Comparator
port map(out1_in2(i),out1_in2(i+16),out2_in3(i),out2_in3(i+16));
end generate;
check2stage6: if(i<16) generate
out2_in3(i)<=out1_in2(i);
out2_in3(i+48)<=out1_in2(i+48);
end generate;

check3stage6: if(i>=24) generate
group3stage6: entity work.Comparator
port map(out2_in3(i),out2_in3(i+8),out3_in4(i),out3_in4(i+8));
end generate;
check4stage6: if(i<24) generate
out3_in4(i)<=out2_in3(i);
out3_in4(i+40)<=out2_in3(i+40);
end generate;

check5stage6: if(i>=4 and i<8) generate
on_stage6: for j in 0 to 6 generate
group4stage5: entity work.Comparator
port map(out3_in4(j*8+i),out3_in4(j*8+i+4),out4_in5(j*8+i),out4_in5(j*8+i+4));
end generate on_stage6;
end generate;

check6stage6: if(i<4) generate
out4_in5(i)<=out3_in4(i);
out4_in5(i+60)<=out3_in4(i+60);
end generate;

check7stage6: if(i< 15) generate
on2_stage6: for k in 0 to 1 generate
group5stage6: entity work.Comparator
port map(out4_in5(2+i*4+k),out4_in5(2+i*4+k+2),out5_in6(2+i*4+k),out5_in6(2+i*4+k+2));
end generate on2_stage6;
end generate;

check8stage6: if(i<2) generate
out5_in6(i)<=out4_in5(i);
out5_in6(i+62)<=out4_in5(i+62);
end generate;

check9stage6: if(i<31) generate
check9stage6: entity work.Comparator
port map(out5_in6(1+i*2),out5_in6(1+i*2+1),sorted(1+i*2),sorted(1+i*2+1));
end generate;
end generate stage6;

sorted(0)<=out5_in6(0);
sorted(63)<=out5_in6(63);

end behavioral;


asked 1 min ago






How to have JavaScript read a value appended with CSS at a given ID


Vote count:

0




Before I get started on this abnormally weird question, lemme just say that I have never heard of the following hack being applied let alone conventionally discussed with any web programmers I know, and this is merely out of curiosity in the event that I'm wrong in my hypothesis that it cannot be done.


That being said, here's my question:



Using a customized CSS based off of the latest Bootswatch version (actually using Cerulean theme), is it possible to append text between hidden p tags AND have JavaScript read the value appended properly?



Extra info: When hardcoding a value into the HTML, JavaScript has NO problem reading the value. When appending however (using #element:after for instance), JavaScript is passing a null value, I figure because the CSS loads after the JavaScript has already checked to see what value is at that particular element ID.


Example Code:


HTML



<div id="hiddenSecrets" style="display:none;">
<p id="valueOne"></p>
<p id="valueTwo"></p>
</div>


CSS



#valueOne:after { content:"2048"; }


JavaScript reads the ID "valueOne" to be null.


Any help is appreciated.


Thanks!



asked 42 secs ago






Grab every 5th tag but only if it doesn't have any children?


Vote count:

0




Ok I'm recently learning CSS and wanted to figure something out for my site but cannot comprehend how to do this.


I want to garb every third li (beginning with the second li) except I dont want it if its either


1) Has any children


2) Has a class assigned to it.


Is this possible with css or javascript?


Thank you



<ol>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
.....
</ol>


asked 41 secs ago






Javascript shorthand OR operation


Vote count:

0




I have feeling this must be a duplicate, but I've been unable to find anything, probably due to different wording, or just because there really is nothing better.


I am generating kind of huge chunk of JS code, which "ORs" object properties with variables, while identifiers don't necessarily match. It looks like this (values are boolean):



a.borderline = a.borderline || borderline;
a.st1 = a.st1 || st;
a.ref64 = a.ref64 || ref;
...


To make it leaner I tried something like



a.st1 |= st;


but it makes a.st1 integer instead of boolean and I don't want to add another line with double negation to retype it back to boolean.


Using intuition I also tried ||=, which did not help :)


Is there any better (shorter) way of writing these commands?



asked 39 secs ago

Erlik

362





COALESCE in SQL problems?


Vote count:

0




I'm trying to use COALESCE in WHERE clause but may be is not the good keyword. If a field is equal to a specific value, I want this record if not I want the record with this field equal to null.



SELECT TOP 1 COL1, COL2, COL3
FROM TABLE1 WHERE COL2 = COALESCE(MY_SPECIFIC_VALUE, COL2) AND COL3 = '42'
AND COL1 = 3


Why I have no result? Because, I have a record with COL2 is null.



SELECT TOP 1 COL1, COL2, COL3 FROM TABLE1 WHERE COL2 = '42' AND COL1 = 3

COL1 COL2 COL3
3 NULL 42


I can try to that :



SELECT TOP 1 COL1, COL2, COL3
FROM TABLE1 WHERE (COL2 = MY_SPECIFIC_VALUE OR COL2 IS NULL) AND COL3 = '42'
AND COL1 = 3


But, what is the result returned? The smallest id? Or it is not specified?


Thx,



asked 2 mins ago

Nuz

13





extract a base directory from the output of ps


Vote count:

0




I am looking to extract a basedir from the output of ps -ef | grep classpath myprog.jar



root 20925 20886 1 17:41 pts/0 00:01:07 /opt/myprog/java/jre/bin -classpath myprog.jar


java is always a sub-dir under the basedir but the install path can vary from server to server e.g.


/usr/local/myprog/java/jre/bin


/opt/test/testing/myprog/java/jre/bin


So once i have my string how do I extract everything from before java until the beginning of the path ? i.e /opt/myprog


thanks



asked 1 min ago

eramm

114

1 Answer



Vote count:

0




Using grep -P:



grep -oP '\S+(?=/java)' <<< "$s"
/opt/myprog


answered 4 secs ago





transforming an xml node to xhtml using xslt


Vote count:

0




yet another xslt question;


I have some XML which looks like this:



<paragraph>
<para>
some random content
</para>

<para>
some more random content
</para>
</paragraph>


What I want to do is take the content of each of these nodes but not persist the nodes and I wondered if there is a way to concatenate this content together into a xsl variable.



asked 36 secs ago






Incremental saving of a UIDocument to improve write times


Vote count:

0




I am using a UIDocument to save a "file" which is really a collection of many files (images, audio, etc.).


In other words I'm using [[NSFileWrapper alloc] initDirectoryWithFileWrappers:wrappers] in my UIDocument subclass implementation of contentsForType.


The problem is that this takes a LONG time when there are many large files. There is no good reason I should be saving all of the files every time, though. Many of these files are images, etc. ("assets") which act as supporting files for my document, and are not changed frequently. Thus, my goal is to find some way to incrementally save the document: to only write the assets which have been changed since the document was opened.


Here is my current implementation of UIDocument.contentsForType:



- (id)contentsForType:(NSString *)typeName error:(NSError *__autoreleasing *)outError {
NSMutableDictionary * wrappers = [NSMutableDictionary dictionary];

NSDictionary *metadataDict = [self.metadata packDetails]?:@{};
NSData *metadata = [NSJSONSerialization dataWithJSONObject:metadataDict options:NSJSONWritingPrettyPrinted error:nil];
NSFileWrapper *metadataWrapper = [[NSFileWrapper alloc] initRegularFileWithContents:metadata];
[wrappers setObject:metadataWrapper forKey:NOTE_METADATA_FILENAME];

for(NSString *assetFilename in self.metadata.assets) {
NSData *data = [self dataForAsset:assetFilename];
if(data.length) {
NSFileWrapper * wrapper = [[NSFileWrapper alloc] initRegularFileWithContents:data];
[wrappers setObject:wrapper forKey:assetFilename];
}
}

NSFileWrapper * fileWrapper = [[NSFileWrapper alloc] initDirectoryWithFileWrappers:wrappers];

return fileWrapper;

}


asked 33 secs ago






ruby difference between last range and the next first range


Vote count:

0




I have a range as follows:



my_range = [1297134..1328348, 1381732..1382716, 1406478..1408262, 1425452..1427966, 1607341..1609354, 1616388..1616625, 1844576..1846076, 1847450..1847672]


I like to loop through all these ranges and find the difference between the last range and the next first range, so for example:



1381732 - 1328348
1406478 - 1382716
etc..


I know there is the .first and .last methods but I have no idea how to state the the last range and the next first range. Would appreciate some help.


Thanks



asked 2 mins ago






How do we auto-verify an email address is Amazon SES using their API?


Vote count:

0




Is there a way we can create a simple HTML button that on-click feeds an input email address (via a form field) to the Amazon SES API to verify a new address? Rather than having to manually login and verify people one by one in AWS?



asked 3 mins ago






HTML CSS DIV Overflow


Vote count:

-1




One of my divs scrolls under a larger screen size. I wandered if instead of getting a scroll bar (overflow:hidden removes the extra content, I want it there), I want the element to get bigger but instead of scrolling, just make itself larger and ignore the fact that the rest of the page will be shorter. Make sense? –



asked 1 min ago






Use of "seeds" option from train() function in caret


Vote count:

0




I have a question regarding the seeds options in the train() fonction from the caret package. This option is supposed to ensure that the samples used by different process in a parallelized cross-validation are consistent across the workers.


Here is an example of the creation of a seeds argument :



#create a list of seed, here change the seed for each resampling
set.seed(123)
seeds <- vector(mode = "list", length = 11)#length is = (n_repeats*nresampling)+1
for(i in 1:10) seeds[[i]]<- sample.int(n=1000, 3) #(3 is the number of tuning parameter, mtry for rf, here equal to ncol(iris)-2)

seeds[[11]]<-sample.int(1000, 1)#for the last model

#control list
myControl <- trainControl(method='cv', seeds=seeds, index=createFolds(iris$Species))


I can't get why so many arguments (10*3+1) are necessary to setup the folds. For me, the same folds are used by the models which evaluate each parameters and I really don't understand the need of the 14th parameter. How all these parameters are used by the workers ? I couldn't find any information in the documentation.


Thank you.



asked 53 secs ago

Alex

11





Google Maps and WatchPosition() refreshing map


Vote count:

0




I am still learning to use google maps and watch position. I have found some code online that I am using to learn but as I test it out with Chrome both on my desktop and my android phone I notice that the map refreshes every time that it collects a new position. Is it possible to have the location refresh without the need to refresh the whole page?



<!DOCTYPE html>
<html>
<head>
<script src="http://ift.tt/oRGprm"></script>
<script>

jQuery(window).ready(function(){
gMapInit();
jQuery("#watchPositionBtn").click(initiate_watchlocation);
jQuery("#stopWatchBtn").click(stop_watchlocation);
});
function gMapInit(){
var google_tile = "http://ift.tt/1hS8Zgu"
jQuery("#googleMap").html(
jQuery(document.createElement("img")).attr("src", google_tile)
);
}
var watchProcess = null;

function initiate_watchlocation() {
if (watchProcess == null) {
watchProcess = navigator.geolocation.watchPosition(handle_geolocation_query, handle_errors);
}
}

function stop_watchlocation() {
if (watchProcess != null)
{
navigator.geolocation.clearWatch(watchProcess);
watchProcess = null;
}
}

function handle_errors(error)
{
switch(error.code)
{
case error.PERMISSION_DENIED: alert("user did not share geolocation data");
break;

case error.POSITION_UNAVAILABLE: alert("could not detect current position");
break;

case error.TIMEOUT: alert("retrieving position timedout");
break;

default: alert("unknown error");
break;
}
}

function handle_geolocation_query(position) {
var text = "position.coords.latitude: " + position.coords.latitude + "<br/>" +
"position.coords.longitude: " + position.coords.longitude + "<br/>" +
"position.coords.altitude: " + position.coords.altitude + "<br/>" +
"position.coords.accuracy(meters): " + position.coords.accuracy + "<br/>" +
"position.coords.altitudeAccuracy(meters): " + position.coords.altitudeAccuracy + "<br/>" +
"position.coords.heading: " + position.coords.heading + "<br/>" +
"position.coords.speed: " + position.coords.speed + "<br/>" +
"position.timestamp: " + new Date(position.timestamp);
jQuery("#APIReturnValues").html(text);
jQuery("#APIReturnValues").css("border","3px solid green");

var image_url = "http://ift.tt/R2SqEo" + position.coords.latitude + ',' + position.coords.longitude +
"&zoom=18&size=600x800&markers=color:blue|label:S|" + position.coords.latitude + ',' + position.coords.longitude;

jQuery("#googleMap").html(
jQuery(document.createElement("img")).attr("src", image_url)
);
}
</script>
</head>
<body>
<div>
<button id="watchPositionBtn" >Watch Current Position</button>
<button id="stopWatchBtn" >Stop Watch Position</button>
</div>
<div id="APIReturnValues"></div>
<div id="googleMap" style=" padding:1px; border:1px solid; height:400px; width:300px;">
</div>
</body>
</html>


asked 1 min ago






how is Orion context data persisted in Cosmos?


Vote count:

0




I've heard about a connector persisting Orion context data in Cosmos in order to create a historical view of such data.


What's the name of such connector and where can I find documentation about it? What's the format of the persisted data? Where is the data stored within Cosmos?



asked 58 secs ago






how can I stay in the same page when user insert null value in search box


Vote count:

0




I have a Header, which I include it in every page, that contain search when the user enter value it will display the result but when he/she but null value in the text box it display all the result in the database how can I prevent that and stay in the same page where he/she is


--- HTML---



<form action="search.php" method="post">
<input type="search" placeholder=" search..."name="data" style=" margin:30px 0px 0px 0px; ">
<input type="submit" style="visibility:hidden" name="search"/>
</form>


--- php ---



$search=$_POST['data'];

$data2 = mysql_query("select * from project,person where project.projectname LIKE '%$search%' and person.personstatus=1 and project.status='submitted' and project.personid=person.personid") or die(mysql_error());

if (mysql_num_rows($data2)){
echo '<div style="width:1170px;min-height:100%; margin:20px 90px 0px 0px;
display:inline-block; background-color:#fff;">
<h2 style="color:rgb(58,147,231);font-size:20px;"> Project </h2> ';
while($info = mysql_fetch_array( $data2 ))
{
$projectid=$info['projectid'];
$img=$info['imgProject'];
$proName=$info['projectname'];
$type=$info['projecttype'];
$person=$info['personid'];
$personname=$info['personname'];

echo '<a href="project.php?projectid='.$projectid.'"><div class="note" style=" background-color:#E6E6E6; display:inline-block;width:200px; height:250px; margin-left:30px;">';
echo '<center><h4 style="color:rgb(58,147,231);">'.$proName.'</h4>';
echo'<img src="'.$img.'" width="200" height="160"><br>';
echo'<b>Project name : </b>'.$personname.'<br>';
echo'<b>Project type : </b>'.$type.'<br>';

echo' </div></a></center>';
}
}
else {
$errors[]="NO result found";
}
echo '</div>';


I hope you can help me solve this problem



asked 1 min ago






matlab array elements that meet a condition no loop


Vote count:

0




I have an array of elements and 2 other arrays

I'm doing something like this:



a=[1 3 2 45 4 23 16];
b=[3 9 1 27 33 50 5];
m=100;
k=linspace(min(a),max(a),m);
res=zeros(m,1);
for i=1:m
res(i) = sum((a < k(i))*(b < k(i)));
end


Is there any way to get the same result with no loops?



asked 42 secs ago






Getting secured cookies from a child window with phonegap


Vote count:

0




I try to get secure cookies from a child window.


I do this :



var authWindow = window.open("https://"+externUrl, '_blank'/*, 'location=yes, toolbar=no, width=400, height=400'*/);

setInterval(function(){
console.log(authWindow.document.cookie);
}, 1000);


But it only print unsecured cookies.


enter image description here


While a cookie named JSESSIONID (the one I need) exists :


enter image description here


If someone knows how to get it. With pure javascript or with cordova plugin, I would be glad :) On cordova I use InAppBrowser



asked 38 secs ago

Anc Ainu

1,337





Conversion of console app code to Windows Form code in VB


Vote count:

0




every one. I humbly want to ask for your support on this. I am doing my best trying to learn the Google Drive SDK and have followed all the steps provided in the video as well as on the page: http://ift.tt/1c2jasq


I have however come to halt as I realize the sample code provided is CSharp and no VB version. I've tried converting it to VB using the Telerik converter but the results are not encouraging as I still see curly brackets in there and what not. I know I see those,because its a console App and I will be sincere that Im not quite good at console app code.


I therefore humbly seek assistance on how to convert this already converted C# to VB code to a Windows Form version. Thank you.



Namespace GoogleDriveSamples
Class DriveCommandLineSample
Private Shared Sub Main(args As String())
Dim credential As UserCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(New ClientSecrets() With { _
Key .ClientId = "CLIENT_ID_HERE", _
Key .ClientSecret = "CLIENT_SECRET_HERE" _
}, New () {DriveService.Scope.Drive}, "user", CancellationToken.None).Result

' Create the service.
Dim service = New DriveService(New BaseClientService.Initializer() With { _
Key .HttpClientInitializer = credential, _
Key .ApplicationName = "Drive API Sample" _
})

Dim body As New File()
body.Title = "My document"
body.Description = "A test document"
body.MimeType = "text/plain"

Dim byteArray As Byte() = System.IO.File.ReadAllBytes("document.txt")
Dim stream As New System.IO.MemoryStream(byteArray)

Dim request As FilesResource.InsertMediaUpload = service.Files.Insert(body, stream, "text/plain")
request.Upload()

Dim file As File = request.ResponseBody
Console.WriteLine("File id: " + file.Id)
Console.WriteLine("Press Enter to end this process.")
Console.ReadLine()
End Sub
End Class
End Namespace


asked 19 secs ago






Making a batch file


Vote count:

0




I've written a batch file to close few applications. One of my application asks confirmation message and requires to click on 'Yes' to close it. Is there any command that close these kind of application via batch file?



asked 1 min ago






Detect "Delay write failed" occurence


Vote count:

-1




I am loosing my patience with "delay write failed" errors. It silently disconnects the database from the application so nothing gets saved in the database while using it. Is there a way to detect the occurrence itself so I can flash a warning ? Or perhaps monitoring the connection itself for a disconnection ? Everyone seems to miss the balloon tip from the Windows XP so I figured to flash a more visible warning that the application must be restarted. It seems Microsoft has found a way to force people to upgrade....



asked 1 min ago






SASS IE and Media queries (jakearchibald) with ruby command


Vote count:

0




Using http://ift.tt/1rENssO This document lets IE ignore media queries, but since I'm new to sass I'm not too sure how the file structure works. All I know is _layout.scss is the main file where I'll do regular sass.


Here is the file structure:



assets/
css/
_global.scss
_layout.scss
_utils.scss

all-old-ie.css
all-old-ie.scss

all.css
all.scss


How are they all working together?


And what will my command prompt ruby look like?


eg sass --watch _layout.scss:all.css Thanks in advance,



asked 1 min ago






Monitoring a crawler


Vote count:

0




I have a crawler written in Python, I was wondering what the proper way is to monitor the crawler?


If the crawler is running on the server, how do I know when it produces an error or even crashes?



asked 1 min ago






Login, Navigate and Retrieve data behind a proxy with Python


Vote count:

0




I want, with a python script, to be able to login a website and retrieve some data. This behind my company's proxy.


I know that this question seems a duplicate of others that you can find searching, but it isn't.


I already tried using the proposed solutions in the responses to those answers but they didn't work... I don't only need a piece of code to login and get a specific webpage but also some "concepts" behind how all this mechanism works.


Here is a description of what I want to be able to do:


Log into a website > Get to page X > Insert data in some form of page X and push "Calculate" button > Capture the results of my query


Once I have the results I'll see how to sort how the data.


How can I achieve this behind a proxy? Every time I try to use "request" library to login it doesn't work saying I am unable to get page X since I did not authenticate... or worst, I am even unable to get to that side because I didn't set up the proxy before.



asked 1 min ago

Con7e

121





change data source of the jasper report from php


Vote count:

0




I am using jasper reports with php. http://ift.tt/1iC3HS4 .I was able to make connection and show the report in php. I am using yii with postgresql. The problem is I am using multiple databases. I am using separate database for each user. But in Jasper server the data source is given for a report during creation. Now I want to change the data source of the report from php. Please help.



asked 23 secs ago






HTML/CSS: strange behaviour in Chrome code inspector


Vote count:

0




On this page, towards the bottom of the page is a horizontal menu and some small text, just below the photo of the London bridge.


This text is displayed inside #footer-widgets, which has a CSS margin-top of 14px.


When I select #footer-widgets in Chrome code inspector, the selection extends to the top of the page. However, #footer-widgets begins just below the photo of the bridge.


Why isn't the CSS being implemented properly, and why do I see #footer-widgets' selection extend to the top of the screen in Chrome code inspector.



asked 1 min ago

Steve

184





UPDATE SET gets MySQL error


Vote count:

0




Hi i have a reads counter, but i always get an MySQL error:


MySQL Error: 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 ''reads') VALUES ('2') WHERE id = '20'' at line 1



$reads = $row['reads']+1;
$newsid = $row['id'];

if(!$query = $db->query("UPDATE cmsss_news_articles SET reads = '$reads' WHERE id = '$newsid'")) {
echo "<center><b>Error, cant update row</b></center>";
}


Can you please help me where is the mistake?



asked 2 mins ago


1 Answer



Vote count:

0




reads is a reserved word in MySQL. Escape it with backticks.



answered 13 secs ago

juergen d

70.4k




Why is `int` datatype not mandatory to be mentioned for function arguments in the function definition?


Vote count:

0




Recently I went through some code similar to this: (The code is proprietary, and hence adding a similar one)



#include<stdio.h>

void test_it(var)
{
printf("%d\n",var);
}

int main()
{
test_it(67);
return 0;
}


The arguments of test_it do not have datatype mentioned.


I compiled it as gcc test_it.c ... : Surprisingly No Warnings/Error


Again I compiled using: gcc -Wall test_it.c ... : No Warnings/Error yet again


(Getting more aggressive now...)


I compiled it again using: gcc -Wall -Wextra test_it.c ... :

warning: type of ‘var’ defaults to ‘int’ finally I got the warning.


I tried using multiple arguments as:



void test_it(var1, var2)
{
printf("%d\n%d\n",var1, var2);
}

int main()
{
test_it(67,76);
return 0;
}


Same beahavior!!


Also I tried this:



void test_it(var)
{
printf("%d\n",var);
}

main() // Notice that no `int` there
{
test_it(67);
return 0;
}


This code gave warning with -Wall option only.


So my question is why the int datatype is not mandatory for function arguments in function definition?



asked 44 secs ago






Smooth scroll down of submenu on main menu hover using css


Vote count:

0




I am trying to get a smooth drop-down transition to the sub-menu items on hovering the main-menu item. Initially the sub-menu is hidden and on hover of main-menu item the sub-menu displays, but not a smooth drop-down. Here is a fiddle http://ift.tt/1n0Bfyt


No Jquery/Javascript please


HTML



<ul class="main-menu">
<li> <a href="">Menu 1</a>
<ul class="sub-menu">
<li >Sub menu 1.1</li>
<li>Sub menu 1.2</li>
<li>Sub menu 1.3</li>
</ul>
</li>
<li><a href="">Menu 2</a>
<ul class="sub-menu">
<li>Sub menu 2.1</li>
<li>Sub menu 2.2</li>
<li>Sub menu 2.3</li>
</ul>
</li>
<li><a href="">Menu 3</a>
<ul class="sub-menu">
<li>Sub menu 3.1</li>
<li>Sub menu 3.2</li>
<li>Sub menu 3.3</li>
</ul>
</li>
<li><a href="">Menu 4</a>
<ul class="sub-menu">
<li>Sub menu 4.1</li>
<li>Sub menu 4.2</li>
<li>Sub menu 4.3</li>
<li>Sub menu 4.4</li>
</ul>
</li>
<li><a href="">Menu 5</a>
<ul class="sub-menu">
<li>Sub menu 5.1</li>
<li>Sub menu 5.2</li>
<li>Sub menu 5.3</li>
</ul>
</li>
</ul>


CSS



ul{
list-style:none;
padding:0;
}
a{
text-decoration:none;
display:block;
}

.main-menu{
width:50%;
margin-left:15%;
}
.sub-menu{
display:none;
background-color:#D7D5D5;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
transition: all 0.5s ease;
}

.sub-menu li{
padding: 3px 8px;
}

.main-menu > li > a{
background-color:#4D4A4A;
color:#fff;
border-bottom: 1px solid #3D3B3B;
border-radius:2px;
padding: 5px 10px;
font-size:18px;
}

.main-menu li:hover > ul{
display:block;
}


asked 2 mins ago






Grab focus to embedded window inside Gtk::Socket


Vote count:

0




I have embedded gvim inside a Gtk::Socket which is placed in a Gtk::Box, how can I grab focus to the embedded gvim window so that I achieve the same as actually pointing and clicking in the embedded window?


Using ->grab_focus() on the Gtk::Socket widget does not have any effect.



asked 1 min ago

gauteh

2,593





How to avoid the syntax check on string in Pycharm


Vote count:

0




Where is the option to disable the syntax check on the strings? I hate the jagged line under my comments and strings.





asked 1 min ago






Jasper Reports new line


Vote count:

0




I'm new in Jasper Reports. I use iReport 4.5 in NetBeans. I need create some text and insert into text new variable. All works, but new line doesn't create. Tell me please, how to solve it? Thanks!


<?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://ift.tt/1bXYvZE" xmlns:xsi="http://ift.tt/ra1lAU" xsi:schemaLocation="http://ift.tt/1bXYvZE http://ift.tt/18OQfHh" name="jasper_report_template" pageWidth="595" pageHeight="842" columnWidth="515" leftMargin="40" rightMargin="40" topMargin="50" bottomMargin="50"> <property name="ireport.zoom" value="1.3310000000000004"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <parameter name="ReportTitle" class="java.lang.String"/> <parameter name="Author" class="java.lang.String"/> <queryString> <![CDATA[]]> </queryString> <field name="country" class="java.lang.String"> <fieldDescription><![CDATA[country]]></fieldDescription> </field> <field name="name" class="java.lang.String"> <fieldDescription><![CDATA[name]]></fieldDescription> </field> <title> <band height="240" splitType="Stretch"> <textField isBlankWhenNull="true" bookmarkLevel="1"> <reportElement x="0" y="0" width="515" height="27"/> <textElement textAlignment="Center"> <font size="10" pdfEncoding="Cp1251"/> </textElement> <textFieldExpression> <![CDATA["Some text "+ $P{ReportTitle} +" my name +"<br/>"+ is "]]> </textFieldExpression> <anchorNameExpression><![CDATA["Title"]]></anchorNameExpression> </textField> </band> </title> <columnHeader> <band height="24" splitType="Stretch"/> </columnHeader> <detail> <band height="21" splitType="Stretch"/> </detail> </jasperReport>



asked 43 secs ago






Creating a task for 1 second


Vote count:

0




I am trying to configure a crontab task that every second loads me a '.php' file in another server. That means from server1 I call a file in server2.


So server1 do a crontab tast like 0 * * * * wget http://ift.tt/1iBz1QI


file2, a php file, has a while(true){//tasks; sleep(1)}


My question is if this is the best way to do what I want and in case that isn't the best, tell me the right one


Thanks in advice!


P.D: I haven't any knowledge in shell programming.



asked 2 mins ago






JQuery AutoComplete Selected Value Undefined in Update Mode


Vote count:

0




I Implemented JQuery Autocomplete ,But In Insert Mode its Working fine,But In Update Mode i am Getting Undefined. Here i Wrote my Code .So Please Help Me anyone. This is the Code. $(document).ready(function () { $.ajaxSetup({ cache: false }); var GetListUrl = '/Manager/GetManagersList'; Managers("ParentName");

function Managers(groupCtrlId) { $('#' + groupCtrlId).autocomplete({ source: function (request, response) { $.ajax({ url: GetListUrl, data: "{ 'prefixText': '" + request.term + "' }", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", success: function (data) { response(data) }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert('Error occured while autocomplete'); } }); }, select: function (event, ui) { $("#" + this.id).val(ui.item.Text); $("#" + this.id.replace("Name", "Id")).val(ui.item.Value); return false; }, minLength: 1, change: function (event, ui) { $("#" + this.id).val(ui.item.Text); $("#" + this.id.replace("Name", "Id")).val(ui.item.Value); return false; //ProductGroupOnChange(this.id.replace("Name", "Id")); } }) .data("autocomplete")._renderItem = function (ul, item) {

return $("


").attr('class', 'autocompleteresults').append($("" + item.Text + "").html(item.Text)).appendTo(ul); }; } });


asked 42 secs ago






Mixed Logit fitted probabilities in RSGHB


Vote count:

0




My question has to do with using the RSGHB package for predicting choice probabilities per alternative by applying mixed logit models (variation across respondents) with correlated coefficients. I understand that the choice probabilities are simulated on an individual level and in order to get preference share an average of the individual shares would do. All the sources I have found treat each prediction as a separate simulation which makes the whole process cumbershome if many predictions are needed. Since one can save the respondent specific coefficient draws wouldn't it be faster to simply apply the logit transform to each each (vector of) coefficient draw? Once this is done new or excisting alternatives could be calculated faster than rerunning a whole simulation process for each required alternative. For the time being using a fitted() approach will not help me understand how prediction actually works. Thanks in advance for any feedback.



asked 1 min ago






Processing of OpenStreetMaps (OSM) in c++


Vote count:

0




I want to process OSM files and the best would be to do it all within C++. My goal is to be able to get grayscale maps, eventually I am considering also clustered recognized shapes (circles for round buildings, long 'thick' splines for roads, rectangulars etc.)


Anyway, the question is to you, can you push me into proper direction, what shall I use to be able to process .osm for my purpose?


Never worked with them before, neither with too much with various c++ libraries, so it'd take me lot of time before I on my own recognize where to go. I am aware of processes of feature detection and description, yet don't know if they also apply in this case.


Please help me out, regards.



asked 49 secs ago

beginh

304





How to receive the data from gimbal beacon in gimbal format


Vote count:

0




I have a gimbal beacon. How can i receive data which the gimbal data is advertising? I dont want to configure the gimbal to iBeacon mode. which app should i download for receiving the data from the gimbal beacon.



asked 53 secs ago






mardi 29 avril 2014

Get reference of parent browser from java applet


Vote count:

0




Is this possible to get reference of parent browser in which applet is embed from applet code. I need to take control on browser from applet .Controls like catching key events on browser other text inputs (not applet) .



asked 32 secs ago






Real time audio streaming to mobile device - dynamic playback speed


Vote count:

0




Here's the scenario:


I am using Nicecast (on OS X) to encode an MP3 stream (from microphone input), and sending it to an Ubuntu computer running Icecast2 streaming server. The streaming server is connected just to my LAN (not the internet) via Wi-Fi router. The stream is listened to by: iOS devices, Android devices, Windows Phones, Windows computers, Mac computers, etc. (most use VLC).


The latency from the microphone pickup to the audio playing through the client's speakers is about 1-2 seconds. This is ok for my application.


However, when there is network congestion (or the client's CPU is busy doing something else, or any number of reasons), the stream stops (breaks) for a few seconds, then when all is back to "normal", Icecast sends a blast of data to get caught back up to real time again. The client's buffer receives this blast of data and stores it (as it should) and starts playing again where it left off (which is also good, because it means no audio content was lost or missed, which is what I need for my application). But now the latency is about 4-5 seconds.


I need to keep the delay to around 1-2 seconds. So I thought if I could just speed up the playback to 1.5x, for example, after a few seconds, we'd be back to the 1-2 second latency. In other words, if buffer has 'x' amount of data in it, playback at 1.0x speed. If buffer reaches 'y' amount of data or more, playback at 1.5x speed until buffer is back to 'x' amount of data. A kind of "dynamic playback speed" (is there a better (or correct) name for this?).


So, my questions:



  1. Could I use VLC (client) to provide this solution?

  2. Are there other stream clients that could handle this well? (especially ones that work on multiple platforms)

  3. Or are there other streaming platforms that handle this automatically, or with a little configuration?


Any thoughts & comments would be much appreciated! Thanks!



asked 1 min ago






MouseEnter MouseLeave event to hide and show button makes button non responding


Vote count:

0





private void panelControl1_MouseEnter(object sender, EventArgs e)
{
button2.Show();
}

private void panelControl1_MouseLeave(object sender, EventArgs e)
{
button2.Hide();
}


enter image description here


When I enter the panel, button shows up but clicking on button doesn't work. Above are the image and code.



asked 18 secs ago






Update raw query is not working in django


Vote count:

0




Here i passing value by post request from form and and want to update only notes field from TestcaseCache table pk is id of TestcaseCache table



def saveReviewTestcase(request,self,test_id):

if request.method == 'POST':
print test_id
input_notes=request.POST.get('textarea')
cursor = connection.cursor()
cursor.execute("UPDATE TestcaseCache SET id= test_id WHERE notes = %s", [self.input_notes])
row = cursor.fetchone()
print row


asked 42 secs ago






Tic Tac Toe Image Display


Vote count:

0




I have created a client/server tic tac toe game and I am now having trouble is displaying the image when you click on a square. I am using Eclipse and I have both the images in the SRC folder. Have any ideas why the images will not show up?


Server



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
* A server for a network multi-player tic tac toe game. Modified and
* extended from the class presented in Deitel and Deitel "Java How to
* Program" book. I made a bunch of enhancements and rewrote large sections
* of the code. The main change is instead of passing *data* between the
* client and server, I made a TTTP (tic tac toe protocol) which is totally
* plain text, so you can test the game with Telnet (always a good idea.)
* The strings that are sent in TTTP are:
*
* Client -> Server Server -> Client
* ---------------- ----------------
* MOVE <n> (0 <= n <= 8) WELCOME <char> (char in {X, O})
* QUIT VALID_MOVE
* OTHER_PLAYER_MOVED <n>
* VICTORY
* DEFEAT
* TIE
* MESSAGE <text>
*
* A second change is that it allows an unlimited number of pairs of
* players to play.
*/
public class TicTacToeServer {

/**
* Runs the application. Pairs up clients that connect.
*/
public static void main(String[] args) throws Exception {
ServerSocket listener = new ServerSocket(8901);
System.out.println("Tic Tac Toe Server is Running");
try {
while (true) {
Game game = new Game();
Game.Player playerX = game.new Player(listener.accept(), 'X');
Game.Player playerO = game.new Player(listener.accept(), 'O');
playerX.setOpponent(playerO);
playerO.setOpponent(playerX);
game.currentPlayer = playerX;
playerX.start();
playerO.start();
}
} finally {
listener.close();
}
}
}

/**
* A two-player game.
*/
class Game {

/**
* A board has nine squares. Each square is either unowned or
* it is owned by a player. So we use a simple array of player
* references. If null, the corresponding square is unowned,
* otherwise the array cell stores a reference to the player that
* owns it.
*/
private Player[] board = {
null, null, null,
null, null, null,
null, null, null};

/**
* The current player.
*/
Player currentPlayer;

/**
* Returns whether the current state of the board is such that one
* of the players is a winner.
*/
public boolean hasWinner() {
return
(board[0] != null && board[0] == board[1] && board[0] == board[2])
||(board[3] != null && board[3] == board[4] && board[3] == board[5])
||(board[6] != null && board[6] == board[7] && board[6] == board[8])
||(board[0] != null && board[0] == board[3] && board[0] == board[6])
||(board[1] != null && board[1] == board[4] && board[1] == board[7])
||(board[2] != null && board[2] == board[5] && board[2] == board[8])
||(board[0] != null && board[0] == board[4] && board[0] == board[8])
||(board[2] != null && board[2] == board[4] && board[2] == board[6]);
}

/**
* Returns whether there are no more empty squares.
*/
public boolean boardFilledUp() {
for (int i = 0; i < board.length; i++) {
if (board[i] == null) {
return false;
}
}
return true;
}

/**
* Called by the player threads when a player tries to make a
* move. This method checks to see if the move is legal: that
* is, the player requesting the move must be the current player
* and the square in which she is trying to move must not already
* be occupied. If the move is legal the game state is updated
* (the square is set and the next player becomes current) and
* the other player is notified of the move so it can update its
* client.
*/
public synchronized boolean legalMove(int location, Player player) {
if (player == currentPlayer && board[location] == null) {
board[location] = currentPlayer;
currentPlayer = currentPlayer.opponent;
currentPlayer.otherPlayerMoved(location);
return true;
}
return false;
}

/**
* The class for the helper threads in this multithreaded server
* application. A Player is identified by a character mark
* which is either 'X' or 'O'. For communication with the
* client the player has a socket with its input and output
* streams. Since only text is being communicated we use a
* reader and a writer.
*/
class Player extends Thread {
char mark;
Player opponent;
Socket socket;
BufferedReader input;
PrintWriter output;

/**
* Constructs a handler thread for a given socket and mark
* initializes the stream fields, displays the first two
* welcoming messages.
*/
public Player(Socket socket, char mark) {
this.socket = socket;
this.mark = mark;
try {
input = new BufferedReader(
new InputStreamReader(socket.getInputStream()));
output = new PrintWriter(socket.getOutputStream(), true);
output.println("WELCOME " + mark);
output.println("MESSAGE Waiting for opponent to connect");
} catch (IOException e) {
System.out.println("Player died: " + e);
}
}

/**
* Accepts notification of who the opponent is.
*/
public void setOpponent(Player opponent) {
this.opponent = opponent;
}

/**
* Handles the otherPlayerMoved message.
*/
public void otherPlayerMoved(int location) {
output.println("OPPONENT_MOVED " + location);
output.println(
hasWinner() ? "DEFEAT" : boardFilledUp() ? "TIE" : "");
}

/**
* The run method of this thread.
*/
public void run() {
try {
// The thread is only started after everyone connects.
output.println("MESSAGE All players connected");

// Tell the first player that it is her turn.
if (mark == 'X') {
output.println("MESSAGE Your move");
}

// Repeatedly get commands from the client and process them.
while (true) {
String command = input.readLine();
if (command.startsWith("MOVE")) {
int location = Integer.parseInt(command.substring(5));
if (legalMove(location, this)) {
output.println("VALID_MOVE");
output.println(hasWinner() ? "VICTORY"
: boardFilledUp() ? "TIE"
: "");
} else {
output.println("MESSAGE ?");
}
} else if (command.startsWith("QUIT")) {
return;
}
}
} catch (IOException e) {
System.out.println("Player died: " + e);
} finally {
try {socket.close();} catch (IOException e) {}
}
}
}
}


Client



import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class TicTacToeClient {

private JFrame frame = new JFrame("Tic Tac Toe");
private JLabel messageLabel = new JLabel("");
private ImageIcon icon;
private ImageIcon opponentIcon;

private Square[] board = new Square[9];
private Square currentSquare;

private static int PORT = 8901;
private Socket socket;
private BufferedReader in;
private PrintWriter out;

/**
* Constructs the client by connecting to a server, laying out the
* GUI and registering GUI listeners.
*/
public TicTacToeClient(String serverAddress) throws Exception {

// Setup networking
socket = new Socket(serverAddress, PORT);
in = new BufferedReader(new InputStreamReader(
socket.getInputStream()));
out = new PrintWriter(socket.getOutputStream(), true);

// Layout GUI
messageLabel.setBackground(Color.lightGray);
frame.getContentPane().add(messageLabel, "South");

JPanel boardPanel = new JPanel();
boardPanel.setBackground(Color.black);
boardPanel.setLayout(new GridLayout(3, 3, 2, 2));
for (int i = 0; i < board.length; i++) {
final int j = i;
board[i] = new Square();
board[i].addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
currentSquare = board[j];
out.println("MOVE " + j);}});
boardPanel.add(board[i]);
}
frame.getContentPane().add(boardPanel, "Center");
}

public void play() throws Exception {
String response;
try {
response = in.readLine();
if (response.startsWith("WELCOME")) {
char mark = response.charAt(8);
icon = new ImageIcon(mark == 'X' ? "X.png" : "O.png");
opponentIcon = new ImageIcon(mark == 'X' ? "O.png" : "X.png");
frame.setTitle("Tic Tac Toe - Player " + mark);
}
while (true) {
response = in.readLine();
if (response.startsWith("VALID_MOVE")) {
messageLabel.setText("Valid move, please wait");
currentSquare.setIcon(icon);
currentSquare.repaint();
} else if (response.startsWith("OPPONENT_MOVED")) {
int loc = Integer.parseInt(response.substring(15));
board[loc].setIcon(opponentIcon);
board[loc].repaint();
messageLabel.setText("Opponent moved, your turn");
} else if (response.startsWith("VICTORY")) {
messageLabel.setText("You win");
break;
} else if (response.startsWith("DEFEAT")) {
messageLabel.setText("You lose");
break;
} else if (response.startsWith("TIE")) {
messageLabel.setText("You tied");
break;
} else if (response.startsWith("MESSAGE")) {
messageLabel.setText(response.substring(8));
}
}
out.println("QUIT");
}
finally {
socket.close();
}
}

private boolean wantsToPlayAgain() {
int response = JOptionPane.showConfirmDialog(frame,
"Want to play again?",
"Tic Tac Toe is Fun Fun Fun",
JOptionPane.YES_NO_OPTION);
frame.dispose();
return response == JOptionPane.YES_OPTION;
}

/**
* Graphical square in the client window. Each square is
* a white panel containing. A client calls setIcon() to fill
* it with an Icon, presumably an X or O.
*/
static class Square extends JPanel {
JLabel label = new JLabel((Icon)null);

public Square() {
setBackground(Color.white);
add(label);
}

public void setIcon(Icon icon) {
label.setIcon(icon);
}
}

/**
* Runs the client as an application.
*/
public static void main(String[] args) throws Exception {
while (true) {
String serverAddress = (args.length == 0) ? "localhost" : args[1];
TicTacToeClient client = new TicTacToeClient(serverAddress);
client.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
client.frame.setSize(240, 160);
client.frame.setVisible(true);
client.frame.setResizable(false);
client.play();
if (!client.wantsToPlayAgain()) {
break;
}
}
}
}


asked 46 secs ago