EzDevInfo.com

guides

Ruby Guides

Guides when moving jquery-ui-draggable boxes

I am working on how to show guides when moving boxes like it is in Google Docs Drawing. I would prefer an open-source code or any type of guide before starting writing my own.

  1. I do not need drag-n-drop across multiple browser windows so i don't need HTML5 Drag-n-Drop.
  2. Also i am using jquery-ui-draggable for boxes.

enter image description here


Source: (StackOverflow)

Is it possible to access rails guides for rails 2.3?

It used to be that the ruby on rails guides for version 3.0 were at http://edgeguides.rubyonrails.org/ and the guides for version 2.3 were at http://guides.rubyonrails.org . Now that version 3 has been released, its guides have been moved to the main URL.

Is there any way to access the guides for rails 2.3?


Source: (StackOverflow)

Advertisements

resize/manually enter breaks on colorbar guide of geom_tile AND replace y-axis labels

I am revisiting this issue I ran into approximately a year ago. I would like my 'colourbar' guide to effectively be displayed on a log scale so that the takeaway when looking at it is that increasingly darker values of blue reflect greater significance.

With the following code, I generate the below image:

pz <- ggplot(dat.m, aes(x=variable,y=Category)) +
  geom_tile(aes(fill=value)) +
  xlab(NULL) + ylab(NULL) +
  scale_fill_gradientn(colours=c("#000066","#0000FF","#DDDDDD","white"), 
                   values=c(0,0.05,0.050000000000001,1.0),
                   breaks=c(0, 0.000001, 0.01, 0.05, 1),
                   guide = "colourbar") +
  theme_bw()+
  theme(panel.background = element_blank(),
        panel.border = element_blank(),
        axis.ticks.x = element_blank(),
        axis.ticks.y = element_blank()) +
  theme(legend.position="top",
        legend.text = element_text(angle=45),
        axis.text.x = element_text(angle=45)
  )

colourbar

Or, I can display it as a "legend" as opposed to a "colourbar":

enter image description here

But what I really desire is something like this:

enter image description here

I have tried adding 'trans="log"' (scale_fill_gradientn(trans="log")), but there are lots of zeros in my data which causes a problem. If you have any ideas it would be greatly appreciated!


Previous wording:

I am trying to make a heatmap of p-values for different samples for various categorizations. There are two things I would like to modify on this plot:

  1. I would like to adjust the legend of my geom_tile plot to emphasize the lower end of the legend scale while still maintaining the full spectrum of the gradient - similar to how it would look if it were a log scale. So essentially the white to blue transition from 1.0-0.05 and the blue to darkblue transition from 0.05-0.00 will be approximately equal in size. Is there a way that I can manually adjust the colorbar guide?

  2. I would like to replace the y-axis names so that I can remove my "empty" row label. Note, the Categories are simply represented as letters here, but in my real data set they are long names. I have inserted "dummy" rows of data to split categorizations into chucks and ordered the tiles within each block to go from most significant to not significant - I am sure there is a better solution to this, but this is what I came up with after many failed attempts of other ideas I found on stack overflow! I have tried labeling them with scale_y_discrete, but this gets jumbled with the aforementioned ordering.

Help with either of these issues will be much appreciated!

sample_heatmap

Here is a sample dataset:

dput(dat.m)
structure(list(Category = structure(c(12L, 11L, 10L, 9L, 8L, 
7L, 6L, 5L, 4L, 3L, 2L, 1L, 12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 
4L, 3L, 2L, 1L, 12L, 11L, 10L, 9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 
1L), class = "factor", .Label = c("j", "i", "empty2", "h", "empty1", 
"g", "f", "e", "d", "c", "b", "a")), variable = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L), .Label = c("b2", "c1", "c2"), class = "factor"), 
    value = c(7.40214650772221e-06, 0.0075828339, 0.1825924627, 
    0.0384381317, 0.0440256659, 0.3659284985, 0.9777569144, 1, 
    0.0075828339, 1, 0.2193606406, 0.3659284985, 0.0004289756, 
    0.0011541045, 0.0004289756, 0.4400885491, 0.6121402215, 0.6724032426, 
    0.2735924085, 1, 0.018824582, 1, 0.4386503891, 0.4249526456, 
    1.05094571578633e-05, 0.0027216795, 0.715979827, 0.0050376405, 
    0.7473334763, 0.9053300832, 1, 1, 0.0015392848, 1, 0.039679469, 
    0.0950327519)), .Names = c("Category", "variable", "value"
), row.names = c(NA, -36L), class = "data.frame")

