Posts

Showing posts from January, 2014

Error of finding a database size using a SQL query in SQL Server 2008 on Windows 7 -

i use sql query find size of databases in sql server 2008 ms sql server management studio. i run sql query: select d.name, round (sum(mf.size) * 8 / 1024, 0) size_mbs sys.master_files mf inner join sys.databases d on d.database_id = mf.database_id d.database_id > 4 -- skip system databases , d.name = 'my_database' -- after removing this, still cannot find 'my_database' in results. group d.name order d.name my_database has been set on server result show nothing , cannot find it! any appreciated. thanks ! check user running has permission see database. try logging sql management studio using credentials , connection string running query with.

Add track to playlist using Deezer API and PHP -

i have looked through documentation of deezer api , unable comprehend how add track through api php, if can @ all. - lack of understanding rather poor documentation. i looking way add 100 tracks new playlist each week. have read on deez's use of oauth , track api object can not life me understand how make authentication. in essence, trying achieve web based application user can add songs playlist. believe, deezer's oauth asks user allow permissions, want application have full control of playlist without having ask people login , grant them. could please have more information on whether possible , without having grant permission each time? not interact other user accounts, own. user searches track id form obtains track id via api call user submits , track id added playlist id update: i have since figured out how add track using oauth. however, else add track after submitting using form (step 3), need login , accept oauth permissions. there way can set cod

regex - htaccess Rewrite for any domain -

i have following lines written multiple times accommodate multiple domains use. there way write once domain follow same rule? rewritecond %{http_host} ^(www\.)?example\.com$ [nc] rewritecond %{the_request} \s/+example.com/(\s*) [nc] rewriterule ^ /%1 [r=301,l] rewritecond %{http_host} ^(www.)?example.com$ rewritecond %{request_uri} !^/example.com/ rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /example.com/$1 [l] rewritecond %{http_host} ^(www.)?example.com$ rewriterule ^(/)?$ example.com/index.php [l] try single block of rule doamins: rewriteengine on rewritebase / rewritecond %{http_host} ^(?:www\.)?(.+)$ [nc] rewritecond %1::%{the_request} ^(.+?)::\s/+\1/(\s*) rewriterule ^ /%1 [r=301,l] rewritecond %{http_host}::%{request_uri} ^(?:www\.)?(.+?)::/(?!\1/) [nc] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ %1/$1 [l] rewritecond %{http_host} ^(?:www\.)?(.+)$ [nc] rewrit

Puzzle about virtual function inheritance in C++ -

i'm noob in c++, , have following header file (header.h) #ifndef header_h #define header_h #include <iostream> using namespace std; class predicate { public: virtual void print() = 0; }; class unaryintegerpredicate : public predicate { public: virtual void print(); }; class biaryintegerpredicate : public predicate { public: virtual void print(); }; #endif and in separate .cpp file (source.cpp), tried implement print method, got "expected expression" error. #include "stdafx.h" #include "header.h" #include <iostream> using namespace std; unaryintegerpredicate::unaryintegerpredicate() : predicate() { virtual void print() { cout << "int : boolean" << endl; } } what wrong here, thanks! i see coming java background. need is void unaryintegerpredicate::print() { cout << "int : boolean" << endl; } you don't need stuff surrounding t

sitecore6 - Programmatic upload to sitecore media library fails -

this 1 doozy.. should mention sitecore 6.5 we have been using method programmatically upload files sitecore's media library many years no problems: public static mediaitem createmediaitem(string medialibrarypath, string filepath, string alttext, bool overwriteexisting) { mediacreatoroptions options = new mediacreatoroptions(); options.database = factory.getdatabase("master"); options.language = sitecore.globalization.language.parse(settings.defaultlanguage); options.versioned = settings.media.uploadasversionablebydefault; options.keepexisting = !overwriteexisting; options.destination = medialibrarypath.startswith("/") ? "/sitecore/media library" + medialibrarypath : "/sitecore/media library/" + medialibrarypath; options.filebased = settings.media.uploadasfiles; options.alternatetext = alttext; mediacreator creator = new mediacreator();

javascript - Bootstrap enable button on input -

i having issues getting done correctly. want "sendit" button enable (remove disable) there characters in box. i've tried multiple things can not work. part of html: <input type="password" id="inputpassword" class="form-control" placeholder="password" required> <input id="sendit" class="btn btn-lg btn-primary btn-block disabled" type="submit" value="generate codes"></input> js file $(document).ready(function() { var pass_error = 1; // check name field if (inputpassword === '') { pass_error = 1; } else { pass_error = 0; } enablebutton(); }); // verzendknop pas activeren nadat alles ingevuld en gecontroleerd function enablebutton() { if (pass_error!== 0) { $('#btn btn-lg btn-primary btn-block').attr('disabled', 'disabled');

