Search Results

Search found 8042 results on 322 pages for 'days'.

Page 26/322 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • SQL: Find difference between dates with grouping

    - by ajbeaven
    I have a problem that seems similar to this fellow - I just want to display the data slightly differently. I'm pretty terrible with SQL so can't modify it to suit, but perhaps someone else can. My table looks similar to this (date format is dd/mm/yyyy): ID User Date_start Role 1 Andy 01/04/2010 A 2 Andy 10/04/2010 B 3 Andy 20/04/2010 A 4 John 02/05/2010 A I want to show the total number of days that anyone was in a certain role. Users stay in the role until there is another entry into the table. Users can only be in one role at a time. So the summary data would look like this (assuming that the date is 04/05/2010): A: 26 days B: 10 days Thanks for any help :)

    Read the article

  • How do I best run a search on Date when it is not a :has_many association?

    - by Angela
    I have a number of activities that have a calculated scheduled date. The activities, for example, Email, have a email.days method which is the days from a Contact.start_date on which it should be sent. This means contact.start_date + email.days yields a date on which email is sent to contact. I would like to use link_to around the date, so I can see all the emails and associated contacts that are to be scheduled on that date. However, this "date" is not an attribute or an associate, so I'm not linking to a model's view. It's calculated. So: 1) What should the actual "format" of the date that gets passed in the URl be? What is the method to do the consistent conversion? 2) How do I (find) all instances, because this "date" is not an actual attribute, is it a calculated value which changes depending on the two associated models of Contact and Email. Thanks.

    Read the article

  • Help with Ruby Date Compare

    - by Kevin
    Yes, I've read and done teh Google many times but I still can't get this working... maybe I'm an idiot :) I have a system using tickets. Start date is "created_at" in the timestamps. Each ticket closes 7 days after "created_at". In the model, I'm using: def closes (self.created_at + 7.days) end I'm trying to create another method that will take "closes" and return it as how many days, hours, minutes, and seconds are left before the ticket closes. Anyone want to help and/or admonish my skills? ;)

    Read the article

  • asp.net membership provider api. usability. best-practice

    - by Andrew Florko
    Hello everybody, Membership/Role/Profile providers API appeared in early days of asp.net Nearly everytime I can't live with standard API & have to add some extra functionality (for sorting, retrieving e.t.c.). I also have to use different database structure often (with foreign key to some tables for example) or think about performance improvements. These considerations forced teams I took part in to build own providers but I can't stand to implement providers API (because we don't use 70% of standard functionality at least). Moreover, providers that were built for exact projects were rarely reused. I wonder if someone found swiss-knife early-days-API providers implementation that is usefull for any kind of project without refactoring... Or do you use your own implementations of early-days-API's Or may be you abandon standard architecture and use lightweight implementations ? Thank you in advance

    Read the article

  • how to get day name in datetime in python

    - by gadss
    how can I get the day name (such as : Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday) in datetime in python?... here is my code in my handlers.py from django.utils.xmlutils import SimplerXMLGenerator from piston.handler import BaseHandler from booking.models import * from django.db.models import * from piston.utils import rc, require_mime, require_extended, validate import datetime class BookingHandler(BaseHandler): allowed_method = ('GET', 'POST', 'PUT', 'DELETE') fields = ('id', 'date_select', 'product_name', 'quantity', 'price','totalcost', 'first_name', 'last_name', 'contact', 'product') model = Booking def read(self, request, id, date_select): if not self.has_model(): return rc.NOT_IMPLEMENTED try: prod = Product.objects.get(id=id) prod_quantity = prod.quantity merge = [] checkDateExist = Booking.objects.filter(date_select=date_select) if checkDateExist.exists(): entered_date = Booking.objects.values('date_select').distinct('date_select').filter(date_select=date_select)[0]['date_select'] else: entered_date = datetime.datetime.strptime(date_select, '%Y-%m-%d') entered_date = entered_date.date() delta = datetime.timedelta(days=3) target_date = entered_date - delta day = 1 for x in range(0,7): delta = datetime.timedelta(days=x+day) new_date = target_date + delta maximumProdQuantity = prod.quantity quantityReserve = Booking.objects.filter(date_select=new_date, product=prod).aggregate(Sum('quantity'))['quantity__sum'] if quantityReserve == None: quantityReserve = 0 quantityAvailable = prod_quantity - quantityReserve data1 = {'maximum_guest': maximumProdQuantity, 'available': quantityAvailable, 'date': new_date} merge.append(data1) return merge except self.model.DoesNotExist: return rc.NOT_HERE in my code: this line sets the date: for x in range(0,7): delta = datetime.timedelta(days=x+day) new_date = target_date + delta

    Read the article

  • Can not get json response using $.getJSON

    - by Mellon
    I am currently developing a Ruby on rails 3 application. My server controller function render a json object as response: class DaysController < BaseController ... def the_days ... render :json => days end end In my javascript,I use the following code to get json response from server( that's from the_day function in controller) $.getJSON( url, {emp_id: emp_id}, function(data) { var result = data.response; alert(result) alert(data) }, "json" ); I use firefox browswer and checked with Firebug, in Firebug Net-XHR, I see the Get request is successful, and the response "days" is there. That's both request and response are successful. But I did not see the two alert window defined in the above $.getJSON function, why? Why I can not get the response "days" in $.getJSON function??

    Read the article

  • Best way to store weekly event in MySQL?

    - by mazin k.
    I have a table of weekly events that run on certain days of the week (e.g. MTWTh, MWF, etc.) and run on a certain time (e.g. 8am-5pm). What's the best way to store day of week information in MySQL to make retrieving and working with the data easiest? My CakePHP app is going to need to retrieve all events happening NOW(). For time of day, I would just use TIME. For days of the week, I had considered a 7-bit bitfield, a varchar ("MTWThFr" type deal) for the days of the week, but both of those seem like clunky solutions (the varchar being clunkier). Any suggestions?

    Read the article

  • Default Values Specflow Step Definitions

    - by Gavin Osborn
    I'm starting out in the world of SpecFlow and I have come across my first problem. In terms of keeping my code DRY I'd like to do the following: Have two scenarios: Given I am on a product page And myfield equals todays date Then... Given I am on a product page And myfield equals todays date plus 4 days Then... I was hoping to use the following Step Definition to cover both variants of my And clause: [Given(@"myfield equals todays date(?: (plus|minus) (\d+) days)?")] public void MyfieldEqualsTodaysDate(string direction, int? days) { //do stuff } However I keep getting exceptions when SpecFlow tries to parse the int? param. I've checked the regular expression and it definitely parses the scenario as expected. I'm aware that I could so something as crude as method overloading etc, I was just wondering if SpecFlow supported the idea of default parameter values, or indeed another way to achieve the same effect. Many Thanks

    Read the article

  • Why do date manipulation in Java with milliseconds?

    - by staticsan
    I was recently faced with the problem of calculating the number of days from two dates in Java (without using joda, I'm afraid). Searching on the 'net shows most answers to this question say to get the milliseconds of the two days and convert that to days, which I found appalling. However, a scant few show a different approach: use a temporary variable to count how many times it takes adding 1 day to the first date to get to the second. This leaves the conversions to the code that does it best: the library. Why do so many people advocate the first? In another project, I had previously encountered numerous subtle date calculation problems involving time-zones, daylight-saving and once even leap years using seconds to do date comparisions and calculations. All these went away when all the comparison and calculation code was rewitten to use the language libraries. (This was in PHP, though, where the libraries are structured quite differently to Java.) So I'm understandably reluctant to use this "common wisdom" in the world of Java about comparing dates.

    Read the article

  • Database normalization and duplicate values

    - by bretddog
    Consider a Parent / Child / GrandChild structure in a database table schema, or even a deeper hierarchy. These being in the same aggregate. One table DAYS keeps a single row per day, and has a "Date" field. This is the root table, or maybe a child of the root. No row can ever be deleted in this table. In this case, however complex my table schema looks like, however far away in the hierarchy any other table is, is there any reason why any other table would hold a Date value? Can't it instead just have a FK to the DAYS table. I obviously assume that the creation of these date fields happen not before such datefield exist in the DAYS table. I'm now thinking just about the date part to be relevant, not the time part. Not sure if all databases can store these individually. That's maybe relevant, but not really the focus of the question.

    Read the article

  • How to handle date difference between client and server?

    - by daydreamer
    I have an API which looks like /summary/yyyy/mm Which returns the summary of their data for the year and month requested. One of the things it returns the number of days left if this is current year and month. For example: days_left: 9 for 2013 and 10 and current date on server is 21 Oct 2013 How I calculate remaining days? This is implemented in python as def current_financial_month_details(self): time_from, time_to = self \ .get_start_end_time_current_financial_month() today = datetime.today() from_time = datetime(year=today.year, month=today.month, day=today.day) return { 'time_from': time_from, 'time_to': time_to, 'remaining_days': (time_to - from_time).days } The problem? The server is in east coast and the client(me with browser) is on pacific time zone When its 9PM PST the time changes in east coast, so if I run hit /summary/2013/10 and if it is Oct 21 2013 for me on PST, the date has already changed on EST, so days_left: 8 which is incorrect on client end. right? How do I handle this situation?

    Read the article

  • Timespan not accepting day in MVC3

    - by middelpat
    I have a MVC3 application in which i want to set a timespan to for example 2 days and 5 hours. when i enter 02:05:00:00 it gives me the following exception: System.OverflowException: SqlDbType.Time overflow. Value '2.05:00:00' is out of range. Must be between 00:00:00.0000000 and 23:59:59.9999999. When i enter 05:00:00 it correctly saves 5 hours into the database. according to MSDN timespan has a property for days. How do i correctly set the days? Model: public class ProductionTimeVM { [Required] public TimeSpan DefaultTime { get; set; } } In my view i just use: @Html.TextBoxFor(x => x.DefaultTime) For my controller: public ActionResult SaveProductionTime(ProductionTimeVM vm) { ProductionTime productionTime = new ProductionTime(); productionTime.Default = vm.DefaultTime; //some more code } Any idea's?

    Read the article

  • How can I display a list of three different Models sortable by the same :attribute in rails?

    - by Angela
    I have a Campaign model which has_many Calls, Emails, and Letters. For now, these are each a separate Model with different controllers and actions (although I would like to start to think of ways to collapse them once the models and actions stabilize). They do share two attributes at least: :days and :title I would like a way to represent all the Calls, Emails, and Letters that belong_to a specific Campaign as a sortable collection (sortable by :days), in a way that outputs the model name and the path_to() for each. For example (I know the below is not correct, but it represents the kind of output/format I've been trying to do: @campaign_events.each do |campaign_event| <%= campaign_event.model_name %> <%= link_to campaign_event.title, #{model_name}_path(campaign_event) %> end Thanks so much. BTW, if this matters, I would then want to make the :days attribute editable_in_place.

    Read the article

  • insert into table where if not in list

    - by jim smith
    Can anybody help me with the syntax? insert into history (company,partnumber,price) values ('blah','IFS0090','0.00') if company NOT IN ('blah','blah2','blah3','blah4','blah4') and partnumber='IFS0090'; Background: I have a history table which stores daily company, products and prices. But sometimes a company will remove itself for a few days. Complicating the issue is because I'm only saving daily CHANGES to prices only and not snapshotting the entire days list (the data would be huge) when I display the data the company will still come up for the previous days price. So I need to do something like this, where a 0.00 price means they're no longer there.

    Read the article

  • PHP: Auto Updating subscriptions?

    - by Duncan Palmer
    Hey guys I am currently making a website and I am hopefully going to start a premium service for it. What I am currently looking into right now is how to make an "auto updating" shop which removes 1 day from how many days left the user has left on their premium status. so for example if the users purchases 30 days of premium, each day that 30 with negate 1 so.. 30, 29, 28, 27.. etc and then if the days gets to 0 in will remove premium status. The only way I can think of keeping track of this right now is by manually monitoring each persons premium status but that wouldnt be very practical. What would the best way for me to do this? (hopefully "automatically") Thanks.

    Read the article

  • How can I use edit_in_place in the show of a different model in Rails?

    - by Angela
    I have a model Campaign and the campaign/show goes through a loop of the Emails. Campaign has_many Emails. <h2>Emails to Send Today</h2> <% for email in @campaign.emails %> <p><strong>Email: </strong><%= link_to email.title, email_path(email) %> sent after <%= distance_of_time_in_words(email.days.days) %></p> <% end %> I would like to be able to edit in place the subject and/or the email.days value from the Campaign/show page. How do I do that? (Added complexity, these are clickable links).

    Read the article

  • How to get time from db depending upon conditions

    - by Somebody is in trouble
    I have a table in which the value are Table_hello date col2 2012-01-31 23:01:01 a 2012-06-2 12:01:01 b 2012-06-3 20:01:01 c Now i want to select date in days if it is 3 days before or less in hours if it is 24 hours before or less in minutes if it is 60 minutes before or less in seconds if it is 60 seconds before or less in simple format if it is before 3days or more OUTPUT for row1 2012-01-31 23:01:01 for row2 1 day ago for row3 1 hour ago UPDATE My sql query select case when TIMESTAMPDIFF(SECOND, `date`,current_timestamp) <= 60 then concat(TIMESTAMPDIFF(SECOND, `date`,current_timestamp), ' seconds') when TIMESTAMPDIFF(DAY, `date`,current_timestamp) <= 3 then concat(TIMESTAMPDIFF(DAY, `date`,current_timestamp), ' days')end when TIMESTAMPDIFF(HOUR, `date`,current_timestamp) <= 60 then concat(TIMESTAMPDIFF(HOUR, `date`,current_timestamp), ' hours') when TIMESTAMPDIFF(MINUTE, `date`,current_timestamp) <= 60 then concat(TIMESTAMPDIFF(MINUTE, `date`,current_timestamp), ' minutes') from table_hello Only problem is i am unable to use break and default in sql like switch case in c++

    Read the article

  • PHP: report table with date gaps

    - by Daniel
    Hi. I have a table in DB which contains summaries for days. Some days may not have the values. I need to display table with results where each column is a day from user selected range. I've tried to play with timestamp (end_date - start_date / 86400 - how many days in report, then use DATEDIFF(row_date, 'user_entered_start_date') and create array from this indexes), but now I've got whole bunch of workarounds for summer time :( Any examples or ideas how to make this correct? P.S. I need to do this on PHP side, because DB is highly loaded.

    Read the article

  • Update someones birthday with javascript

    - by user2768038
    So far the only mathematical way I can think of doing it is this: var age = 18 var today = new Date(); var myDate = new Date(); myDate.setFullYear(2013,3,13); /* My birthday is april 13th */ var y = (today - myDate); var days = ( y / (1000*60*60*24)); if(days >= 360){ var age = age +1; } if(days >= 720){ var age = age +1; } //etc...... document.write(age); Is there a better way of doing the if statements? so that I don't have to write one out for every year? I can't think!

    Read the article

  • Get records in particular date range

    - by developer
    Hi All, I have a column in database that shows DateCreated. Now I want to filter records depending on the date range selected. Eg, Created within 60 days, created withing year, etc. I have a variable dateCreated that shows me what the user has selected as the range.i.e., whether it is Created within 60 days, created withing year. if (datecreated == "Created within 60 days") { DateTime CurrTime = DateTime.Now; if (prg.Subscriber.Username == CurrentUsername && prg.Program.DateCreated<=DateTime.Now - 60) { UserPrgList.Add(new ProgramSubscriptionViewModel(prg)); } } But the above code wont work..what would be the syntax to get the records within a particular range??

    Read the article

  • Humanizing time

    - by keruilin
    I have a number of products that are perishable. Therefore, each product has an attribute called hours_expiration that tells how many hours the product can be used before it goes bad. For ex, apple expires in 168 hours; nut expires in 4320 hours. Given, the product's hours-to-expiration and the current time (Time.now or Date.now), how can I humanize the time-to-expiration in some of the following sample ways? Your item is set to expire in about: 6 months and 14 days 1 month and 13 days 1 month and 1 day 27 days 1 day 23 hours 1 hour 50 minutes 1 minute Looking for something robust and simple!

    Read the article

  • WebLogic Server Virtual Developer Day and Upcoming Developer Webcasts

    - by james.bayer
    We have a series of Virtual Developer Days for WebLogic for different geographies coming up as well as developer-oriented webcasts focusing on building a sample application with popular modern technologies.  The first one is Feb 1st, 2011 for North America, but there are others coming up through mid-March as well.  Check them out and register below. Virtual Developer Days for WebLogic AMER Conference begins: February 1, 2011 at 9:30am PST EUROPE/RUSSIA Conference begins: Thursday Feb 10, 2011 - 9:30 a.m. UK Time / 10:30 a.m. CET INDIA Conference begins: Thursday Feb 17, 2011 -  9:30am India time Register here for the Virtual Developer Day in your geography.   WebLogic Developer Webcasts Watch this brief video to learn more about the developer webcasts where we’ll build an application over several weeks focusing on different features like JPA, Data Grids, JMS, JAX-RS and more.  Register here for the WebLogic developer webcasts.

    Read the article

  • SQLAuthority News – Meeting with Allen Bailochan Tuladhar – An Unlimited Experience

    - by pinaldave
    Allen  Tuladhar I recently came back from my 9-day trip in Nepal and I must say that this is one of the best trips I had in my lifetime. Allen Bailochan Tuladhar is a wonderful person and an extreme enthusiast for Microsoft Technology. Allen is the Chief Executive Officer of Unlimited Technologies Pvt Ltd., Country Manager of Microsoft MDP Nepal, the Member Secretary of Nepali Language in Information Technology, and member of the Steering Committee of the Government of Nepal. He is the person who keeps the Nepal’s Tech Community constantly motivating and taking it to the next level. I have met Allen for many times before, but this was the first time I was with him in Kathmandu, Nepal. I was very impressed with the amount of the work he does in the community. During my 9 days of stay, every single day was a new lesson for me. I was amazed and overwhelmed with the many things he does every single day. Not only he does he work closely with Government of Nepal ministry, but he is also the most known person in the Student Community. His expertise in the technical subject matter is not limited to one technology; rather, I have seen him actively engaging himself in  discussions of various tech topics. Allen presending at TechMela Kathmandu, Nepal Allen is currently active in working out to localize Windows and Office and incorporate it using the Nepali language. I was able to witness and experience how the localization works, as well as the procedure on how to do such. If you know the whole localization process, you must have realized how big and daunting of a process it is. I was glad that I became a part of it. Prominent Personality of Nepal on Panel Discussion Another great opportunity I had when I was at Allen’s office is that I have learned how the radio technology talk show works. Nepali Radio station has the weekly program in their local language, in which MS technology is discussed and industry leaders are invited to talk about their experience with the technology. I found the program so interesting because it has so much variety in terms of technology subjects. Well, my understanding of Nepali language is limited but I did understand quite a bit. Ravi, Nutan, Pinal, Gandip I got the chance to meet lots of Database Professionals as well. People in Nepal are very polite even though they are very strong in their technology fundamentals. I had in-depth discussion regarding High Availability scenarios, as well Query Tuning. Database professionals from the leading financial sectors of Nepal wanted me to visit their Data Center and help them out with a few advances. In no time, Allen organized a visit for me. He sent me a Nepali-speaking expert from his own organization to accompany me in overcoming any difficulties while I was on my way helping this financial district. Pinal (SQLAuthority) and Deependra (Unlimited) When I was going to Nepal, I was really not sure if I would be able to stay busy for 9 days straight in Community-related activity. However, on the 9th day I realize that I can still stay here for more than 9 days because in every single day, I feel enthusiastic enough to do something new. Allen Bailochan Tuladhar Even though I was working  very hard every day, I hardly had the chance to work with and talk to him one-on-one for the first few days. One of the evenings, Allen invited me to his home and we discussed about his future ideas. I was really surprised to see how much a man can do for his technical community and for his country. When I asked Allen’s wife and daughter if they ever think it’s getting too much with regards to Allen putting tough efforts to the community, their answer was something I did not expect. I found out that Allen’s wife manages all the back office and logistics of the community events and his daughter manages the websites. I felt that they do not have any complain,  and instead, their whole family is in this activity as deeply as it can get, which I thought is a very good thing. Pinal and Allen I want to end this post with an interesting story that happened during our lunch hour at one of the Nepali restaurants. While we were having our lunch and having some chitchat, Allen suddenly stood up and called several people walking along the pavement. He introduced them all to me as Microsoft Student Partners. He asked all of them to order their favorite dish and called the waiter to inform that he will pick up their tab. Figuring out the question written on my face, he just said one sentence: “They are all future technology professionals who are going to make all of us proud.” I guess I have a lot of things to learn. Hats off to Allen! Pinal and Allen at Microsoft MDP Unlimited Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: MVP, SQL, SQL Authority, SQL Query, SQL Server, SQL Tips and Tricks, SQLAuthority Author Visit, T SQL, Technology

    Read the article

  • No, iCloud Isn’t Backing Them All Up: How to Manage Photos on Your iPhone or iPad

    - by Chris Hoffman
    Are the photos you take with your iPhone or iPad backed up in case you lose your device? If you’re just relying on iCloud to manage your important memories, your photos may not be backed up at all. Apple’s iCloud has a photo-syncing feature in the form of “Photo Stream,” but Photo Stream doesn’t actually perform any long-term backups of your photos. iCloud’s Photo Backup Limitations Assuming you’ve set up iCloud on your iPhone or iPad, your device is using a feature called “Photo Stream” to automatically upload the photos you take to your iCloud storage and sync them across your devices. Unfortunately, there are some big limitations here. 1000 Photos: Photo Stream only backs up the latest 1000 photos. Do you have 1500 photos in your Camera Roll folder on your phone? If so, only the latest 1000 photos are stored in your iCloud account online. If you don’t have those photos backed up elsewhere, you’ll lose them when you lose your phone. If you have 1000 photos and take one more, the oldest photo will be removed from your iCloud Photo Stream. 30 Days: Apple also states that photos in your Photo Stream will be automatically deleted after 30 days “to give your devices plenty of time to connect and download them.” Some people report photos aren’t deleted after 30 days, but it’s clear you shouldn’t rely on iCloud for more than 30 days of storage. iCloud Storage Limits: Apple only gives you 5 GB of iCloud storage space for free, and this is shared between backups, documents, and all other iCloud data. This 5 GB can fill up pretty quickly. If your iCloud storage is full and you haven’t purchased any more storage more from Apple, your photos aren’t being backed up. Videos Aren’t Included: Photo Stream doesn’t include videos, so any videos you take aren’t automatically backed up. It’s clear that iCloud’s Photo Stream isn’t designed as a long-term way to store your photos, just a convenient way to access recent photos on all your devices before you back them up for real. iCloud’s Photo Stream is Designed for Desktop Backups If you have a Mac, you can launch iPhoto and enable the Automatic Import option under Photo Stream in its preferences pane. Assuming your Mac is on and connected to the Internet, iPhoto will automatically download photos from your photo stream and make local backups of them on your hard drive. You’ll then have to back up your photos manually so you don’t lose them if your Mac’s hard drive ever fails. If you have a Windows PC, you can install the iCloud Control Panel, which will create a Photo Stream folder on your PC. Your photos will be automatically downloaded to this folder and stored in it. You’ll want to back up your photos so you don’t lose them if your PC’s hard drive ever fails. Photo Stream is clearly designed to be used along with a desktop application. Photo Stream temporarily backs up your photos to iCloud so iPhoto or iCloud Control Panel can download them to your Mac or PC and make a local backup before they’re deleted. You could also use iTunes to sync your photos from your device to your PC or Mac, but we don’t really recommend it — you should never have to use iTunes. How to Actually Back Up All Your Photos Online So Photo Stream is actually pretty inconvenient — or, at least, it’s just a way to temporarily sync photos between your devices without storing them long-term. But what if you actually want to automatically back up your photos online without them being deleted automatically? The solution here is a third-party app that does this for you, offering the automatic photo uploads with long-term storage. There are several good services with apps in the App Store: Dropbox: Dropbox’s Camera Upload feature allows you to automatically upload the photos — and videos — you take to your Dropbox account. They’ll be easily accessible anywhere there’s a Dropbox app and you can get much more free Dropbox storage than you can iCloud storage. Dropbox will never automatically delete your old photos. Google+: Google+ offers photo and video backups with its Auto Upload feature, too. Photos will be stored in your Google+ Photos — formerly Picasa Web Albums — and will be marked as private by default so no one else can view them. Full-size photos will count against your free 15 GB of Google account storage space, but you can also choose to upload an unlimited amount of photos at a smaller resolution. Flickr: The Flickr app is no longer a mess. Flickr offers an Auto Upload feature for uploading full-size photos you take and free Flickr accounts offer a massive 1 TB of storage for you to store your photos. The massive amount of free storage alone makes Flickr worth a look. Use any of these services and you’ll get an online, automatic photo backup solution you can rely on. You’ll get a good chunk of free space, your photos will never be automatically deleted, and you can easily access them from any device. You won’t have to worry about storing local copies of your photos and backing them up manually. Apple should fix this mess and offer a better solution for long-term photo backup, especially considering the limitations aren’t immediately obvious to users. Until they do, third-party apps are ready to step in and take their place. You can also automatically back up your photos to the web on Android with Google+’s Auto Upload or Dropbox’s Camera Upload. Image Credit: Simon Yeo on Flickr     

    Read the article

  • Project Navigation and File Nesting in ASP.NET MVC Projects

    - by Rick Strahl
    More and more I’m finding myself getting lost in the files in some of my larger Web projects. There’s so much freaking content to deal with – HTML Views, several derived CSS pages, page level CSS, script libraries, application wide scripts and page specific script files etc. etc. Thankfully I use Resharper and the Ctrl-T Go to Anything which autocompletes you to any file, type, member rapidly. Awesome except when I forget – or when I’m not quite sure of the name of what I’m looking for. Project navigation is still important. Sometimes while working on a project I seem to have 30 or more files open and trying to locate another new file to open in the solution often ends up being a mental exercise – “where did I put that thing?” It’s those little hesitations that tend to get in the way of workflow frequently. To make things worse most NuGet packages for client side frameworks and scripts, dump stuff into folders that I generally don’t use. I’ve never been a fan of the ‘Content’ folder in MVC which is just an empty layer that doesn’t serve much of a purpose. It’s usually the first thing I nuke in every MVC project. To me the project root is where the actual content for a site goes – is there really a need to add another folder to force another path into every resource you use? It’s ugly and also inefficient as it adds additional bytes to every resource link you embed into a page. Alternatives I’ve been playing around with different folder layouts recently and found that moving my cheese around has actually made project navigation much easier. In this post I show a couple of things I’ve found useful and maybe you find some of these useful as well or at least get some ideas what can be changed to provide better project flow. The first thing I’ve been doing is add a root Code folder and putting all server code into that. I’m a big fan of treating the Web project root folder as my Web root folder so all content comes from the root without unneeded nesting like the Content folder. By moving all server code out of the root tree (except for Code) the root tree becomes a lot cleaner immediately as you remove Controllers, App_Start, Models etc. and move them underneath Code. Yes this adds another folder level for server code, but it leaves only code related things in one place that’s easier to jump back and forth in. Additionally I find myself doing a lot less with server side code these days, more with client side code so I want the server code separated from that. The root folder itself then serves as the root content folder. Specifically I have the Views folder below it, as well as the Css and Scripts folders which serve to hold only common libraries and global CSS and Scripts code. These days of building SPA style application, I also tend to have an App folder there where I keep my application specific JavaScript files, as well as HTML View templates for client SPA apps like Angular. Here’s an example of what this looks like in a relatively small project: The goal is to keep things that are related together, so I don’t end up jumping around so much in the solution to get to specific project items. The Code folder may irk some of you and hark back to the days of the App_Code folder in non Web-Application projects, but these days I find myself messing with a lot less server side code and much more with client side files – HTML, CSS and JavaScript. Generally I work on a single controller at a time – once that’s open it’s open that’s typically the only server code I work with regularily. Business logic lives in another project altogether, so other than the controller and maybe ViewModels there’s not a lot of code being accessed in the Code folder. So throwing that off the root and isolating seems like an easy win. Nesting Page specific content In a lot of my existing applications that are pure server side MVC application perhaps with some JavaScript associated with them , I tend to have page level javascript and css files. For these types of pages I actually prefer the local files stored in the same folder as the parent view. So typically I have a .css and .js files with the same name as the view in the same folder. This looks something like this: In order for this to work you have to also make a configuration change inside of the /Views/web.config file, as the Views folder is blocked with the BlockViewHandler that prohibits access to content from that folder. It’s easy to fix by changing the path from * to *.cshtml or *.vbhtml so that view retrieval is blocked:<system.webServer> <handlers> <remove name="BlockViewHandler"/> <add name="BlockViewHandler" path="*.cshtml" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> </handlers> </system.webServer> With this in place, from inside of your Views you can then reference those same resources like this:<link href="~/Views/Admin/QuizPrognosisItems.css" rel="stylesheet" /> and<script src="~/Views/Admin/QuizPrognosisItems.js"></script> which works fine. JavaScript and CSS files in the Views folder deploy just like the .cshtml files do and can be referenced from this folder as well. Making this happen is not really as straightforward as it should be with just Visual Studio unfortunately, as there’s no easy way to get the file nesting from the VS IDE directly (you have to modify the .csproj file). However, Mads Kristensen has a nice Visual Studio Add-in that provides file nesting via a short cut menu option. Using this you can select each of the ‘child’ files and then nest them under a parent file. In the case above I select the .js and .css files and nest them underneath the .cshtml view. I was even toying with the idea of throwing the controller.cs files into the Views folder, but that’s maybe going a little too far :-) It would work however as Visual Studio doesn’t publish .cs files and the compiler doesn’t care where the files live. There are lots of options and if you think that would make life easier it’s another option to help group related things together. Are there any downside to this? Possibly – if you’re using automated minification/packaging tools like ASP.NET Bundling or Grunt/Gulp with Uglify, it becomes a little harder to group script and css files for minification as you may end up looking in multiple folders instead of a single folder. But – again that’s a one time configuration step that’s easily handled and much less intrusive then constantly having to search for files in your project. Client Side Folders The particular project shown above in the screen shots above is a traditional server side ASP.NET MVC application with most content rendered into server side Razor pages. There’s a fair amount of client side stuff happening on these pages as well – specifically several of these pages are self contained single page Angular applications that deal with 1 or maybe 2 separate views and the layout I’ve shown above really focuses on the server side aspect where there are Razor views with related script and css resources. For applications that are more client centric and have a lot more script and HTML template based content I tend to use the same layout for the server components, but the client side code can often be broken out differently. In SPA type applications I tend to follow the App folder approach where all the application pieces that make the SPA applications end up below the App folder. Here’s what that looks like for me – here this is an AngularJs project: In this case the App folder holds both the application specific js files, and the partial HTML views that get loaded into this single SPA page application. In this particular Angular SPA application that has controllers linked to particular partial views, I prefer to keep the script files that are associated with the views – Angular Js Controllers in this case – with the actual partials. Again I like the proximity of the view with the main code associated with the view, because 90% of the UI application code that gets written is handled between these two files. This approach works well, but only if controllers are fairly closely aligned with the partials. If you have many smaller sub-controllers or lots of directives where the alignment between views and code is more segmented this approach starts falling apart and you’ll probably be better off with separate folders in js folder. Following Angular conventions you’d have controllers/directives/services etc. folders. Please note that I’m not saying any of these ways are right or wrong  – this is just what has worked for me and why! Skipping Project Navigation altogether with Resharper I’ve talked a bit about project navigation in the project tree, which is a common way to navigate and which we all use at least some of the time, but if you use a tool like Resharper – which has Ctrl-T to jump to anything, you can quickly navigate with a shortcut key and autocomplete search. Here’s what Resharper’s jump to anything looks like: Resharper’s Goto Anything box lets you type and quick search over files, classes and members of the entire solution which is a very fast and powerful way to find what you’re looking for in your project, by passing the solution explorer altogether. As long as you remember to use (which I sometimes don’t) and you know what you’re looking for it’s by far the quickest way to find things in a project. It’s a shame that this sort of a simple search interface isn’t part of the native Visual Studio IDE. Work how you like to work Ultimately it all comes down to workflow and how you like to work, and what makes *you* more productive. Following pre-defined patterns is great for consistency, as long as they don’t get in the way you work. A lot of the default folder structures in Visual Studio for ASP.NET MVC were defined when things were done differently. These days we’re dealing with a lot more diverse project content than when ASP.NET MVC was originally introduced and project organization definitely is something that can get in the way if it doesn’t fit your workflow. So take a look and see what works well and what might benefit from organizing files differently. As so many things with ASP.NET, as things evolve and tend to get more complex I’ve found that I end up fighting some of the conventions. The good news is that you don’t have to follow the conventions and you have the freedom to do just about anything that works for you. Even though what I’ve shown here diverges from conventions, I don’t think anybody would stumble over these relatively minor changes and not immediately figure out where things live, even in larger projects. But nevertheless think long and hard before breaking those conventions – if there isn’t a good reason to break them or the changes don’t provide improved workflow then it’s not worth it. Break the rules, but only if there’s a quantifiable benefit. You may not agree with how I’ve chosen to divert from the standard project structures in this article, but maybe it gives you some ideas of how you can mix things up to make your existing project flow a little nicer and make it easier to navigate for your environment. © Rick Strahl, West Wind Technologies, 2005-2014Posted in ASP.NET  MVC   Tweet !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs"); (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })();

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >