Categories
Mastering Development

How to access and map a Hash to minimum value when there are multiple values per key?

I’m looking to map an ID to the latest year. If I have a hash which has one key to one value I don’t have a problem: hash = { “123456”=>[[“123456”, “1975”], [“123456”, “2009”]], “123999”=>[[“123999”, “1928”], [“123999”, “2012”]] } hash.map{|key, value| value.max} # => [[“123456”, “2009”], [“123999”, “2012”]] I’m hoping to do the same but […]

Categories
Mastering Development

SyntaxError: Unable to parse bindings with json

I’m just starting with Knockout JS, and I’m having trouble finding what is wrong here. I’m calling a controller Web Service to get some data that I want to display in my page. This is my ViewModel: function ViewModel() { var self = this; self.MonthSalesList = ko.observableArray(); var url = ‘myurl’; self.GetQueryData = function () […]

Categories
Mastering Development

sqlite library cannot update database file that has been installed

I can open, read and update a database using the sqlite3 command line tool, like this: C:\ProgramData\spectronix\oximeter>C:\Users\James\code\bin\sqlite3 spectrumalpha.dat SQLite version 3.16.2 2017-01-06 16:32:41 Enter “.help” for usage hints. sqlite> .schema CREATE TABLE run ( run INTEGER PRIMARY KEY, timestamp, desc ); CREATE TABLE distance ( hwid, distance ); CREATE TABLE spectrum ( run, timestamp, hwid, […]

Categories
Development

Import a PEM certificate to a cert store

I have a .pem certificate which i need to import to a certificate store. I am following the below method: $certLocation = “Cert:\LocalMachine\Root” Import-Certificate -FilePath C:\Certificate\Certificate.pem -CertStoreLocation $certLocation I am running the powershell in admin mode. When i run this script a user prompt pops up for me to enter admin credentials. Since i will […]

Categories
Development

Efficient method to range query problem python3

I tried a range query question in hackerrank(1). I used segment tree to solve this but my code was not efficient. I need to clarify the problems with my code and have a more efficient solution with python3. What are the other approaches to solve this problem. What is the most efficient approach. Here’s my […]

Categories
Development

unexpected keyword argument ‘instance’ in Django ModelForm with formsets

So I have a Folder model, and 2 other models that are related to it via a ForeignKey. I have this method for creating 3 separate objects using 3 forms (creating the Folder object, and uploading files to 2 separate models that are related to Folder): @login_required def nouveaudossier(request): DocumentFormSet = modelformset_factory(DocumentdeBase, form=DocumentdebaseForm, extra=5) PhotoAvantFormSet […]

Categories
Development jQuery

how localize jquery datepicker?

I try to localize datepicker, but i can`t figure how with this code. code is: this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId=”ui-datepicker-div”,this._inlineClass=”ui-datepicker-inline”,this._appendClass=”ui-datepicker-append”,this._triggerClass=”ui-datepicker-trigger”,this._dialogClass=”ui-datepicker-dialog”,this._disableClass=”ui-datepicker-disabled”,this._unselectableClass=”ui-datepicker-unselectable”,this._currentClass=”ui-datepicker-current-day”,this._dayOverClass=”ui-datepicker-days-cell-over”,this.regional=[],this.regional[“”]={closeText:”Done”,prevText:”Prev”,nextText:”Next”,currentText:”Today”,monthNames:[“January”,”February”,”March”,”April”,”May”,”June”,”July”,”August”,”September”,”October”,”November”,”December”],monthNamesShort:[“Jan”,”Feb”,”Mar”,”Apr”,”May”,”Jun”,”Jul”,”Aug”,”Sep”,”Oct”,”Nov”,”Dec”],dayNames:[“Sunday”,”Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”,”Saturday”],dayNamesShort:[“Sun”,”Mon”,”Tue”,”Wed”,”Thu”,”Fri”,”Sat”],dayNamesMin:[“Su”,”Mo”,”Tu”,”We”,”Th”,”Fr”,”Sa”],weekHeader:”Wk”,dateFormat:”mm/dd/yy”,firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:””}, I need localize monthNames and dayNamesMin like this: this.regional[“en”]={monthNames:[“January”,”February”,”March”,”April”,”May”,”June”,”July”,”August”,”September”,”October”,”November”,”December”],dayNamesMin:[“Su”,”Mo”,”Tu”,”We”,”Th”,”Fr”,”Sa”]} and this.regional[“cs”]={monthNames:[“Leden”,”Únor”,”Březen”,”Duben”,”Květen”,”Červen”,”Červenec”,”Srpen”,”Září”,”Říjen”,”Listopad”,”Prosinec”],dayNamesMin:[“Ne”,”Po”,”Út”,”St”,”Čt”,”Pá”,”So”]} but when i input “en or cs” i immediately get error. Any suggest?

Categories
Development

I could not remove items from the arraylist. How to remove items from the array list in android?

I could not remove items from the arraylist while using interface in android. @Override public void spinnerData(SpinnerData2 spinnerData) { spinnerDataList.add(spinnerData); /*int j = spinnerDataList.indexOf(spinnerData); int st= spinnerDataList.size();*/ /*Toast.makeText(this, “”+st, Toast.LENGTH_SHORT).show();*/ } @Override public void spinnerDataRemove(SpinnerData2 spinnerData) { spinnerDataList.remove(spinnerData); }

Categories
Development

How can I avoid using endless nested replace methods to abbreviate street addresses?

I am having a hard find figuring out how to write some Visual Basic code that would replace an seemingly endless nested series of Replace() methods. Here is what I have right now: Replace(Replace(Replace(Replace(Replace(Replace(Replace(rs(“street”), “Blvd.”, “Boulevard”), “St.”, “Street”), “Lane”, “Ln.”), “Avenue”, “Ave.”), “Road”, “Rd.”), “Highway”, “Hwy.”), “Court”, “Ct.”) There must be a way to create […]

Categories
Development

How can I avoid using endless nested replace methods to abbreviate street addresses?

I am having a hard find figuring out how to write some Visual Basic code that would replace an seemingly endless nested series of replace() methods. Here is what I have right now: replace(replace(replace(replace(replace(replace(replace(rs(“street”),”Blvd.”,”Boulevard”),”St.”,”Street”),”Lane”,”Ln.”),”Avenue”,”Ave.”),”Road”,”Rd.”),”Highway”,”Hwy.”),”Court”,”Ct.”) There must be a way to create a function, pass it an address, and more efficiently achieve what I am after. […]