java - mystery about Linked_List traversing -

the answer might obvious, still feel need ask. programmed simple linked_list fun , training , noticed 1 method supposed print elements of list runs faster method prints list backward. i kept thinking reason explain this, kept going in circle, interesting know why. here first method (this simple traversing of list) public void list(){ node<e> iter = head; while(iter != null){ system.out.print(iter.getvalue() + ", "); iter = iter.getnext(); } } here other method, prints list backward public void list_inverse(){ node<e> iter = head; stack<node<e>> stack = new stack<node<e>>(); while(iter != null){ stack.push(iter); iter = iter.getnext(); } while(!stack.isempty()){ node<e> tmp = stack.peek(); stack.pop(); system.out.print(tmp.getvalue() + ", "); } } so idea of secon

spring - Errors in JSP with missing variables on tomcat 7 -

i have spring installation running fine on tomcat 6 in attempting update tomcat 7 lot of errors in jsp files. notable if variable doesn't exist doesn't evaluate null used to, errors out. there configuration value this? or way test if variable exists? every-time ask nonexistent variable test if empty or null throws error... i.e. ${not empty cmspage.label} //throws error if cmspage.label doesn't exist. used resolve false if didn't exist... edit: it seems root cause javax.el.propertynotfoundexception, makes sense. guess confusing me why started when updated. our jsp pages used never care whether property existed or not. have lot of old code uses null checks check properties don't have go through of catch propertynotfoundexceptions. maybe there config value can use ignore these? or if needed best way check if property exists? here stack trace: org.apache.jasper.jasperexception: exception occurred processing jsp page /web-inf/views/desktop/pages/category/

java - How to track the total number of attempts made by the user to input data -

