Posts

Showing posts from June, 2013

javascript - Calculation is not working with custom Cell Rendering with AJAX in Handsontable -

in table(handsontable) have 4 columns cars , a , b , c . data cars , a columns loaded mysql database. (like php demo ). data of column b populated mysql database via ajax depending on value of cars . code follows: {type: { renderer : function (instance, td, row, col, prop, value, cellproperties) { handsontable.textcell.renderer.apply(this, arguments); var cr,prc; cr = instance.getdataatcell(row, 0); prc = instance.getdataatcell(row, 1); $.ajax({ url: "php/act-go-t.php", data: {cars: cr, price: prc}, datatype: 'json', type: 'post', success: function (res) { if (res.result[0].tax === null) { td.innerhtml = '0.000'; } else { td.inne...

javascript - Few large arrays, or one large array of few variables? -

apologies if question has been asked before i'm finding hard word question in way might have been asked before. q: more efficient have like: mass[128] = {0.0} speed[128] = {0.0} age[128] = {0} or: properties[128] = {mass=0.0, speed=0.0, age=0} and why? there simple rule bear in mind, (are few larger arrays better many small etc)? i'm writing in js using chrome. reading , writing elements often. thanks much! in general, answer here is: makes sense let write simplest, clearest code; , worry performance or memory issue if run one. using array of objects named properties more efficient in terms of access time on modern javascript engine, , less efficient in terms of memory use. in both cases, difference incredibly minor , imperceptible. if values numbers , arrays can of fixed size, might use typed arrays , since arrays (where normal arrays aren't 1 unless javascript engine can optimization). there downsides typed arrays (their being fixed size, in...

java - Function composition chain using method -

how should declare method combine can take arguments in such way: function<list<string>,string> f1; function<string,list<integer>> f2; function<list<integer>,integer> f3; system.out.println(this.combine(f1)); system.out.println(this.combine(f1,f2)); system.out.println(this.combine(f1,f2,f3)); etc this generic object parameter indicating type of objects contains, in above example list of string thanks help thanks, right. method combine should return value of last function, so: obj obj = new obj(arrays.aslist(args)); string s = obj.combine(f1); list<integer> l = obj.combine(f1,f2); integer = obj.combine(f1,f2,f3) you can't overload combine method

cuda - Using cuBLAS-XT for large input size -

this link says cublas-xt routines provide out-of-core operation – size of operand data limited system memory size, not gpu on-board memory size. means long input data can stored on cpu memory , size of output greater gpu memory size can use cublas-xt functions, right? on other hand, this link says "in case of large problems, cublasxt api offers possibility offload of computation host cpu" , "currenty, routine cublasxtgemm() supports feature. case problems input size greater cpu memory size? i don't difference between these two! appreciate if helps me understand difference. the purpose of cublasxt allow operations automatically run on several gpus. so, example, matrix multiply, or other supported operations, can run on several gpus. the cublasxtgemm routine has special capability, in addition parallelizing matrix multiply across 2 or more gpus, can parallelize across 2 or more gpus plus use host cpu additional computation engine. the matrix ...

hadoop - Unable to indentify the bug in my Reducer join code -

i have 2 datasets: users: bobby 06 amsterdam sunny 07 rotterdam steven 08 liverpool jamie 23 liverpool macca 91 liverpool messi 10 barcelona pique 04 barcelona suarez 09 barcelona neymar 11 brazil klopp 12 liverpool userlogs: sunny newplayer 12.23.14.421 klopp crazy 88.33.44.555 bobby newplayer 99.12.11.222 steven captain 99.55.66.777 jamie local 88.99.33.232 suarez spain 77.55.66.444 i want join these 2 datasets using reducer join. wrote classes in way: mapperclass: public class mapperclass { public static class usermap extends mapper<longwritable, text, text, text> { @override protected void map(longwritable key, text value, context context) throws ioexception, interruptedexception { string line = value.tostring(); string[] tokens = line.split(" "); string name = tokens[0]; string city = tokens[2]; context.write(new text(name), new text("userfile" + ...

c# - Visual Studio - cannot run any projects: application was unable to start correctly (0xc0000142) -

Image
windows 10 x64 visual studio 2012 x32 .net framework 3.5 , 4.6 i cannot run/debug/f5 projects in visual studio. have tried nopcommerce, blogenginedotnet, file->new website, etc. first getting error .net 4.5 , .net 4.0 not being registered, installed fix microsoft ( https://support.microsoft.com/en-us/kb/3002339 ) resolved issue. now, everytime try f5 error below. i've searched until ready beat head against desk. found lot of posts few years ago saying use dependency walker see if pre reqs fail, dependency walker says windows 8. uninstall visual studio 2012 x32 , install new visual studio 2012 x64 because os 64 bit above code helps make working.

javascript - React making components out of elements -

i putting elements of website making react components out of them. here's button example: import react 'react'; class button extends react.component { render() { return <button classname={this.props.bstyle}>{this.props.title}</button>; } } export default button; i have lots of other elements put react components there's going large list of them. the problem have lots of them , need import list can grow big. just imagine 50 of these: import element './element.component'; // x50 ? my question is...is better approach importing large lists of components in react? you can import of elements 1 file , export individually. able import elements , use elements.somecomponent. // common.js because ll commonly use them import element './element.component'; import element2 './element.component2'; // x50 ? /* ... */ export { element, element2 /* ... */ }; // in someotherfile.js import * elements './...

char - Parsing token strings in C -

i trying parse csv file in c. have each line of file scanned array called lines, works. then, check each character in line see if comma (44). i having trouble last else statement, should start new token when there comma. the first token of line read correctly, rest not (strange symbols/characters appear in output). tried removing '\0' statement, since i'm not sure needed it, have same problem. guessing kind of undefined behavior, not sure. thanks! //[rows = num strings] [max num chars per string] int max_len = 21; int num_strings = 12; char lines[num_strings][max_len]; //open file data = fopen("data.txt", "r"); //check if file opened correctly if (data == null) { printf ("file did not open correctly.\n"); } //parse each token char tokens[60][21]; int counter = 0; //read each line for(int i=0; i<num_strings; i++) { //scan line lines[i] fscanf(data, "%s", lines[i]); printf("\nthis line = %s\...

android - Uploading image to Firebase: Null pointer Exception(bitmap.compress) -

since firebase documentation not begginers, can hard , complex beginners. i want upload image storage of firebase. read documentation , tried gives nullpointerexception . i think null pointer exception imageview. there abc.jpg image in drawable folder. there no maintains.jpg file on firebase side. should there maintains.jpg file on firebase? couldn't understand here activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_h...

java - Operation on ArrayList elements without using any loop -

i writing 1 java program in don't want use loop array list elements. sure below program print output 0 n without using loop because arraylist inherits tostring() method loop in abstractcollection. import java.util.*; class withoutloop{ public static void main(string[] args){ scanner scan = new scanner(system.in); arraylist<integer> arr = new arraylist<>(); int n = scan.nextint(); for(int i=0;i<=n;i++) arr.add(i); system.out.println(arr); } } but want put calculations using each element in array list without loop.like below program import java.util.*; class withoutloop{ public static void main(string[] args){ scanner scan = new scanner(system.in); arraylist<integer> arr = new arraylist<>(); int n = scan.nextint(); int m = scan.nextint(); int count = 0; for(int i=0;i<=n;i++) arr.add(i); for(int i=2;i<=m;i++){ iterator = arr.iterator(); while(it.hasnext()){ intege...

python - Calculate PMI values using a given context window -

given following basis: basis = "each word of text converted follows: move consonant (or consonant cluster) appears @ start of word end, append ay." and following words: words = "word, text, bank, tree" how can calculate pmi-values of each word in "words" compared each word in "basis", can use context window size 5 (that 2 positions before , 2 after target word)? i know how calculate pmi, don't know how handle fact of context window. i calculate 'normal' pmi-values follows: def pmi(contingencytable): (a,b,c,d,n) = contingencytable # avoid log(0) += 1 b += 1 c += 1 d += 1 n += 4 r_1 = + b c_1 = + c return log(float(a)/(float(r_1)*float(c_1))*float(n),2) i did little searching on pmi, looks heavy duty packages out there, "windowing" included in pmi "mutual" seems refer joint probability of 2 different words need firm idea respect problem statement...

PHPExcel how to generate excel file via controller of Laravel 5 -

i use library phpexcel included in classes directory. simple test in controller. in controller, placed code: `include(app_path().'/classes/phpexcel.php');` `include(app_path().'/classes/phpexcel/writer/excel2007.php');` then instantiate object phpexcel : `$workbook = new phpexcel;` i activate sheet on work (the default form), method ->getactivesheet() . `$sheet = $workbook->getactivesheet();` i filled first cell method ->setcellvalue() . `$sheet->setcellvalue('a1','maitrepylos');` finally create file, need instantiate object writer, specific type of picture want generate. `$writer = new phpexcel_writer_excel2007($workbook);` i give name file, , save : `$records = 'storage/app/sampledata/fichier.xlsx';` `$writer->save($records);` result: have generated error class 'app\http\controllers\phpexcel_writer_excel2007' not found who can me better organize code...

php - PayU Payment Gateway - I can't use API PayU Version 2 -

i use laravel 5 , via composer install official openpayu php library 2.2 ( https://github.com/payu/openpayu_php ) but require: merchantposid, signaturekey, oauthclientid , oauthclientesecret. and have in merchant admin panel: api_key, api_login, public_key, merchant_id. i related: merchantposid = merchant_id signaturekey = api_key oauthclientid = merchant_id oauthclientesecret = api_login | api_key but not working method create or others methods of class openpayu_order error: oauth error: [code=401], [message=invalid_client - can't find oauthclient clientid = 123445] will settings wrong? necessary require new? when adding new pos in payu admin panel, have choose "rest api" on "classic api". classic api doesn't use oauthclient, client_id won't found.

json - Sending post request to shapeshift -

using example pose request https://info.shapeshift.io/api#api-7 : url: shapeshift.io/shift method: post data type: json data required: withdrawal = address resulting coin sent pair = coins being exchanged in form [input coin]_[output coin] ie btc_ltc returnaddress = (optional) address return deposit if goes wrong exchange desttag = (optional) destination tag want appended ripple payment rsaddress = (optional) new nxt accounts funded, supply on nxt payment apikey = (optional) affiliate public key, volume tracking, affiliate payments, split-shifts, etc... example data: {"withdrawal":"aaaaaaaaaaaaa", "pair":"btc_ltc", returnaddress:"bbbbbbbbbbb"} success output: { deposit: [deposit address (or memo field if input coin bts / bitusd)], deposittype: [deposit type (input coin symbol)], withdrawal: [withdrawal address], //-- match address submitted in post withdrawaltype: [withdr...

ios - Change NCWidgetDisplayMode programmatically in IOS10 Widget -

i looking programmatically change height of today extension. ios10 sdsk introduced ncwidgetdisplaymode trying use programmatically change height of preferredcontentsize . i have implemented widgetactivedisplaymodedidchange : @available(iosapplicationextension 10.0, *) func widgetactivedisplaymodedidchange(activedisplaymode: ncwidgetdisplaymode, withmaximumsize maxsize: cgsize) { if (activedisplaymode == ncwidgetdisplaymode.compact) { self.preferredcontentsize = maxsize } else { self.preferredcontentsize = cgsize(width: maxsize.width, height: 280) } } i want widget height expand when uibutton pressed : @ibaction func multiplybyonethousand (sender: anyobject) { if self.extensioncontext?.widgetactivedisplaymode == ncwidgetdisplaymode.compact { self.widgetactivedisplaymodedidchange(.expanded, withmaximumsize: cgsizemake(0, 300)) } } however when run code, height of today extension not change , console gives me following erro...

Webpack sass-loader with bootstrap -

i have got head webpack has thrown fit when try include bootstrap-sass index.scss file. this webpack conf works great , outputs .css file css/stylehseet.css 'use strict'; var path = require('path'); var extracttextplugin = require('extract-text-webpack-plugin'); module.exports = { entry: { stylesheet: path.resolve(__dirname, 'scss/index.scss') }, output: { path: path.resolve(__dirname), filename: 'bundle.bootstrap-sass.js' }, module: { loaders: [ { test: /\.scss$/, loader: extracttextplugin.extract( 'style', // backup loader when not building .css file 'css!sass' // loaders preprocess css ) } ] }, plugins: [ new extracttextplugin('css/[name].css') ], resolve: { modulesdirectories: [ './node_module...

c# - Asmx file is not returning XML -

i practising asmx web services, encounter problem. have class file employee.cs consists of 3 fields id, name, salary . my service code : [scriptmethod(responseformat = responseformat.xml)] public string getemlpoyees() { employee emps = new employee[]{ new employee () { // data... } }; return emps; } here returns error red marking instance emps cannot implicitly convert type projectname.employee[] string i think might minor issue new web service.....it's getting on nerves......how rid of issue....thanks in advance the signature of public function getemlpoyees says going return string , instead returning emps array of employee[] the compiler expecting return type declare in functions signature, both types should match. you need change return type employee[] this: [scriptmethod(responseformat = responseformat.xml)] public employee[] getemlpoyees() { employee emps = new employee[]{ new employee () { ...

java - Fading in an image on top of a jPanel -

i want have image fade in onto panel part of card layout. when i'm @ place in program, panel show on top , want image loaded in fade-in effect. big project paste relevant code. i have gui class contains jframe, jpanels etc. when event triggered, code runs: cardmain.show(pmain, "cleprechaun"); fadein.run(pleprechaun); it loads correct panel , runs static method in fadein class, supposed add image onto panel pleprechaun. here fadein class: import java.awt.alphacomposite; import java.awt.component; import java.awt.graphics; import java.awt.graphics2d; import java.awt.image; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.imageicon; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.timer; public class fadein extends jpanel implements actionlistener { image imagem; timer timer; private float alpha = 0f; public fadein() { imagem = new imageicon("darkforest.jpg")...

hadoop - Apache pig program -

Image
need write pig script counting no:of words in file containing below text what|is|hadoop history|of|hadoop how|hadoop|name|was|given problems|with|traditional|large-scale|systems|and|need|for|hadoop understanding|hadoop|architecture fundamental|of|hdfs|(blocks,|name|node,|data|node,|secondary|name|node) rack|awareness read/write|from|hdfs hdfs|federation|and|high|availability load data chararray.replace '|' space i.e. ' ' , tokenize line give words , group , count words a = load '/user/hadoop/data.txt' (line:chararray); b = foreach generate flatten(tokenize(replace(line,'\\|',' '))); c = group b $0; d = foreach c generate group, count(b); dump d; output

How to trim the display text of hyperlink in Excel -

i have cells contain hyperlinks. hyperlinks have leading blanks. if use trim, result returned text, not hyperlink. is there worksheet function (not vba) can remove leading blanks , retain functionality of hyperlink? example: ____link1text (where ___ blanks , link1text hyperlink in cell). thank you. you can try: =hyperlink(trim(a1)) however, if link1text (without leading spaces) not actual url or full file path, excel formula not work. you'll need vba routine extract actual hyperlink address. if case, try udf (user defined function): function gethyperlink(rg range) string gethyperlink = rg.hyperlinks(1).address end function and use formula in cell: =hyperlink(gethyperlink(a1),trim(a1))

c++ - Iterative mergesort from index a to index b -

i'm trying sort of mergesort going it'll mergesort(int[] a, int start, int stop) start index start sorting , stop index stop sorting. idea can have 4 different threads sorting 4 subsections of array @ same time. can call mergesort(a, 0, length/4); mergesort(a, length/4, length/2); mergesort(a, length/2, (3/4)*length); etc. on different threads. i've come across bunch of iterative algorithms go 0 length when edit bit try them work subsections of array segfaults on inputs large , bunch of silent errors when looking in valgrind. here's have right now: void mergesort(int *a, int *b, int low, int high) { int pivot; if (low < high) { pivot = (low + high)/2; if(level < maxlevel) { // if have not reached max threads spawn mergesort(a, b, low, pivot); // need change these spawn threads mergesort(a, b, pivot + 1, high); merge(a, b, low, pivot, high); } else { level += 2; // tell wh...

Eclipse/C++ cannot find header files -

i've added macos x c++ linker , gcc c++ compiler includes , libraries libraries , paths, i'm still unable #include library path , file i've added. code: #include <opencv2/text/ocr.hpp> error: fatal error: 'opencv2/text/ocr.hpp' file not found eclipse setup: (project > properties > c/c++ build > settings) macos x c++ linker > libraries library search paths: /usr/local/cellar/opencv3/3.1.0_4/lib /usr/local/cellar/opencv3/3.1.0_4/include/opencv2 /usr/local/cellar/opencv3/3.1.0_4/include/opencv2/text libraries: ocr gcc c++ compiler > includes include paths: /usr/local/cellar/opencv3 mac file structure: ocr.hpp exists in /usr/local/cellar/opencv3/3.1.0_4/include/opencv2/text my thoughts: it seems eclipse still looking in ~/cellar/opencv instead of ~/cellar/opencv3 . because can #include libraries in /usr/local/cellar/opencv/2.4.13.1/include/opencv2 without adding paths eclipse project settings. but ca...

ruby on rails - Undefined method 'nested attribute' for model -

Image
i'm trying to create 2 type of addresses: pick address , delivery address. created polymorphic address model associated listing , order. want create new address in listings , orders views using fields for. reason works when create listing, when try create order undefined method 'address' model order. note: irrelevant code has been omitted snippets below. address.rb class address < applicationrecord belongs_to :addressable, polymorphic: true, optional: true end listing.rb class listing < applicationrecord has_many :orders has_one :pickup_address, as: :addressable, class_name: "address", dependent: :destroy accepts_nested_attributes_for :pickup_address end order.rb class order < applicationrecord belongs_to :listing has_one :delivery_address, as: :addressable, class_name: "address", dependent: :destroy accepts_nested_attributes_for :delivery_address end in form views have app/views/listings/_form.html.erb <%= f...

javascript - jquery jquery.RotateImageMenu Uncaught SyntaxError: Unexpected end of input -

i have jquery server [ http://melodia.esy.es/wp-includes/js/jquery/jquery.js] the script based on 1.5.2 / jquery.min.js after editing script shows me message uncaught syntaxerror: unexpected end of input rotateimagemenu.init i integrate script js.query version 1.12.4 can please help jquery(function ($) { var $listitems = $('#rm_container > ul > li'), totalitems = $listitems.length, //the controls $rm_next = $('#rm_next'), $rm_prev = $('#rm_prev'), $rm_play = $('#rm_play'), $rm_pause = $('#rm_pause'), //the masks , corners of slider $rm_mask_left = $('#rm_mask_left'), $rm_mask_right = $('#rm_mask_right'), $rm_corner_left = $('#rm_corner_left'), $rm_corner_right= $('#rm_corner_right'), rotateimagemenu = (function() { //difference of animation time between items var timediff = 300, //time between each image animation (slideshow...

Register/Login Notworking android/PHP -

hi guys set table on 000webhost. set column id, name, username, age , password. reason username not show in table when run code register , im not sure error is. here code register.php: <?php $con = mysqli_connect("*****", "****", "*****", "****"); $name = $_post["name"]; $age = $_post["age"]; $username = $_post["username"]; $password = $_post["password"]; $statement = mysqli_prepare($con, "insert user (name, username, age, password) values (?, ?, ?, ?)"); mysqli_stmt_bind_param($statement, "siss", $name, $username, $age, $password); mysqli_stmt_execute($statement); $response = array(); $response["success"] = true; echo json_encode($response); ?> as stated in comments: you're trying insert string using i parameter being integer. the order matters when binding. you need change present parameters ssis while making sure age column indeed in...

amazon web services - Bitnami Parse server - set public folder -

i trying migrate parse hosting migrated parse app on aws. my app server & dashboard working, need set public folder. right i'm getting service unavailable error when enter domain: chabadworld.net my parse app on chabadworld.net:1337/parse what should configure load parse/public/index.html homepage

qt - Download big files with QNetworkreply::readAll freeze for a few seconds -

i used example doc http://doc.qt.io/qt-4.8/qnetworkaccessmanager.html i create startdownload : connect(pushbutton, signal(clicked(bool)), this, slot(startdownload(bool))); in startdownload(bool) put this: file = new qfile("c:/foo/bar/bigfile.7z"); file->open(qiodevice::writeonly); qnetworkrequest request; request.seturl(qurl("http://localhost/bigfile.7z")); request.setrawheader("user-agent", "myownbrowser 1.0"); qnetworkreply *reply = manager->get(request); connect(reply, signal(readyread()), this, slot(slotreadyread())); connect(reply, signal(error(qnetworkreply::networkerror)), this, slot(sloterror(qnetworkreply::networkerror))); connect(reply, signal(sslerrors(qlist<qsslerror>)), this, slot(slotsslerrors(qlist<qsslerror>))); in slotreadyread put this: file->write(reply->readall()); but when download arrives @ end there small freezing 2 seconds , returns normal , download complete. ...

Webpack make jQuery globally available during development -

i'm writing react app live inside of webpage contains jquery. means need global access jquery during development, not want include bundle on build ( since jquery exist on page deployed ). i'm having difficulty getting jquery global ( aka accessible anywhere via $ or window.jquery ) work. need jquery@1.7.2. here i've done far: npm install jquery@1.7.2 then, in webpack.dev.config.js: plugins: [ new webpack.provideplugin({ $: "jquery", jquery: "jquery", "window.jquery": "jquery" }) ] ...however, when run dev server ( webpack-dev-server ) , try use jquery in module, get: error '$' not defined any ideas? main goals are: should present during development build, not bundled production should globally accessible component via window object not have explicitly imported each module ( assume it's global ) after spending time on this, here observations: installing jquery@1.7.2 , thr...

c - How can I detect different control signals? -

in program, want detect when user presses ctrl + a,b,c,d,e... different actions each character. have : int main(){ signal(sigint, sighandler); while(1) { sleep(1); } return(0); } void sighandler(int signum){ printf("caught signal %d, coming out...\n", signum); exit(1); } i'd control ctrl+chars ctrl+c being detected, how can detect other characters too? no. ctrl + c not "control signal". in posix systems, terminals have 3 keypresses cause kernel send signal process reading terminal: ctrl + c interrupt ( sigint ), ctrl + \ quit ( sigquit ), ctrl + z suspend ( sigtstp ). can override keypresses ctrl + key combination using posix termios interface -- remember, there 3 (signals , possible keypresses). it more common use termios interface (or equivalently stty command in scripts) put terminal raw mode, in case application gets keypresses not consumed kernel or graphical user interface (key combinations reserved...

string - Swift rangeOfString index 0 or 1 -

i have array of names , want filter out has first or second letter "e", following array var usernames = ["john","tom","ed","ben","albert"] the outputshould ["ed","ben"]. albert should not included position not 1st or second let filterednames = username.filter { (inputstr) -> bool in if let inputrang = inputstr.range(of: "e", options: .caseinsensitive, range: nil, locale: nil) { //how check position 0 or 1 here return true } return false } let result = usernames.filter { $0.lowercased().characters.prefix(2).contains("e") } print(result) // ["ed", "ben"] this should it.

angularjs - Why html element not working if I attach it using JQuery? -

i work on angularjs project. i try append html-string div using jquery that: var html = '<a class="navbar-brand" ui-sref="sitesdamages.siteslist" style="padding: 11px 09px;" title="events"><i class="glyphicon glyphicon-exclamation-sign"></i></a>' $("#inspectorarea").append(html); after append html-string icon appears on appended div , when click on icon it's not work(when navigate mouse on anchor mouse not converted pointer , when click on icon in anchor don't reaction.) while if put html element direct on template works fine. any idea why html-string not working if append string?

android - Canceling AlarmManager when notification is clicked -

i'm developing app uses setrepeating method send notification , want app cancel alarm manager when notification clicked (not swiped)..is there way that? if not there way put button in notification same thing or must put button in app self cancel it? this part use intent , alarmmanager public void onclick(view v) { intent = new intent(getapplicationcontext(), notifications.class); pend = pendingintent.getbroadcast(getapplicationcontext(), 100, intent, pendingintent.flag_update_current); = (alarmmanager) getsystemservice(alarm_service); am.setrepeating(alarmmanager.rtc_wakeup, calendar.gettimeinmillis(), 1000 * 60, pend); when notification clicked (not swiped)..is there way that? yes, when issue notification have add alarm id pending intent: intent notificationintent = new intent(context, notificationslandingactivity.class); notificationintent.putextra("alarm_id","123"); pendingintent pendingintent = pendingin...

android - how to set 'this' object(TableLayout) by findViewById? -

i defined own tablelayout extents tablelayout. in class i'm trying create mytablelayout object: int tablelayoutid = r.id.tablelayoutid; mytablelayout tablelayout = new mytablelayout(this); tablelayout.createtablelayout(tablelayoutid); in last line above, object tablelayout calls function 'createtablelayout'. in function, i'm trying set it('this' object) findviewbyid i'm doing silly guess. how should set it? public class mytablelayout extends tablelayout { public mytablelayout(context context) { super(context); } public void createtablelayout(int tablelayoutid) { // should write here(instead line below) in order let // 'this' have returned view findviewbyid = (mytablelayout) findviewbyid(tablelayoutid); ... } } or maybe should other way? ==================================== =============== edit ================ ==================================== after reading cricket co...

javascript - How can you pass JSON data into a Nunjucks file? -

i have .njk file populate data json file. currently using webpack. here json file: { "ranking": "colors", "description": "here ranking of favorite colors", "rankings": [ { "rank": 1, "institution": "red", }, { "rank": 2, "institution": "blue", }, { "rank": 3, "institution": "green", } ] } in nunjucks file, syntax need use pass in data? the code worked me: var json1 = require('./data/data-1.json'); const solutiontemplate = require('./solution.njk'); let togglesolutionfunc = function() { if (document.getelementbyid('solution-content') != null) { document.getelementbyid('solution-content').innerhtml = solutiontemplate.render(json1);

mysql - Count in query ruin expected result -

Image
database structure data without count in query: select id, test order asc limit 1 good result: with count in query: select id, a, count(*) test order asc limit 1 bad result: why happening? alternative? try select id, a, (select count(*) test) cnt test order asc limit 1 it should give expected results. though i'm pretty sure optimizer execute subquery once, makes sense check execution plan explain .

getchar - Can't understand return value of getche() C -

#include <stdio.h> #include <conio.h> #define max 30 void main() { char str[max]; char str2[max]; int i=0; char c2,c1; printf("inserire stringa 1:\n"); { c2=getche(); if(c2<0) { c1=getche(); } else { c1=c2; } str[i]=c1; i++; }while(i<=max&&c1!='\n'); printf("\n"); i=0; printf("inserire stringa 2:\n"); { c2=getche(); if(c2<0) { c1=getche(); } else { c1=c2; } str2[i]=c1; i++; }while(i<=max &&c1!='\n'); printf("\n"); } i can't understand code does.expecially if cycle:when c2<0?what return getche function? while condition giving me problems:even if press enter doesn't esc fro cycle , overwrite first word until don't write 20 chars.

how do i toggle visibility between 2 canvas -

i swape canvas page, have try code gives me error; if (e.keycode == 13) { thecanvas.style.visibility == 'visible' thecanvas.style.visibility = 'hidden'; thecanvas1.style.visibility = 'visible'; } else { thecanvas.style.visibility = 'visible'; thecanvas1.style.visibility = 'hidden'; } }); try this if (e.keycode == 13) { thecanvas.style.visibility = 'hidden'; thecanvas1.style.visibility = 'visible'; }); the else not needed , main if statement hope helped mukund2003

3DS Max model won't appear in Blitz3D -

first post, yay, guess. i'm new blitz3d, i'm learning how import model 3ds max blitz. here's code: graphics3d 640,480,32,2 setbuffer backbuffer() camera = createcamera() light = createlight() bottle = loadmesh("bottle.3ds") scaleentity bottle,0.1,0.1,0.1 end i put model file , code in folder together, there's black when compile , run code. since scaleentity isn't giving error, model seem load. however, entities created @ 0, 0, 0 default, chances can't see bottle because camera inside it. try along lines of positionentity camera, 0, 0, -5 , see if helps. also, if entire code, you're missing renderworld , flip ; either within loop, or followed waitkey , can see what's being displayed before program closes.

JavaScript on iPad needs regular reboot of network connectivity -

one website regularly access on ipad has various javascript elements stop working after around 15 minutes of use (it appears not after set number of actions, if 1 interaction leave 15 minutes have same problem). the problem happens on 2 different ipads on same network. old ipad 3 latest ios 9.3.5 , brand new ipad mini 2 latest ios. if use mobile internet connection (tethered phone) rather in-house wifi don't have problem. the problem doesn't occur on desktop browsers, when running ipad updating agent. the website owners supposedly investigating, have said can't recreate on mobile test devices. don't know how hard have tried mind you! originally though thing can make website work again switch off , power on again ipad. closing tabs, or whole browser, or clearing history etc, makes no difference, powering off , on again. have more figured out disconnecting network , reconnecting, reloading page appears reload failing javascript elements. using private browsi...

CouchDB Proxy Authentication Doesn't work -

when send http request couchdb server shown in docs here couchdb proxy authentication , doesn't give response shown in docs, empty data. doing wrong? also, able start session proxy auth? if try post /_session, 500 error code. get /_session http/1.1 host: 127.0.0.2:5984 user-agent: curl/7.51.0 accept: application/json content-type: application/json; charset=utf-8 x-auth-couchdb-username: john x-auth-couchdb-roles: blogger < http/1.1 200 ok < cache-control: must-revalidate < content-length: 132 < content-type: application/json < date: sun, 06 nov 2016 01:10:58 gmt < server: couchdb/2.0.0 (erlang otp/17) < {"ok":true, "userctx":{"name":null,"roles":[]}, "info":{"authentication_db":"_users","authentication_handlers":["cookie","default"]}} it's not proxy authentication broken in couchdb 2.0, it's...

python - Remove period[.] and comma[,] from string if these does not occur between numbers -

i want remove comma , period text when these not occur between numbers. so, following text should return "this shirt, nice. costs dkk ,.1.500,00,." "this shirt nice costs dkk 1.500,00" i tried text = re.sub("(?<=[a-z])([[$],.]+)", " ", text) but not substitute in text. you try this: >>> s = "this shirt, nice. costs dkk ,.1.500,00,." >>> re.sub('(?<=\d)[.,]|[.,](?=\d)', '', s) 'this shirt nice costs dkk 1.500,00' using positive lookbehind assertion check symbols preceded non digit character, , alternation on same character set using positive lookahead assertion check followed non digit character. https://regex101.com/r/54stmm/4

What it is the most efficient way to shift and add extra row of data to match delta using python pandas -

Image
what efficient way use pandas align , shift data add row 0 in or b columns if difference higher 2 abs, in order recursively make difference of a-b < 2 ex.- [column a] [diff - b] [column b] 0 0 0 4.54 4.54 0 <-- need add 0 shift 4.54 0 4.54 4.54 0 4.54 4.54 -3.04 1.5 after added [column a] [diff - b] [column b] 0 0 0 0 0 0 0 -4.54 4.54 <--recursive need same 4.54 0 4.54 4.54 0 4.54 4.54 -3.04 1.5 the whole idea push data match on lower diff. if notice need add , shift every time find diff absolute higher 2 on column or column b split dataframe before , after df0, df1 = df.iloc[:1], df.iloc[1:] create series of goes in between s = pd.series(0, df.co...