Daily Archives

Articles indexed Tuesday August 28 2012

Page 9/19 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Appending column to a data frame - R

    - by darkie15
    Is it possible to append a column to data frame in the following scenario? dfWithData <- data.frame(start=c(1,2,3), end=c(11,22,33)) dfBlank <- data.frame() ..how to append column start from dfWithData to dfBlank? It looks like the data should be added when data frame is being initialized. I can do this: dfBlank <- data.frame(dfWithData[1]) but I am more interested if it is possible to append columns to an empty (but inti)

    Read the article

  • Shell access to files created by Apache user in PHP

    - by Alexandru Trandafir Catalin
    My website creates files with owner apache:apache when uploading a file, like this: drwxr-xr-x 2 apache apache 4096 Aug 28 14:07 . drwxr-xr-x 9118 apache apache 233472 Aug 28 14:07 .. -rw-r--r-- 1 apache apache 41550 Aug 28 14:07 468075_large.jpg -rw-r--r-- 1 apache apache 26532 Aug 28 14:07 468075_medium.jpg -rw-r--r-- 1 apache apache 50881 Aug 28 14:07 468075_original.jpg -rw-r--r-- 1 apache apache 4316 Aug 28 14:07 468075_small.jpg Now I am trying to create a file inside the same folder with the user that owns that domain in Plesk and I get permission denied. How can I have both apache and shell user with permissions over that files? Thanks.

    Read the article

  • Google maps nearest points avoiding rivers / by itinerary

    - by Karl Lacroix
    Here is the deal : I need to find the closest points from a point with a radius. For example, I need to get all the points in a 15 km radius. Thats easy with Google Maps Radius and all the examples on the web ;) The problem is that from my office, a point is under the 15km radius, but it's on the other side of a river, so the car itinerary is about 30 km (using a bridge)! Is there a simple solution to exclude those points or to calculate by intineraries ? I supposed that I'll need to calculate all itineraries with returned points? DirectionsRequest API? Thanks! :)

    Read the article

  • Sending and receiving a TMemoryStream using IdTCPClient and IdTCPServer

    - by Martin Melka
    I found Remy Lebeau's chat demo of IdTCP components in XE2 and I wanted to play with it a little bit. (It can be found here) I would like to send a picture using these components and the best approach seems to be using TMemoryStream. If I send strings, the connection works fine, the strings are transmitted successfully, however when I change it to Stream instead, it doesn't work. Here is the code: Server procedure TMainForm.IdTCPServerExecute(AContext: TIdContext); var rcvdMsg: string; ms:TMemoryStream; begin // This commented code is working, it receives and sends strings. // rcvdMsg:=AContext.Connection.IOHandler.ReadLn; // LogMessage('<ServerExec> '+rcvdMsg); // // TResponseSync.SendResponse(AContext, rcvdMsg); try ms:=TMemoryStream.Create; AContext.Connection.IOHandler.ReadStream(ms); ms.SaveToFile('c:\networked.bmp'); except LogMessage('Failed to receive',clred); end; end; Client procedure TfrmMain.Button1Click(Sender: TObject); var ms: TMemoryStream; bmp: TBitmap; pic: TPicture; s: string; begin // Again, this code is working for sending strings. // s:=edMsg.Text; // Client.IOHandler.WriteLn(s); ms:=TMemoryStream.Create; pic:=TPicture.Create; pic.LoadFromFile('c:\Back.png'); bmp:=TBitmap.Create; bmp.Width:=pic.Width; bmp.Height:=pic.Height; bmp.Canvas.Draw(0,0,pic.Graphic); bmp.SaveToStream(ms); ms.Position:=0; Client.IOHandler.Write(ms); ms.Free; end; When I try to send the stream from the client, nothing observable happens (breakpoint in the OnExecute doesn't fire). However, when closing the programs(after sending the MemoryStream), two things happen: If the Client is closed first, only then does the except part get processed (the log displays the 'Failed to receive' error. However, even if I place a breakpoint on the first line of the try-except block, it somehow gets skipped and only the error is displayed). If the Server is closed first, the IDE doesn't change back from debug, Client doesn't change its state to disconnected (as it normally does when server disconnects) and after the Client is closed as well, an Access Violation error from the Server app appears. I guess this means that there is a thread of the Server still running and maintaining the connection. But no matter how much time i give it, it never completes the task of receiving the MemoryStream. Note: The server uses IdSchedulerOfThreadDefault and IdAntiFreeze, if that matters. As I can't find any reliable source of help for the revamped Indy 10 (it all appears to apply for the older Indy 10, or even Indy 9), I hope you can tell me what is wrong. Thanks - ANSWER - SERVER procedure TMainForm.IdTCPServerExecute(AContext: TIdContext); var size: integer; ms:TMemoryStream; begin try ms:=TMemoryStream.Create; size:=AContext.Connection.IOHandler.ReadLongInt; AContext.Connection.IOHandler.ReadStream(ms, size); ms.SaveToFile('c:\networked.bmp'); except LogMessage('Failed to receive',clred); end; end; CLIENT procedure TfrmMain.Button1Click(Sender: TObject); var ms: TMemoryStream; bmp: TBitmap; pic: TPicture; begin ms:=TMemoryStream.Create; pic:=TPicture.Create; pic.LoadFromFile('c:\Back.png'); bmp:=TBitmap.Create; bmp.Width:=pic.Width; bmp.Height:=pic.Height; bmp.Canvas.Draw(0,0,pic.Graphic); bmp.SaveToStream(ms); ms.Position:=0; Client.IOHandler.Write(ms, 0, True); ms.Free; end;

    Read the article

  • Lucene neo4j sort with boolean fields

    - by Daniele
    I have indexed some documents (nodes of neo4j) with a boolean property which not always is present. Eg. Node1 label : "label A" Node2: label : "label A" (note, same label of node1) special : true The goal is to get Node2 higher than node 1 for query "label A". Here the code: Index<Node> fulltextLucene = graphDb.index().forNodes( "my-index" ); Sort sort = new Sort(new SortField[] {SortField.FIELD_SCORE, new SortField("special", SortField.????, true) }); IndexHits<Node> results = fulltextLucene.query( "label", new QueryContext( "label A").sort(sort)); How can I accomplish that? Thanks

    Read the article

  • How to ensure javascript in the browser is always enabled while traversing my plone site

    - by user956424
    I wish to disable loading the plone site if JS is disabled in the browser. Where exactly do I change the code? Which template/skin do I choose? I want to ensure that JS is always enabled while browsing any part of the plone site. While browsing, if JS is disabled, I can redirect to another page with tag to enable the JS in the browser and give a hlink to the site back if it is enabled. I am using Plone 4.1

    Read the article

  • Previously working emberjs1.0-pre form on jsfiddle returns "error": "Please use POST request"

    - by brg
    This code ** http://jsfiddle.net/wagenet/ACzaJ/8/ ** was working a few days ago, when i returned to it today, it throws {"error": "Please use POST request"}, when i click add button Also the jsfiddle editor.js always throws exception on this line: function stop(){cc = stop; throw StopIteration;}; Does anyone knows the cause of this issue. Many thanks Update 1 Based on @Peter Wagenet's suggestions below, the form now logs entries or inputs to the console but it doesn't display on the result section of jsfiddle instead what is displayed on jsfiddle result section or page is still this error {"error": "Please use POST request"} ** http://jsfiddle.net/ACzaJ/18/ Update 2 In this fiddle, http://jsfiddle.net/ACzaJ/19/, i have successfully eliminated this error {"error": "Please use POST request"} by adding event.preventDefault(); to the submit action in Todos.TodoFormView. That allows us to use arbitrary view methods as action handlers. The existing issue is that the input to the form, only displays on the console and not on jsfiddle result section, though no error displays on the result section, there is a new error appearing in the console of the updated fiddle: Uncaught Error: Cannot perform operations on a Metamorph that is not in the DOM. Finally solved I needed to comment out App.initialize() for it to work as expected. This the working fiddle ** http://jsfiddle.net/ACzaJ/20/. I don't know why that is so, but my guess is that, App.initialize works with other parts like the router for routing, ApplicationController and ApplicationView with {{outlet}} in the handlebars, which i didn't need for this fiddle. Finally Finally and completely solved This ** http://jsfiddle.net/tQWn8/ works with App.initialize. But you have to declare all those components above and pass the router to App.initialize, like this App..initialize(router). If you don't do this, then you will get the old error Uncaught Error: Cannot perform operations on a Metamorph that is not in the DOM.

    Read the article

  • Why does php show error for my SQL query

    - by ZincX
    UPDATE: My mistake - I made a typo. Nevermind this question. I'm using php to update a mysql database. The resultant query I'm using when i print it out on my webpage before executing is as follows: INSERT INTO perch2_content_items (itemOrder, regionID, pageID, itemRev, itemID, itemJSON, itemSearch ) SELECT MAX(itemOrder)+1, 105, 81, 11, 118, 'json', 'search' FROM perch2_content_items WHERE regionID=105 When I copy and paste this query directly into the phpmyadmin SQL interface, it works fine. The table gets updated. However, when I try to execute it using my php code as follows, it throws an error. $insertToPerch = "INSERT INTO perch2_content_items (itemOrder, regionID, pageID, itemRev, itemID, itemJSON, itemSearch ) SELECT MAX(itemOrder)+1, $regionID, $pageID, $regionRev, $newItemID, 'json', 'search' FROM perch2_content_items WHERE regionID=$regionID"; mysql_query(insertToPerch) or die(mysql_error()); The error I'm getting is: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insertToPerch' at line 1 Can anybody help me figure out why it is failing.

    Read the article

  • What is causing my HTTP server to fail with "exit status -1073741819"?

    - by Keeblebrox
    As an exercise I created a small HTTP server that generates random game mechanics, similar to this one. I wrote it on a Windows 7 (32-bit) system and it works flawlessly. However, when I run it on my home machine, Windows 7 (64-bit), it always fails with the same message: exit status -1073741819. I haven't managed to find anything on the web which references that status code, so I don't know how important it is. Here's code for the server, with redundancy abridged: package main import ( "fmt" "math/rand" "time" "net/http" "html/template" ) // Info about a game mechanic type MechanicInfo struct { Name, Desc string } // Print a mechanic as a string func (m MechanicInfo) String() string { return fmt.Sprintf("%s: %s", m.Name, m.Desc) } // A possible game mechanic var ( UnkillableObjects = &MechanicInfo{"Avoiding Unkillable Objects", "There are objects that the player cannot touch. These are different from normal enemies because they cannot be destroyed or moved."} //... Race = &MechanicInfo{"Race", "The player must reach a place before the opponent does. Like \"Timed\" except the enemy as a \"timer\" can be slowed down by the player's actions, or there may be multiple enemies being raced against."} ) // Slice containing all game mechanics var GameMechanics []*MechanicInfo // Pseudorandom number generator var prng *rand.Rand // Get a random mechanic func RandMechanic() *MechanicInfo { i := prng.Intn(len(GameMechanics)) return GameMechanics[i] } // Initialize the package func init() { prng = rand.New(rand.NewSource(time.Now().Unix())) GameMechanics = make([]*MechanicInfo, 34) GameMechanics[0] = UnkillableObjects //... GameMechanics[33] = Race } // serving var index = template.Must(template.ParseFiles( "templates/_base.html", "templates/index.html", )) func randMechHandler(w http.ResponseWriter, req *http.Request) { mechanics := [3]*MechanicInfo{RandMechanic(), RandMechanic(), RandMechanic()} if err := index.Execute(w, mechanics); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } } func main() { http.HandleFunc("/", randMechHandler) if err := http.ListenAndServe(":80", nil); err != nil { panic(err) } } In addition, the unabridged code, the _base.html template, and the index.html template. What could be causing this issue? Is there a process for debugging a cryptic exit status like this?

    Read the article

  • Persisting cookie for iPhone UIwebview mobile web app

    - by Brad Thomas
    I'm using MVC4 forms auth. My mobile web app runs in full screen UIwebview on iphone. I have a home screen icon for my mobile web app. The app needs to launch external links. Those launch in Safari, which works fine. However returning to the mobile web app by clicking again on the home screen icon, seems to have logged the user out. Ideally I want the user to remain logged into the web app after viewing the external links in Safari. Maybe the cookie got deleted? Can I persist the cookie?

    Read the article

  • Meteor 0.3.9 on Windows XP exits with code: -1073741819

    - by slawpe13
    I have installed recently Meteor 0.3.9 on Windows XP (msi installer from: http://win.meteor.com/) and when I try to run (under CMD): meteor create --example leaderboard cd leaderboard meteor I get: [[[[[ C:\temp\leaderboard ]]]]] Running on: http://localhost:3000/ Exited with code: -1073741819 Exited with code: -1073741819 Exited with code: -1073741819 Your application is crashing. Waiting for file change. How can I fix that error?

    Read the article

  • Debugging segfault on swig/python/c++

    - by Pradyot
    I am trying to figure out what the best way to debug a segault with swig/python/c++. A core file is being generated. I have a basic MessageFactory(defined in c++ that provides a simple interface to accept a few strings as input and return a string as output). This interface is then specified in a .i file. swig is used to generate Wrapper.cpp as well as a MessageFactory.py from the .i file. This along with supporting files is compiled into a dynamic lib. The point of failure , is when the MessageFactory is instantiated within python code. Any suggestions on how I can go about debugging this? I've tried running the script within pdb, what I know from that is import on the generated MessageFactory.py is whats causing the seg-fault.

    Read the article

  • 2D distortion of a face from an image on iOS? (similar to Fat Booth etc.)

    - by Dominik Hadl
    I was just wondering if someone knows about some good library or tutorial on how to achieve a 2D distortion of a face taken from an image taken by the user. I would like to achieve a similar effect to the one in Fatify, Oldify, all those Fat Booths, etc., because I am creating an app where you will throw something at the face and I would the face to jiggle and move when the object hits it. How should I do this?

    Read the article

  • Announcing Windows Azure Mobile Services

    - by ScottGu
    I’m excited to announce a new capability we are adding to Windows Azure today: Windows Azure Mobile Services Windows Azure Mobile Services makes it incredibly easy to connect a scalable cloud backend to your client and mobile applications.  It allows you to easily store structured data in the cloud that can span both devices and users, integrate it with user authentication, as well as send out updates to clients via push notifications. Today’s release enables you to add these capabilities to any Windows 8 app in literally minutes, and provides a super productive way for you to quickly build out your app ideas.  We’ll also be adding support to enable these same scenarios for Windows Phone, iOS, and Android devices soon. Read this getting started tutorial to walkthrough how you can build (in less than 5 minutes) a simple Windows 8 “Todo List” app that is cloud enabled using Windows Azure Mobile Services.  Or watch this video of me showing how to do it step by step. Getting Started If you don’t already have a Windows Azure account, you can sign up for a no-obligation Free Trial.  Once you are signed-up, click the “preview features” section under the “account” tab of the www.windowsazure.com website and enable your account to support the “Mobile Services” preview.   Instructions on how to enable this can be found here. Once you have the mobile services preview enabled, log into the Windows Azure Portal, click the “New” button and choose the new “Mobile Services” icon to create your first mobile backend.  Once created, you’ll see a quick-start page like below with instructions on how to connect your mobile service to an existing Windows 8 client app you have already started working on, or how to create and connect a brand-new Windows 8 client app with it: Read this getting started tutorial to walkthrough how you can build (in less than 5 minutes) a simple Windows 8 “Todo List” app  that stores data in Windows Azure. Storing Data in the Cloud Storing data in the cloud with Windows Azure Mobile Services is incredibly easy.  When you create a Windows Azure Mobile Service, we automatically associate it with a SQL Database inside Windows Azure.  The Windows Azure Mobile Service backend then provides built-in support for enabling remote apps to securely store and retrieve data from it (using secure REST end-points utilizing a JSON-based ODATA format) – without you having to write or deploy any custom server code.  Built-in management support is provided within the Windows Azure portal for creating new tables, browsing data, setting indexes, and controlling access permissions. This makes it incredibly easy to connect client applications to the cloud, and enables client developers who don’t have a server-code background to be productive from the very beginning.  They can instead focus on building the client app experience, and leverage Windows Azure Mobile Services to provide the cloud backend services they require.  Below is an example of client-side Windows 8 C#/XAML code that could be used to query data from a Windows Azure Mobile Service.  Client-side C# developers can write queries like this using LINQ and strongly typed POCO objects, which are then translated into HTTP REST queries that run against a Windows Azure Mobile Service.   Developers don’t have to write or deploy any custom server-side code in order to enable client-side code below to execute and asynchronously populate their client UI: Because Mobile Services is part of Windows Azure, developers can later choose to augment or extend their initial solution and add custom server functionality and more advanced logic if they want.  This provides maximum flexibility, and enables developers to grow and extend their solutions to meet any needs. User Authentication and Push Notifications Windows Azure Mobile Services also make it incredibly easy to integrate user authentication/authorization and push notifications within your applications.  You can use these capabilities to enable authentication and fine grain access control permissions to the data you store in the cloud, as well as to trigger push notifications to users/devices when the data changes.  Windows Azure Mobile Services supports the concept of “server scripts” (small chunks of server-side script that executes in response to actions) that make it really easy to enable these scenarios. Below are some tutorials that walkthrough common authentication/authorization/push scenarios you can do with Windows Azure Mobile Services and Windows 8 apps: Enabling User Authentication Authorizing Users  Get Started with Push Notifications Push Notifications to multiple Users Manage and Monitor your Mobile Service Just like with every other service in Windows Azure, you can monitor usage and metrics of your mobile service backend using the “Dashboard” tab within the Windows Azure Portal. The dashboard tab provides a built-in monitoring view of the API calls, Bandwidth, and server CPU cycles of your Windows Azure Mobile Service.   You can also use the “Logs” tab within the portal to review error messages.  This makes it easy to monitor and track how your application is doing. Scale Up as Your Business Grows Windows Azure Mobile Services now allows every Windows Azure customer to create and run up to 10 Mobile Services in a free, shared/multi-tenant hosting environment (where your mobile backend will be one of multiple apps running on a shared set of server resources).  This provides an easy way to get started on projects at no cost beyond the database you connect your Windows Azure Mobile Service to (note: each Windows Azure free trial account also includes a 1GB SQL Database that you can use with any number of apps or Windows Azure Mobile Services). If your client application becomes popular, you can click the “Scale” tab of your Mobile Service and switch from “Shared” to “Reserved” mode.  Doing so allows you to isolate your apps so that you are the only customer within a virtual machine.  This allows you to elastically scale the amount of resources your apps use – allowing you to scale-up (or scale-down) your capacity as your traffic grows: With Windows Azure you pay for compute capacity on a per-hour basis – which allows you to scale up and down your resources to match only what you need.  This enables a super flexible model that is ideal for new mobile app scenarios, as well as startups who are just getting going.  Summary I’ve only scratched the surface of what you can do with Windows Azure Mobile Services – there are a lot more features to explore.  With Windows Azure Mobile Services you’ll be able to build mobile app experiences faster than ever, and enable even better user experiences – by connecting your client apps to the cloud. Visit the Windows Azure Mobile Services development center to learn more, and build your first Windows 8 app connected with Windows Azure today.  And read this getting started tutorial to walkthrough how you can build (in less than 5 minutes) a simple Windows 8 “Todo List” app that is cloud enabled using Windows Azure Mobile Services. Hope this helps, Scott P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu

    Read the article

  • Adding an Admin user to an ASP.NET MVC 4 application using a single drop-in file

    - by Jon Galloway
    I'm working on an ASP.NET MVC 4 tutorial and wanted to set it up so just dropping a file in App_Start would create a user named "Owner" and assign them to the "Administrator" role (more explanation at the end if you're interested). There are reasons why this wouldn't fit into most application scenarios: It's not efficient, as it checks for (and creates, if necessary) the user every time the app starts up The username, password, and role name are hardcoded in the app (although they could be pulled from config) Automatically creating an administrative account in code (without user interaction) could lead to obvious security issues if the user isn't informed However, with some modifications it might be more broadly useful - e.g. creating a test user with limited privileges, ensuring a required account isn't accidentally deleted, or - as in my case - setting up an account for demonstration or tutorial purposes. Challenge #1: Running on startup without requiring the user to install or configure anything I wanted to see if this could be done just by having the user drop a file into the App_Start folder and go. No copying code into Global.asax.cs, no installing addition NuGet packages, etc. That may not be the best approach - perhaps a NuGet package with a dependency on WebActivator would be better - but I wanted to see if this was possible and see if it offered the best experience. Fortunately ASP.NET 4 and later provide a PreApplicationStartMethod attribute which allows you to register a method which will run when the application starts up. You drop this attribute in your application and give it two parameters: a method name and the type that contains it. I created a static class named PreApplicationTasks with a static method named, then dropped this attribute in it: [assembly: PreApplicationStartMethod(typeof(PreApplicationTasks), "Initializer")] That's it. One small gotcha: the namespace can be a problem with assembly attributes. I decided my class didn't need a namespace. Challenge #2: Only one PreApplicationStartMethod per assembly In .NET 4, the PreApplicationStartMethod is marked as AllMultiple=false, so you can only have one PreApplicationStartMethod per assembly. This was fixed in .NET 4.5, as noted by Jon Skeet, so you can have as many PreApplicationStartMethods as you want (allowing you to keep your users waiting for the application to start indefinitely!). The WebActivator NuGet package solves the multiple instance problem if you're in .NET 4 - it registers as a PreApplicationStartMethod, then calls any methods you've indicated using [assembly: WebActivator.PreApplicationStartMethod(type, method)]. David Ebbo blogged about that here:  Light up your NuGets with startup code and WebActivator. In my scenario (bootstrapping a beginner level tutorial) I decided not to worry about this and stick with PreApplicationStartMethod. Challenge #3: PreApplicationStartMethod kicks in before configuration has been read This is by design, as Phil explains. It allows you to make changes that need to happen very early in the pipeline, well before Application_Start. That's fine in some cases, but it caused me problems when trying to add users, since the Membership Provider configuration hadn't yet been read - I got an exception stating that "Default Membership Provider could not be found." The solution here is to run code that requires configuration in a PostApplicationStart method. But how to do that? Challenge #4: Getting PostApplicationStartMethod without requiring WebActivator The WebActivator NuGet package, among other things, provides a PostApplicationStartMethod attribute. That's generally how I'd recommend running code that needs to happen after Application_Start: [assembly: WebActivator.PostApplicationStartMethod(typeof(TestLibrary.MyStartupCode), "CallMeAfterAppStart")] This works well, but I wanted to see if this would be possible without WebActivator. Hmm. Well, wait a minute - WebActivator works in .NET 4, so clearly it's registering and calling PostApplicationStartup tasks somehow. Off to the source code! Sure enough, there's even a handy comment in ActivationManager.cs which shows where PostApplicationStartup tasks are being registered: public static void Run() { if (!_hasInited) { RunPreStartMethods(); // Register our module to handle any Post Start methods. But outside of ASP.NET, just run them now if (HostingEnvironment.IsHosted) { Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(StartMethodCallingModule)); } else { RunPostStartMethods(); } _hasInited = true; } } Excellent. Hey, that DynamicModuleUtility seems familiar... Sure enough, K. Scott Allen mentioned it on his blog last year. This is really slick - a PreApplicationStartMethod can register a new HttpModule in code. Modules are run right after application startup, so that's a perfect time to do any startup stuff that requires configuration to be read. As K. Scott says, it's this easy: using System; using System.Web; using Microsoft.Web.Infrastructure.DynamicModuleHelper; [assembly:PreApplicationStartMethod(typeof(MyAppStart), "Start")] public class CoolModule : IHttpModule { // implementation not important // imagine something cool here } public static class MyAppStart { public static void Start() { DynamicModuleUtility.RegisterModule(typeof(CoolModule)); } } Challenge #5: Cooperating with SimpleMembership The ASP.NET MVC Internet template includes SimpleMembership. SimpleMembership is a big improvement over traditional ASP.NET Membership. For one thing, rather than forcing a database schema, it can work with your database schema. In the MVC 4 Internet template case, it uses Entity Framework Code First to define the user model. SimpleMembership bootstrap includes a call to InitializeDatabaseConnection, and I want to play nice with that. There's a new [InitializeSimpleMembership] attribute on the AccountController, which calls \Filters\InitializeSimpleMembershipAttribute.cs::OnActionExecuting(). That comment in that method that says "Ensure ASP.NET Simple Membership is initialized only once per app start" which sounds like good advice. I figured the best thing would be to call that directly: new Mvc4SampleApplication.Filters.InitializeSimpleMembershipAttribute().OnActionExecuting(null); I'm not 100% happy with this - in fact, it's my least favorite part of this solution. There are two problems - first, directly calling a method on a filter, while legal, seems odd. Worse, though, the Filter lives in the application's namespace, which means that this code no longer works well as a generic drop-in. The simplest workaround would be to duplicate the relevant SimpleMembership initialization code into my startup code, but I'd rather not. I'm interested in your suggestions here. Challenge #6: Module Init methods are called more than once When debugging, I noticed (and remembered) that the Init method may be called more than once per page request - it's run once per instance in the app pool, and an individual page request can cause multiple resource requests to the server. While SimpleMembership does have internal checks to prevent duplicate user or role entries, I'd rather not cause or handle those exceptions. So here's the standard single-use lock in the Module's init method: void IHttpModule.Init(HttpApplication context) { lock (lockObject) { if (!initialized) { //Do stuff } initialized = true; } } Putting it all together With all of that out of the way, here's the code I came up with: using Mvc4SampleApplication.Filters; using System.Web; using System.Web.Security; using WebMatrix.WebData; [assembly: PreApplicationStartMethod(typeof(PreApplicationTasks), "Initializer")] public static class PreApplicationTasks { public static void Initializer() { Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility .RegisterModule(typeof(UserInitializationModule)); } } public class UserInitializationModule : IHttpModule { private static bool initialized; private static object lockObject = new object(); private const string _username = "Owner"; private const string _password = "p@ssword123"; private const string _role = "Administrator"; void IHttpModule.Init(HttpApplication context) { lock (lockObject) { if (!initialized) { new InitializeSimpleMembershipAttribute().OnActionExecuting(null); if (!WebSecurity.UserExists(_username)) WebSecurity.CreateUserAndAccount(_username, _password); if (!Roles.RoleExists(_role)) Roles.CreateRole(_role); if (!Roles.IsUserInRole(_username, _role)) Roles.AddUserToRole(_username, _role); } initialized = true; } } void IHttpModule.Dispose() { } } The Verdict: Is this a good thing? Maybe. I think you'll agree that the journey was undoubtedly worthwhile, as it took us through some of the finer points of hooking into application startup, integrating with membership, and understanding why the WebActivator NuGet package is so useful Will I use this in the tutorial? I'm leaning towards no - I think a NuGet package with a dependency on WebActivator might work better: It's a little more clear what's going on Installing a NuGet package might be a little less error prone than copying a file A novice user could uninstall the package when complete It's a good introduction to NuGet, which is a good thing for beginners to see This code either requires either duplicating a little code from that filter or modifying the file to use the namespace Honestly I'm undecided at this point, but I'm glad that I can weigh the options. If you're interested: Why are you doing this? I'm updating the MVC Music Store tutorial to ASP.NET MVC 4, taking advantage of a lot of new ASP.NET MVC 4 features and trying to simplify areas that are giving people trouble. One change that addresses both needs us using the new OAuth support for membership as much as possible - it's a great new feature from an application perspective, and we get a fair amount of beginners struggling with setting up membership on a variety of database and development setups, which is a distraction from the focus of the tutorial - learning ASP.NET MVC. Side note: Thanks to some great help from Rick Anderson, we had a draft of the tutorial that was looking pretty good earlier this summer, but there were enough changes in ASP.NET MVC 4 all the way up to RTM that there's still some work to be done. It's high priority and should be out very soon. The one issue I ran into with OAuth is that we still need an Administrative user who can edit the store's inventory. I thought about a number of solutions for that - making the first user to register the admin, or the first user to use the username "Administrator" is assigned to the Administrator role - but they both ended up requiring extra code; also, I worried that people would use that code without understanding it or thinking about whether it was a good fit.

    Read the article

  • O'Reilly deal of the week to 23:59 PT 4/Sept/2012 - Master Regular Expressions

    - by TATWORTH
    O'Reilly at http://shop.oreilly.com/category/deals/regular-expressions-owo.do?code=WKRGEX are offering 50% off a range of e-books on mastering Regular Expressions "Take the guesswork out of using regular expressions. Learn powerful tips for matching, extracting, and transforming text as well as the gotchas to avoid. For one week only, SAVE 50% on these e-books and discover a whole new world of mastery over your code." I recommend Mastering Regular Expression to Dot Net developer as it covers the use of regular expressions across a number of environments, including Dot Net.

    Read the article

  • When should I use SATA 6gb/s?

    - by Gili
    I purchased a Baraccuda hard-drive (model ST3000DM001) that supports a maximum read transfer rate of 210 MB/s and SATA 1.5/3/6 Gb/s. My motherboard has a limited number of 6 Gb/s ports so I'd like to reserve them for when it's really necessary. When does a hard-drive benefit from a SATA 6 Gb/s port? Doesn't it require a transfer speed of at least 375 MB/s to surpass the limit of SATA 3 Gb/s? Are there any other benefits of SATA 6 Gb/s vs 3 Gb/s ports?

    Read the article

  • allow infiniband for non root users

    - by user1219721
    I got Infiniband running on RHEL 6.3 [root@master ~]# ibv_devinfo hca_id: mthca0 transport: InfiniBand (0) fw_ver: 4.7.927 node_guid: 0017:08ff:ffd0:6f1c sys_image_guid: 0017:08ff:ffd0:6f1f vendor_id: 0x08f1 vendor_part_id: 25208 hw_ver: 0xA0 board_id: VLT0060010001 phys_port_cnt: 2 port: 1 state: PORT_ACTIVE (4) max_mtu: 2048 (4) active_mtu: 2048 (4) sm_lid: 2 port_lid: 3 port_lmc: 0x00 link_layer: InfiniBand port: 2 state: PORT_DOWN (1) max_mtu: 2048 (4) active_mtu: 512 (2) sm_lid: 0 port_lid: 0 port_lmc: 0x00 link_layer: InfiniBand but it's only working as root. when trying from a non-super user, I got nothing : [nicolas@master ~]$ ibv_devices device node GUID ------ ---------------- mthca0 001708ffffd06f1c So, how to allow regular users to use infiniband ?

    Read the article

  • DNS not being "replicating" everywhere

    - by cromestant
    We have a DNS server, and created a new CNAME: lets say login.server.domain now, if I do NSLOOkup from within our network I get back the config (this is a public address) but if I test from outside I get a not found error.. ** server can't find login.server.domain NXDOMAIN What could be happening? why is this only replicating within our network? FYI config has over 48 hours so not a time issue. thanks in advance

    Read the article

  • Why would a PCI scan fail because of components that are not even installed?

    - by Brandon
    Recently a PCI scan was run against a web server and the result was a failure. Some of the issues could be fixed, however others simply make no sense to me. The machine was a clean install, there are only two things running, the .NET 3.5 website and the dotDefender web application firewall. However there are several errors similar to: Web server vulnerability Impact: /servlet/SessionServlet: JRun or Netware WebSphere default servlet found. All default code should be removed from servers. Risk Factor: Medium/ CVSS2 Base Score: 6.4 CVE: CVE-2000-0539 I'm not sure what this is, but I can't find anything on the server that looks anything like this. Web server vulnerability Impact: /some.php?=PHPE9568F35- D428-11d2-A769-00AA001ACF42: PHP reveals potentially sensitive information via certain HTTP requests that contain specific QUERY strings. Risk Factor: Medium/ CVSS2 Base Score: 5.0 PHP is not installed. Trying to add that query string to any page does nothing because the application ignores it. And doing that phpVersion check results in a 404. Similar to this, there are dozens of errors related to JSP and Oracle that are also not installed. Web server vulnerability Impact: /admin/database/wwForum.mdb: Web Wiz Forums pre 7.5 is vulnerable to Cross-Site Scripting attacks. Default login/pass is Administrator/letmein Risk Factor: Medium/ CVSS2 Base Score: 4.0 There are several errors like this, telling me that Web Wiz Forums, Alan Ward A-Cart 2.0, IlohaMail, etc. are all vulnerable. These are not installed or referenced anywhere I can find. There are even references to pages that simply don't exist, like OpenAutoClassifieds. Can anyone point me in the right direction as to why these errors are showing up or where I might look to find these components if they are in fact installed? Note: This website and server are for a subdomain of the main website. The main website runs on a server that is running Apache/PHP, but I don't have access to that server. The report says the subdomain was the site being scanned, but is it possible for it to have scanned the main site as well?

    Read the article

  • How can I easily test connectivity to external sources with WinHTTP?

    - by Mike B
    I've got an server application that uses Winhttp to fetch information from an external source. Occasionally, I'll need to troubleshoot connectivity issues and I'd like an easy way to test connections through winHTTP (on the off-chance that there's something that is specifically impeding winHTTP and not other unrelated connectivity commands like telnet). Does IE use WinHTTP? If not, are there any tools (preferably already integrated into Windows) that I can use? Occasionally I'll use IE but I'm not sure if that's quite the same.

    Read the article

  • Debian on Hyper-V

    - by Tobia
    I installed Debian with kernel 2.6.32-5-686 on a Hyper-V virtual machine. I had to add a legacy network card. I follow this tutorial http://www.microsofttranslator.com/bv.aspx?ref=Internal&from=ru&to=en&a=http://blogs.technet.com/b/abeshkov/archive/2011/03/17/hyperv_5f00_debian.aspx to add Hyper-V driver but when I reboot with the new kernel it crash during bootup. Is there any other way to load hyper-v drivers? I really need to change that legacy network card because my debian machine is going to be used as proxy. Thank you.

    Read the article

  • how to actually install PHP etc on a windows 2003 server

    - by user1624421
    We're just purchasing a dedicated windows 2003 server (in fact I think it's a VPS) How do we actually go about installing software on to it? Simply searching for "installing PHP5 on windows server" just produces material about installing it as if one had access to the computer with a keyboard and mouse. Am I being thick? I've had experience managing a linux server before but that had everything pre-configured and we accessed it via Web Hosting Manager. I don't get the actual concept of connecting to a remote PC and...downloading files? If there's any good books available please point me in the right direction.

    Read the article

  • Why do SNMP agents need MIB files?

    - by user1495181
    After reading up on SNMP and some of the questions help here I think understand the agent role as a SNMP service to device (Like SQL, it is an API to storage). When you execute a SQL query the SQL engine does all the work and returns the result - You don't need to be aware of how the storage and where the storage is done. But MIBs are not actual storage , so what is the role of my agent? if the agent only register the MIB like i follow in this tutorial, is it not used as handler at all? Say that I want monitor my application's pending request queue, so I want an agent that all SNMP request for application_pending_request will be fired for it and it will return the queue depth. Why do I need to have an actual MIB when all I need to poll my application queue in order to get result?

    Read the article

  • setting up a WGR614v7 behind a linux box

    - by commodore fancypants
    Here's the setup, I have an openSUSE box with 2 NICs, one goes to my home network router, the other has DHCP running and it attached to a wireless router. I'm trying to get this setup to work before I switch to the linux box as my home network router. My DHCP will offer the wireless router (a WGR614v7) an address, but anything that connects to the wireless router ends up with a APIPA address. I have all the firewalls on the wireless network turned off as well as the wireless router's own DHCP. The linux box isn't offering addresses to anything past the wireless router. Is this a problem with the router or my DHCP setup? For testing purposes, I have both NICs set in the internal zone and I've tried wireless and wired connections to the WGR614v7 both to no avail.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >