Posts

Showing posts from July, 2012

vb.net - Visual basic database login: manager and admin logins -

i have code open form if login credentials matches database. dont know how add separate login manager. in database made column yes/no called ismanager , checked 1 of users cant seem if checked , open different form. can please improve code make change? public class login public function login() 'save database file in u:\my documents\visual studio 2008\projects\sequenceselectionrepetition\sequenceselectionrepetition\bin\debug 'right-click sequenceselectionrepetition solution explorer , select add reference 'choose com , choose microsoft activex daba objects 2.5 library dim dbconn new adodb.connection dim users new adodb.recordset dim username string dim userdb string dim passdb string dim userfound boolean dbconn.open("provider = microsoft.ace.oledb.12.0;" & "data source = '" & application.startuppath & "\capsule staff.accdb'") users.open("credentials", dbconn, ado

vb.net - VB SaveFileDialog returns "No items match your search." for a specific folder filtering for .txt for example -

vb savefiledialog returns "no items match search." specific folder filtering .txt example. open file dialog other applications eg. notepad show .txt files. sorry not posting code, after finding solution can see important. found solution ' not work i.e. dialog returns "no items match search." filedialog1.filter = "" savefiledialog1.filter += "|c/c++|*.cpp;*.c;*.h;*.rc" savefiledialog1.filter += "|csharp|*.cs" savefiledialog1.filter += "|css|*.css" savefiledialog1.filter += "|eruby|*.erb;*.rhtml" savefiledialog1.filter += "|java|*.java" savefiledialog1.filter += "|javascript|*.js" savefiledialog1.filter += "|jsp|*.jsp" ' solves problem, dialog shows files selected file extension(s) savefiledialog1.filter = "" savefiledialog1.filter += "|c/c++ (*.cpp;*.c;*.h;*.rc)|*.cpp;*.c;*.h;*.rc" savefiledialog1.filter += "|csharp (*.cs)|*.cs" savef

php - All combinations of 2D array with mutual exclusivity -

i have array looks this: $i[0] = ['a', 'b', 'c']; $i[1] = ['d', 'e']; $i[2] = ['a', 'b', 'c']; $i[3] = ['d', 'e']; $i[4] = ['f', 'g', 'h']; i want possible permutations or combinations of array, without using same value twice 2 or more sub-arrays. instance, result a d b e f possible, not a d d f . i have tried basic permutation algorithms, can't wrap head around how modify want. here's i've got currently: function array_permutation(array $a){ $count = array_map('count', $a); $finalsize = 1; foreach ($count $val) { $finalsize *= $val; } $output = []; ($i = 0; $i < $finalsize; $i++) { $output[$i] = []; ($c = 0; $c < count($a); $c++) { $index = ($i + $finalsize) % $count[$c]; array_push($output[$i], $a[$c][$index]); } } return $output; } a simple a

ruby on rails - How to use variable from link -

i have link reads <a href="<%= user_collections_path(@user, :status => "got") %>">collection</a> and reads <a href="<%= user_collections_path(@user, :status => "want") %>">wantlist</a> they link same view produce different lists. on view page want able alter text depending on if collection or wantlist page. this: <% if :status == 'got' %>collection<% elsif :status == 'want' %>wantlist<% end %> obviously doesn't work after experimentation can't work out how query status passed in link. possible? you should doing this <% if params[:status] == 'got' %>collection <% elsif params[:status] == 'want' %>wantlist <% end %>

jquery - Canvas arrow is not shown in Chrome -

i have drawn arrow in canvas using below code. window.onload = function() { var canvas = document.getelementbyid("arrow"); var context = canvas.getcontext("2d"); context.beginpath(); context.strokestyle = "red"; context.fillstyle = "red"; context.moveto(150, 400); context.lineto(400, 400); context.lineto(375, 375); context.arcto(400, 400, 375, 425, 35); context.lineto(400, 400); context.stroke(); context.fill(); }); but arrow not shown on screen. in html5 spec , canvas element has default coordinate size of 300×150px. if use css resize canvas to, say, 500×500px, canvas coordinates stretched (300, 150) still bottom right of canvas: http://jsfiddle.net/mh4uh/ you need apply canvas width , height property: <canvas id="arrow" width="500" height="500"></canvas> alternatively, can use javascript set width , height match on-

c - Command terminated when inputting large number -