And here is my code:

col_blue <- c("#FFFFFF","#000099","#000066","#000033")
ggplot(dat.m, aes(x=variable,y=Category)) +
  geom_tile(aes(fill=value)) +
  xlab(NULL) + ylab(NULL) +
  scale_fill_gradientn(colours=col_blue, values=c(1,0.05,0.01,0),guide="colorbar") +
  theme_mary(base_size=12)

UPDATE:

So now I have modified the code as such with the following results. I am getting closer to what I hope to achieve but I would like to play with the proportions of the colourbar to show the gradient from 0.05-0.0 a bit more clearly.

col_blue <- c("#FFFFFF","#000099","#000066","#000033")
ggplot(dat.m, aes(x=variable,y=Category)) +
  geom_tile(aes(fill=value)) +
  xlab(NULL) + ylab(NULL) +
  scale_fill_gradientn(colours=col_blue, values=c(1,0.05,0.01,0), guide=FALSE) +
  scale_colour_gradientn(guide = "colourbar", limits = c(0,1),breaks=c(1,0.05,0.01,0),values=c(1,0.05,0.01,0),colours=c("#FFFFFF","#000099","#000066","#000033"))

image2


Source: (StackOverflow)

iOS Drag-and-Drop Alignment Guides

I'm looking to develop an iOS app that includes drag and droppable interface elements, but with alignment guides like those in Keynote or OmniGraffle or Interface Builder (the yellow lines in Keynote) such that when you drag something near enough to vertical or horizontal alignment with another object in the canvas, it displays a guide line and automatically snaps into to alignment.

So far, I haven't been able to find any published API to implement this. Does such a thing exist anywhere? It's a little bit difficult of a concept to Google successfully. If not, any pointers on rolling my own with a minimum of pain? Thanks!


Source: (StackOverflow)

ggplot legend title top center

Is there a way to put legend title on top and center compared to the legend itself?

Example:

cons2 <- data.table(
value_date  = c(as.Date('2013-04-30'),as.Date('2013-04-30'),as.Date('2013-06-13'),as.Date('2013-06-13')),
ticker = c('AAPL','FTW','AAPL','FTW'),
discount = c(0.34,0.10,0.25,0.20),
b = c(0.40,0.55,.60,0.90),
yield = c(0.08,0.04, 0.06,0.03))


headers <- cons2[ticker == 'AAPL' & value_date == '2013-06-13']

p <- ggplot(cons2) 
p <- p + geom_point(aes(yield,b, size = discount, color=factor(value_date))) 
p <- p + guides(size = "none")
p <- p + scale_colour_manual(values = c("#1c2f80","#779438"))
p <- p + geom_text(data = headers, aes(yield, b, label=ticker), size = 4)
p <- p + geom_smooth(data = cons2[value_date == '2013-06-13'], aes(yield, b), method="lm", se=FALSE)
p <- p + geom_line(data = cons2, aes(yield, b, group = ticker))
p <- p + theme(legend.position="bottom")
p <- p + guides(colour=guide_legend(title.position="top"))
p

Source: (StackOverflow)

What happens to the Bottom Layout Guide when an InputView is displayed (i.e. keyboard)

So everyone loves this new Layout semantics in storyboard, it's dynamic in a way it adapts at runtime when we're inside a UINavigationController for example.

Now what about inputViews? I know inputViews are NOT part of my view, but wouldn't it make sense to affect the bottom layout guide of the containing view when a keyboard is displayed?

I mean, I've seen several coding solutions to this issue, but only one affectively takes advantage of the bottom layout guide (the others are deprecated or plain simple wrong approaches), but even that one sounds hard-wacky-coding and naturally it doesn't animate.

