Tuesday, 1 October 2013

Is a game view "stack" really a Stack? – gamedev.stackexchange.com

Is a game view "stack" really a Stack? – gamedev.stackexchange.com

Given the academic definition of a Stack as "A data structure where items
are added in a FILO manner and accessed in such a way that only the top
item may be examined or removed to be modified." Game …

Monday, 30 September 2013

how to explain prime numbers to children – math.stackexchange.com

how to explain prime numbers to children – math.stackexchange.com

My little cousin (12year) asked me about how emails are encrypted and I
want to answers her in such a way she understands it. This is diffuct, but
I am happy with teaching the definition of a prime …

Safe to leave oven on at 180F while at work to cook ribs=?iso-8859-1?Q?=3F_=96_cooking.stackexchange.com?=

Safe to leave oven on at 180F while at work to cook ribs? –
cooking.stackexchange.com

I'm currently at work and I'm having a little panic attack. I followed a
recipe that require the ribs to be wrapped in foil and cooked at 180F for
9hours. I left about 30 minutes ago and for who ...

CSS - using ':before' to place an image not appearing in Firefox

CSS - using ':before' to place an image not appearing in Firefox

I'm trying to position a temporary 'beta' ribbon image positioned in the
top left of a wordpress based site.
The following code functions as intended in Chrome and IE. In Firefox,
nothing is appearing:
#page-wrapper:before
{
width: 50px;
content: " ";
background: url(wp-content/uploads/2013/09/betaribbon2.png) no-repeat;
position: absolute;
height: 50px;
pointer-events: none;
}
Can anyone shed light on what I'm doing wrong?
Thanks,
LB

Is it possible to load multiple instances of yepnope on a single page?

Is it possible to load multiple instances of yepnope on a single page?

This question was already sort of asked here, but it does not have a
definitive answer. The comments there state that yepnope will not load the
same script twice, so you don't have to worry about that.
But what I'm wondering is whether it is possible to load multiple
instances of yepnope. Because I want to use it to asynchronously load
scripts in both the <head> and before the </body>.

Sunday, 29 September 2013

Segmentation Fault error - Implementing Stack using Linked lists

Segmentation Fault error - Implementing Stack using Linked lists

I am currently in a University program studying Data Structures in C and I
am having a lot of trouble right now. I want to make clear that what I am
asking help for is not for marks, just practice challenge problems.
The goal is to implement a stack using Linked Lists. By looking through
the lecture notes I think I have most of the functions down. I need to
demonstrate Push() and Pop() will an append and a pretend. Using Cygwin, I
compiled with no errors. but when I try to run it, I get a "Segmentation
Fault". What does this mean and how do I fix it? if I remove "stack =
initLListStack();", the error disappears. Here is my code:
#include <stdio.h>
#include <stdlib.h>
typedef struct Link{
int *value;
struct Link *next;
}Link;
typedef struct LList1{
int *size;
Link *head;
}LList1;
typedef struct LListStack{
LList1 *llist;
}LListStack ;
LListStack *initLListStack(void)
{
LListStack *stack = (LListStack *) malloc(sizeof(LListStack)) ;
stack->llist->size = 0;
stack->llist->head = NULL;
return(stack);
}
void removefront(LList1 *llist)
{
if(llist->head != NULL){
llist->head = llist->head->next;
llist->size--;
}
}
Link *FindLastLink(LList1 *llist, Link *link)
{
if(link = NULL){
return(NULL);
}
else if(link->next == NULL){
return(link);
}
else{
return(FindLastLink(llist, link->next));
}
}
Link *FindSecondLastLink(LList1 *llist, Link *link)
{
if(link = NULL){
return(NULL);
}
else if(link->next->next == NULL){
return(link);
}
else{
return(FindSecondLastLink(llist, link->next));
}
}
void removelast(LList1 *llist)
{
Link *secondlastlink = (Link *) malloc(sizeof(Link));
secondlastlink = FindSecondLastLink(llist, llist->head);
secondlastlink->next = NULL;
llist->size--;
}
void prepend(int *newValue, LList1 *templist)
{
Link *node = (Link *) malloc(sizeof(Link));
node->value = newValue;
node->next = templist->head;
templist->head = node;
templist->size++;
}
void append(int *newValue, LList1 *templist)
{
Link *node = (Link *) malloc(sizeof(Link));
Link *lastlink = (Link *) malloc(sizeof(Link));
lastlink = FindLastLink(templist, templist->head);
node->value = newValue;
lastlink->next = node;
node->next = NULL;
templist->size++;
}
void prepush(int *value, LListStack *stack)
{
prepend(value, stack->llist);
}
void apppush(int *value, LListStack *stack)
{
append(value, stack->llist);
}
int prepop(LListStack *stack, int *value)
{
int result ;
if ((!isEmpty(stack)))
{
removefront(stack->llist);
result = 1 ;
}
else {
result = 0 ;
}
return(result) ;
}
int isEmpty(LListStack *stack)
{
int empty;
if (stack->llist->head == NULL)
return( 1 ) ;
else
return( 0 ) ;
}
int apppop(LListStack *stack, int *value)
{
int result ;
if ((!isEmpty(stack)))
{
removelast(stack->llist);
result = 1 ;
}
else
result = 0 ;
return(result) ;
}
//*******MAIN**********//
int main()
{
LListStack *stack = (LListStack *) malloc (sizeof(LListStack));
stack = initLListStack(); //if I take this away, I can run the program
return(0);
}
I don't have that much in Main() yet because I'm just trying to get it to
run first. Initializing the Stack seems to be the problem.
Thanks for your help guys!

data.table and paste aggregation very slow for big data, bottleneck in large code, large data

data.table and paste aggregation very slow for big data, bottleneck in
large code, large data

I just finished profiling my R code and it turns out that most operations
are done relatively fast, but for my large data this part of the code its
taking most of the time:
collapsed.bam.dt =
split.bam.dt[,list(read.parent.cigar=paste(block.read.parent.cigar,collapse=""),
parent.ref.cigar=paste(block.parent.ref.cigar,collapse=""),
read.ref.cigar=paste(block.read.ref.cigar,collapse=""),
read.ref.start=block.ref.start[1]),
by = read.index];
Note that block.read.parent.cigar, parent.ref.cigar, read.ref.cigar are of
type "character" and I want to concatenate them. In the case of
read.ref.start they are all the same so I just take the first one.
I am not sure if others have found that aggregating data in very large
data tables takes too much time.
Most of my code runs with mclapply with 48 cores so runs pretty fast, but
I cannot think about other ways to improve/parallelize the line above. If
you have some ideas/suggestions please let me know.
Thanks!