how come message "command terminated" when try input large number (around 10 million)? program displays whether number prime or not. see code below: #include <stdlib.h> #include <stdio.h> #include <stdbool.h> int main ( int argc, char *argv[] ) { unsigned long long number; bool prime ( unsigned long long ); printf ("enter positive integer greater 1: "); scanf ("%llu", &number ); prime( number ) ? printf ( "%llu prime.\n", number ): printf ( "%llu not prime.\n", number); return exit_success; } bool prime ( unsigned long long number ) { unsigned long long i, j; bool isprime[number + 1]; ( = 2; <= number; i++ ) isprime[i] = true; ( = 2; <= number - 1; i++ ) ( j = 1; i*j <= number; j++ ) isprime[i*j] = false; return isprime[number]; } the problem attempt create array isprime on stack larger available memory. should cre

How to return multiple values between two dates in excel? -

we have spreadsheet of our employees, , need generate list of employees who's 3 month probation period expire in coming week. in other words, need list automatically display employees records who's 3 month probation period expire in next 7 days. needs array because there multiple records each week, , change every day. column id number, value need return. our data looks this: a b c id name hire date 1234 joe blow february 21, 2014 2345 man chu february 26, 2014 3456 jim hill february 26, 2014 4567 brad chill february 28, 2014 5678 mike grow march 5, 2014 6789 hibs bee march 5, 2014 1230 sarah mean march 7, 2014 i've tried index&match `{=index($a:$a,small(if(and($c:$c">="&(today()-90),$c:$c"<="&(today()-80)),row($c:$c)),row(1:1)),1)} other formulas, it's not working, , can't figure out why. any appreciated, much. driving me crazy! your comme

c++ - Is there a time function its result is guaranteed to change every time is called? -

i tought gettickcount64() until tried this: #include <fstream> #include <windows.h> #include <iostream> void dosomething(); int main() { srand(gettickcount64()); std::fstream file; file.open("test.dat", std::ios_base::out | std::ios_base::trunc); (;;) file <<std::boolalpha<<(gettickcount64()==gettickcount64()) << std::endl; } and this: #include <fstream> #include <windows.h> #include <iostream> void dosomething(); int main() { srand(gettickcount64()); std::fstream file; file.open("test.dat", std::ios_base::out | std::ios_base::trunc); __int64 a, b; (;;) { = gettickcount64(); dosomething(); b = gettickcount64(); file <<std::boolalpha<<(a==b) << std::endl; } } void dosomething() { int t=(see below); (int = 0; < (rand() % t); i++) __noop; } with 1st variant received 1 false every 200.000 true (806642 iterations). with second varian

Why is Java pass by value only? -

so here worthy downvote question. i understand java pass value , means , how works. not can explain pass value is. more curious why java not include pass reference? imagine useful? helpful know cement reasoning in head.... i hate 'it because is' scenarios surely equivalent of 'because said so'. have answer why java includes pass value? o'reilly's java in nutshell david flanagan puts best: "java manipulates objects 'by reference,' passes object references methods 'by value.'" design decision java. when pass objects around, still manipulating same underlying object reference same memory location. i'm not sure specific scenario thinking can't existing java mechanisms.

android - Horizontal Scroll View (4 listview) -

