Posts

Showing posts from April, 2010

functional programming - Clojure - more idiomatic to return a closure, or partially apply the function? -

i'm using external library, , passing function write. this, example: (ext-func my-func) ... my-func needs given data computation. way see it, have 2 basic choices: 1) write my-func in such way accepts data, , returns function, have data bound via closure when external library calls it. example: (defn my-func [mydata] (fn [] (... access mydata via closure ... ))) (ext-func (my-func somedata)) 2) not return function my-func , bind data when pass ext-func : (defn my-func [mydata] (... evaluate, use mydata, etc.)) (ext-func (partial my-func somedata)) i suppose 1 use answered how intend use function otherwise. if i'm going using other places, may prefer not return function, example. but, other things being equal... ...which of these more idiomatic approach? partial sugar create anonymous function. check out it's source . so, they're equivalent. take pick. neither more idiomatic, matter of personal preference.

reactjs - react-css-modules with decorators not working -

trying decorator syntax working react css modules shown here. https://github.com/gajus/react-css-modules#decorator i've got react-css-modules working using function syntax, e.g. cssmodules(table, styles) but when using decorators, e.g. @cssmodules(styles) export default class extends react.component {} nothing seems instantiated , no errors thrown either. i've got babel-plugin-syntax-decorators loaded. what missing? thanks!!

angularjs - Trouble with Protractor and Angular 2 application with Angular sign in -

i've been having issues getting protractor e2e test work. application i'm testing angular 2 , sign in through separate angularjs site. i'm trying create test logging in, checking site loads correctly given credentials, , logging out. can log in fine, navigate site, , navigate auth page. however, once gets there, protractor stops before clicks sign out button , webdriver stays stuck on page instead of closing. here page object code functions: `var loginpage = function() { this.loginemail = element(by.css('[id="email-input"]')); this.loginpassword = element(by.css('[ng-model="loginform.password"]')); this.signinbutton = element(by.css('[name="signin"]')); this.twofactorcodeinput = element(by.css('[id="code-input"]')); this.verifytwofactorbutton = element(by.css('[name="verifytwofactor"]')); this.signoutbutton = element(by.css('[ng-click="signout()"]'

google bigquery - Big Query InsertAll using C# -

i'm using code while trying insert data using big query. running without exceptions, table empty. problem code? string service_account_email = "myaccount"; var certificate = new x509certificate2(@"xxx.p12", "notasecret", x509keystorageflags.exportable); serviceaccountcredential credential = new serviceaccountcredential( new serviceaccountcredential.initializer(service_account_email) { scopes = new[] { bigqueryservice.scope.bigqueryinsertdata, bigqueryservice.scope.bigquery } }.fromcertificate(certificate)); // create service. var service = new bigqueryservice(new baseclientservice.initializer() { httpclientinitializer = credential, applicationname = "test" }); google.apis.bigquery.v2.data.tabledatainsertallrequest tabreq = new google.apis.bigquery.v2.data.tabledatainsertallrequest(); list<goo

Rotating model in openGL 2 in iOS -

i'm working opengl on ios , android, i'm trying draw model, sphere, set camera/eye coords inside sphere, set texture , enable panning , zoom achieve 360 degree effect, made android using opengl 1.0, having lot of problems in ios, made using opengl 2.0, set , working, i'm having problem panning, in order rotate model view matrix, i'm applying rotate transformation, works if change axis rotation, messes other 2 axis, @ end if apply rotation in both axis, x , y, sphere rotates if kind of transformation has been don in z axis, texture ends upside-down or being displayed in diagonal, i'm doing exact same transformations in android , don't have problem there, has experience issue? suggestion? clue? code? article? think when apply first transformation coords in space change , next transformation not being applied properly. here's ios code : - (void)glkview:(glkview *)view drawinrect:(cgrect)rect { glclear(gl_color_buffer_bit); glkmatrixstackpush(_o

