Posts

Showing posts from March, 2015

c++ - Overriding a base class function with different return types -

i have base class named variable: class variable { protected: std::string name; public: variable(std::string name=""); variable (const variable& other); virtual ~variable(){}; }; i have several derived classes, such int, bool, string etc. example: class bool: public variable{ private: bool value; public: bool(std::string name, bool num); ~bool(); bool (const bool& other); bool getval(); each derived class has method named getval() returns different type (bool, int, etc.). want allow polymorphic behavior variable class. tried: void getval(); seemed wrong , compiler showed error: shadows variable::getval() sounds bad. thought of using template <typename t> t getval(); didn't help. any suggestions? have use casting that? many thanks... you can't overload return type . think template work better in case. there's no need polymorphism or inheritance here: template<class t> class v

jquery - Hiding placeholder inside updatepanel from asp.net -

i using updatepanel inside jquery popup on asp.net page. in updatepanel , have 2 placeholders. on 1 placeholder, have form buttons. when click save button, record saved in database. after record saved. want hide placeholder form. and show other placeholder thank message. how can ? i doing this: registerph.visible = false; thankyouph.visible = true; modalupdatepanel.update(); my html markup this: <asp:updatepanel id="modalupdatepanel" runat="server" updatemode="conditional"> <triggers> <asp:asyncpostbacktrigger controlid="btnregister" eventname="click" /> </triggers> <contenttemplate> <asp:placeholder id="registerph" runat="server"> </asp:placeholder> <asp:placeholder id="thankyouph" runat="server" visible="false"> <div class="row"> <div class="re

php - I want a like button that contains custom parameters, how can I do that? -

i want insert facebook button page: <div class="fb-like" data-href="http://www.site.com/news/b_news.php" data-send="false" data-layout="box_count" data-width="450" data-show-faces="true"></div> i want pass custom parameters every single article have. example, have index.php?function=news&id=33 , , whenever article id 33, want article's title , image liked page's image , title appearing on facebook. know these meta tags, static pages, since i've got 1 in website , meta tags should this: <meta content="'.$new['id'].'" property="og:description"></meta> i'm fetching description data array, database. how can solve this? just set meta tags dynamically (pseudo-code below): // controller // default values $view->meta_title = 'hello'; $view->meta_image = 'http://image'; $article = model_article($id) if ($article-&

How to set SQL Server 2008 R2 remote transaction time out -

i have written stored procedure executing c# windows application. connecting server using entity data model. the problem stored procedure takes more 4 minutes execute , complete process but whenever executing gives error timeout expired. timeout period elapsed prior completion of operation or server not responding. as searched due remote transaction time out because executing c# code because when executing server complete no error pls me.. have @ following, must finout these helpful http://technet.microsoft.com/en-us/library/ms190181(v=sql.105).aspx .net 4.0 entity framework timeout expired

PHP Fatal error: Allowed memory exhausted -

fatal error: allowed memory size of 134217728 bytes exhausted (tried allocate 32 bytes) for work have convert , reformat several xls , xlsx files csv. since i'm lazy , don't own copy of excel wrote few lines using phpexcel loops through directory on hard drive, converts each file , saves directory. the script works great, saves me loads of time, if there more 4 or files converted memory error. is there way clear data memory after it's no longer needed? can see below, tried doing bunch of unsets didn't seem help. error_reporting(e_all); ini_set('display_errors', true); ini_set('display_startup_errors', true); set_time_limit(0); require_once 'phpexcel.php'; require_once 'helper.php'; function swapext($file, $ext){ return str_replace(substr($file,strpos($file,".")),".".$ext,$file);} function makecsv($table){$csv = ""; foreach($table $r){$csv .= implode(",", $r).",\n";}return $csv

php - Form field Validation custom email requirements -

looking create form validation on email text field. have used validation ensure correct email produced. but here looking create more custom rule allows emails ending in format .ac.uk here user able provide university/college/instituion long last 6 characters in string = .ac.uk general format mail follows: email@university.ac.uk solution preferably in php, looking @ employing rule using end part in statement: ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$ making part *(\.[a-z]{2,3}) relate .ac.uk many thanks, appreciated jeanclaude i first run email through filter_var($email, filter_validate_email) rather using simple regex. it's not perfect (i've found few edge cases don't validate correctly) works well. once know it's valid email address can trust substr($email, -6) == '.ac.uk' , done it. like: if (filter_var($email, filter_validate_email) && strtolower(substr(trim($email), -6))) === '.ac.

python - CMake compilation error: Unknown CMake command "PYQT4_WRAP_UI" -

i tring compile qgis1.8 on centos6.3 after reading this post . i have added below code /qgis-1.8.0/python/cmakelists.txt @ top 1,2,3 line cmake_minimum_required(version 2.6) find_package(qt4) include(${qt_use_file}) however still have below errors: cmake error @ plugins/plugin_installer/cmakelists.txt:18 (pyqt4_wrap_ui): unknown cmake command "pyqt4_wrap_ui". -- configuring incomplete, errors occurred! -- cache values cmake_backwards_compatibility:string=2.4 cmake_build_type:string= cmake_install_prefix:path=/usr/local executable_output_path:path= library_output_path:path= qt_qmake_executable:filepath=/usr/bin/qmake-qt4 how can continue compile qgis source code?

gitignore - How can I tell git to ignore LibreOffice lock files? -

i have git repo contains xslx files. edit them libreoffice every once in while. libreoffice won't remove lock files ( ./folder/.~lock.filename.xslx# ). causes files liested new on every git status . i git ignore them. tried following in .gitignore doesn't seem work: *.~lock* .~lock* */.~lock* any ideas? update also tried: .~lock.*# as seen in http://lists.freedesktop.org/archives/libreoffice-commits/2012-december/040253.html no success. to test patterns .gitignore , git ls-files -ix '.~lock*' to see if cached aka staged aka tracked aka added files match ignore patterns (and may have been added in error), git ls-files -ic --exclude-standard as @nevikrehnel pointed out, git won't ignore tracked files. un-track file, git rm --cached path/to/it which take out of next commit, way take file out of earlier history rewrite e.g. git commit --amend if last commit, git rebase -i if you've got few or git filter-branch

calendar - Rails event_calendar week view -

this question exists on stackoverflow not answered, got suggestions... most people suggest use full_calendar, because complete, couldn't work...maybe because i'm on rails 4 , ruby 2, or maybe don't have compatible model, event calendar seens complete , easy enough anyways... i found on event_calendar ( lib / event_calendar / calendar_helper.rb ) these comments # # helper methods working calendar week # by these comments guess possible use in week view. tried ? if have suggestions work week calendar on rails appreciate! if looking answer, suggestion calenderize gem! https://rubygems.org/gems/calendarize

sql - change specific data of column -

i have table in 10 record, want update specific column data, means part column data , not, example in row 1 want change std standard , other data remain same, change same thing in row in single query. can possible? , remember cant remove , add cell again because change id id - col1 - col2 1 - - std abcad 2 - b - std bcddsad 3 - c - std avadsad 4 - - std abcdsad 5 - b - std bcddsa 6 - c - std avadsad 7 - - std abcdsd 8 - b - std bcddsds 9 - c - std avadsd you can use replace function this update table set col2 = replace(col2, 'std', 'standard');

titanium - Cannot read property '__transform' of null data binding issue -

i getting error cannot read property '__transform' of null data binding issue. the line of code of corresponding error resources section: text: "undefined" != typeof $model.__transform["topic"] ? $model.__transform["topic"] : $model.get("topic") i assume somehow model not getting referenced correctly. here model code. in file chatthreadsql.js in models directory: exports.definition = { config: { "columns": { "uuid":"text unique primary key", "topic": "text", "created":"text", //"patient": "", }, adapter: { "type": "sql", "collection_name": "chatthreadsql_col", // idattribute tells alloy/backbone use column in // table unique identifier field. without // specifying this, alloy's default behavior create // , "alloy_id" field uniquely ident

objective c - Navigationbar changes bartintcolor randomly only on iPhone 4 -

i have serious problem app on iphone 4 devices running ios 7. app has tabbarcontroller 5 tabs each tab has navigationcontroller (and view navigationbar). app working great on iphone 5 , devices in simulator not real iphone 4. my goal every tab has own navigationbar color, in viewwillappear method made example this: [self.navigationcontroller.navigationbar setbartintcolor:[uicolor colorwithred:0.102 green:0.129 blue:0.282 alpha:1.0]]; [self.navigationcontroller.navigationbar settranslucent:yes]; as mentioned before, works great except real iphone 4. if switch through tabs seems working, colors of navigationbars correct. when open 1 tab again (which have opened before) navigationbar plain white!!! i confused why? for ran same issue... bug , reported. see apple dev forum. seems happening if use mapkit.

python 2.7 - I'm getting a error in Google App Engine to do with import sqlite3? Can somebody help me please? -

the error getting is: raise importerror('no module named %s' % fullname) importerror: no module named _sqlite3 from _sqlite3 import * dbapi2 import * import sqlite3 it has with: import sqlite3 can me please? i'm using google app engine python on windows 7 machine in case has it. the appreciate. thanks as far aware, google app engine not support sqlite. has own database system, uses vaguely sql language call gql. to prevent accidently using wrong database, developement environment has intercepted import of sqlite, , has raised error.

java - Having a access database conenction issue -

i'm working on login system compares user inputted values in access data , i'm having issues accessing database. error message dispayed "[microsoft][odbc microsoft access driver]could not find file'(unknown)'." appreciate help, thank you. here code: private void btnloginactionperformed(java.awt.event.actionevent evt) { connection conn = null; string sql="select username, password employeedetails"; try { boolean found = false; class.forname("sun.jdbc.odbc.jdbcodbcdriver"); conn = drivermanager.getconnection("jdbc:odbc:driver={microsoft access driver (*.mdb)};dbq=accountdetails.mdb"); statement stmt=conn.createstatement(); resultset rs = stmt.executequery(sql); user = username.gettext(); string pwd = new string (password.getpassword()); while(rs.next()) { string uname

html - How to create a fixed element -

Image
as can see in picture, how can make menu tab fixed one? i tried changing div positioning property fixed , problem gets overlaid on picture. menu part gets screen when tab1 clicked. i want make menu part fixed , while clicking on menu contents , that : menu 1,2,3 , right side content part should change. i have uploaded files here: link . use position: fixed bottom: 54px; //change want width: 100%; //change want

php - Magento - Get Best Sellers Product including Soldout Products -

this code products available in stock. want products, including sold-out. have idea? $productcount = 5; $storeid = mage::app()->getstore()->getid(); $productsbestsellermens = mage::getresourcemodel('reports/product_collection') ->addorderedqty() ->addattributetoselect('*') ->setstoreid($storeid) ->addcategoryfilter($mensid) ->setpagesize($productcount); the comment osdave place start finding answer question. at it's heart magento uses zend_db when accessing database. result can use 'magic' __tostring() method of zend_db_select output underlying mysql query generated php code. category filtering specific situation i've adapted original code slightly: $productcount = 5; $storeid = mage::app()->getstore()->getid(); $productsbestsellermens = mage::getresourcemodel('reports/product_collection') ->addorderedqty

django - Apache2 can not parse html under mac os x 10.8.5 -

environment: mac os x 10.8.5, , apache2. recently, build apache2+django+mysql. but found apache2 can not parse html, show html code in browser. how should problem? thank much. apache does not parse html . experiencing encoding problem or invalid html (browsers tolerate lot, has wrong...). use standard httpd.conf , point web browser domain , see happens. problem somewhere else in stack.

delphi - control string in TRichEdit -

using 2 buttons add lines trichedit control; there way can use second button continue line of first button? i have tried using control string sequence of #8 backspace it, doesn't work me. else can do? if understand question correctly, can concatenating (adding) second half of string first half you've added. procedure tform1.button1click(sender: tobject); begin richedit1.lines.add('this first half'); end; procedure tform1.button2click(sender: tobject); var lastline: integer; begin lastline := richedit1.lines.count - 1; // make sure we've added text before if lastline <> -1 richedit1.lines[lastline] := richedit1.lines[lastline] + ', , here second half.'; end;

c# - link two check boxes to one messagebox? -

in form when check both checkboxes messagebox displayed. both checkboxes linked 1 messagebox. have tried different messagebox functionality end displaying messagebox when 1 check box marked. if (e.keycode == keys.q) checkbox1.checked = !checkbox1.checked; if (e.keycode == keys.a) checkbox2.checked = !checkbox2.checked; messagebox.show("task completed", "form1"); this worked me. private void cbox2_checked(object sender, routedeventargs e) { if (cbox1.ischecked == true && cbox2.ischecked == true) { messagebox.show("task completed", "form1"); } } private void cbox1_checked(object sender, routedeventargs e) { if (cbox1.ischecked == true && cbox2.ischecked == true) { messagebox.show("task completed", "form1"); } } set if statements @ both checked even

css - Vertical text, centered in div -

Image
i'm stuck on making text (single line) run vertically , remain centered in container, left right , top bottom. how done css? use transform property rotate div here css , padding making vertical center align , text-align making gorizontal center align. crossbrowser solution: div { margin: 50px; width: 100px; text-align: center; height: 50px; background: red; -moz-transform: scale(1) rotate(90deg) translatex(0px) translatey(0px) skewx(0deg) skewy(0deg); -webkit-transform: scale(1) rotate(90deg) translatex(0px) translatey(0px) skewx(0deg) skewy(0deg); -o-transform: scale(1) rotate(90deg) translatex(0px) translatey(0px) skewx(0deg) skewy(0deg); -ms-transform: scale(1) rotate(90deg) translatex(0px) translatey(0px) skewx(0deg) skewy(0deg); transform: scale(1) rotate(90deg) translatex(0px) translatey(0px) skewx(0deg) skewy(0deg); } p { margin: auto; padding: 15px; } live demo: http://jsfiddle.net/yanx

VB.NET Try Catch block issues -

the program need complete focusing on try catch blocks. problem having error message shown every time user tries input anything, valid numeric data. i've been trying figure out past few hours, maybe can see mistake... private sub calculatebutton_click(byval sender system.object, byval e system.eventargs) handles calculatebutton.click 'convert input values numeric variables. dim snowboardinteger, withbootsinteger, totalinteger integer try 'convert snowboard numeric variable. snowboardinteger = integer.parse(snowboardstextbox.text) try 'convert boots if snowboard sucessful. withbootsinteger = integer.parse(withbootspricetextbox.text) 'calculate total price. totalinteger = snowboardinteger + withbootsinteger 'calculate summary values. snowboardsuminteger += snowboardinteger withbootssuminteger += withbootsinteger totalsuminte

How to check open ports using powershell? -

i write script check radom ip or hostname see if ports open. here have far. scripts name checkports. foreach ($xhost in $computername){ write-host $xhost foreach ($port in $ports) { $socket = new-object system.net.sockets.tcpclient $connection = $socket.beginconnect($xhost,$port,$null,$null) $connection.asyncwaithandle.waitone(5000,$false) | out-null if ($connection -eq $true) { write-host = "$xhost port $port open" } else { write-host = "port $port closed" } $socket.endconnect($connection) $socket.close() } } i input values in following way: .\checkport '192.186.1.5' or '192.168.1.5', '192.168.1.105', 192.168.1.110' | checkport it doesn't seem reading ip address or displaying results. i wondering if point out there show me doing wrong in script? i've been able use 'test-port' function boe

javascript - Set variable across JQuery loaded pages -

i have page has 3 sections. on left static menu e.g. <a href="#" class="actionlink" id="newfile"><li>new file</li></a> this can start new actions e.g. $('.actionlink').click(function() { var folderid; // trying set id here var filename = $(this).attr('id'); $("#myaction").load('/ajax/actions/' + filename + '.php?folder_id=' + folderid); }) so, loads /ajax/actions/newfile.php in middle page loaded using jquery .load() . within page in middle series of folders have id. on click, these folders display contents shown on right of page. e.g. <span id="12" class="folder active99">music</span> $('.folder').click(function() { var folderid = $(this).attr('id'); $("#myaction").load('/ajax/actions/links.php?folder_id=' + folderid); }) when clicked shows contents on right. note variable folderid.

class - Java Dice Program Always goes to Else statement despite the outcome of the users choice -

the program asks user how many players wishes have, once prompted program runs, player 1 receives 3 rolls of 2 6 sided dices (3 times) , on next players. players can choose rolls keep or potentially keeping both. the problem occurs however, rolls same every player, it's math.random has no effect in player class program. problem occurs here : else { joptionpane.showmessagedialog(test,"tie "+ data[0] + " , " + data[1]); program goes else statement of class when 2 players selected. goes else statement on every single player count in, anywhere 2-4 players, results in proceeding specified else statement. i have tried running loop in pairofdice class around 2 die's, no avail did not change rolls of dice. have tried reset die values after every time program has gone through 1 loop, caused values stuck @ zero. input appreciated. import javax.swing.*;//main logic program public class logic { public static void main (string [] args) { pairofdice

c# - Function as variable throwing error NotImplementedException unhandled -

okay have added function c# script fetch ip address , send output string in variable heres source using system; using system.collections.generic; using system.linq; using system.text; using system.collections.specialized; using system.net; using system.io; namespace consoleapplication1 { class program { static void main(string[] args) { string url = "http://localhost/test2.php"; webclient webclient = new webclient(); namevaluecollection formdata = new namevaluecollection(); formdata["var1"] = formdata["var1"] = string.format("machinename: {0}", system.environment.machinename); formdata["var2"] = stringgetpublicipaddress(); formdata["var3"] = "dgpass"; byte[] responsebytes = webclient.uploadvalues(url, "post", formdata); string responsefromserver = encoding.utf8.getstring(responsebytes); console.writeline(responsefromse

android - Cannot touch a external view from inside a AsyncTask... but not always -

i have made asynctask should compile textview. short recap of did. deleted lot of lines hope didn't forget anything. public class myclass extends relativelayout { private textview messagetextview; public myclass(context context) { super(context); init(context); } public myclass(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); init(context); } public myclass(context context, attributeset attrs) { super(context, attrs); init(context); } private void init(context context) { createlayoutcontent(); run(); } private void createlayoutcontent (context context) { this.setlayoutparams(new relativelayout.layoutparams (relativelayout.layoutparams.match_parent, 0)); messageview = new textview(context); messageview.settext("test"); this.addview(messageview); } private void start() { new

math - Solving the recurrence T(n) = T(n/2) + T(n/4) + T(n/8)? -

i'm trying solve recurrence t(n) = t(n/8) + t(n/2) + t(n/4) . i thought idea first try recurrence tree method, , use guess substitution method. for tree, since no work being done @ non-leaves levels, thought ignore that, tried come upper bound on # of leaves since that's thing that's relevant here. i considered height of tree taking longest path through t(n/2) , yields height of log2(n) . assume tree complete, levels filled (ie. have 3t(n/2)) , , have 3^i nodes @ each level, , n^(log2(3)) leaves. t(n) o(n^log2(3)) . unfortunately think unreasonable upper bound, think i've made bit high... advice on how tackle this? one trick can use here rewriting recurrence in terms of variable. let's suppose write n = 2 k . recurrence simplifies to t(2 k ) = t(2 k-3 ) + t(2 k-2 ) + t(2 k-1 ). let's let s(k) = t(2 k ). means can rewrite recurrence as s(k) = s(k-3) + s(k-2) + s(k-1). let's assume base cases s(0) = s(1) = s(2) = 1, s

C: free(): invalid next size (fast) -

this question has answer here: facing error “*** glibc detected *** free(): invalid next size (fast)” 2 answers hello i've spent last couple hours looking through code attemting find causing memory error. ive been told repeatedly situation of freeing never malloced or freeing twice, have gone through , shrunk code down make sure neither of these possible. whole project linked list, ive taken out of components of project make smallest possible replication of error. thanks! code: #include <stdlib.h> #include <stdio.h> #include <string.h> #include "list.h" struct lnode{ int count; int line; struct lnode *next; char *word; }; struct lnode* newnode (char* word, int line) { struct lnode *mynode = malloc(sizeof(struct lnode*)); mynode->word = (char*)malloc((strlen(word))*sizeof(char)); strcpy(mynode->word,word);

wpf - setting URL as mediaElement source -

i keep getting "object reference not set instance of object" , have absolutely no idea why! mediaelement1.source = new uri(trackstream(0), urikind.absolute) if mouseover check seems fine, variable position contains direct link mp3, says if mouseover source has been set url error. i trying set url first in list have downloaded textfile previously, put array. have tried changing urlkind , omitting it. this works: public mainwindow() { string[] trackstream = new string[] { @"c:\users\public\music\sample music\sound.wma" }; initializecomponent(); media.source = new uri(trackstream[0], urikind.absolute); }

android - Add Spinner To Action Menu Bar -

Image
i looking example how add spinner item array of items android menu options . i many examples there not simple example can fine .i want add item action bar on top of screen. spinner in right on action bar sherlock icslinearlayout private string[] mlocations; actionbar actionbar = getsupportactionbar(); final context themedcontext = actionbar.getthemedcontext(); arrayadapter<string> adapter = new arrayadapter<string>(themedcontext, r.layout.sherlock_spinner_item, mlocations); adapter.setdropdownviewresource(r.layout.sherlock_spinner_dropdown_item); // create ics spinner spinner = new icsspinner(this, null, r.attr.actiondropdownstyle); spinner.setadapter(adapter); spinner.setonitemselectedlistener(new onitemselectedlistener() { @override public void onitemselected(icsadapterview<?> parent, view view, int position, long id) { } @override public void onn

r - Deriving/interpreting factor loadings from factor analysis -

trying factor analysis first time . have set of data representing closing prices of s&p index , 10 other stocks .when run scree test on data set(11 variables ) eigen value of 2 run factanal number of factors =2 , turns out p value low. bump number of factors until 6 after run numerical problems. assume should fail reject hypothesis number of factors 6. now assuming ever have described above correct way proceed how derive factor loadings 6 factors ? comment able figure out factor loadings how interpret them ? as can see lodings empty of factors. these values : loadings: factor1 factor2 factor3 factor4 factor5 factor6 sp500 0.597 0.710 0.150 0.107 0.316 xom 0.963 0.124 0.147 -0.165 bgcp 0.762 0.394 0.148 0.349 intc 0.282 0.935 0.117 fb 0.742 0.634 -0.171 ' the factional() function re

node.js - Heroku App not Found -

i'm in myappname directory. heroku config | app not found i have type heroku config --app myappname mongolab_uri: mongodb://herokuapp1234:abcd1234.mongolab.com:49538:heroku_app1234 path: bin:node_modules/.bin:/usr/local/bin:/usr/bin:/bin how set heroku config detect app without using --app? i'm guessing reason why app.js can't use process.env.mongolab_uri , application error when deploy heroku. install heroku toolbelt in app directory.

file - How to properly use "INCLUDE" in PHP script -

i have php script goes through list of movie data , parses data return movie title , rating several businesses. i'd have data parsing script single file included in several different files, if need edit movie data parser script, same every file it's included in. this code of data parsing script works perfectly. filename, need replace variable, when included in file, can change filename variable name of correct movie list. originally, had each business own php data parsing script, it's not maintainable. foreach (glob('mov/filename.*mov') $filename){ $thedata = file_get_contents($filename) or die("unable retrieve file data"); } $string = $thedata; $titles = explode("\n", $string); function getinfo($string){ $ratings = ['g', 'pg', 'pg-13', 'r', 'nr', 'xxx']; $split = preg_split("/\"(.+)\"/", $string, 0, preg_split_delim_capture); if(count($split) == 3)

java - Scan all the files and Display the name and path of the file with the maximum size -

it program (java) uses system calls extract basic information related system. scan files , display name , path of file maximum size can please confused system calls. thanks this tou need. should read documentation file api . http://docs.oracle.com/javase/7/docs/api/java/io/file.html public class listfiles { public static void main(string[] args) { // directory path here string path = "."; string files=""; double maxbytes = 0; file folder = new file(path); file[] listoffiles = folder.listfiles(); (int = 0; < listoffiles.length; i++) { if (listoffiles[i].isfile() && listoffiles[i].length()>maxbytes) { maxbytes = listoffiles[i].length() files = listoffiles[i].getname(); } } system.out.println(files); } }

c++ - Navigating an Array with Column Boundaries -

let's there square 2 dimensional array of n x n, represented 1 dimension array. let array 5x5, below, , values in array not significant. std::vector< int > array { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4 }; if there 5 rows , 5 columns in array, how can 1 detect if on edge of row? instance, if on index of 9 on 4th row, how can know can go left without changing rows, going right advance next row? how can 1 access cell's neighbors respect edges? index of 9 on 4th row not have right neighbor. the way can think of how current index, in case is int index = row * num_cols + col and perhaps use modulus (index % 5 == 0) determine if on edge. not determine if can go left or right. your formula int index = row * num_cols + col; going or down equivalent adding / subtracting num_cols . is correct. reverse of is int row = index / num_cols; int col = index % num_cols; you know you're on left edge

osx - how to mach_inject without sudo -

i've written plugin finder on mac(mountain lion) , works perfectly, have run bundle sudo. make package(packagemaker) run bundle , failed(install correctly , if run clicking desktop icon failed, if run though commandline sudo, works). know how fix issue installing dropbox (and sync icon shows) the problem you're facing that, internally, mach_inject calls function task_for_pid. this function returns kernel task id given process pid , due security reasons, apple requires use of function can take place users members of either root or procmod groups. explains why running sudo works you. if you're developing own use, simplest method add procmod group. however, if want distribute application, you'll need ensure installer installs program run member of root or procmod groups. one possibility separate application 2 parts, second registered run elevated privileges using smjobbless . if don't program in objective-c, don't worry parts of smjobbless requ

binding - Javafx combobox bound value cannot be set exception -

i'm using trying use javafx combobox cell factory render list, using settext on override updateitem() of celllist, found out when change value on underlying model, doesnẗ afects deployed list on combo box. try make binding both properties , it's works when try clear selection have exception. code: import javafx.application.application; import javafx.beans.property.simplestringproperty; import javafx.event.actionevent; import javafx.event.eventhandler; import javafx.scene.scene; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.stage.stage; import javafx.util.callback; public class basiccomboboxsample extends application { public static void main(string[] args) { launch(args); } @override public void start(stage stage) { final employee john = new employee("john"); final employee jill = new employee("jill"); final employee jack = new employee("jack"); final combobox<empl

xamarin.android - MvvmCross: change update source trigger property of binding on MonoDroid -

i change default binding trigger propertychanged lostfocus on droid edittext view: <edittext android:layout_width="fill_parent" android:layout_gravity="center" android:textsize="16dp" android:minwidth="168dp" local:mvxbind="text selectedcode, updatesourcetrigger=lostfocus" /> but cannot find correct syntax wiki i know possible within framework cannot find reference. ideas? tia. the binding syntax doesn't provide updatesourcetrigger the ways change triggering mechanism are: to provide custom binding or provide custom control i'd go custom binding - like: public class mvxedittextfocuschangetextspecialtargetbinding : mvxandroidtargetbinding { protected edittext edittext { { return (edittext)target; } } private bool _subscribed; public mvxedittextfocuschangetextspecialtargetbindin

java - Breakpoint in loop after large number of iterations in Eclipse -

suppose have following code. while debugging, want eclipse stop when has done 1 million iterations. how this? cannot manually 1 million times. for(int = 0; < 10000000; i++) { //some code } you can put conditional break point in eclipse: put breakpoint right-click->properties turn on "condition" check-box put condition code i == 1000000

How to take in multiple inputs from user in assembly -

i'm pretty new assembly. know how take in 1 value user, if want user input 3 numbers separated spaces. i'm trying store each of them separate register, this. push qword 0 ;make space 8-byte number push qword 0 ;make space 8-byte number push qword 0 ;make space 8-byte number mov qword rdi, formatfloatinput mov qword rsi, rsp mov qword rax, 0 call scanf pop qword r15 ;pop value stack r15 pop qword r14 ;pop next value in stack r14? pop qword r13 ;pop next value in stack r13? sample input: 13 15 36 now r15 should contain 13, r14 contains 15 , r13 contains 36. the c equivalent scanf("%ld %ld %ld&quo

windows phone 8 - WP8: how to get back an IntPtr in c++ -

i'm developping plugin winphone 8 unity3d using c++ , directx. i'm right stuck because don't know how pass intptr type c# code c++ code. it's easier android or ios plugin since can data void*. in windows phone runtime component project it's not possible. read i've got use winrt types. i've search here code samples: in c#: public delegate void wp8enabletexturedrawing(system.intptr texture); private wp8enabletexturedrawing wp8enabletexturedrawing; public void setwp8texturedrawingfunc(wp8enabletexturedrawing func){ wp8enabletexturedrawing = func; } //... wp8enabletexturedrawing(targettexture.getnativetextureptr()); in c++ header file matches delegate way: static void enabletexturedrawing(platform::object ^textureptr); but compiler throws error -> no overload 'wp8texturedrawing.texturedrawing.enabletexturedra wing(object)' matches delegate 'nativetexturedrawer.wp8enabletexturedrawing' i hope has hands in me out. th

Advice with if statements and python math comparators and input function -

the program should ask whole number before printing anything. program must check input numbers between 0 , 5. fail if number of digits entered other 5. failed input can terminate program appropriate error message. inputted numbers may duplicates. (ex. 3, 3, 3, 0, 0 acceptable input.) need getting program print out '.' if input=0. , asking 5 digits @ same time. nums[] nums= input number=int(input) n in number: if n<0 , n>=5 , if len(n)=5: print 'x'*n elif n==0 , if len(n)==5: print '.' elif n>0 or n<5 or len(n)!=5: print "invalid input" your program bit messed up.. forgive me if i'm being little rough first, isn't allowed: nums[] second, number = int(input) is invalid, because input not valid number. third, for n in number number integer, not list! fourth, if number list: len(n) ==5: will still invalid, because n integer! try this: input_list = raw_input("

java - Drag and drop check Boxes from one panel to another -

i want drag , drop check boxes 1 panel in java. have found 1 link looks quite useful, written in 1999 , don't know whether updated or not. http://www.javaworld.com/jw-03-1999/jw-03-dragndrop.html?page=2

ios - acess element of NSArray with its index -

this question has answer here: bracket syntax in objective-c [duplicate] 3 answers what details of “objective-c literals” mentioned in xcode 4.4 release notes? 3 answers is possible access elements of nsarray based on index , use them comparison/operations? just arrayname[ith element] in c/c++ yes , can access elements of nsarray based on index . nsarray *a=@[@"s1",@"s2",@"s3"]; nslog(@"%@",a[1]);

c - Is this filter implementation making correct output? -

i want make finite impulse response fixedpoint arithmetic. put program i'm not sure it's correct: #include <stdio.h> #include "system.h" #define fbits 16 /* number of fraction bits */ const int c0 = (( 299<<fbits) + 5000) / 10000; /* (int)(0.0299*(1<<fbits) + 0.5) */ const int c1 = ((4701<<fbits) + 5000) / 10000; /* (int)(0.4701*(1<<fbits) + 0.5) */ /* ditto c3 , c2 */ const int c2 = (( 4701<<fbits) + 5000) / 10000; /* (int)(0.4701 *(1<<fbits) + 0.5) */ const int c3 = ((299<<fbits) + 5000) / 10000; /* (int)(0.299*(1<<fbits) + 0.5) */ #define half (1 << (fbits) >> 1) /* half adjust rounding = (int)(0.5 * (1<<fbits)) */ signed char input[4]; /* 4 recent input values */ char get_q7( void ); void put_q7( char ); void firfixed() { int sum = c0*input[0] + c1*input[1] + c2*input[2] + c3*input[3]; signed char output = (signed char