Is there a way to tell the view to adjust the bottom layout guide for input views automatically? i mean in storyboard? or do we need to do this sucky code let every time we use a keyboard in our application?

If the Keyboard appearing animated:YES would affect the bottom layout guide in it's progress we'd have yet another apple-is-so-cool-they-make-all-the-hard-work-for-us-while-enforcing-their-user-interface-guidelines....aff that was long :)

Cheers


Source: (StackOverflow)

PHP tutorials/guides that influenced you or improved your code [closed]

What tutorials or guides about features/techniques influenced the way you did something.

Eg a compelling tutorial (located here) about unit testing got you into unit testing. Your code improved dramatically.


Source: (StackOverflow)

Codefolding / Indent guides in Vim?

During a research for useful vim plugins I found a screenshot of a vim window showing some kind of dotted guides highlighting either indentation or folds. I'm not sure about what they highlight actually.

Does anyone know which plugin generates these guides and what their purpose is?

You can find the screenshot right here: http://oi54.tinypic.com/2yysefm.jpg


Source: (StackOverflow)

Guides not properly display when moving jquery-ui-draggable boxes inside element has position relative and margin auto

I've tried sample at here http://stackoverflow.com/a/10246981/3892316 but if I put element inside parent div with position is relative and center div with margin auto -> It will not working properly.

HTML:

<div class="well grid-guide" style="height: 1123px; width: 794px;" id="droptarget" data-role="droptarget">
    <div class="canvas" id="6182df68-a629-4258-9329-571ea313379b_ui-id-1" style="position: absolute; top: 86px; left: 329px;">
        <div style="padding:5px;border-radius:7px;" class="elementContainer">
            <label class="canvas-span" id="label_6182df68-a629-4258-9329-571ea313379b_ui-id-1">Click here to change
            </label>
            <div class="ui-wrapper" style="overflow: hidden; width: 200px; height: 30px; padding-right: 0px; padding-bottom: 0px;">
                <input style="width: 200px; height: 30px; display: block; margin: 0px; resize: none; position: static; zoom: 1;" class="k-textbox" id="input_6182df68-a629-4258-9329-571ea313379b_ui-id-1">
            </div>
        </div>
    </div>
    <div class="canvas" id="6182df68-a629-4258-9329-571ea313379b_ui-id-2" style="position: absolute; top: 201px; left: 272px;">
        <div style="padding: 5px; border-radius: 7px; cursor: default;" class="elementContainer">
            <label class="canvas-span" id="label_6182df68-a629-4258-9329-571ea313379b_ui-id-2">Click here to change
            </label>
            <div class="ui-wrapper" style="overflow: hidden; width: 200px; height: 30px; padding-right: 0px; padding-bottom: 0px;">
                <input style="width: 200px; height: 30px; display: block; margin: 0px; resize: none; position: static; zoom: 1;" class="k-textbox" id="input_6182df68-a629-4258-9329-571ea313379b_ui-id-2">
            </div>
        </div>
    </div>


</div>

Javascript:

var MIN_DISTANCE = 10; // minimum distance to "snap" to a guide
var guides = []; // no guides available ... 
var innerOffsetX, innerOffsetY; // we'll use those during drag ... 
var offset;