python - unbound method must be called with instance as first argument -

i trying build simple fraction calculator in python2.x from fractions import fraction class thefraction: def __init__(self,a,b): self.a = self.b =b def add(self): return a+b def subtract(self,a,b): return a-b def divide(self,a,b): return a/b def multiply(self,a,b): return a/b if __name__=='__main__': try: = fraction(input('please type first fraction ')) b = fraction(input('please type second fraction ')) choice = int(input('please select 1 of these 1. add 2. subtract 3. divide 4. multiply ')) if choice ==1: print(thefraction.add(a,b)) elif choice==2: print(thefraction.subtract(a,b)) elif choice==3: print(thefraction.divide(a,b)) elif choice==4: print(thefraction.multiply(a,b)) except valueerror: print('value error!!!!!') i not sure made correct class c

nosql - Storing MongoDB query in the database -

i have collection subscribers . i want segment of subscribers applying complex filters in query db.subscribers.find({ age: { $gt: 20 }, ...etc }) , don't want save result, since inefficient. instead, save filters applied in query set of rules in segments collection. is approach , efficient way that? should save query object document or define more restrictive schema before saving?

javascript - gulp/minify: index.html gets cryptic extension in file name, how to take advantage? -

i minifying index.html file gulp (note: took on project, build system has been done former dev). it works fine, gulp task generates html file has cryptic extension it, like: index-bd2c7f58f0.html i understand must have it's advantage, can't grasp what...:) because disadvantage is: the node server needs presence of index.html file allow '/' route work. thus far, either have copy file on every build or create link needs updated on every build what missing? should instruct gulp create plain index.html file, or best practices here? also, of various plugin calls responsible attaching extension file name? edit : seems gulp-rev , revreplace calls here gulp task using: gulp.task('html', ['styles', 'scripts'], function () { var client = buildhtml('./client/index.html', './dist/public'); return merge(client); }); function buildhtml(index, distfolder) { var lazypipe = require('lazypipe

c# - WPF MVVM: INPC and mediating communication between view model & model -

i've read various approaches communicating changes in model data view model. suggest model should implement inotifypropertychanged possible, may notify view model of changed properties. suggest service layer between model , view model, service layer implementing inpc, method calls being routed through service layer model service layer notifies view model. i consider latter more granular revision of former , have begun implementing inpc in model classes. feels wrong because a) have write event handler in view model notifications model. takes form of long switch(propertyname) sets corresponding property(s) on view model causing npc sent upwards again. feel i'm writing lot of boiler plate code here. b) view model coupled model via bunch of strings regulated solely convention i.e no 'interface' defined. not mention difficulty causes ides. c) model has modified accomodate context! if closed reason? thought patterns designed increase code reusability & sep

google chrome - Why strange characters appear on the website but not on html editor? -

Image
i copy pasted following html code textbook text editor (sublime). opened html page in google chrome shown in image below. <!doctype html> <html> <head> <title></title> </head> <body> <form action="processorder.php" method="post"><table border="0"> <tr bgcolor="#cccccc">   <td width="150">item</td>   <td width="15">quantity</td> </tr> <tr>   <td>tires</td>   <td align="center"><input type="text" name="tireqty" size="3"      maxlength="3" /></td> </tr> <tr>   <td>oil</td>   <td align="center"><input type="text" name="oilqty" size="3&q

SQL Server select best available time -

Image
below time slots table indicates reserved time isreserved column - 0 not reserved. have day minutes available in table. i need select best available time based table. example: if need book 4 minutes job, should return first available time, , when need book 30 minutes job, query should not return first available there not enough minutes available in timeslot , return next first available. i using sql server 2008 r2 with following query select timeslot jpcbtimeslots timeslot > @starttime , timeslot<= @endtime , isreserved ='0' create table [dbo].[jpcbtimeslots]( [id] [bigint] identity(1,1) not null, [bayid] [int] null, [timeslot] [datetime] null, [isreserved] [int] null, constraint [pk_jpcbtimeslots] primary key clustered ( [id] asc )with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on) on [primary] ) on [primary] go set identity_insert [dbo].[jpcbtimeslots] on

