Displaying 20 results from an estimated 92 matches for "rindex".
Did you mean:
index
2008 Jun 17
3
rindex not working with objects from db model
...d(:all, :conditions=> {...})
my_testscore = current_user.test_score
my_ts = Testscore.new(:score => my_testscore)
test_scores.push(ts)
sorted_ts = test_scores.sort {|x,y| x.score <=> y.score }
index_one = sorted_ts.index(my_ts)
# why doesn''t this work?
index_two = sorted_ts.rindex(my_ts)
It finds index_one correctly, but index_two always equals index_one,
even if there are more than one object with a score of my_testscore.
Please help! Thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because...
2007 Aug 03
2
How to properly finalize external pointers?
...tely.
Shouldn't R_ClearExternalPtr call the finalizer and then unregister it? (this would also work when removing the SEXP external pointer object is difficult because it was handed over to the closing function directly as a parameter)
Best regards
Jens Oehlschl?gel
// C-code
static void rindex_finalize(SEXP extPtr){
pINT ptr = R_ExternalPtrAddr(extPtr);
if(ptr){
Free(ptr);
Rprintf("finalized\n");
}else{
Rprintf("nothing to finalize\n");
}
return;
}
SEXP rindex_open(
SEXP Sn
){
int i,n = INTEGER(Sn)[0];
pINT ptr = Calloc(sizeof(INT)*n, INT...
2015 Jul 01
4
[PATCH 1/2] mllib: add and use last_part_of
...ssword.ml b/customize/password.ml
index 25ce901..d91c4b5 100644
--- a/customize/password.ml
+++ b/customize/password.ml
@@ -98,8 +98,9 @@ let rec set_linux_passwords ?password_crypto (g : Guestfs.guestfs) root password
List.iter (
fun userpath ->
let user =
- let i = String.rindex userpath '/' in
- String.sub userpath (i+1) (String.length userpath -i-1) in
+ match last_part_of userpath '/' with
+ | Some x -> x
+ | None -> error "password: missing '/' in %s" userpath in
try
(* Each line is: &q...
2015 Jul 01
0
pdf-printer
...t;);
$from = substr $from, 0, index($from, ' ') ;
?
## Enable the sections you want to use below only create a pdf is enable.
# *********************** start inputfile = pdf ***********************
@files = </tmp/$RANDOM/*.pdf>;
foreach $file (@files) {
?? $targetfile = substr $file, rindex($file, '/') + 1;
?? system ("/usr/bin/pdftk $file output /tmp/$targetfile 2>/dev/null");
?? system("/usr/bin/mpack -s \"Re: $subject\" -d /home/msg/message.msg \"/tmp/$targetfile\" \"$from\"");
?? system("rm -f \"/tmp/$targetfil...
2015 Jul 01
0
[PATCH 2/3] mllib: add and use last_part_of
...tomize/password.ml
+++ b/customize/password.ml
@@ -97,9 +97,7 @@ let rec set_linux_passwords ?password_crypto (g : Guestfs.guestfs) root password
let users = Array.to_list (g#aug_ls "/files/etc/shadow") in
List.iter (
fun userpath ->
- let user =
- let i = String.rindex userpath '/' in
- String.sub userpath (i+1) (String.length userpath -i-1) in
+ let user = last_part_of userpath '/' in
try
(* Each line is: "user:[!!]password:..."
* !! at the front of the password field means the account is locked.
di...
2015 Jul 01
0
Re: [PATCH 1/2] mllib: add and use last_part_of
...ndex 25ce901..d91c4b5 100644
> --- a/customize/password.ml
> +++ b/customize/password.ml
> @@ -98,8 +98,9 @@ let rec set_linux_passwords ?password_crypto (g : Guestfs.guestfs) root password
> List.iter (
> fun userpath ->
> let user =
> - let i = String.rindex userpath '/' in
> - String.sub userpath (i+1) (String.length userpath -i-1) in
> + match last_part_of userpath '/' with
> + | Some x -> x
> + | None -> error "password: missing '/' in %s" userpath in
Best to translate...
2015 Jul 01
5
[PATCH 1/3] mllib: add an optional filter for rm_rf_only_files
This way it is possible to use rm_rf_only_files, but not removing
specific files.
---
mllib/common_utils.ml | 8 +++++++-
mllib/common_utils.mli | 5 ++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/mllib/common_utils.ml b/mllib/common_utils.ml
index 516cff3..3737b4c 100644
--- a/mllib/common_utils.ml
+++ b/mllib/common_utils.ml
@@ -640,13 +640,19 @@ let rmdir_on_exit =
*
2015 Jul 01
1
Re: [PATCH 1/2] mllib: add and use last_part_of
...gt; --- a/customize/password.ml
> > +++ b/customize/password.ml
> > @@ -98,8 +98,9 @@ let rec set_linux_passwords ?password_crypto (g : Guestfs.guestfs) root password
> > List.iter (
> > fun userpath ->
> > let user =
> > - let i = String.rindex userpath '/' in
> > - String.sub userpath (i+1) (String.length userpath -i-1) in
> > + match last_part_of userpath '/' with
> > + | Some x -> x
> > + | None -> error "password: missing '/' in %s" userpath in...
2007 Aug 23
0
indexing and regression testing
Dear all,
It was a pleasure to meet you at Iowa State University. Two days ago I submitted two experimental packages to CRAN (hope it will be there soon):
rindex: quick indexing of large objects (currently only character, see ?index)
regtest: some first support for automated regression testing (heavily used in \dontshow{} section of ?index)
With rindex you can for example
i <- index(rownames(someDataFrame))
# then this
someDataFrame[match(fewRowNames,...
2000 Nov 21
2
IRIX patch for vorbis *
...rameter), and to use *frames* (what AL wants) and
not *bytes* (what AO passes)
I also added no-dependencies to the Makefile.ams because that needs GNU
CC to work properly and it was turning into a little headache to get
MIPSpro to this in the way GNU make wants it.
IRIX libc doesn't have rindex but it looks like GNU libc has strrchr
(dunno about BSD's libc).
If I'm not mistaken getopts_long is a GNU libc'ism.
And I need to include limits.h to get NAME_MAX.
If you are cool with all of this, I'll clean this patch up. I only
tested with IRIX/MIPSpro.
(In other wo...
2008 Oct 21
4
subscripting a one column matrix drops dimension
......
This breaks:
> cov(x)
[,1]
[1,] 0.9600812
> cov(x[20:30])
Erreur dans cov(x[20:30]) : fournir 'x' et 'y' ou bien 'x' en matrice
And this behavior is braking function clustIndex (when used with
unidimensional data),
from the package cclust, file Rindexes.R, lines 137-147:
ttww <- function(x, clsize, cluster)
{
n <- sum(clsize)
k <- length(clsize)
w<-0
tt <- cov(x)*n
for (l in 1:k)
w<- w+cov(x[cluster==l,])*clsize[l]
zttw <- list(tt=tt, w=w)
return(zt...
2009 May 27
0
[PATCH] src/linux/device.c: Fix segfault when running without `--net'.
...ice.c
+++ b/src/linux/device.c
@@ -63,7 +63,8 @@ bool setup_device(void)
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
#ifdef HAVE_LINUX_IF_TUN_H
- iface = xstrdup(netname);
+ if (netname != NULL)
+ iface = xstrdup(netname);
#else
iface = xstrdup(rindex(device, '/') ? rindex(device, '/') + 1 : device);
#endif
--
1.5.6.5
2010 Feb 10
0
[PATCH] Use /dev/tap0 by default on BSD if mode != router
...okup_config(config_tree, "Device"), &device)) {
+ if (routing_mode != RMODE_ROUTER)
+ device = xstrdup(DEFAULT_DEVICE_TAP);
+ else
+ device = xstrdup(DEFAULT_DEVICE);
+ }
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
iface = xstrdup(rindex(device, '/') ? rindex(device, '/') + 1 : device);
--
1.6.6.1
2011 Nov 28
5
window manager interface commands for linux
How can i replicate this in Linux:
source(file.choose())
I've tried source(tkgetOpenFile()) but with no luck
2006 Jun 01
2
Finding the right interface on FreeBSD
...May 4 18:57:55 2005
+++ tinc-1.0.4.gr/src/bsd/device.c Wed May 17 22:47:27 2006
@@ -38,6 +38,10 @@
int device_fd = -1;
char *device;
+
+static char device_buf[256];
+#define DEVICE_TRIES_MAX 255
+
char *iface;
char *device_info;
static int device_total_in = 0;
@@ -60,8 +64,31 @@
iface = rindex(device, '/') ? rindex(device, '/') + 1 : device;
if((device_fd = open(device, O_RDWR | O_NONBLOCK)) < 0) {
- logger(LOG_ERR, _("Could not open %s: %s"), device, strerror(errno));
- return false;
+ int device_nr;
+
+ /* if device terminates by a number and is of...
2000 Nov 06
5
Aggregate
Hello to all,
I recently downloaded R to my PC and am enjoying getting acquainted with it. Thank you to everyone involved in the R-project!
I am interested in doing a log-linear analysis with R on a data set with dichotomous variables. There are 11 variables (columns) and around 1000 subjects (rows). How do I aggregate my data, i.e. how do I make a new dataset that includes the variable giving
2010 Jan 17
2
For loops in R
Hello.
I've just started using R and am trying to figure out if the two codes
snippets below have the same output
gBest<-floor(runif(popsize,min=1,max=top))
velocity[i,j]<<-.4* velocity[i,j] + 1 * runif(1) * (pbestsVar[i,j] -
popVar[i,j]) + 1 * runif(1) * (archiveVar[gBest,j] - popVar[i,j])
and
for (i in 1:popsize) {
for (j in 1:maxvar) {
gBest<-sample(top,size=1)
2014 Oct 31
0
[PATCH] builder: pass Sources.source objects directly
...f "index file (%s) after parsing (C parser):\n" uri;
List.iter (print_entry Pervasives.stdout) entries
);
@@ -301,10 +301,10 @@ let get_index ~prog ~verbose ~downloader ~sigchecker ~proxy source =
else (
(* Construct the URI. *)
try
- let i = String.rindex source '/' in
- String.sub source 0 (i+1) ^ path
+ let i = String.rindex uri '/' in
+ String.sub uri 0 (i+1) ^ path
with
- Not_found -> source // path
+ Not_found -> uri // path
)
in
diff --git a/builder/index_parser.mli b/bu...
2016 Aug 10
1
[PATCH 2/7] v2v: add basic support for the "deb" package manager
...t;= 0 then
+ raise Not_found
+ else
+ raise exn in
+ if Array.length lines = 0 then
+ error (f_"internal error: file_owner: dpkg command returned no output");
+ let line = lines.(0) in
+ let line =
+ try String.sub line 0 (String.rindex line ':')
+ with Invalid_argument _ ->
+ error (f_"internal error: file_owner: invalid dpkg output: '%s'") line in
+ fst (String.split "," line)
| "rpm" ->
(* Although it is possible in RPM for multiple packages to o...
2000 Dec 15
2
Ports
...ATCOMC__)
#include <fcntl.h>
#include <io.h>
#include <time.h>
#endif
-#ifdef _WIN32
+#ifdef __OS2__
+#define INCL_DOS
+#define INCL_NOPMAPI
+#include <os2.h>
+#endif
+
+#if defined(_WIN32) || defined(__WATCOMC__)
/* This doesn't seem to exist on windows */
char *rindex(char *s, int c)
{
@@ -35,7 +41,9 @@
}
return ret;
}
+#endif
+#ifdef _WIN32
void setbinmode(FILE *f)
{
_setmode( _fileno(f), _O_BINARY );
@@ -49,8 +57,14 @@
}
#endif
+#ifdef __WATCOMC__
+void setbinmode(FILE *f)
+{
+ setmode( fileno(f), O_BINARY );
+}
+#endif
-...