Posts

asp.net - Entity Framework migrations and refactor model into separate project -

i started out asp.net mvc project entity framework code first , migrations enabled. using standard template got model in same project rest of web site. want re-use model in project, cannot find step-by-step recipe how move model , migrations history, separate project. biggest concerns database comes out of sync model, or data in database lost. maybe it's nothing afraid of, i'll happy if can share experience! ok when have migrations turned on can move context, associated entities , migration configurations new project no problem. if leave of namespaces should not need change anything. because key migration history in database based on namespace + class of migration configuration file. example in web application have migrations @ codemigrations.migrations so contextkey in __migrationhistory table ends being codemigrations.migrations.configuration if move code new project , leave namespaces nothing need changed, if want namespaces updated reflect new base ...

python 2.7 - Writing a list of creation time of items in a folder -

i'm trying write text file creation date of each file in directory. had @ this question, i'm still in need of help, besides being curious why code below doesn't work. i think i'm close. kind of works creation date of folder , want know when files created. import os, os.path, time, datetime mydir = '/home/user/ebay/' mydir2 = '/home/user/' def writefiles(): open(mydir2 + '/items.txt', "wb") a: path, subdirs, files in os.walk(mydir): file in files: a.write(file+' , '+(time.ctime(os.path.getctime(file))) + os.linesep) writefiles() i error message: oserror: [errno 2] no such file or directory: 'pkv20zrzms' this odd, because there file called 'pkv20zrzms'. tried add directory location didn't make difference. the reason think i'm close when change (os.path.getctime(file) (os.path.getctime(path) creation date of folder, this: pkv20zrzms , fri mar ...

c# - ado.net OdbcCommand string -

i have database accessible via odbc , trying connect using ado.net's odbcconnection class. when try execute query dbcommand.commandtext = "select top 5 * table limit order column1" it returns entire table , not top 5. i tried using limit @ end of query, , yet not filter down query. how can limit result of query down couple few? thanks

How do I choose a branch other than "default" for "master" when converting a repo from Mercurial to Git? -

i need convert long-standing mercurial repo git repo (one-way, one-time conversion), , i'd pick mercurial branch other default master branch in git repo. i've converted mercurial git on smaller repo before, , after few gotchas easy google , fix, went well. in case, made sense map default branch master . (the other branch mapping "dev" "dev".) in new case, repository have inherited uses default branch development, , merges approved changes stable branch. so, when comes on git, i'd git master branch reflect stable mercurial branch, , branch reflect default mercurial branch. is possible? of course it's possible. just convert mercurial repo git, using whatever tools convenient you. if end final branches not liking, can rename them. use git rename . for example, rename branches "master" "dev" (that is, swap branches each other): git rename -m master master-old git rename -m dev master git rename -m ma...

sql - Number of palindromes in character strings -

i'm trying gather list of 6 letter palindromes , number of times occur using postgres 9.3.5. this query i've tried: select word, count(*) ( select regexp_split_to_table(read_sequence, '([atcg])([atcg])([atcg])(\3)(\2)(\1)') word reads ) t group word; however brings results a) aren't palindromic , b) greater or less 6 letters long. \d reads table "public.reads" column | type | modifiers --------------+---------+----------- read_header | text | not null read_sequence | text | option | text | quality_score | text | pair_end | text | not null species_id | integer | indexes: "reads_pkey" primary key, btree (read_header, pair_end) read_sequence contains dna sequences, 'atgctgatgcggcgtagctggatcga' example. i'd see number of palindromes in each sequence example contain 1 sequence have 4 3 , on. count per row: select read_header, pair_end, substr(read_sequence,...

graph - match colors with categories r -

upd: added reproducible code. dear all, trying match colors , categories. have 7 spreadsheets data. each spreadsheet data on population numbers of given species in several countries. i'd plot population number of each spp in each country against time, every country in different color (see below). thing is, list of countries varies each species, can't make loop: in case of wild boar, poland first color, in case of red deer, third one. example: year lv lt pl uk es 1974 21578 9250 2700 17610 8900 1975 19955 8800 3300 14280 9300 i created spreadsheet match colors , country names: code col.num cz 1 hu 2 pl 3 sl 4 lv 5 lt 6 es 7 ro 8 uk 9 here code match colors , country names (it creates 3 graphs, first 1 % of numbers relatively number in year of 1990): par(mar=c(5.1, 3.5, 4.5, 2), mfrow = c(3,3)) col.num <- 1:9 code <- c('cz', 'hu', 'pl', 'sl', 'lv', ...

sql - MySQL: Calculate 4 Week Average with 4 Week Offset -

this question related post made earlier: mysql: calculating data table 1 month offset but need build procedure queries table of contact data stored week. here's simplified example of table working with: +-----------------+------------+ | week_start_date | contacts | +-----------------+------------+ | 2015-03-08 | 12 | | 2015-03-01 | 20 | | 2015-02-22 | 5 | | 2015-02-15 | 17 | | 2015-02-08 | 8 | | 2015-02-01 | 2 | | 2015-01-25 | 16 | | 2015-01-18 | 10 | | 2015-01-11 | 4 | | ... | ... | +-----------------+------------+ what need figure out how calculate 4 week moving average has 4 week offset on top of that. instance, if wanted average contacts week of march 8, 2015, average of january 18 through february 8. in example above, average be: (10 + 16 + 2 + 8 ) / 4 = 9. , if wanted find average week of march 1, 2015, average of january 11...