postgresql - How to resolve this error - " One of the documents you are trying to access has been deleted, please try refreshing"? in Odoo v8? -

Image
whenever try create employee record in human resources, when click save, above error occurs. i checked in database kind of ir-regularities , found have attached screenshot. as in database error, autoincrement id has been skipped have noticed. clear insight on this, kindly suggest can done. grateful. thanks create new database if can, , re install module , try again.

Jssor Slider... How to change Slider transitions? -

i included responsive jssor slider in 1 page , changes slides using default option. drops out slide1 left, replacing next slide comes right, , on. i want change slide transition effect simple fade effect jssor fades out slide1 meanwhile fades in slide2 , on.... i cant find way insert code generated tool-slideshow-transition-builder....... can't understand how , include js code. the code generated tool-slideshow-transition-builder is: {$duration:3000,$opacity:2} the current js code transitions following in js file: jquery(document).ready(function ($) { var _captiontransitions = []; _captiontransitions["l"] = { $duration: 900, x: 0.6, $easing: { $left: $jease$.$inoutsine }, $opacity: 2 }; _captiontransitions["r"] = { $duration: 900, x: -0.6, $easing: { $left: $jease$.$inoutsine }, $opacity: 2 }; _captiontransitions["t"] = { $duration: 900, y: 0.6, $easing: { $top: $jease$.$inoutsine }, $opacity: 2 }; _captiontransitions["b"] =

How to make json in python? -

i have following data: 0.485431503455,1.88492294876 2.35886680948,1.11511483636 i need covert data following format in python. [0.485431503455,1.88492294876] [2.35886680948,1.11511483636] how can this? you can this: >>> stri = "0.485431503455,1.88492294876" >>> stri = [float(i) in stri.split(",")] >>> stri [0.485431503455, 1.88492294876] i don't know meant make json in python. but guess want use https://docs.python.org/2/library/json.html

angularjs - Persisting state between different views using ui-router -

i having issues maintaining state of item quantity selected in main controller view, after returning cart controller view. example after adding quantity of 2 items in main controller view, reflect 2 items in cart controller view, when go main controller view show though no items have been added in main controller view (state disappears), though cart controller view still show 2 items. need state of quantities persist in both views, when navigating , fourth between views. have idea missing allows persistence between both views? plunker code works fine, it's when navigating between views in actual web application encounter problem. knows how resolve this, thank in advance! https://jsfiddle.net/156mjkqx/ html <div ng-app="app"> <div ng-controller="maincontroller main"> <h2> main controller view </h2> <div> <table> <tr> <td>item</td> <td>price</td

angularjs - Retrieving my data from firebase 3 -

i've been attempting obtain data firebase 3 , wondering if knew of error making. service: .service("searchservice", function($firebasearray, fb) { var database = firebase.database(); var bookid = firebase.auth().currentuser; this.getpostedbooks = function() { return database.ref("postedbooks/" + bookid).once("value"); } controller: $scope.getpostedbooks = function() { searchservice.getpostedbooks().then(function(response) { $timeout(function() { console.log(response.val()) }, 5000); }) i attempted use timeout see if data coming in late, no matter what, null. you try $q service https://docs.angularjs.org/api/ng/service/ $q .service("searchservice", function($firebasearray, $q, fb) { var database = firebase.database(); var bookid = firebase.auth().currentuser; var dfd = $q.defer(); return { getpostedbooks : function() { re

javascript - Check a specific checkbox in HTML table -

i have html table column containing checkboxes. can please tell me how can use javascript set checkbox @ specific row index checked (without using jquery)? thanks the simplest solution give each checkbok specific id. easy check javascript. probably best solution give id contains either row number or unique identifier of data in row.

