Posts

Showing posts from March, 2011

javascript - How to disable or enable button according to if text boxes empty or not? -

i work on angularjs projerct. i have button in template , 2 input text elements. the button have enabled when 2 input boxes has string. here html code: <form id="loginform" class="form-horizontal" role="form"> <div style="margin-bottom: 25px" class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span> <input id="login-username" type="text" class="form-control" ng-model="username" placeholder="username"> </div> <div style="margin-bottom: 25px" class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span> <input id="login-password" type="text" class="form-contr...

c++ - C++98/03 std::is_constructible implementation -

the base components of hobby library has work c++98 , c++11 compilers. learn , enjoy myself created c++98 implementations of several type support functionality (like enable_if , conditional , is_same , is_integral etc. ...) in order use them when there no c++11 support. however while implementing is_constructible got stuck. there kind of template magic (some kind of sfinae) can implement without c++11 support ( declval )? of course there no variadic template support in c++03, specialise implementation till depth. main question if there technique can decide whether t constructible given types or not. it's possible: #include <iostream> template<typename t, t val> struct integral_constant { typedef integral_constant type; typedef t value_type; enum { value = val }; }; typedef integral_constant<bool, true> true_type; typedef integral_constant<bool, false> false_type; template<typename t> struct remove_ref { ...

sql order by - MYSQL has orderBy on count(*) some impact on perfomance? -

