How to refactor these two functions to be more DRY?

I have the following two Python functions: @classmethod def serialize_dict(cls, d): values = [] for column_name in cls().distinguishing_column_names(): value = str(d[column_name]) if value == 'None': value = '' values.append(value) return ' '.join(va

Search for a string in the file name in subdirectories

I have a large directory of folders (call it C:\Main). I need to set up a batch script to search the subfolders of that directory for a string within the filename (not the text within the file). I'm having trouble finding an answer. Essentially, let'

A simpler way to write this if the c ++ function

is there an easier way to write this if statement? int main () { char k[100]; int i=0; ifstream fd ("info.txt"); while (!in.eof()) { fd >> k[i] if (int(k[i]) != 96 || int(k[i]) != 97 || int(k[i]) != 98 || int(k[i]) != 99) i++; } } and so o

How to Trap Drag-Drop Event in Word?

I am creating an Add-in (using C#) for Microsoft Word and want to trigger some functionality when some text/image etc. is dragged from any source and dropped into Word. So basically I want to trap the Drop event in Word. However I am not able to find

Development of applications for iPhone - mathematical symbols

I am quite the beginner - but I have a lot of experience with respect to Electrical Engineering and formulas - over 30 years worth! Trying to construct an app for the iPhone. Loaded the SDK, bought myself a Mac, got a couple of "Chapter" pages w

How to calculate the 90th Percentile, SD, mean for SQL data

Hi I have a table facility. Which holds a score for each day (Multiple scores can be reported each day and both would be valid) I need to calculate the 90th percentile, SD, and Mean for score by month. Facility: Id Month Date score 1 Jan 1 5 1 Jan 1

Multiple Activities / Fragments and Model View Presenter Model

Firstly, I know that with Model View Presenter there are different implementations, and in my mind as long as you have the layers of abstraction clearly defined and doing their appointed roles then how you implement this pattern is open to interpreta

Does it make sense to use timers with a Windows service?

I have a console service I'm currently testing. I was planning on using a timer for it to last all day, with an interval check every 30 seconds, however, it looks like alot of people don't like using timer's with a service in that fashion. Is It wise

Access to PropTypes via the main React packet is obsolete

I'm using redux but when I run my code I have this error: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead. I install npm i prop-types -S but I I still have the same error. ./components/action/

Example using MSCHART in C #

Anybody know where to find an sample form using MSChart in C#? I made an example. //name program.cs using System; using System.Collections.Generic; using System.Windows.Forms; namespace MSChart_Sample { static class Program { /// <summary> /// The m

Pow-on long long signed

I have the following power function which operates on integers and it works fine: int ipow( int base, int exp ) { int result = 1; while( exp ) { if ( exp & 1 ) { result *= base; } exp >>= 1; base *= base; } return result; } Now I'd like to have

How to focus on the spinner?

I have spinner and edittext, and i want if spinner is selected can setfocus in edittext. I am already try, but not going to work, how to fix this? This is my code : edkontak1.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override

Reassign a looped file pointer

I need to reassign a single file pointer to multiple files sequentially. I have the file paths correctly in a string path. when i pass the path and the file pointer to a function to reassign, I get "Aborted (core dumped)".. FILE * fptr; //Global

Storing the buffer address in an unsigned integer;

I have a memory buffer whose address i want to store in an unsigned integer value. uint8_t* _buff = new uint8_t[1024]; uint64_t* _base_addr = (uint64_t *)_buff; I want the address of the location pointed by _buff or _base_addr (anyhow it is the same

Invalid object name (ASP.NET MVC)

I have this error Invalid object name 'dbo.Vacancies' But I have Model for Vacancies Here it is public partial class Vacancy { [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstruc

How to schedule a task that works every day at 1:00 pm

I'm using Quartz library to run a schedule task.I used it like this ISchedulerFactory scheduleFact = new StdSchedulerFactory(); IScheduler scheduler = scheduleFact.GetScheduler(); scheduler.Start(); IJobDetail job = JobBuilder.Create<MyJob>() .WithI

MVC 5 one to many ICollection virtual returns null?

I have a model which looks like this public class MyModel { .... public virtual ICollection<Comm_ent> Comments { get; set; } } and the submodels look like public class Comm_ent { ... public virtual My_Model MyModel{ get;set;} } In my Comm_ent Datata

Sending messages with Websockets

I have the following html/javascript code that uses websockets to communicate with a server. It seems like I can only send(message) only inside the onmessage() and onopen() functions. How can I send data outside of those functions ? <!DOCTYPE HTML>

Addition of 2x2 matrix with NaNs

More of a general MATLAB question than looking for programming advice -- if I have: y = cellfun(@(x)sum(x(:)), Z, 'un', 0); where there are a combinations of NaN's and real numbers in each cell matrix, when I sum all elements of those matrices per ce

DevExpress Cascade Combo Boxes in datagridview

I have a datagridview bound to a datasource, and in each row in the grid there is a category, product, and quantity. I want to filter the products in each row according to the selected category. I'm using C# and DevExpress. How can I do this? Please

Heap or Red-Black Tree?

I am willing to use a data structure as an overflow buffer of constant space. I want to have efficient insert but most importantly efficient removal of the min element. I was thinking of using a heap since I have O(log(n)) find_min() and log(n) inser

print two lines from multiple files with the file name in awk

I have multiple files in a directory. i want to pull out certain lines from all those files and print to an output file. File1 line1 line2 line3 line4 File2 line1 line2 line3 line4 and like so i have many files. Desired Output File1 line2 line4 File2

Add data frames per row with [d] plyr

I have two data frames df1 # a b # 1 10 20 # 2 11 21 # 3 12 22 # 4 13 23 # 5 14 24 # 6 15 25 df2 # a b # 1 4 8 I want the following output: df3 # a b # 1 14 28 # 2 15 29 # 3 16 30 # 4 17 31 # 5 18 32 # 6 19 33 i.e. add df2 to each row of df1. Is ther

Using Backup to Store Files in the Database

I'am trying to use backload ( to upload images to a mvc application we are currently building. It is supposed to be able to store images in database but I had no luck finding an example that demonstrates this fea

Filter to today's date in the Meteor collection

I have a datepicker in my Meteor app. When I insert or update the date into my collection, after creating a variable from the value of the datepicker, I do this: due: moment(new Date(due)).toDate() Which inserts the date into mongo like this: Tue Jun