$( ".canvas" ).draggable({
    start: function( event, ui ) {
         $("#droptarget").append($("<div id=\"guide-h\" class=\"guide\"></div>"));
         $("#droptarget").append($("<div id=\"guide-v\" class=\"guide\"></div>"));
        guides = $.map( $( ".canvas" ).not( this ), computeGuidesForElement );
        innerOffsetX = event.originalEvent.offsetX;
    innerOffsetY = event.originalEvent.offsetY;
        offset = $(this).offset();
    }, 
    drag: function( event, ui ){
        // iterate all guides, remember the closest h and v guides
        var guideV, guideH, distV = MIN_DISTANCE+1, distH = MIN_DISTANCE+1, offsetV, offsetH; 
        var chosenGuides = { top: { dist: MIN_DISTANCE+1 }, left: { dist: MIN_DISTANCE+1 } }; 
        var $t = $(this);
var pos = { top: event.originalEvent.pageY - innerOffsetY, left: event.originalEvent.pageX - innerOffsetX }; 
        var w = $t.outerWidth() - 1; 
        var h = $t.outerHeight() - 1; 
        var elemGuides = computeGuidesForElement( null, pos, w, h ); 
        $.each( guides, function( i, guide ){
            $.each( elemGuides, function( i, elemGuide ){
                if( guide.type == elemGuide.type ){
                    var prop = guide.type == "h"? "top":"left"; 
                    var d = Math.abs( elemGuide[prop] - guide[prop] ); 
                    if( d < chosenGuides[prop].dist ){
                        chosenGuides[prop].dist = d; 
                        chosenGuides[prop].offset = elemGuide[prop] - pos[prop]; 
                        chosenGuides[prop].guide = guide; 
                    }
                }
            } ); 
        } );

        if( chosenGuides.top.dist <= MIN_DISTANCE ){
            $( "#guide-h" ).css( "top", chosenGuides.top.guide.top ).show(); 
            ui.position.top = chosenGuides.top.guide.top - chosenGuides.top.offset;
        }
        else{
            $( "#guide-h" ).hide(); 
            ui.position.top = pos.top; 
        }

        if( chosenGuides.left.dist <= MIN_DISTANCE ){
            $( "#guide-v" ).css( "left", chosenGuides.left.guide.left ).show(); 
            ui.position.left = chosenGuides.left.guide.left - chosenGuides.left.offset; 
        }
        else{
            $( "#guide-v" ).hide(); 
            ui.position.left = pos.left; 
        }
    }, 
    stop: function( event, ui ){
        $( "#guide-v, #guide-h" ).remove(); 
    }
});


function computeGuidesForElement( elem, pos, w, h ){
    if( elem != null ){
        var $t = $(elem); 
        pos = $t.offset(); 
        w = $t.outerWidth() - 1; 
        h = $t.outerHeight() - 1; 
    }

    return [
        { type: "h", left: pos.left, top: pos.top }, 
        { type: "h", left: pos.left, top: pos.top + h }, 
        { type: "v", left: pos.left, top: pos.top }, 
        { type: "v", left: pos.left + w, top: pos.top },
        // you can add _any_ other guides here as well (e.g. a guide 10 pixels to the left of an element)
        { type: "h", left: pos.left, top: pos.top + h/2 },
        { type: "v", left: pos.left + w/2, top: pos.top } 
    ]; 
}

CSS:

body{
    font-family: courier new, courier; 
    font-size: 12px; 
}

#droptarget {

    background: #ccc;
    margin: 0 auto;
    position: relative;
}

.canvas{
    border: 1px solid #ccc; 

    cursor: move;
    position: absolute;         
}

.guide{
    display: none; 
    position: absolute; 
    left: 0; 
    top: 0; 
}

#guide-h{
    border-top: 1px dashed #55f; 
    width: 100%; 
}

#guide-v{
    border-left: 1px dashed #55f; 
    height: 100%; 
}

Demo (Only work properly in small window): http://jsfiddle.net/pmL4p3fL/


Source: (StackOverflow)

Could anyone direct me to a good Java sound guide?

I am currently trying to make a metronome with adjustable rhythm and tempo, but I have no idea how to use the Java sound API.


Source: (StackOverflow)

What are these grey dashed guide lines in Flash?

img: http://tinypic.com/r/34raqvm/5

I received a Flash project from an outside source. In it I found that some library items had these grey, dashed guide lines. It seems like they are used for assigning resize boundaries or something. Anyways, i can't reproduce them in my own library elements nor can I find any information on them. What terms should I use to google so I can read up on these?

cheers!


Source: (StackOverflow)

Show Indent Guide Lines In Xcode