i have simple query count number of records plain query inner joins , criterions. something this. select count(*) ...... .... order .........at 4 fields. my question order asc or desc @ 4 fields has impact on performance? or ignore or optimized engine. sorry if question plain or simple best regards. first, should note query, written, return 1 row. have aggregation function no group by . in situation, order by no-op (i don't know if mysql goes through motions 1 row or not). in general, performance impact of order by depends on number of rows , not number of keys . i can think of 2 occasions when order by has minimal impact on performance: an index can used ordering. it follows group by , uses aggregation keys (this true in mysql sort group by ). and, of course, order by on few rows (such 4 rows ) pretty negligible performance-wise. the impact, though, has less size of keys number of rows , overall size of rows. multiple joins , where clau...

c - removing printf statment from code breaks program -

i have problem can't figure out, hope guys can me. wrote c program convert decimal binary , write bits on integer array, works fine until remove couple of printf statements.since thought weird , removing printf statement doesn't change logic of code tried recreate problem on machine , there works 1 expect , without printfs. here code: #include <stdio.h> #include <stdlib.h> int main(){ int a; printf("input number:\n"); scanf("%d",&a); int size=sizeof(a); size=size*8; printf("size in bits: %d\n",size); int *p; p=malloc(size); int i; for(i=0;i<size;i++){ p[size-i-1]=a&0x1; a=a>>1; } for(i=0;i<size;i++){ printf("%d",p[i]); } printf("\n"); } when remove printf("input number:\n"); and printf("size in bits: %d\n",size); i error a.out: malloc.c:2392: sysmalloc: assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned...

c++ - Why this code is printing 0 to 297 but not 0 to anything greater than 297? -

as can see, in code , im trying print 0 m . ive used "m" variable.(ignone "n", main thing "m" here) if input m = 5 ( accually type 4 input "n" in keyboard ignore , "m" 5 ) . code print 0 1 2 3 4 5 . problem face can see 0 m numbers when m 297 or less 297. when input m more 297 , example 500 . can see numbers 203 - 500 . why not seeing 0 - 500? #include <bits/stdc++.h> using namespace std; int main() { long n, m; cin >> n; m = n + 1; vector<long> v(0); (long = 0; < m; ++i) { v.push_back(i); } (long j = 0; j < m; ++j) { cout << (v.at(j)) << endl; } return 0; } this prints [0, 500] fine me it's scrollback limitation. check settings on terminal if you're using one. if you're on unix-like system can use wc command count number of lines printed , confirm yourself: $ echo "500" | ./a.out | wc -l 501 you can send output less let s...

Python for loop unreasonably stops half way while iterating through CSV rows -

i dealing csv file analysis lecture feedback data, format "5631","18650","10",,,"2015-09-18 09:35:11" "18650","null","10",,,"2015-09-18 09:37:12" "18650","5631","10",,,"2015-09-18 09:37:19" "58649","null","6",,,"2015-09-18 09:38:13" "45379","31541","10","its friday","nothing yet keep up","2015-09-18 09:39:46" i trying rid of bad data. data entries "id1","id2" and corresponding "id2","id1" considered valid. i using nested loops try find matching entry each row. however, outer loop seems stop half way no reason. here's code class filter: file1 = open('encodedpeerinteractions.fa2015.csv') peerinter = csv.reader(file1,delimiter=',') def __init__(self): super() def filter(se...

angularjs - Angular 2 and &nbsp; how to show break lines properly -

i have no idea how this. have list of objects 1 of properties description , value has break lines &nbsp; . i'm using normal way print in html, take below: <div class="row" *ngfor="let item of items"> <p>{{item.description}}</p> </div> and in result can't see break line, see description below: line 1 `&nbsp;` line 2 `&nbsp;` line 3 and should like: line 1 line 2 line 3 any idea how solve it? the &nbsp iso chracter same space shouldnt use write break lines can use br tag , in in binding use [innerhtml] ="ítem.description"

java - create a list from subproperties of another list -

i have 3 classes defined getters , setters follows orm: class author { integer id; string name; } class bookauthor { integer id_book; author author; } class book { string title; list<bookauthor> authors; } i'd create list of id_author class book. i've found way using streams. i've tried this: list<integer> result = authors.stream().map(bookauthor::getauthor::getid).collect(collectors.tolist()); but not seem work. can access "id" property in author class? edit: maybe way be: list<author> authorlist = authors.stream().map(bookauthor::getauthor).collect(collectors.tolist()); list<integer> result = authorlist.stream().map(author::getid).collect(collectors.tolist()); thank you. i assume authors variable list (or collection) of bookauthor, not author (that seems based on code). i think have right idea, dont think can chain :: operators. so try lambda: authors.stream(). map(ba -> ba.getautho...

android - Where to place php files used to connect to a database in a real web server and not WAMP -

Image
i followed this tutorial , describes how connect database using android app. i need create folder structure similar 1 below: my question in real server should proposed files placed? i have path of home directory/my domain/....(folders)... place structure inside or outside domain folder.., , if outside how going access them if use following? require_once 'outsidefolder/include/config.php'; shouldn't blocked permissions? my question in real server should place proposed files? you must place file.php in www folder. for example, if have wamp server installed, must place files (e.g. file.php , etc) in path c:\{wamppathinstalled}\www\mywebsite , {wamppathinstalled} path wamp installed on c drive (or if drive, use drive letter instead). you can access scripts running http://localhost/mywebsite/myfile.php in browser. tell me real server (iis or other) & can indicate best place in case. if use plesk, response must in this link .

delphi - Native DLL - C# -

i have native dll library wrote in delphi. want refer lib c# , returned string. function function getcode (auser,apassword: pansichar): pansichar; stdcall; c# code [dllimport("c:\\library.dll", callingconvention = callingconvention.stdcall, charset = charset.ansi)] private static extern string getcode([marshalas(unmanagedtype.lpstr)]string auser, [marshalas(unmanagedtype.lpstr)]string apassword); public string getcode(string login, string password) { return getcode(login, password); } trying call function application exits code -1073740940 (0xc0000374). do have expirence it? thank help with return value of string , marshaller assumes responsibility freeing returned string. call cotaskmemfree . no doubt string not allocated on com heap. hence error, ntstatus error code of status_heap_corruption . your p/invoke should return intptr instead avoid this: [dllimport("c:\\library.dll", callingconvention = callingconvention.st...

python - Failed to start browser "Entity not found". Webdriver Firefox -

selenium ver 3.0.1 firefox ver 47 64bit - windows 10, geckodriver ver 11. from selenium import webdriver selenium.webdriver.firefox.firefox_binary import firefoxbinary binary=firefoxbinary('c:\program files\mozilla firefox\firefox.exe') wb=webdriver.firefox(firefox_binary=binary) wb.get("www.python.org") error messages: wb=webdriver.firefox(firefox_binary=binary) file "c:\python34\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 145, in init keep_alive=true) file "c:\python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 92, in init self.start_session(desired_capabilities, browser_profile) file "c:\python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in start_session response = self.execute(command.new_session, capabilities) file "c:\python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute self.error_h...

python - How to import graph from another class in Kivy? -

i import graph nicegraph class .kv file, have not idea, how that. i readed documentation, couldn't find using class in class. here's try. class nicegraph(boxlayout): graph = graph(xlabel='x', ylabel='y', x_ticks_minor=5, x_ticks_major=25, y_ticks_major=1, y_grid_label=true, x_grid_label=true, padding=5, x_grid=true, y_grid=true, xmin=-0, xmax=100, ymin=-1, ymax=1) plot = meshlineplot(color=[1, 0, 0, 1]) plot.points = [(x, sin(x / 10.)) x in range(0, 101)] graph.add_plot(plot) class kivytesting(boxlayout): pass class kivytestingapp(app): def build(self): return kivytesting() kivy_testing_app = kivytestingapp() kivy_testing_app.run() and there's .kv file <kivytesting>: orientation: 'vertical' padding: 10 slider_colors: 0, 0, 0 canvas.before: color: rgb: root.slider_colors rectangle: pos: root.pos size: root.size bo...

sonata admin - How to achieve select tag in editable column, in list view, in SonataAdminBundle? -

Image
how achieve drop down select tag illustrated below? protected function configurelistfields(listmapper $listmapper) { $listmapper ->add('foo',null, ['editable'=> true])

How to properly use a php page displayed on form action -

i've got finished site , i'm working on customer callback form put in name, email, tel me contact them. way have on form action specify "php/sendform.php" scrip. in script put html normal web pages have footer , header message thank contacting us. works seems little awkward , i've never seen on other mainstream sites, of sudden address bar changes php page other pages on site html. so question is, there way maybe call php in async way? or somehow mask address bar doesn't reveal php directory because says site.com/php/sendform.php. thanks. you can use url rewriting. change form action submit . , in .htaccess file add these lines: rewriteengine on rewriterule ^submit?$ php/sendform.php [nc,l] so php page this: yourdomain.extension/submit

java - Android How to Loop MediaPlayer between Specified bounds -

i'm trying loop section of audio file. suppose audio file's duration 2:00 minutes. set start , end bounds need loop. example start bound 01:05 , end bound 01:45. want loop mediaplayer between these 30 seconds. here's code : mediaplayer mp = null; mp.setaudiostreamtype(audiomanager.stream_music); mp.setlooping(true); mp.setdatasource(getapplicationcontext(),"audio file path"); int start = 65*1000; int end = 95*1000; mp.start(); mp.seekto(start); i'm able start mediplayer @ start position, don't know how stop in middle , again loop same start position , end @ end position.

javascript - Issues with callback function -

this question has answer here: how return response asynchronous call? 21 answers i have simple question has been bouncing on head how handle this. i've been using api requires callback function capture values, , i'm having issues in returning output of function other functions i'm using on project. for example: function a() { var callback = function(e) { var id = e.data.responsedata.id; }; api.getid(callback); } if try call variable id, give me undefined i'm assuming id value not being passed available globally. on other side if run this: function a() { var callback = function(e) { var id = e.data.responsedata.id; console.log(id); }; api.getid(callback); } it return me on console correctly value of id. any ideas on i'm missing here? thanks once again. rafa you need return variable ...

php - PhpStorm does not recognise class aliases -

Image
i've taken @ question , unfortuently there no answer. i'm using phpstorm , building project composer project loaded. i'm trying make phpstorm recognises classes/functions when ctrl+click on them, specifically, projects installed via composer. i have tried changing source folders in settings / directories still cannot work. i using require __dir__ . '/vendor/autoload.php'; load composer dependancies. what need phpstorm recognise declarations files loaded through composer? to support question, here pictures: my test.php file: (notice how can't recognise class): project/test.php a project added via composer , installed using autoloader: project/vendor/braintree/braintree_php/lib/braintree/subscription.php my composer.json file: project/composer.json well ... technically package has no braintree_subscription class defined (i mean -- "proper" definition). 2nd screenshot shows definition of subscription class \braintree...

c++ - Graphics library for visualising binary search tree -

the problem - visualize binary search tree using c++ , graphics library. ideally i'd write this . tree implemented. need write visualization. firstly of course want draw tree (other features find animations, etc i'll add in future). size of tree unknown (it can сonsist of 4-5 nodes or 100-200 or more). graph should scalable (ideally - mouse scroll). so question graphics library should use this? , i'd know if there small examples of understand basics. i think fast way it's opengl. recommend excellent library https://github.com/memononen/nanovg