in linear layout have 2 listview's vertically oriented. want add "second slide" 2 more listview's simmilar before. when open app, first 2 listview vertically oriented shown, , when scroll right 2 listview shown. and tried horizontal scroll, had 2 linear layout in horizontal scroll view brackets. in first linear layout first 2 listview's , in second linear layout 2 ... and got in console: horizontalscrollview can host 1 direct child... so, if i'm right, can't have 2 linear layouts in horizontalscrollview. have idea how it? i'm new in android, don't have idea how it... thank you, matija :) so, if i'm right, can't have 2 linear layouts in horizontalscrollview that's correct, @ least not 2 direct children of scrollview error message tells you. you could, however, wrap 2 linearlayout s in linearlayout (sounds horizontal orientation though i'm having trouble picturing doing). if explain little better tryin

c# - FileLoadException while accessing assembly dlls in project application folder -

i want load assemblies stored inside project application folder on c: drive. this code: public static void main(string[] args) { assembly asm = null; asm = assembly.loadfrom("c:\\sampleproj\\workspace\\test_app\\bin\\debug\\assemblies"); } the exception getting is: could not load file or assembly 'file:///c:\sampleproj\workspace\test_app\bin\debug\assemblies' or 1 of dependencies. access denied. i tried following, error remains same: keep project in other drive , access assemblies there removed read-only permission project folder-sub folders granted full control permissions users in project folder properties clicked on unblock button dll properties please help. as wrote in comment, not specifying valid path (you specifying folder when need specify dll). if want load assemblies in folder use piece of code: private static list<assembly> assemblies = new list<assembly>(); private static void

How to style each list item background of the wordpress navigation separately -

so i'm working standard wordpress navigation , need change background of each menu item when link inside list item active. .current-menu-item trick list items problem have same styling each element. for instance: <nav> <div> <ul> <li> <a href="index.html">home</a> </li> <li> <a href="portfolio.html">portfolio</a> </li> </ul> </div> </nav> does have experience this? i tried using pages like: http://codex.wordpress.org/function_reference/wp_nav_menu without result unfortunately.. also using child selectors didn't work.. it sounds want different active states each individual link. .current-menu-item captures active link, doesn't offer customization each individual link. i think can use combination of nth-child , .current-menu-item. know .current-m

PHP exec works on apache2 but not on nginx -

i'm trying launch unoconv using exec in php. works apache2, not nginx. i've checked php.ini , disable_functions not contain exec in both apache2 , nginx php.ini files. i'm not familiar unconv, i've had similar problem porting server apache nginx , exec . nginx + php-fpm have bare minimal $path set compared apache , , it's unoconv not on path. you try modifying path settings, better way specify absolute path of unoconv you can find absolute path using which unoconv you should re-direct error output stdout, can see why unoconv isn't starting exec("/path/to/unoconv -param0 -param1 2>&1", $output); print_r($output); //this should give failure reason

python - In PyGame, how to move an image every 3 seconds without using the sleep function? -

recently i've learned basic python, writing game using pygame enhance programming skills. in game, want move image of monster every 3 seconds, @ same time can aim mouse , click mouse shoot it. at beginning tried use time.sleep(3) , turned out pause whole program, , can't click shoot monster during 3 seconds. so have solution this? thanks in advance! :) finally solved problem of guys. thank much! here part of code: import random, pygame, time x = 0 t = time.time() while true: screen = pygame.display.set_mode((1200,640)) screen.blit(bg,(0,0)) if time.time() > t + 3: x = random.randrange(0,1050) t = time.time() screen.blit(angel,(x,150)) pygame.display.flip() pygame has clock class can used instead of python time module. here example usage: clock = pygame.time.clock() time_counter = 0 while true: time_counter = clock.tick() if time_counter > 3000: enemy.move() time_counter =

android - Dynamically added items in LinearLayout margin -

i have code add checkboxes array linearlayout. linearlayout my_layout = (linearlayout) findviewbyid(r.id.test); (int n = 0; n < listitems.size(); n++) { checkbox cb = new checkbox(getapplicationcontext()); cb.setid(integer.parseint(listitems.get(n).get("cbid"))); cb.settext(listitems.get(n).get("product")); cb.settextcolor(color.black); my_layout.addview(cb); } how can make sure between each checkbox there margin of 2-3dp? , background of checkboxes has rounded edges? this xml set boxes in <linearlayout android:id="@+id/parent" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <linearlayout android:id="@+id/test" android:layout_width="260dp" android:layout_height="wrap_content" android:orientation="vertical"

apache - Redirect http:// to all pages https:// -

i'd redirect pages http:// https://. i'm using kohana framework homepage redirects. go example.com/anyoldpage , doesn't redirect http:// if go http://example.com/anyoldpages , if go https://example.com , works. can please me? rel="canonical" works across website. example: if user lands on http://example.com/anyoldpage or http://www.example.com/anyoldpage page rel="canonical" works , presents https:// in seo terms works great. i'm going buying green bar ssl certificate want .htaccess file work. the current code is. rewriteengine on rewritecond %{http_host} ^do-main com [nc] rewriterule (.*) https://www.example.com/$1 [r=301,nc] rewriteengine on rewritecond %{https} !on rewriterule (.*) https://%{http_host}%{request_uri} please , thank :) you have lines, this: rewriteengine on rewritecond %{https} !on rewriterule (.*) https://%{http_host}%{request_uri}

ios - Tricky Object Sorting and Removing from NSMutableArray -

i have array of objects (that contain message), every object has same structure. has message property nsdictionary . 1 dictionary looks this: <message: { keycreatedate = "06/08/14 21:23"; keymessage = lorem ipsum; keyreceiverchannel = samplestring; keysenderuser = samplename; },... my goal make "inbox" display newest messages every user in each cell. want show newest messages each user, fb messages, what'sapp or imessage inbox, every cell in table view represents recent message friend. looks easy, it's harder imaged. need remove every message every friend, keep newest one. can remove message 1 user, can't keep newest while removing others. possible this? i can remove message 1 specified user code: nsmutablearray *originalarray = [[nsmutablearray alloc]initwitharray:message]; nsmutablearray *objectstoremove = [[nsmutablearray alloc]init]; nsmutablearray *clonearray = [nsmutablearray arraywitharray:originalarray]