Comming from a background using Visual Studio and Notepad++ im used to the indent guides which help to visually enhance sections of code where the curly braces are used, {.

Xcode (No indent guides)

xcode

Visual Studio (Nice tidy indent guides) vs2010

As you can see from the images above sometimes there are sections of code where multiple levels of curly braces are open and it gets messy without any indent guides. Are there any options or plugins that will allow xcode to display the indent guides in between sections of code? Like the VS2010 sample?

Thanks


Source: (StackOverflow)

from Python to C#. Starting from zero?

Hello stackoverflow community,

I'm almost finished with MIT OpenCourseWare about Computer Science and I have a big problem. Everything there was in Python and now I have to use C# because of my studies but im lost, im totally lost, I have no idea what I'm doing, how this and that works. I cant understand almost no concept in C#. Im reading guides, tutorials. I read many topics/question here also. Any suggestions? I just tryed to write something on my own like a script on my friends game but I'm stuck. I cant even choose a random array from two dimensional array and then iterate over that chosen array.

class MainClass
    {
        static double[]result = { 120, 160, 200 };
        static double[,]steeds = {
            {150,0,255} , //black steed
            {255,150,0} , //maroon steed
            {0,255,150}   //white steed
        };
        public static void Main (string[] args)
        {
            Random r = new Random();
            double[]random_steed = steeds[ ////here i cant even type a char "r" it gives me "Random" automatically
        }

I would like to choose a random array from that 2-dimensional one and then iterate over it. Please help me and I would be very thankful for goods and easy guides/tutorials/courses in C#.


Source: (StackOverflow)

ggplot2: cannot display the legend text in multiple rows using guide_legend

I am trying to create a histogram for the data that looks like the following (yrly_data variable in the code below).

> yrly_data
   Series Dates         YTD
1    Fund  2013  0.08434377
2    Fund  2014  0.07869951
3  Index1  2013  0.32361649
4  Index1  2014  0.13653722
5  Index2  2013 -0.02017807
6  Index2  2014  0.05941566
7  Index3  2013 -0.02011621
8  Index3  2014  0.07471164
9  Index4  2013  0.11662013
10 Index4  2014 -0.20183881
> dput(yrly_data)
structure(list(Series = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 
4L, 5L, 5L), .Label = c("Fund", "Index1", "Index2", "Index3", 
"Index4"), class = "factor"), Dates = c(2013L, 2014L, 2013L, 
2014L, 2013L, 2014L, 2013L, 2014L, 2013L, 2014L), YTD = c(0.084343775, 
0.078699508, 0.323616491, 0.136537222, -0.020178073, 0.059415661, 
-0.020116206, 0.074711644, 0.116620129, -0.20183881)), .Names = c("Series", 
"Dates", "YTD"), class = "data.frame", row.names = c(NA, -10L
))

My code looks like:

library(ggplot2)
rcnt = 3 # number of legend rows
yrly_data$YTD = as.numeric (yrly_data$YTD)
hgrm = ggplot(data = yrly_data, aes(x = Dates, fill = Series, weight = YTD))
hgrm = hgrm + geom_bar(position = 'dodge', colour="black") # create clustered bar chart
hgrm = hgrm + theme(legend.position = 'top') + guides(colour = guide_legend(nrow = rcnt))
plot(hgrm)

I get this error:

stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
Warning message:
In loop_apply(n, do.ply) :
  position_dodge requires constant width: output may be incorrect

Everything works except I get the legend text in a single row. Any ideas why and how to fix this?

enter image description here

Thanks. CM


Source: (StackOverflow)

guide_legend and ggplot2, format nrow

I am trying to format an over-long legend on a ggplot so that there is a maximum no. of rows. I've read all the documentation that I could find, especially this: http://docs.ggplot2.org/0.9.3.1/guide_legend.html but for some reason, the legend will not format.

I've given a reproducible sample below using the quakes dataset, and converted the column stations to character so that they plot individually (otherwise, they seem to plot as groups).

plotquakes <- function(magreq) {
    library(ggplot2)
    magdata <- subset(quakes, mag > magreq)
    magdata$stations <- as.character(magdata$stations)
    g <- ggplot(magdata, aes (x = lat, y = long))
    g + geom_point(aes(alpha = stations), fill = "black", pch=21, size = 6) + 
    labs(x = "Latitude", y = "Longitude") + 
    geom_vline(xintercept = 0, col = "red") + 
    geom_hline(yintercept = 0, col = "red") +
    guides(col = guide_legend(nrow = 16))
}

plotquakes(5)

And what I get is this:

enter image description here

whereas I would like to have a maximum of 16 data fields per column in the legend.


Source: (StackOverflow)