javascript - document.getElementById not working with Webpack -

i've been trying implement basic javascript webpack have found lot of trouble trying basic methods work. know problem js loading before dom fixes issue have been futile. for instance, i'm trying run let taskinput = document.getelementbyid('new-task'); , when search taskinput variable in console return of uncaught referenceerror: taskinput not defined(…) . i've tried quite few different solutions make code operate after dom has loaded nothing seems work. i tried basic attempt of putting javascript file @ bottom of dom. i've tried basic js method so: document.onreadystatechange = function() { if (document.readystate === "complete") { initapplication(); } function initapplication() {(... placed code in here ...)} i've tried using jqueries $( document ).ready(function() { }); i've tried injecting javascript file html html-webpack-plugin is there i'm missing webpack? index.html <!doctype html> <htm...

java - How to debug try and catch blocks? -

i wondering if there can me out these 2 debugging assignments in java, involving try/catch/throw statements. can't seem figure out how debug either assignment working in netbeans zip file attached. all or appreciated. thanks. assignment 1: package debugmeone; import java.io.file; import java.io.filenotfoundexception; import java.util.scanner; /* * file requires debugging. partial file read text file * simple error checking. if file not found (you testing this) * filenotfoundexception should thrown. second catch statement * producing error (red stop sign). why? job have both * exception , filenotfoundexception in file. not remove either 1 * of them. don't create file accountrecords.txt; testing * file not found condition there no need create file. * * output should be: * * run: * error - file not found: accountrecords.txt * java result: 100 * build successful (total time: 0 seconds) */ public class readtextfile { private scanner in...

ios - AVPlayer takes long time to start playing -

after update swift 3 i´ve realised app takes long time start playing audio file remote server. in swift 2.3 didn't´t happen. i´ve been trying debug day long couldn't´t find anything. i´ve been printing states of avplayer @ each moment , found changes loading playing within seconds takes around 20 seconds start playing song. i using jukebox teodorpatras i fixed myself next line of code: player?.playimmediately(atrate: 1.0) what line is, starts playing without ensuring buffer it´s enough not suffer interruptions. in case prefer on having wait several seconds.

ember.js - Ember data createRecord creates multiple records -

when inspect data in ember inspector see multiple record 1 id(int) , 1 without id(null). using ember 2.9.1 save: function(){ var title = this.get('title'); this.store.createrecord('post',{ title:title }).save(); this.setproperties({ title:''}); this.transitiontoroute('posts'); } node backend router.post('/', function(req, res, next) { post.create({ title: req.body.data.attributes.title }).then(function () { res.set('content-type','application/vnd.api+json'); return res.send({ "msg": "post created successfully", data:null }); }); }); return res.status(201).send({ data:{ type:'post', attributes:{ id:post.id, name:post.title } } }); the following code works properly.this known issue in ember data.

php - Returning non-integer values in table for tinyint(1) Boolean data type -

i'm going using tinyint(1) / boolean datatype field in database (mysql) represent 2 values 'solo' , 'dual', 1 equal dual , 0 equal solo. however, i'm wondering how display in table. since data stored 1 , 0 in database, how change corresponding 'dual' or 'solo' when creating tables using html, mysql, , php? not asking code wondering if possible before using boolean datatype. thanks with simple function: function from_db_bool($bool){ return $bool ? 'dual' : 'solo'; } function to_db_bool($string){ return strtolower($string) == 'dual' ? 1 : 0; } when inserting, use to_db_bool() when printing out db use from_db_bool()

python requests http response 500 (site can be reached in browser) -

i trying figure out i'm doing wrong here, keep getting lost... in python 2.7, i'm running following code: >>> import requests >>> req = requests.request('get', 'https://www.zomato.com/praha/caf%c3%a9-a-restaurant-z%c3%a1ti%c5%a1%c3%ad-kunratice-praha-4/daily-menu') >>> req.content '<html><body><h1>500 server error</h1>\nan internal server error occured.\n</body></html>\n' if open 1 in browser, responds properly. digging around , found similar 1 urllib library ( 500 error urllib.request.urlopen ), not able adapt it, more use requests here. i might hitting here missing proxy setting, suggested example here ( perl file::fetch failed http response: 500 internal server error ), can explain me, proper workaround one? one thing different browser request user-agent; can alter using requests this: url = 'https://www.zomato.com/praha/caf%c3%a9-a-restaurant-z%c3%a1ti%c5%a1%c3%...

javafx - Gef4 GridLayout / Spreadsheet -

i'm developing gef (version 4) application (which should used eclipse plugin). i've done lot of research , looked @ mvc example on github ( can found here ) 1 question still remains. the requirement have has "look" spreadsheet or that. model can shortly described follows: have different categories on x axis , groups on y axis. each category has 1 column assigned. groups there can multiple entries in 1 row (nested). since knowledge in gef limited , haven't found useful stuff on internet, possible realize that? stuck on how design data model / how model requirements correctly. means how dynamically build grid , put content in correct cells (matching category , group). data read emf instance. in pure javafx application, have used gridpane , added nested gridpanes necessary handle nested y-rows, works. have no idea how starting point doing gef. thanks hints!

java - Could someone help me execute this jar file? -

this question has answer here: how run jar file 11 answers i downloaded file website ! problem have no knowledge of java :p ! ( cannot execute file ) here's file: atome.jar when double click, nothing happens !! please guys me ! this jar not created executed simple double-click used in program. in fact, in manifest file in jar, there no main class defined , none of class files in jar main class (i tried 3 principal classes) so, jar library should used developer

node.js - How to Reserve or Protect a keyword in Mongoose Schema -

my question pretty straightforward. how protect keyword in mongoose user cannot save word database. use case: have application user creates username. want prevent words being used username in mongoose schema cannot stored in database. possible in mongoose schema? if not, there workarounds? thank in advance.

typescript1.8 - How to correctly add .js libraries to my application so that I can import them in TypeScript modules -

Image
before learned little bit of how typescript modules work if wanted use js library jquery add script tag referencing library, i'm using typescript find examples : import * $ 'jquery' but jquery not typescript module, how work? how should add external non-typescript library modules? edit #1 tsconfig.json explicitly telling typescript use amd format (i chose 1 on commonjs because read since amd loads modules asynchronously, more appropriate web applications) { "compileroptions": { "sourcemap": false, "target": "es5", "module": "amd", "outdir": "scripts" }, "exclude": [ "node_modules", "wwwroot" ] } to install type definitions use typings typings install dt~jquery --global --save having mentioned i'm using, don't understand how requirejs able find third-party libraries when i'm specifying file load (...

jquery - How to simplify following multiple onclick function -

i have following code , need mothod simplify onclick function instead of repeating many times. function onloadhandler() { var st1 = $("#i11031821").contents().find("p:contains('application , acceptance of')"); var st2 = $("#i11031821").contents().find("p:contains('provision of services')"); var st3 = $("#i11031821").contents().find("p:contains('users generally')"); var st4 = $("#i11031821").contents().find("p:contains('member accounts')"); var st5 = $("#i11031821").contents().find("p:contains('member’s responsibilities')"); var st6 = $("#i11031821").contents().find("p:contains('breaches members')"); var st7 = $("#i11031821").contents().find("p:contains('transactions between buyers and')"); var st8 = $("#i11031821").contents().find("p:contain...

float2 matrix (as 1D array) and CUDA -

i have work float2 matrix 1d array. wanted check things , have written code: #include <stdio.h> #include <stdlib.h> #define index(x,y) x+y*n __global__ void test(float2* matrix_cuda,int n) { int i,j; i=blockidx.x*blockdim.x+threadidx.x; j=blockidx.y*blockdim.y+threadidx.y; matrix_cuda[index(i,j)].x=i; matrix_cuda[index(i,j)].y=j; } int main() { int n=256; int i,j; ////////////////////////////////////////// float2* matrix; matrix=(float2*)malloc(n*n*sizeof(float2)); ////////////////////////////////////////// float2* matrix_cuda; cudamalloc((void**)&matrix_cuda,n*n*sizeof(float2)); ////////////////////////////////////////// dim3 block_dim(32,2,0); dim3 grid_dim(2,2,0); test <<< grid_dim,block_dim >>> (matrix_cuda,n); ////////////////////////////////////////// cudamemcpy(matrix,matrix_cuda,n*n*sizeof(float2),cudamemcpydevicetohost); for(i=0;i<n;...

c++ - Abort trap 6 when returning from main in OS X but NOT on linux -

i have program seems run fine on linux (ubuntu 14.04), when running on os x (10.11.6) abort trap 6. i've attached code suspect problem not tied specific code. code class project, i'm not trying crack passwords or anything. here's code, believe important stuff happens in main. #include <openssl/aes.h> #include <openssl/evp.h> #include <openssl/conf.h> #include <openssl/err.h> #define key_bytes key_length/8 #define key_length 128 unsigned char* h(unsigned char* p, unsigned char* hp); void handleerrors(void); int encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key, unsigned char *iv, unsigned char *ciphertext); //assumes we've padded zeros unsigned char* h(unsigned char* p, unsigned char *hp){ encrypt((unsigned char*)"0000000000000000", key_bytes, p , (unsigned char*)"0000000000000000", hp); return hp; } void handleerrors(void) { printf("panic!!\n"); /...

php - How can I store mysql results in different individual variables with one connection to the databse? -

i working on personal project , need help. after lot of research can't seem find proper solution problem(probably because not php developer - still learning). ok need 3 post titles database , store each 1 of them in individual variables. need them individual because want use them in different parts of website. have managed doing 3 different queries databse wich suppose bad. there way send 1 query databse , store them @ once inside different variables? tried array , although close enough didn't seem working. here code: try { $stmt = $db->query('select posttitle blog_posts order postid desc limit 0,1'); $sslider_title1=''; while($row = $stmt->fetch()){ $sslider_title1 = $row['posttitle']; } } catch(pdoexception $e) { echo $e->getmessage(); } try { $stmt = $db->query('select posttitle blog_posts order postid desc limit 1,2'); $sslider_title2=''; while($row = $stmt->fetch()){...

npm - Using angular-in-memory-web-api with Angular CLI -

i'm running frustrating issues while attempting add angular-in-memory-web-api angular 2 project created angular cli . here current dependencies object within package.json : "dependencies": { "@angular/common": "2.0.0", "@angular/compiler": "2.0.0", "@angular/core": "2.0.0", "@angular/forms": "2.0.0", "@angular/http": "2.0.0", "@angular/platform-browser": "2.0.0", "@angular/platform-browser-dynamic": "2.0.0", "@angular/router": "3.0.0", "@angular/upgrade": "2.0.0", "core-js": "^2.4.1", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.12", "systemjs": "0.19.27", "zone.js": "^0.6.23", "angular-in-memory-web-api": "0.1.13", "bootstrap...

wordpress - Sort posts by custom field number -

i'm using query posts. $args = array( 'post_type' => 'spaces', 'post_per_page' => '500', 'orderby' => 'rand', 'meta_key' => 'space-city', 'meta_value' => $search, ); $query = new wp_query($args); now need order results total of comments on each post. i've custom field number called "space-comments", i've no idea how sort posts second meta_key. i made tests, able post when "space-comments" has value. when there no value, post don't show up. any ideia how can start? the wp_query can accept meta_query argument populated array of sub-arguments. array can have sub arrays each own meta query, can create nice compound searches across meta data. see example https://codex.wordpress.org/class_reference/wp_query...

php - Set a variable equal to result of Mysql query -

i have 2 mysql tables - membership , renewals2017. want set variable called $email value of following query, not sure doing correctly. tables inner joined member_id in membership table , m_id in renewals2017 table. value of email in membership table. reason want set variable $email because using value send email. here query: set $email = ("select membership.e_mail_address membership inner join renewals2017 on renewals2017.m_id = membership.member_id";); if there better way this, or not correct, please let me know. thank you. there (currently) no keyword set in php, declare variable assigning value it. use mysqli_connect() connect database, mysqli_query() perform query, , fetch_array() iterate on each returned record - see example below: //update parameters per credentials below $connection = mysqli_connect("databaseserver", "username", "password", "databasename"); $query = $connection->query("select memb...

css - Changing bootstrap panel color using sass -

i'm pretty new using both twitter bootstrap , sass. trying modify background color of panel-header in bootstrap using .sass file in rails application. this bootstrap css according inspect element: .panel-default > .panel-heading { color: #333333; background-color: #f5f5f5; border-color: #ddd; and here's i'm trying in sass file change color .panel-default .panel-heading background-color: #fdf1d8 i'm wondering if problem has selector used in bootstrap css? don't know how translates indented sass. suggestions? what doing spit out following: .panel-default .panel heading { background-color: #fdf1d8; } > specific, should use it, too: .panel-default > .panel-heading { background-color: #fdf1d8` }

php - Connection falied: could not find driver -

i'm on windows 10 , i'm using wamp. trying create login form prepared pdo statements. below code connect.php script issuing error: "connection failed: not find driver". <?php $server = 'localhost'; $username = 'root'; $password = ''; $db = 'login'; try{ $conn = new pdo("mysqli:host=$server;dbname=$db", $username, $password); $conn->setattribute(pdo::attr_errmode, pdo::errmode_exception); echo "connected successfully"; }catch(pdoexception $e){ echo "connection falied: " . $e->getmessage(); } ?> this list php.ini file shows , dlls associated pdo extension=php_openssl.dll extension=php_pdo_firebird.dll extension=php_pdo_mysql.dll extension=php_pdo_oci.dll extension=php_pdo_odbc.dll extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll extension=php_pdo_mysql.dll extension=php_pdo.dll extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll extension=php_pgsql.dll ;ex...

android - TextViews overlapping in Relative layout -

i have these 2 textviews in content_main, beginner , can't figure out why overlapping in center, tried chanign , still doesn't work. <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:gravity="top" android:text="" android:id="@+id/nametextview" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" android:textsize="35sp" android:textcolor="#1a237e" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancelarge" android:gravity="bottom" android:text="" android:id="@+id/temperaturetextview" android:layout_alignparenttop="false" ...

sql - MySQL query to Hiveql -

work(id, rank) data: work ------------------ 1 | 1 | b 1 | c 1 | d 2 | 2 | c 2 | b 3 | c i need find pairs of ids have common rank count , should display if count of rank greater 2 , print them in descending order. have written mysql query but, new sparksql , hiveql. please me how that. example using data above result set should be: mysql query is: select a.id,b.id work a, work b a.id>b.id group a.id,b.id having group_concat(distinct a.rank order a.rank)=group_concat(distinct b.rank order b.rank) --------------------- id1 | id2 | count --------------------- | b | 3 b | c | 3 i don't think hive supports group_concat() . think same thing: select a.id, b.id, a.cnt (select a.*, count(*) on (partition a.id) cnt work ) join (select b.*, count(*) on (partition b.id) cnt work b ) b on a.rank = b.rank , a.cnt = b.cnt a.id < b.id -- *think* allowed in hive; not, subquery or expression in `having` clause same thing ...

keyboard - Is CTRL+M the same as Enter? -

so, i've gotten whitespace programming, , 1 of characters listed [lf] . not knowing was(yes, yes, yell @ me want being idiot), looked , found on wikipedia typed using ctrl+m (aka ^m ). so, used while, when went , took @ article, said lf known crlf , "carriage return line feed", if remember correctly. mean enter , technically "carriage return" works newlines? sorry if stupid question :t carriage return (ascii code 13) , line feed (ascii code 10) 2 separate characters. @elisadoff said, windows systems use crlf combo signal end of line, while *nix systems use lf. for programming in whitespace, every interpreter have used runs on windows (including online ones i've checked) seems ignore carriage return character, can safely use enter key type lf whitespace. the main difference find in using lf instead of crlf if opened such text file on windows (say, in notepad), entire contents may on single line, since windows expecting cr. programs (notepad+...

cakephp - CakePHP3 Render View to a Variable -

i want render view variable without directly sending browser. used cakephp2.*. but, cannot figure out how in cakephp3. please tell me how it? viewbuilder introduced in cakephp 3.1 , handles rendering of views. when ever want render variable go @ how send email works. from controller: function index() { // can have view variables. $data = 'a view variable'; // create builder (hint: new viewbuilder() constructor works too) $builder = $this->viewbuilder(); // configure needed $builder->layout('default'); $builder->template('index'); $builder->helpers(['html']); // create view instance $view = $builder->build(compact('data')); // render variable $output = $view->render(); }

javascript - Convert to DSTV (.NC1) to Three.js View -

i want make online dstv file viewer. dstv (.nc1) commonly used in steel industry contains information build steel member torch cuts, holes, miters, etc. i want create web based dstv file viewer people can upload or drag & drop dstv file site , load part in viewer , people can see part, rotate it, etc. i having hard time figuring out route should go in terms of building part, steel beam, dstv file. imagine have create code creates basic outline of angles, beams, channels, plates, tubes, etc , building using information dstv, part length, dimensions, features etc. any appreciated. thanks, jude

javascript - Viewing items in a cart which is an array of objects -

i'm trying build oo shopping cart in javascript. i've got adding random products cart , can click basket. how iterate on basket items can have remove button beside each record? i thinking along these lines: <body> <form action="#"> <button onclick="cart().add();">add random product</button> <button onclick="cart().getbasket();">view cart</button> </form> <script type="text/javascript"> (var i=0; < cart().getbasket().length; i++){ console.log(cart().getbasket()[i]); } </script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script src="shopping-cart.js"></script> <script> $(document).ready(function(){ ...

python - Filter elements from list based on them containing spam terms -

so i've made script scrapes sites , builds list of results. each result has following structure: result = {'id': id, 'name': name, 'url': url, 'datetime': datetime, } i want filter results list of results based on spam terms being in name. i've defined following function, , seems filter results, not of them: def filterspamgigslist(thelist): index = 0 spamterms = ['paid','hire','work','review','survey', 'home','rent','cash','pay','flex', 'facebook','sex','$$$','boss','secretary', 'loan','supplemental','income','sales', 'dollars','money'] in thelist: y in spamterms: if y in i['name'].lower(): thelist.pop(inde...

asp.net - How to keep the variable value after post back -

i trying keep variable value after post back. tried both session variable , viewstate failed keep value of random number same. every time after button press (after page refresh) getting new random value want keep same value. //in code behind public static int randnumber{ get; set; } protected void page_load(object sender, eventargs e) { //by using session session["rand"] = rnd.next(0, 10); randnumber = int32.parse(session["rand"].tostring()); //by view state int rand = rnd.next(0, 10); viewstate["key"] = rand; randnumber = int32.parse(viewstate["key"].tostring()); } for post in form: <asp:button id="button1" runat="server" text="button" onclick="button1_click" /> and tried access in page below: <p>random no: <%= randnumber %></p> only set new random number if it's not post checking ispostback public int randnumber{ g...

html - reCapctcha - form has been validated -

i implementing recaptcha, box checkbox user click , confirm he's not robot being presented, doubt if working, because i'm using if (grecaptcha.getresponse () = = "") , not know if robot circumvent this, because i'm not analyzing response google api returns, i'm checking if there return. note: page html, implement recaptcha in jsp. the following code: function logar(){ if (grecaptcha.getresponse() == "") { alert("você não clicou no recaptcha, por favor, faça!") return false; } else { document.login.submit(); } } <script src='https://www.google.com/recaptcha/api.js?hl=pt' async defer></script> <form class="form-inline" role="form" name="login" action="logincontroller.do" method="post"> <div class="modal-body"> usuario: <input type="text" name="login...

javascript - Using jquery from angular directive does not work -

i trying implement jquery-ui's sortable on elements inside ng-repeat. problem : cannot sortable action on elements inside ng-repeat. i've checked answers. code seems similar answers apparently work, code doesn't work below html snippet: <div class="container-fluid rt-widget-list-dim-adj"> <div my-dir> <div ng-repeat="widget in model.widgets" ng-switch="widget.widgettype"> <div ng-switch-when="header"> <ng-include src="'views/widget/widget-header.view.client.html'"> </div> <div ng-switch-when="image"> <ng-include src="'views/widget/widget-image.view.client.html'"> </div> <div ng-switch-when="youtube"> <ng-include src="'views/widget/widget-youtube.view.client.html'"> ...

java - Ionic build android process exception error -

,hi all, after running cordova build --release android i error: * went wrong: execution failed task ':transformclasseswithmultidexlistforrelease'. > com.android.build.api.transform.transformexception: com.android.ide.common.process.processexception: org.gradle.process.internal.execexception: process 'command 'c:\program files\java\jdk1.7.0_79\bin\java.exe'' finished non-zero exit value 1 i tried find fix in internet nothing works open suggestions. thanks! i have updated jdk 1.8.0 , run smoothly :)

Problems using Colorama on Python 2.7 -

i'm learning use colorama in python, installed , i'm able import module no problems primary prompt. >>> import colorama >>> colorama import * >>> print(fore.blue + 'blue text') blue text now, if create small piece of code this: #!/usr/bin/env python2.7 colorama import * print(fore.blue + 'blue text') i following message: file "colorama_test.py", line 3, in <module> colorama import * file "/home/olg32/python/colorama_test.py", line 5, in <module> print(fore.blue + 'blue text') nameerror: name 'fore' not defined which tells me module not being found. mentioned installed , tested primary prompt. path definition issue or that? current directory module installed: usr/local/lib/python2.7/dist-packages/colorama-0.3.7-py2.7.egg does path needs defined somewhere? sorry i'm new on python. any appreciated. thank you. hopefully have worked out answer hav...