javascript - Fancybox 1.2.5 callbackOnShow - I have some syntax errors -

i trying run function when box loads, v1.2.5 seems should callbackonshow attribute. here code, have syntax error noob, having trouble figuring out. $("a#inline").fancybox({ 'hideoncontentclick': false, 'autodimensions': false, 'framewidth': 932, 'frameheight': 496, 'padding': '0', 'overlayopacity': '0.7', 'callbackonshow': $(function () { $('#palette').on('mouseover', 'a', function (event) { $('#palettecolorname').text("color: " + event.target.title); }); $('#palette').on('mouseleave', 'a', function () { $('#palettecolorname').text("color: "); }); }); possible alternatives welcome to. here fiddle version of trying functioning inside fancybox. js fiddle a few things there. shouldn't enclose options in quotes.

php - How to add formula which is sum of $Quantity and display at the bottom? How to auto numbered list when data is fetched? -

mysql_select_db("fyp",$connect); $sql="select * `table 1` year='$year'"; //query database $query=mysql_query($sql,$connect); while($hdata=mysql_fetch_array($query)) { $country=$hdata['country']; $method=$hdata['method']; $type=$hdata['type']; $pline=$hdata['pline']; $ptype=$hdata['ptype']; $year=$hdata['year']; $quarter=$hdata['quarter']; $revenue=$hdata['revenue']; $quantity=$hdata['quantity']; echo "<tr>"; echo "<td align='middle'>$country</td>"; echo "<td align='middle'>$method</td>"; echo "<td align='middle'>$type</td>"; echo "<td align='middle'>$pline</td>"; echo "<td align='middle

excel - How do I use a sub from a different work book -

in personal.xlsb workbook, have code: public sub password(byval target range) = "" n = 1 len(target) = & "*" next n target.numberformat = """" & & """;""" & & """;""" & & """;""" & & """" end sub in new workbook, have code: private sub worksheet_change(byval target range) if target.address = info.range("aa9").address workbooks("personal.xlsb").password target end if end sub i keep getting error saying, compile error: invalid use of property here's how run macro personal workbook: application.run "personal.xlsb!password", target [edit] it's worth noting instead of loop build * string, this: public sub password(byval target range) dim smask string smask = mid(worksheetfunction.rept(";&qu

javascript - Jquery event is fired for all button having same class name rather than current selected button -

basically when click on first .menu-btn should called first .dropdown please note content generated on fly, can't use different ids all $(document).ready(function() { $(".menu-btn").click(function() { $(".dropdown").toggleclass('expand'); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <table class="table table-striped"> <tr> <th>&nbsp;</th> <th>col 1</th> <th>col 2</th> <th>col 3</th> </tr> <tr> <td> <div class="mobile-nav" style="border:0px solid red"> <div class="menu-btn" id="menu-btn"> <div></div> <span></span> <span></span> <span></span> </div> &l

jquery - How to Remove all the click handlers in javascript -

i have d3 elements in html page consisting of 'g' elements contain class bubble , structure looks this. when click, event registers , click class added. function recorddata registers event. need remove click events on 'g' elements after 1 iteration not register twice if g element repeated in iteration. how can remove event listeners on 'g' element specially 1 added in through recorddata. <g id="4119-virtuality" angle="3.7699111843077517" class="bubble" transform="translate(102.63251712643411,493.138632973281)" style="pointer-events: auto; fill: black; font-weight: bold;"> <circle r="52.21875" style="opacity:0"></circle> <rect rx="5" ry="5" style="fill: rgb(170, 170, 170);" x="-52.21875" y="-45" width="104.4375" height="90"></rect> <text text-anchor="middle" style=

operating system - .bat file execution in python not giving the required results -

this content of bat file proselint exe file proselint c:\users\rahul\desktop\proselint-0.5.3\proselint\proselint\something.md > ooo.txt running bat file double clicking produces following output c:\users\rahul\desktop\proselint-0.5.3\proselint\proselint\something.md:2:1: misc.mondegreens 'a girl kaleidoscope eyes' preferred form. c:\users\rahul\desktop\proselint-0.5.3\proselint\proselint\something.md:1:38: misc.mondegreens 'laid him on green' preferred form. which correct output in ooo.txt when try run bat python script following output c:\users\rahul\desktop\proselint-0.5.3\proselint\proselint>proselint c:\users\rahul\desktop\proselint-0.5.3\proselint\proselint\something.md 1>ooo.txt which nothing command executed python code used was: import os os.system("c:/users/rahul/desktop/proselint-0.5.3/proselint/proselint/command.bat") note : using subprocess gives me same output ooo.txt from subprocess import call call("c:/us

Java REST API: Can not deserialize instance of Object out of START_ARRAY token -

i have rest api written using java , jersey. below related code of web api. @get @path("/getallphase1") @produces(mediatype.application_json) public list<phase1bean> getallphase1() { phase1interface phase1interface = new phase1impl(); list<phase1bean> allphase1 = phase1interface.getallphase1(); return allphase1; } in web application's rest client, wrote below code. client client = clientbuilder.newclient(); client.target("http://localhost:8080/xxx/rest") .path("phase1/getallphase1") .request(mediatype.application_json) .get(phase1bean.class); unfortunatly generates below error exception in thread "main" javax.ws.rs.client.responseprocessingexception: com.fasterxml.jackson.databind.jsonmappingexception: can not deserialize instance of bean.phase1bean out of start_array token @ [source: org.glassfish.jersey.message.internal.rea

ms access - Database that use sql queries -

i run there's no data when run it...how can fix problem ? suggestion ?-microsoft access using microsoft access (or other dbms tool), create tables (using ddl sql), , enter sample data (using ddl sql or gui). 5 records per table enough. use suitable data type each field. make sure create relationship between tables, using ddl sql. then, write dml sql queries answer questions below (one query per question) , run them. find names of pilots certified boeing aircraft code far: select distinct e.empname employee e,aircraft a,certified c e.empid=c.empid , c.aircraftid=a.aircraftid , a.aircraftname='boeing'; what start simplest possible select, , add conditions. in case, start with: select distinct e.empname employee e,aircraft a,certified c` and see there data. add first condition (i.e. where e.empid=c.empid ), second, etc., , , end distinct . way, see problem might be. also, aware if case (upper/lower) of contents. if database case-sensitive , 1

qt - Why am I unable to make a QMenu invisible? -

i added qmenu designer qmainwindow actions debugging , tests. want make invisible realese compilation. however when call: ui->menutests->setvisible(false); nothing happens? how make menu not visible without removing application? (i can disable it, horrible....) set visible/unvisible action, not qmenu: ui->menutests->menuaction()->setvisible(false);

arrays - Add condition to AngularJS map function -

i'm using below loop through array , add property each item of array. $scope.addresses = $scope.addresses.map(function(address) { address.location = "x"; return address; }); this @ end return items. how can add condition loop? can check property , based on property return addresses property true ? any appreciated! you should use filter function you can read here: https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/array/filter basically filter function gets boolean function parameter (let's call f ), , returns array items f returns true for. for example: var mapped = $scope.addresses = $scope.addresses.map(function(address) { address.location = "x"; return address; }); var filtered = mapped.filter(function (address) { return address.location.length > 5; }); filtered hold collection of addresses have location more 5 characters.

ios - Cause of CloudKit Dashboard error "Sorry, we could not process your request"? -

i have had "sorry, not process request" week when trying access cloudkit dashboard. it occurs when go dashboard link in xcode, after have entered login credentials. cloudkit working fine app can sync existing data , write new data. is problem @ moment? ideas going wrong? i have found workaround, login developer account separately @ https://developer.apple.com/ , try cloudkit dashboard link again.

asp.net - Can I open a project using .Net framework 3.5 in Visual Studio 2015? -

can open website project using .net framework 3.5 in visual studio 2015 community? lastly, framework visual studio 2015 community supports? as of now, don't have visual studio 2015 installed in pc. install. thanks:) hope answer questions. visual studio 2015 released @ same time .net 4.6 designed , released together. you able open .net framework 3.5 website.

objective c - How to format UITextField with NSNumberFormatter? -

hope helps others, since haven't seen similar post on web shows how format text field using nsnumberformatter @ same time keep uitextfield cursor position should naturally be. those, because after formatting, nsstring inside uitextfield , setting field end cursor placed end of field . nice convert swift needs it. and here answer issue, using uikeyboardtypenumberpad, work fine uikeyboardtypedecimalpad, if other keyboard types used, feel free add regex before using next code: - (int)getcharoccurencies:(nsstring *)character instring:(nsstring *)string{ nsmutablearray *characters = [[nsmutablearray alloc] initwithcapacity:[string length]]; (int i=0; < [string length]; i++) { nsstring *ichar = [nsstring stringwithformat:@"%c", [string characteratindex:i]]; [characters addobject:ichar]; } int count = 0; (nsstring *ichar in characters) { if ([ichar isequaltostring:character]) { count++; }

magento - Remote server responded with a text response - API connection error -

i'm trying connect magento shop trustpilot , when try connect using http://example.com - error: "connection problem: remote server responded text response. may not api url?". i have made soap rule in magento , user , have api connection works already. any advices?

angularjs - How to give a specific value to input with ' ng-model="searchQuery" '? -

i creating app using ionic framework , i'm facing problem. i'd create search function tags. when click on button, value given input. my code : <div id="rech-btns" class="padding" ng-model="searchquery" ng-controller="rechctrl"> <button class="button button-outline button-balanced espace rech-text" ng-click="showdiv('facile')"> facile </button> <!-- there others buttons deleted them see whole code --> </div> <div id="rechrech"> <label class="item item-input"> <i class="icon ion-search placeholder-icon"></i> <!-- <input type="search" placeholder="recherche..." /> --> <input type="search" ng-model="searchquery"> <!--<input type="text" text="facile" ng-model="searchquery">--> </label>

php - Unable to display image in listview item -

i trying image url , display listview item. url take mysql database via php. currently not able image display in listview item. the process using first download image , cache display on listview item. ( base on have search on web, can take direct url , display listview item). any advise or coding great. below code using , facing problem. public void getproduct () { class getjson extends asynctask<void, void, string> { progressdialog loading; @override protected void onpreexecute() { super.onpreexecute(); loading = progressdialog.show(getactivity(), "fetching data", "wait...", false, false); } @override protected void onpostexecute(string s) { super.onpostexecute(s); loading.dismiss(); json_string = s; jsonobject jsonobject = null; arraylist<h

php - Serve HTML file if it exists, otherwise redirect to index with mod_rewrite -

i'd write rewrite rule following: if of following files exist on server static html file in specific directory i'd .htaccess serve static file. otherwise, i'd id (first number after slash) passed query parameter www.gallery.com/index.php www.gallery.com/1-driving-to-the-beach.html www.gallery.com/2-swimming.html example: assume www.gallery.com/2-swimming.html doesn't exist html file on server. want id=2 sent /index.php can use <?php ob_start(); ?> <html></html> <?php file_put_contents('2-swimming.html', ob_get_contents()); ?> questions: what rewrite rule .htaccess file should contain? how grab id in index.php when url redirected .htaccess? add rule htaccess file in document root: rewriteengine on rewritecond %{request_filenane} !-f rewritecond %{request_filenane} !-d rewriterule ^([0-9]+)-(.*)\.html$ /index.php?id=$1 [l] that sends id portion of request index.php parameter id .