Displaying 20 results from an estimated 2000 matches similar to: "subbing a string vector for another string vector"
2006 Sep 03
7
using polymorphic associations with acts_as_list
This is what I have
class Photo < ActiveRecord::Base
belongs_to :image, :polymorphic => true
acts_as_list :scope => image
end
class Place < ActiveRecord::Base
has_many :photos, :as => :image
end
class Child < ActiveRecord::Base
has_many :photos, :as => :image
end
I want to be able to reorder the images. What I need is for the
position of the photos to be set
2006 Mar 20
1
FileColumn question
Can someone please help me with this.
I have an Images table :-
create table images (
id integer unsigned not null auto_increment primary key,
image varchar(200) not null default ''''
)ENGINE=InnoDB default CHARSET=latin1;
And a car table :-
create table cars (
id integer unsigned not null auto_increment primary key,
user_id integer unsigned not null,
title varchar(100) not
2008 Oct 07
3
vectorized sub, gsub, grep, etc.
R pattern-matching and replacement functions are
vectorized: they can operate on vectors of targets.
However, they can only use one pattern and replacement.
Here is code to apply a different pattern and replacement
for every target. My question: can it be done better?
sub2 <- function(pattern, replacement, x) {
len <- length(x)
if (length(pattern) == 1)
pattern <-
2008 Jan 22
1
getting multiple select to work: options_for_select
Hi,
<%= select_tag ''image_id'', options_for_select(Image.find(:all) {|
an_image| [ an_image.name, an_image.id ] }), :multiple => true %></p>
* I am in a view, and I am trying to search the image table and make a
multiple select box with each image''s name.
* Right now it is working, but I see this:
---------------------------------------------
2006 Jul 17
6
3 newbie questions
hey all,
I have 3 tables like this:
Images (id,name)
Tags (id,name)
ImagesTags(imageid,tagid)
in my image model I do a "has_and_belongs_to_many :tags" but to make
it work I need to rename ImagesTags(imageid,tagid) to
Images_Tags(image_id,tag_id). My question is that given that I can''t
rename the table, is there any way to make it work with the original
names?
Second question:
2012 Jul 18
0
Rails 3.1 Optional Routes
Hi all,
I am using Rails 3.1 and Ruby 1.9.2
In my application i am using optional routes like below
match ''Gallery(/:gallery_id(/:image_id))(/page/:g_page)'' => "wps/
gallery#show_gallery_page",:as => :gallery_page
in console i am trying to call the routes like below
include Rails.application.routes.url_helpers
=> Object
1.9.3dev :002 > gallery_page_path
2019 Jul 02
1
eliminate a partial argument match warning in R CMD check
Hello,
I'm seeing a nuisance warning when I run `R CMD check --as-cran
whatever_x.y.z.tar.gz`.
I generally work with these options set:
options(
warnPartialMatchArgs = TRUE,
warnPartialMatchAttr = TRUE,
warnPartialMatchDollar = TRUE
)
And I see this:
* checking use of SHLIB_OPENMP_*FLAGS in Makefiles ...Warning in dir("src",
patt = "[.]c$") :
partial argument
2006 Aug 09
8
AJAX image manipulation
I have this code in a controller that returns images to my browser...with
ROR.
def index
@products = Product.find_all_ pictures
end
....this is the .rhtml..
<% for photo in @pic -%>
<div class="entry">
<img src="<%= photo.image_url %>"/>
<h3><%= h(photo.title) %></h3>
<%= photo.description %>
2014 Apr 28
2
Re: [supermin] Be smarter about finding suitable kernel images
* Richard W.M. Jones:
> On Sat, Apr 26, 2014 at 02:27:07PM +0200, Hilko Bengen wrote:
>> ---
>> src/kernel.ml | 43 ++++++++++++++++++++++++++++---------------
>> 1 file changed, 28 insertions(+), 15 deletions(-)
>>
>> diff --git a/src/kernel.ml b/src/kernel.ml
>> index ed5aea3..436b1b0 100644
>> --- a/src/kernel.ml
>> +++ b/src/kernel.ml
2006 Jan 14
0
Compact db design a bad idea?
Hi,
I have tried two db designs and both can work but I wonder which one
the Rails Gurus would go with. This is a general db design question
that has cropped up in a few situation. Here is the example I''ve been
working on.
In an online store, categories has_and_belongs_to_many images and
products has_and_belongs_to_many images. The db has the basic three
tables
categories
- id
- name
2014 Apr 26
2
[supermin] Be smarter about finding suitable kernel images
---
src/kernel.ml | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/src/kernel.ml b/src/kernel.ml
index ed5aea3..436b1b0 100644
--- a/src/kernel.ml
+++ b/src/kernel.ml
@@ -23,6 +23,19 @@ open Utils
open Ext2fs
open Fnmatch
+let patt_of_cpu host_cpu =
+ let models =
+ match host_cpu with
+ | "mips" |
2017 Sep 20
4
[PATCH 0/4] Replace some uses of the Str module with PCRE.
Str is a pretty ugly regexp module. Let's try to replace it with
PCRE. This series of commits goes some small way towards that
eventual goal.
- - -
I wonder if there was a deep reason why we had this?
let unix2dos s =
String.concat "\r\n" (Str.split_delim (Str.regexp_string "\n") s)
I replaced it with what I think should be (nearly) equivalent:
let unix2dos s =
2010 May 03
7
rendering images dynamically
Hi,
I have a rails application where I respond to a request by fetching
image urls from various web api calls and need to display them as they
come available. I am able to display all the images once I get them
all, but that causes an unacceptable delay for my user.
One approach I am trying is, from my controller, set an @image
variable, and then pass in a block to the model that retrieves the
2017 Sep 22
27
[PATCH v3 00/22] Replace almost all uses of the Str module with PCRE.
v1:
https://www.redhat.com/archives/libguestfs/2017-September/msg00135.html
v2:
https://www.redhat.com/archives/libguestfs/2017-September/msg00158.html
v3 is almost identical to v2, but I have added 4 extra commits to
almost finish the job of replacing Str everywhere possible (note it's
not possible to replace Str in common/mlstdutils or the generator
because those are pure OCaml).
As
2008 Feb 26
2
Combining series of variables using identifier
R users,
I have df like this
a <- data.frame( indx = 1:20,
var1 = rep(c("I20", "I40", "A50", "B60"), each=5),
var1_lab= rep(c("cat", "dog", "mouse", "horse"), each=5),
var2 = rep(c("B20", "X40", "D50",
2006 May 29
4
has_many <-> belongs_to trouble
Hi all, finally im starting with rails, i have a simple relationship
has_many ans belongs_to that i dont now how to manage the update action,
here are my models
class Item < ActiveRecord::Base
has_many :images
end
class Image < ActiveRecord::Base
belongs_to :item
end
And my table structure:
Items => id, title, desc
Images => id, image, item_id
ok, i have a number of
2012 Aug 01
2
add vectors to multiple objects
Hi everyone,
I try to add many vectors (L1,L2,L3....) to many list objects (a.list, b.list....) in a workspace. Somethings like below, but it is not working. Any suggestions will be appreciated. Best, John
lf=ls(pattern=".lst")
for (x in listfiles) {
dat=read.delim(x,header=F)
for (i in 1: lf) {
assign(i$add,as.numeric(dat[,3]))
#or i$add=as.numeric(dat[,3]
2006 Oct 23
6
nested if/else very slow, more efficient ways?
Hello,
in the data.frame "resultsfuzzy" I would like to replace the
characters in the second column ("5a", "5b", ... "5e") with numbers
from 1 to 5. The data.frame has 39150 entries. I seems to work on
samples that are << nrow(resultsfuzzy) but it takes suspicously long.
Do you have any suggestions how to make the character replacing more
2024 May 09
2
Strange variable names in factor regression
On converting character variables to ordered factors, regression result
has strange names. Is it possible to obtain same variable names with
and without intercept?
Thanks,
Naresh
mydf <- data.frame(date = seq.Date(as.Date("2024-01-01"),
as.Date("2024-03-31"), by = 1))
mydf[, "wday"] <- weekdays(mydf$date, abbreviate = TRUE)
mydf.work <- subset(mydf, !(wday
2017 Nov 22
6
assign NA to rows by test on multiple columns of a data frame
Given this data frame (a simplified, essential reproducible example)
A<-c(8,7,10,1,5)
A_flag<-c(10,0,1,0,2)
B<-c(5,6,2,1,0)
B_flag<-c(12,9,0,5,0)
mydf<-data.frame(A, A_flag, B, B_flag)
# this is my initial df
mydf
I want to get to this final situation
i<-which(mydf$A_flag==0)
mydf$A[i]<-NA
ii<-which(mydf$B_flag==0)
mydf$B[ii]<-NA