i have made simple guessing game. want count sum of attempts user made before finding original number. means once hidden number matched user input, should tell how many numbers has been entered before user won. this code: package guessinggame; import java.util.scanner; public class guessinggame { public static void main(string[] args) { int hiddennum = 10; scanner input = new scanner(system.in); while (true) { system.out.println("enter numebr guessing: "); int guessednum = input.nextint(); if (guessednum == hiddennum) { system.out.println("congratulation! number matched"); system.exit(0); } else if (guessednum < hiddennum) { system.out.println("not matched! try bigger number"); } else if (guessednum > hiddennum) { system.out.println("not matched! try smaller number");

r - How do I generate a boxplot using the original data order (not alphabetical)? -

Image
i new r. i've made boxplot of data r sorting factors alphabetically. how maintain original order of data? code: boxplot(ms~code,data=input) i have 40 variables wish boxplot in same order original data frame lists them. i've read may able set sort.names=false maintain original order don't understand piece of code go. is there way redefine input before goes boxplot? thank you. factor variable again wish in line 3 data(insectsprays) data <- insectsprays data$spray <- factor(data$spray, c("b", "c", "d", "e", "f", "g", "a")) boxplot(count ~ spray, data = data, col = "lightgray") the answer above 98% of way there. set.seed(1) # original order e - input <- data.frame(code=rep(rev(letters[1:5]),each=5), ms=rnorm(25,sample(1:5,5))) boxplot(ms~code,data=input) # plots alphabetically input$code <- with(input,factor(code,levels=unique(code)

java - How can I fire integration tests separately using failsafe-plugin? -

i cannot run integration tests, unit tests. here maven config (see code below). uses 2 plugins. 1 of them maven-failsafe-plugin , second 1 maven-surefire-plugin . <properties> <project.build.sourceencoding>utf-8</project.build.sourceencoding> <project.reporting.outputencoding>utf-8</project.reporting.outputencoding> <skiptests>false</skiptests> <skipits>${skiptests}</skipits> <skiputs>${skiptests}</skiputs> </properties> <dependencies> <dependency> <groupid>org.testng</groupid> <artifactid>testng</artifactid> <version>6.8.7</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-surefire-plugin</artifactid> <version>2.16</vers

oop - php num_rows greater than 0 -

in effort update old code , learn @ same time, i've become lost. i'm not sure if got right, i'm hoping point me in right direction instead of bashing newbness. know move away mysql statements why i'm trying move oop , learn go. not sure if should use if($rs->num_rows > 0) or if should if($rows_returned > 0) the following i'm hoping decent start, original @ bottom. <? // functions.php required connect database usual require("db.inc.php"); //our sql statement $sql1 = 'select * flights flightnumber='" . $_request['data2'] . "''); $rs=$conn->query($sql1); if($rs == false) { trigger_error('wrong sql:' . $sql1 . ' error:' . $conn->error, e_user_error); }else { $rows_returned = $rs->num_rows; if ($rs->num_rows > 0 ){ ($i=0$i<$num_result;$i++) { $rs->data_seek(0); while($row = $rs->fetch_assoc()){ echo '1|flightplan\n'; echo $row['depar

mysql - How to find the minimum values of a query's column -

how find minimum value of column of query? my table x's data looks this: (id, something, userid, something) values ('r001','something','u0006','something'), ('r002','something','u0014','something'), ('r001','something','u0006','something'), ('r002','something','u0015','something'), ('r003','something','u0003','something'), ('r001','something','u0014','something'), ('r001','something','u0002','something'); my query, looks this: select distinct userid, count( id ) count x group userid order count desc and query returns: userid count u0006 2 u0014 2 u0002 1 u0003 1 u0015 1 how minimum values of count in query, bearing in mind there multiple minimum values? the return want query this: userid u0002 u0003 u0015 thanks, in advance :

jQuery selector - get <select> element only if <option> is not disabled -

i'm looking jquery selector return <select> element if <option> selected not disabled. html: <form> <select name="input-select"> <option disabled selected>select option</option> <option value="1">1</option> <option value="2">2</option> </select> </form> now, if run jquery selector: $("form select option:selected:not([disabled])") it either return [] if disabled option select, or either return <option> selected. need <select> element return, know using .parent() , can't use reason in code. also $("form select option:selected:not([disabled]):parent") doesn't return parent, though :parent there that? edit: may guys understand goal: $.each($("form").find("input[name], textarea[name], select[name] option:selected:not([disabled]):parent"), function(index, value) {

ios - Slow UITableView Scrolling from JSON -

my uitableview scrolls when load local json. images being loaded external url. first try loading json in viewwillappear method: dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default,0), ^{ nsstring *filepath = [[nsbundle mainbundle] pathforresource:@"homepage" oftype:@"json"]; nserror *error = nil; nsdata *data = [nsdata datawithcontentsoffile:filepath]; self.titlelabels = [nsjsonserialization jsonobjectwithdata:data options:kniloptions error:&error]; }); and in tableview (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath, have following: hometableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"cell"]; if(cell == nil) { [tableview registernib:[uinib nibwithnibname:@"homecell" bundle:nil] forcellreuseidentifier:@"cell"]; cell = [tableview dequeuereusablecellwithidentifier:@"cell"]; } nsdictionary *titlelabels = [self.titlelab

jquery - Performing SQL-like set operations on Datatables -

i have array several hundred elements ids of data in datatable have created ex, [102,105,155,21,13,225...etc]. need do, in sql terms, perform update inner join on table rows , array, , set resulting rows specific class. i have attempted .each , .find methods, not them work, , looping through table potentially thousands of times, given size of array, highly inefficient. are there methods in jquery work datatables allow trying accomplish? how can implemented?

sass - Importing rails-assets.org stylesheets from SCSS -

is possible import stylesheet rails-assets.org gem using scss's import instead of sprocket's require ? example: given gemfile : source 'https://rails-assets.org' gem "rails-assets-rrssb" using sprockets stylesheet, you'd use require in application.css (working): *= require rrssb/scss/rrssb however, i'm using scss , use import in application.css.scss (not working): @import "rrssb/scss/rrssb"; go rvm gem directory ( rvm gemdir ) , gem rails-assets pulled ( /gems/rails-assets-your_gem-version ). in app/assets/stylesheets directory find file. import/require file path relative app/assets/stylesheets . the same goes javascripts (in app/assets/javascripts ). this worked me rails-assets-bootstrap-sass-official , file trying import bootstrap-sporckets , (including other files) under app/assets/stylesheets/bootstrap-sass-official import was: @import "bootstrap-sass-official/bootstrap-sprockets"

Clojure watch function executing, but 'map' as part of function not executing -

(defonce instance (atom {:id nil :canvas nil :subscribers #{"test1" "test2"})) (defn replace-canvas [canvas id] (println "replaced" id "'s canvas")) (defn update-subscribers [k r old-state new-state] (pprint "this function being called") (pprint "i can execute consecutive forms") (map (partial replace-canvas (new-state :canvas)) (new-state :subscribers))) (add-watch instance :update-subs update-subscribers) when instance atom changes, watch function ostensibly called because "this function being called" , "i can execute consecutive forms" both printed, map function never seems take place. i'm not sure why be, , couldn't find in documentation add-watch placed restrictions on put inside watch function. even if replace map in update-subscribers more straightforward like (map println (new-state :subscribers)) the map doen't seem have effect. any

orchardcms - Orchard CMS: How to cancel a remove event -

i have created code disallow deletion of content item if item has localized dependencies. created new "extension" interface , (default)class within orchard.framework.contentmanagement, , created new class within orchard.localization modul, using suppressdependency attribute. returns simple boolean value based on query see if there contentitems list current item mastercontentitem this called admincontroller within orchard.core.contents, , if returns true add message , redirect returnurl, otherwise removal continues normal. all of working perfectly. however, refactor take advantage of existing infrastructure icontentmanager , add removing() method localizationparthandler. my question - possible "cancel" remove action based on output of contenthandler invoked earlier... as mentioned in comment i'm not sure want accomplish, guess want create own module , within module create handler implementation in thing... from understand want hook remov

javascript - run animation then remove element -

i tring run simple animation remove div since lies on buttons can not click them after animation. js $(".intro").eq(0).delay(800).animate({"opacity":"0"},1000 ); i tried doing remove element after animation removes before. $(".intro").eq(0).delay(800).animate({"opacity":"0"},1000 ).remove(); remove in animate function's callback: $(".intro").eq(0).delay(800).animate({opacity: 0}, 1000, function() { $(this).remove() }); alternatively, add complete function in option object: $(".intro").eq(0).delay(800).animate({opacity: 0}, {duration: 1000, complete: function() {$(this).remove();}}); you can add more options it, easing example. check api doc

reading complex and uneven data from text using java -

i have read texts file not , little complex in order index . word / doc_id : position1 postition2 (....and on), doc_id : position1 postition2 (....and on), so word appear in n number of documents , appear n number of times in document. example copying small section of file, cannot put words occur many times because of space constraints. example: 13137 . speeding / d85 : 5999 , 13138 . spell / d53 : 1513 , 13139 . spelling / d3 : 344 351 , 13140 . spending / d71 : 398 , 13141 . spiderman / d60 : 650 733 997 1023 1053 1133 1152 1169 , 13142 . spiders / d75 : 704 , d91 : 19834 , (...and on) please me this. also, format file in better way generated file, may can reformat , generate better formatted text file. thank :) perhaps should use new line delimiter. here's mean 13137 . speeding / d85 : 5999 13138 . spell / d53 : 1513 13139 . spelling / d3 : 344 351 13140 . spending / d71 : 398 13141 . spiderman / d60 : 650 733 997 1023 1053 1133 1152 1169

java - Cannot put @JsonIgnore annotation on both field and the setter - Mapping Exception -

i have used @jsonignore annotation in both field , setter in entity achieve deserialization issue mentioned in following question. my issue prevent deserialization of particular field had serialized. this question posted earlier but getting following exception due modification when trying build spring web project. module did change builds successfully. org.springframework.data.mapping.model.mappingexception: ambiguous mapping! annotation jsonignore configured on field yyyyyy , 1 of accessor methods in class xxxxxentity! any comment highly appreciated. the exception triggered spring-data change restricts same annotation on field , method level. however, restriction somehow buggy escapes non spring data annotation in case. they've fixed in more recent version, finding proper version should fix issue well. learn more check out these threads https://jira.spring.io/browse/datacmns-556 , read comments understand rational , problem the issue fixing (from can pic

c# - Read previous line using File.ReadLines -

this question has answer here: how read text file reversely iterator in c# 8 answers i want read text file last line because big size , want check today's log content. i'm using file.readlines () , success read last line. how can read previous line? or there way current line number can subtract number? foreach (string f in directory.getfiles(sdir, "*.log", searchoption.alldirectories)) { string last = file.readlines(f, encoding.default).last(); //read last line here if (last.indexof("error", stringcomparison.ordinalignorecase) > 0) { writeerror(last); } } foreach (string f in directory.getfiles(sdir, "*.log", searchoption.alldirectories)) { string last="", prev=""; foreach (string cur in file.readlines(f, encoding.default) ) { prev = last;

html - Leaflet map in a flexbox layout -

i can't seem (dead simple) leaflet.map render inside of flexbox . assume may issue invalidatesize dead simple (broken) example: jsbin if remove flexbox css it'll work: jsbin html <body> <div id="content"> <div id="mappane"></div> </div> </body> css body { display: flex; flex-flow: column wrap; } #content { flex: 1 1; order: 2; } #mappane { height: 100%; } the power of flex has now there no height map pane inherit parent #content getting height flex property (telling grow). #mappane therefore has correct height — 100% of 0 0 . bring map pane flex world add display: flex #content . still grow existing flex: 1 property: #content { display: flex; } add flex: 1 #mappane : #mappane { flex: 1; } complete example $(function() { l.map("mappane"); }); html, body { margin: 0px; height: 100%; } body { d

android layout - Button text lost when in landscape mode -

Image
i have simple screen 4 buttons , images: and when change landscape mode images cropped , text lost: i using linear layout follows: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignparentbottom="true" android:layout_centerhorizontal="true" android:orientation="vertical" android:background="@drawable/rings" > <linearlayout android:id="@+id/row1" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_weight="1" android:gravity="top|fill_vertical" android:orientation="horizontal" > <button android:id="@+id/classesbutton"

Does git merge --no-commit prevent any changes? -

if i'm unsure git merge, , use git merge --no-commit, prevent actual changes occurring in repo? no, you’d need still git merge --abort, otherwise you’ve got uncommitted merge sitting there waiting manual commits. still safety measure though if you’re unsure things.

adding article effect a WordPress post or article -

can share on how go adding article effects such ones being showed here http://tympanus.net/codrops/2014/05/22/inspiration-for-article-intro-effects/ ; i'm planning incorporate them on wordpress platform, particularly on single post template. thanks in advance :) use single.php display single post single.php single post page, theme page displaying 1 post usually in theme folder /wp-content/themes/your-theme-name/ and use required css / jscript on header.php or footer.php article reference: http://www.heidicool.com/samplewordpress/theme-files/single-php/

angularjs list box value selection -

<select multiple ng-multiple="true" class="form-control emailreminder width-169" ng-if="checked" ng-model="selectedreminder" ng-options="x x.title x in emailreminderlist" value="{{x.id}}"> </select> i not able selected value list in angularjs in controller.js please suggest code selected array value push new array when submit page html <select multiple="multiple" id="idselect" class="form-control emailreminder width-169" ng-if="checked" ng-model="selectedreminder" ng-options="x x.title x in emailreminderlist"> </select> in controller $scope.savereminder = function() { angular.foreach($scope.selectedreminder, function($value, $key) { $scope.list.push($value.title); }); console.log($scope.list); };

dataframe - R : Calculate frequency of a transaction and increment for every transaction -

i have dataframe called cust > head(cust,15) txn_date cust_no credit 1 2013-12-02 12345000 400.00 2 2013-12-02 12345000 300.00 3 2013-12-02 12345000 304.71 4 2013-12-02 12345000 475.00 5 2013-12-02 12345000 325.00 6 2013-12-02 34567890 1390.00 7 2013-12-02 34567890 100.00 8 2013-12-02 34567890 500.00 9 2013-12-02 23232323 5.00 10 2013-12-02 23232323 130.00 11 2013-12-02 23232323 5975.00 12 2013-12-02 23232323 3711.00 13 2013-12-02 14345422 12530.50 14 2013-12-02 14345422 3312.00 15 2013-12-02 98765432 370.00 to calculate total amount, based on cust_no, have used within , applied cumsum it, below newcust <-within(cust, { runningtotal <- ave(cust$credit, cust$cust_no, fun = cumsum)}) and hence result this, can see credit getting incremented based on cust number >head(newcust,15) txn_date cust_no credit runningtotal 1 2013-12-02 12345000 400.00 400.00 2 2013-12-02 12345000 300.00 700.00 3 2013-12-02 123

javascript - Display ajax response value in table -

i want display sql query result on table during ajax call.i wrote code executes query during ajax call when tried display these values in table displays null value on div tag.what reason?how can display result set value in table format. mycode: viewquery.jsp <%-- document : viewquery created on : nov 10, 2014, 10:23:48 author : user --%> <%@page import="java.util.arraylist"%> <%@page import="querywork.readxml"%> <%@page import="java.sql.resultset"%> <%@page import="querywork.dbconnection"%> <!-- change template, choose tools | templates , open template in editor. --> <!doctype html> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <title&g