Posts

php - Integrating CodeIgniter libraries (like tank auth) -

i've done quite bit of research , haven't found satisfying answer. how should use codeigniter libraries such tank auth? i've found handful of ways, seem sort of lackluster: do use controller is, adding controller functions/including styles needed? do use controller example model own after, relying on calls $this->tank_auth , views included tank auth? or extend my_controller tank-auth controller, extend particular controller needs authentication, , call parent::login() (or register(), activate(), etc )? the first option seems best, seems difficult avoid copying lot of code (what happens if want login form, don't want redirect /auth/login?) the second option has same problem, worse. need include logic of tank auth controller's login function each time wanted use login_form view, correct? the last seems hacky , seems anti-mvc me, maybe i'm wrong. check out http://philsturgeon.co.uk/blog/2010/02/codeigniter-base-classes-keeping-it-dry ...

regex - get all lines NOT end with 'rpms' in sed -

i want append following line lines. if have tips, please let me know. lot. i have tried sed -e '/?!(rpms$)/{n;s/\n//}' filename but failed. i think looking put lines don't end rpms on single line: sed -e ':a;/rpms$/!{n;s/\n//;ba}' instead of trying negate pattern, can negate test putting negation operator ! after pattern. to handle case there more 2 lines without rpms @ end, added label :a , unconditional jump ba label.

Scheme using modulo operator on a list -

i found max value of list , want return numbers except numbers have modulo equal 0 max value , im not quite sure how use modulo operator on whole list numbers need can lead me in right direction have far (define (findlargest a_list) (if (null? a_list) ;if empty list #f ;its false (let loop ((a_list (cdr a_list)) ;binds loop variable a_list value of cdr a_list(second , subsequent items in list) (maxval (car a_list))) ;maxval set car of a_list (first item of list) (cond ((null? a_list) maxval) ;if list empty return max ((> (car a_list) maxval) ;checks see if current element > max (loop (cdr a_list) (car a_list))) ;find new max (else (loop (cdr a_list) maxval)));keeps same max you're reinventing wheel findlargest , there's built-in procedure that: (define (findlargest lst) (apply max lst)) now, regarding question - looks perfect job filter : (define (filter-max-mo...

c# - IIS: Unexpected behavior in case of unhandled exception in Application_Start -

i'm using windows 7, iis 7.5.7600.16385 , .net 4.6.1 installed , have mvc application. some days ago had strange behavior @ our application. unfortunately service called inside application_start not available , unhandled exception thrown inside. expected behavior application_start() called again next request or the next request starting directly application_beginrequest() mentioned in what happens if unhandled exception thrown in application_start? . unfortunately following result: in case of exception inside application_start() error 500 @ first request. that's ok. after other requests returning exception thrown @ first request. verified throwing exception timestamp inside @ local environment. each response contains exception timestamp first request , http answer still 500. has no dependency url called. @ our code no breakpoint hit iis log show requests. seems answer cached somewhere. personally behavior because application doesn't respond requests undefined ...

Redirecting all queries to secondary in sharded cluster in mongodb -

how redirect queries secondary in sharded cluster rather setting readpreference variable while making connection mongo router. in short, mongo router redirect read queries secondary primary default. you readpreference connection string option, or query option (if driver supports this). connection mongos router readpreference set gets honoured, when selecting member of each shard's replicaset gets queried, if there no mongos router in way.

java - Call "addkeylistener" on JPanel object or JFrame object -

all. i got confused how event handling stuff works. can give me hints, thank! here understand, in order event handling, there 3 steps: (1) implement listener (action, key, ...) (2) provide event handler (actionperformed ...) (3) register listener source (this step got confused) i had see people doing addkeylistener on jpanel object, , doing on jframe object. personally, try both, , event can handle, , can not be, depend on either jpanel obj. or jframe obj choose addkeylistener. so, in kind of situation can determine either jpanel or jpanel should used, , other object have similar issue? thank you! below practice code of trying make snake game. not done yet, has issue described, calling addkeylistener work on jframe, fail on jpanel. snake.java package com.snake; import javax.swing.*; import java.awt.*; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.awt.event.keyevent; import java.awt.event.keylistener; import java.util.arrayl...

arrays - Validating a Barcode in C -

i beginner c coder working on program validate bar codes. far have code reads in 12 digit bar code. however, having trouble on attaching 12 digit input functions odd_value , even_value. need theses values validate bar code. #include <stdio.h> #define array_size 12 int print_values(int* x) { printf("\nstep 1: sum of odds times 3 \n" ); printf("step 2: sum of digits \n"); printf("step 3: total sum \n" ); printf("step 4: calculated check digit \n" ); printf("step 5: check digit , last digit \n" ); return 0; } int odd_value() { int sum_odd = (x[0] + x[2] + x[4] + x[6] + x[8] + x[10])*3; return sum_odd; } int even_value() { int sum_even = (x[1] + x[3] + x[5] + x[7] + x[9] + x[11]); return sum_even; } int fill_array(){ int i; printf("enter barcode check. separate digits space >\n"); for(i=0; i<array_size; i++){ if(scanf("%d:", &x[i]) != 1) return 0; } return 1; } int main()...