python can't install mysql library -

i want connect mysql database python i tried this: pip install mysql-python question suggested no module named mysqldb but got exception cleaning up... command c:\python27\python.exe -c "import setuptools, tokenize;__file__='c:\\use rs\\user\\appdata\\local\\temp\\pip_build_user\\mysql-python\\setup.py';exec(com pile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __f ile__, 'exec'))" install --record c:\users\user\appdata\local\temp\pip-kkagjy-re cord\install-record.txt --single-version-externally-managed --compile failed wit h error code 1 in c:\users\user\appdata\local\temp\pip_build_user\mysql-python storing debug log failure in c:\users\user\pip\pip.log in python code, keep getting error no module named mysqldb i using windows 7 i found solution myself http://www.codegood.com/archives/129 download , enough

drop down menu - Making this function infinitely nesting based off a table -

i solved problem make dropdown menu in world of warcraft off of table. now need able nest far down user supplies. how this? here function use: local info = uidropdownmenu_createinfo() if level == 1 a,b in pairs(menulist) info.text = b[1] info.hasarrow = b[2] uidropdownmenu_addbutton(info, level) end elseif level == 2 a,b in pairs(menulist[uidropdownmenu_menu_value][3]) info.text = b info.func = onclick uidropdownmenu_addbutton(info, level) end end here table example used: testmenulist = {greetings = {"greetings", true, {"hi", "hello", "good day"}}, farewells = {"farewells", true, {"bye", "goodbye", "later"}}} it can setup 2 levels down. first , submenus. can me out? here solution: function iolib_createdropdown(parent, name, title, width, anchor, posx, posy,

apache - php doc_root in php.ini and DocumentRoot in httpd.conf -

i wanted learn more php , apache decided install them manually. don't understand how 2 files work (or if go hand in hand in situation). whenever load localhost webpage, location of php files directed specify in httpd.conf file. i've made 2 root folders sake of testing, c:/users/alex/test , c:\users\alex\my websites. apache not use location specified in php.ini (doc_root = "c:\users\alex\my websites"), instead uses location specified in httpd.conf (documentroot "c:/users/alex/test" ). can please explain when root useful in php.ini? most you're running mod_php inside of apache (this common way run php under apache). means php environment controlled entirely apache (in unix environments apache has own user well). can reconfigure use fast cgi (which way run php under other web servers nginx) , setting matter under type of setup. here's manual entry setting php's "root directory" on server. used if non-empty. if php

java - method resolution when instantiating an interface -

edit: forgot code snippet _ added here i trying learn java book 'learning java' has following code snippet listed example interface callbacks. in code snippet, there 1 class implementing interface textreceiver. question - since code instantiating interface directly, if there class implemented interface textreceiver , provided whole different method body interface method receivetext 1 in tickertape, how java resolve reference method receivetext in sendtext method of textsource? seems introduce ambiguity - also, seems credence have seen online not being able instantiate interfaces - wanted confirm before assuming interface textreceiver { void receivetext( string text ); } class tickertape implements textreceiver { public void receivetext( string text ) { system.out.println("ticker:\n" + text + "\n"); } } class textsource { textreceiver receiver; textsource( textreceiver r ) { receiver = r; } public void

wordpress - Google Adword not working /conversion.js not found -

i'm working on wordpress site. task add conversion script in thankyou page. added script here: http://www.livingedge.co.nz/thanks-for-getting-in-touch/ , unfortunately not work. says conversion.js not found. see attached screenshot: http://screencast.com/t/52ixquzhknxz i added conversion script on footer put in conditional load on thakyoupage. i'm new , can't figure out possible cause of such problem. tried adding script in header, on page editor, on form redirect. q: possible cause of issue? the url using conversion script incorrect — correct 1 has "www" in domain name. the fact you've got link wrong makes me think may looking @ incorrect directions. follow instructions given in google documentation page " setting conversion tracking " precisely.

PHP redirect in HTML assist -

i'm looking assistance on redirect of href. in php above html code : <?php session_start(); $cid = $_session['userid']; ?> in html below , possible me redirect them using href? for example: <a href="<?php $cid.memberpage.net;?>"only , join now</a> is possible so? need thank in advance. you can redirect user in many ways.. using php: <?php $cid="http://your.awesome.site/page.php"; header('location: '.$cid); ?> or using attribute <a href="<?=$cid;?>"only , join now</a> or automatically refresh in n sec <meta http-equiv="refresh" content="n; url='<?=$cid;?>'"><!-- replace n number of sec want user stay on page --> hope helps.

javascript - angular resource promise catch, jasmine toThrow() -

i have code in angular controller: user angular $resource returns promise when method called. $scope.credentials = { username:"", password:"", rememberme:false }; var currentuser = {}; $scope.login = function(callback){ user.get($scope.credentials) .$promise .then(function(user){ $scope.currentuser = user; return cb ? cb(user) : user; }) .catch(function(res){ throw "loginerror"; }); }; i'm trying test whether throws error or not jasmine so: expect(function(){ scope.login(); }).tothrow(); but error thrown: expected function throw exception. i have tested acceptance of promise, works expected, i'm assuming theres asynchronous aspect i'm not able deal with. i tried calling passing in , calling done() didn't work either. edit: i mocking out backend so: beforeeach(inje

javascript - Creating a calendar event with Google Apps Script from html5 time and date inputs? -

i have app uses html service create personal work time clock. can write start date , time end date , time along note spreadsheet. can pull spreadsheet data , display table of recent shifts app. the trouble when try , create calendar event. here have far. <h1>when did work?</h1> <div> <form id='timeclock'> <p class='in'>date in: <input type="date" id="datein" name="datein"></p> <p class='in'>time in: <input id="clockin" type="time" name="clockin" value="23:00:00"> </p> <p class='out'>date out: <input type="date" id="dateout" name="dateout"></p> <p class='out'>time out: <input id="clockout" type="time" name="clockout" value="07:30:00"></p> <textarea name="note"></textarea>

python - How to get the caller script name -

i'm using python 2.7.6 , have 2 scripts: outer.py import sys import os print "outer file launching..." os.system('inner.py') calling inner.py: import sys import os print "[caller goes here]" i want second script (inner.py) print name of caller script (outer.py). can't pass inner.py parameter name of first script because have tons of called/caller scripts , can't refactor code. any idea? thanks, gianluca one idea use psutil. #!env/bin/python import psutil me = psutil.process() parent = psutil.process(me.ppid()) grandparent = psutil.process(parent.ppid()) print grandparent.cmdline() this ofcourse dependant of how start outer.py. solution os independant.

sql server - Sql Get months Name between two dates in a table -

my table has columns id , startdate , enddate i need use way every row of table : not specific value : declare @start date = '2011-05-30' declare @end date = '2011-06-10' ;with months (date) ( select @start union select dateadd(month,1,date) months dateadd(month,1,date)<= dateadd(s,-1,dateadd(mm, datediff(m,0,@end)+1,0)) ) select datename(month,date) months is possible ?? if properly, might looks as: declare @tbl table (id int, start date, finish date) insert @tbl values (1, '2011-05-30', '2011-06-10'), (2, '2011-08-14', '2011-08-29'), (3, '2012-01-01', '2012-09-15') ;with periods as( select id, start, finish @tbl ) ,months(id, date) ( select id, start @tbl union select tbl.id, dateadd(month,1,months.date) months inne

cPanel/WHM Account creation error -

i have vps heartinternet running whm, have created many accounts in past no problem tried create 1 when got error: [a fatal error or timeout occurred while processing directive][a fatal error or timeout occurred while processing directive] (it shown twice above) there pop saying: 'ensuring services online' sit there doing nothing. i spoke guys @ heartinternet asked error logs shown following error: can't call method "errstr" on unblessed reference @ /usr/local/cpanel/cpanel/mysqlutils/connect.pm line 166. he replied this: i have logged server , found additional errors when attempting set account; whostmgr::accounts::create::__createaccount('hasshell', 1, 'quota', 'unlimited', 'dbuser', '****', 'password', '**********', 'username', '****', 'domain', '****.co.uk', 'maxftp', 'unlimited', 'cpmod', 'x3', 'plan', '',

haskell - Indexing Data.Vector with an array of indices -

is possible in haskell index vector data.vector using vector of integers b, i.e. a[b] = [ a[b[0]], a[b[1]], ... ] ? seems planned further versions vector tutorial , section 2.11 suggests. of course, 1 can write function this, involve lot of copying. it advisable use backpermute map (xs!) more efficient.

node.js - es.merge usage in gulp: Object #<Stream> has no method 'end' -

i struggling 2 parallel processing routes work in gulp. code looks this: gulp.task('build', function(){ return gulp.src(src,{cwd:srcdir}) .pipe(concat('sdk.js', {newline:'\n\n'})) .pipe(gulp.dest('dist/')) .pipe(jshint()) .pipe(jshint.reporter('default')) .pipe(es.merge( gulp.src('dist/sdk.js') .pipe(preprocess({context:{debug:true}})) .pipe(rename('sdk.debug.js')), gulp.src('dist/sdk.js') .pipe(preprocess({context:{}})) .pipe(uglify()) .pipe(rename('sdk.min.js')) )) //some more processing .pipe(gulp.dest('dist/')) ; }); i have found suggestion here such way of forking , merging streams should work. however, error: stream.js:79 dest.end(); ^ typeerror: object #<stream> has no method 'end'

objective c - NS_DESIGNATED_INITIALIZER expected : (colon) -

i trying declare designated initializer this: - (instancetype)initwithdelegate:(id <mydelegate>)delegate ns_designated_initializer; but showing me compilation error: expected ':' interestingly when try write (reference link: adopting modern objective-c ) - - (instancetype)init ns_designated_initializer; it shows error: expected ';' after method prototype. any ideas on how use ns_designated_initializer? ns_designated_initializer macro not defined in library headers xcode 5 - need xcode 6 use it. note link says "pre-release". the macro defined in following way (quoting nsobjcruntime.h ) #ifndef ns_designated_initializer #if __has_attribute(objc_designated_initializer) #define ns_designated_initializer __attribute__((objc_designated_initializer)) #else #define ns_designated_initializer #endif #endif note can still use - (instancetype)initwithdelegate:(id <mydelegate>)delegate __attribute__((objc_designated_initial

clock division in two in verilog -

i trying divide input clock 2 i.e output clock should half frequency of input clock. module clk_div(in_clk, out_clk, rst); input in_clk; input rst; output out_clk; reg out_clk; @(posedge in_clk) begin if (!rst) begin out_clk <= 1'b0; end else out_clk <= ~out_clk; end endmodule the testbench is module dd; // inputs reg clk_in; reg reset; // outputs wire clk_out; // instantiate unit under test (uut) clk_div uut ( .clk_in(clk_in), .reset(reset), .clk_out(clk_out) ); #10 clk_in =~clk_in ; initial begin // initialize inputs clk_in = 0; reset = 0; #100; reset = 1; end endmodule the output waveform shows input clock being generated. no matter try output clock waveform not come. code correct clock division two? you need change port names in instance. change instance to: clk_div uut ( .in_clk(clk_in), .rst(reset), .out_clk(clk_out) ); i divide-by-2 fix.

Counting hover times with jQuery -

i new javascript. want count how many times mouse hovers on word. tried code shown here - jquery count hover event - i'm not doing right. for example: <div> <p>the quick <a class="link1" style="color:#ff0000;">brown</a> fox jumps on <a class="link2" style="color:#ff0000;">lazy</a> <a class="link3" style="color:#ff0000;">dog</a>.</p> </div> javascript: jquery('.link1').mouseover(function(){ var $this = $(this); var count = parseint($this.data('count'), 10) + 1; $this.data('count', count); }); and repeat link2 , link3 "lazy" , "dog", doesn't work. can help, please? problem is, anchor element doesnt have data-count , cause error @ time of hover. add attribute work fine. <div> <p>the quick <a class="link1" data-count="0" style="col

How to make SearchView always expanded in android? -

i have searchview in top of layout (not in action bar), there anyway force view expanded (opened)? if not, wish place fancy image near it, there anyway make searchview hide image when expanded (clicked/expanded)? you can use property android:iconifiedbydefault="false" on xml or set programatically seticonifiedbydefault(false) . acording documentation property set searchview expanded want. take @ searchview.seticonifiedbydefault(boolean iconified)

asp.net mvc - MVC error path cannot be null -

i have 2 questions: 1) list of record database , displaying on index page table. error: additional information: argument 'path' cannot null, empty or contain white space. controller: public actionresult index() { records m = new records(); var records = db.records .include((m.types).tostring()); return view(records .tolist()); } in modal: public partial class records { public int id { get; set; } public nullable<int> types{ get; set; } public nullable<system.datetime> date { get; set; } } 2) have created models database using .edmx file, apply validation above fields. can [required]public nullable<int> types{ get; set; } etc... future if decide change database , perform update .edmx file [require] labels gone. how solve problem' route config file public class routeconfig { public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.a

c# - MachineKey.Encode output is hex how do i set it do base64? -

i'm trying match viewstate encryption in code, issue output of machinekey.encode hex encoded , not base64 encoded. code is: var plaintextbytes = encoding.utf8.getbytes("hello"); var encryptedvalue = machinekey.encode(plaintextbytes, machinekeyprotection.all); encrypteddata.text = encryptedvalue; var decryptedbytes = machinekey.decode(encryptedvalue, machinekeyprotection.all); decrypteddata.text = encoding.utf8.getstring(decryptedbytes); do have idea how can make code output base64 encoded string viewstate data encrypted? first off, consider using machinekey.protect , .unprotect, encode , decode obsolete. protect returns byte[], can pass convert.tobase64string byte[] encryptedvalue = machinekey.protect(encoding.utf8.getbytes("hello"), "some reason or another"); string encryptedutf8 = convert.tobase64string(encryptedvalue);

objective c - iOS Parse Query - Percentage Logging Different Numbers -

i'm returning 2 different queries parse...1 likecount , 1 dislikecount. when query each , set them equal respective labels come out correct. trying percentage of likes dividing likecount likecount+dislikecount. the query run when button pressed , push segue initialized. logs correct numbers (usually first time). however, after first time query run , 1 or maybe both of numbers values don't update , outputs labels initial text. @property (nonatomic, assign) float likecount; @property (nonatomic, assign) float dislikecount; - (void)queryforuseractivity { //create array check either user photo nsarray *userphotos = @[self.firstuserphoto, self.seconduserphoto]; pfquery *queryforlikes = [pfquery querywithclassname:kddactivityclasskey]; [queryforlikes wherekey:kddactivitytypekey equalto:kddactivitytypelikekey]; [queryforlikes wherekey:kddactivityfirstuserphotokey containedin:userphotos]; [queryforlikes wherekey:kddactivityseconduserphotokey contai

java - How to execute normal SQL query in Hibernate without HQL? -

i have pretty complex join query select few items db, , doesn't involve update required table. why, don't want use hql (hibernate query language, instead want execute simple sql query. is possible execute normal sql - join query involves 3 different tables in hibernate? use java - struts framework. if not possible have stick hql , post here query need in writing down hql based class(tables) creations , hql based query string. also, if please give me example query couple or 3 table joins , how set parameters sql. from below line of code can use query hibernate its call native sql session.createsqlquery("select * table join table1 b on a.id = b.id ").list(); for more go here

javascript - ko does not update binded controls if model is changed programmatically -

my model looks this. multi-functional page , model needs modified sometimes, when specific elements clicked, done using ajax call. update function updates model result, see below. unfortunately, model updates, elements on page stay same :( function viewmodel(result,currenttheme) { var self = this; self.isblankform = ko.observable(); self.snapedit = ko.observable(); self.snapeditsuccess = ko.observable(); self.ismenotified = ko.observable(); self.isemailsenttouser = ko.observable(); self.fromemailbox = ko.observable(); self.subjectemailbox = ko.observable(); self.themenames = ko.observablearray([]); self.themechoice = ko.observable(); self.bgcolor = ko.observable(); self.frmcolor = ko.observable(); self.txtcolor = ko.observable(); self.btncolor = ko.observable(); self.btntxtcolor = ko.observable(); self.appid = ko.observable(); self.revid = ko.obs

javascript - Moving Background Image diagonally across the screen -

i'm new here, can't comment/follow-up yet on question partially provided answer i'm trying achieve. on question here [ moving background image in loop left right fantastic , detailed answer jack pattishall jr lets me set page background scroll either vertically or horizontally. is there way combine directional code, page background scrolls diagonally (i.e. bottom left top right)? i've been "mutilating" jack's code days now, can't figure out how make background scroll in 2 directions simultaneously. :-( starting example mentioned above , here changes: html, body { height: 100%; width: 100%;} body { background-image: url('http://coloradoellie.files.wordpress.com/2013/10/25280-ginger-kitten-leaping-with-arms-outstretched-white-background.jpg?w=300&h=222'); background-repeat: repeat-x repeat-y; // line removed entirely } $(function(){ var x = 0; var y = 0; setinterval(function(){ x+=1;

famo.us - code like Lightbox example -

i'm searching code example of lightbox demo famo.us. unfortunately, interesting part of app in codepen uglified in pens version of famous.lib.js. it's not whole gallery thing i'm interested in, "just" scollable view multiple elements in 1 row, depending on size , screen size. has experiences in developing view/layout this? thanks in advance i have been doing work scrollview , gridlayout. can calculate grid dimensions based on contextsize , target/min cell size. here example started. adding gridlayout sole view in scrollview. know may work against scrollviews efficient rendering in scrollview rendering entire grid, doing examples sake. use modifier around gridlayout ensure size of view calculated , scrollview scrolls right amount. anyway, here did.. var engine = require('famous/core/engine'); var surface = require('famous/core/surface'); var rendernode = require('famous/core/rendernode'); var mod

iOS bluetooth low energy not detecting peripherals -

my app won't detect peripherals. im using light blue simulate bluetooth low energy peripheral , app won't sense it. installed light blue on 2 devices make sure generating peripheral signal , is. suggestions? labels updating , nslog showing scanning starting. thanks in advance. #import <uikit/uikit.h> #import <corebluetooth/corebluetooth.h> @interface viewcontroller : uiviewcontroller @property (weak, nonatomic) iboutlet uitextfield *navdestination; @end #import "viewcontroller.h" @implementation viewcontroller - (ibaction)connect:(id)sender { } - (ibaction)navdestination:(id)sender { nsstring *destinationtext = self.navdestination.text; } - (void)viewdidload { } - (void)viewwilldisappear:(bool)animated { [super viewwilldisappear:animated]; } - (void)didreceivememo

javascript - loading files (with regular expressions) in JS -

i have bunch of images foldered this: /first/345.jpg /second/12.jpg /third/394.jpg /fourth/234.jpg /fifth/5.jpg i'm trying go through folders , load image contained. there 1 image in each folder. how can tell javascript choose image, regardless of name? look @ code: for (var i=0; i<dirlist.length; i++) { // dirlist array containing folder names something.load.image("c:/.../"+ dirlist[i] +"/"+ anydigit + ".png"); } how can replace "anydigit" make work? regular expressions? thank you! just tested this. following list png in directory 1/ , 2/ var dirs = ['1/', '2/']; $.each(dirs, function(i, dir) { $.ajax({ url: dir, success: function(data) { $(data).find("a:contains(.png)").each(function() { var href = $(this).attr('href'); $('<p></p>').html(href).appendto($('div')); }); }}); });

Something like a manual refresh is needed angularjs, and a $digest() iterations error -

(post edited again, new comments follow line) i'm changing title of posting since misleading - trying fix symptom. i unable figure out why code breaking $digest() iterations error. plunk of code worked fine. totally stuck, decided make code little more angular-like. 1 anti-pattern had implemented hide model behind controller adding getters/setters controller. tore out , instead put model $scope since had read proper angular. to surprise, $digest() iterations error went away. not know why , not have intestinal fortitude put old code , figure out. surmise involving controller in get/put of data added dependency under hood. not understand it. edit #2 ends here. (post edited, see edit below) i working through first error: 10 $digest() iterations reached. aborting! error today. i solved way: <div ng-init="lineitems = ctrl.getlineitems()"> <tr ng-repeat="r in lineitems"> <td>{{r.text}}</td> <td>

core graphics - iOS - Can UIGraphicsGetCurrentContext be used outside drawRect? -

i want dynamically change current cgcontextref according different user actions? possible or modification possible within drawrect: of view instance? happens when call uigraphicsgetcurrentcontext() outside drawrect: , there limitations in doing so, recommended? possible implications need consider? according docs graphics context set before function called. means if function not called won't set , if don't make system call again (never reason) won't there either. use 1 of these functions force view drawrect: setneedsdisplay: setneedsdisplayinrect: it doesn't mean can stuff inside drawrect however. context sort of globally available @ moment , can call clean separate functions or classes drawing things. passing reference functions clean way it.

httphandler - save file in Silverlight without showing Save as dialog -

is possible save file users local downloads folder without prompting them save dialog? i have application user right mouse clicks choose option save specific file. i have used ihttphandler interface not sure how call handler in code system start saving downloads file without user having navigate different page one way out host required file on public url , navigate url in new tab/window silverlight app.. htmlpage.window.navigate(new uri("<your file's url>"), "_blank"); this should cause browser open link in new tab , in turn download automatically (occasionally depending on user settings)..

ruby - How is the `flash` in Rails made global to an application? -

i'm curious how rails achieves this. notice can access flash variable globally in app, isn't prefixed @ or $ . i can see there's method accessing flash , there's initializer set @flash , how can call flash local variable? session further apneadiving 's answer, flash part of middleware stack ( actiondispatch::flash ). it's non-persistent session cookie: -- from the docs : the flash special part of session cleared each request. means values stored there available in next request, useful passing error messages etc. much in same way params works (on per request basis), flash variable populated data previous request. -- middleware if take apneadiving 's comment, you'll see flash created through middleware stack - meaning local nature of variable set particular request (much same params ). why can access / set flash message in controller - because it's defined higher "middleware stack" - provides