Search Results

Search found 1573 results on 63 pages for 'adam lane'.

Page 39/63 | < Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >

  • Rails - Seeking a Dry authorization method compatible with various nested resources

    - by adam
    Consensus is you shouldn't nest resources deeper than 1 level. So if I have 3 models like this (below is just a hypothetical situation) User has_many Houses has_many Tenants and to abide by the above i do map.resources :users, :has_many => :houses map.resorces :houses, :has_many => :tenants Now I want the user to be able edit both their houses and their tenants details but I want to prevent them from trying to edit another users houses and tenants by forging the user_id part of the urls. So I create a before_filter like this def prevent_user_acting_as_other_user if User.find_by_id(params[:user_id]) != current_user() @current_user_session.destroy flash[:error] = "Stop screwing around wiseguy" redirect_to login_url() return end end for houses that's easy because the user_id is passed via edit_user_house_path(@user, @house) but in the tenents case tenant house_tenent_path(@house) no user id is passed. But I can get the user id by doing @house.user.id but then id have to change the code above to this. def prevent_user_acting_as_other_user if params[:user_id] @user = User.find(params[:user_id] elsif params[:house_id] @user = House.find(params[:house_id]).user end if @user != current_user() #kick em out end end It does the job, but I'm wondering if there is a more elegant way. Every time I add a new resource that needs protecting from user forgery Ill have to keep adding conditionals. I don't think there will be many cases but would like to know a better approach if one exists.

    Read the article

  • How to create a Web slice with Search?

    - by Adam
    Does anyone know how bing's weather webslice search works? I am attempting to create a web slice(only available in IE8) with search built in and I have read that forms are not allowed and neither is javascript. Any help would be appreciated.

    Read the article

  • XNA Music mixing real-time

    - by Adam L. S.
    I've created a "format" to store segments of music (prelude part, repeated part, ending part) and time information for these segments (offset, scored length) so I can mix it up in real-time as if it were one piece of music, while repeating the repeated part (optionally) indefinitely. This way, the segments can store decay where the next segment is played, while the previous one is finished. (I've created a player for this in Java, and used the Clip class.) I wanted this format, so I can provide a finite length music (for a jukebox feature), while I play infinite length music in-games. However, when I wanted to code a class in XNA that manages this "format" I've noticed, that there is no obvious way to play "Songs" simultaneously/overlapped. How can I do this/what is the best practice, not leaving the XNA framework? (I don't want to create infinite play-lists.)

    Read the article

  • XAttribute Generating strange namespaces

    - by Adam Driscoll
    I'm constructing an XElement with a couple attributes that have different namespaces. The code looks like this: var element = new XElement("SynchronousCommand", new XAttribute("{wcm}action", "add"), new XAttribute("{ns}id", Guid.NewGuid()), new XElement... ); The XML that is generated looks like this: <unattend xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:schemas-microsoft-com:unattend"> <SynchronousCommand d5p1:action="add" d5p2:id="c0f5fc6d-d407-4d3d-8a05-d84236cca2fb" xmlns:d5p2="ns" xmlns:d5p1="wcm"> ... </SynchronousCommand> </unattend> I'm just wondering if the auto-generated d5p2 is valid and why it is doing this. According to the XML standards here it seems like it would be valid. But why is it not: <unattend xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:schemas-microsoft-com:unattend"> <SynchronousCommand wcm:action="add" ns:id="c0f5fc6d-d407-4d3d-8a05-d84236cca2fb" > To generate the XML I'm doing this: public class unattend { public List<XElement> Any {get;} } var unattend = new unattend(); unattend.Add(element); serializer.Serialize(xmlWriter, unattend);

    Read the article

  • SQL Server getdate() to a string like "2009-12-20"

    - by Adam Kane
    In Microsoft SQL Server 2005 and .NET 2.0, I want to convert the current date to a string of this format: "YYYY-MM-DD". For example, December 12th 2009 would become "2009-12-20". How do I do this in SQL. The context of this SQL statement in the table definiton. In other words, this is the default value. So when a new record is created the default value of the current date is stored as a string in the above format. I'm trying: SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD] But SQL server keeps converting that to: ('SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD]') so the result is just: 'SELECT CONVERT(VARCHAR(10), GETDATE(), 102) AS [YYYY.MM.DD]' Here's a screen shot of what the Visual Studio server explorer, table, table definition, properties shows: These wrapper bits are being adding automatically and converting it all to literal string: (N' ') Here's the reason I'm trying to use something other than the basic DATETIME I was using previously: This is the error I get when hooking everything to an ASP.NET GridView and try to do an update via the grid view: Server Error in '/' Application. The version of SQL Server in use does not support datatype 'date'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: The version of SQL Server in use does not support datatype 'date'. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [ArgumentException: The version of SQL Server in use does not support datatype 'date'.] Note: I've added a related question to try to get around the SQL Server in use does not support datatype 'date' error so that I can use a DATETIME as recommended.

    Read the article

  • Implementing Google Search Appliance results into website

    - by Adam Jenkin
    I’m interested to hear peoples preferred methods or approaches to implementing the search results from a Google Search Appliance into an existing website. More specifically how do people prefer to implement/embed the search results into their existing site and persist the surrounding website elements (menus, membership etc) around the search results. As far as I am aware there are 3 different approaches. Sub-domain, handle everything in the xslt – create a search.mysite.com which is completely handled by google xslt and embed surround site components in xslt. Embed search results into existing site using an iframe – Use the existing website and just use an iframe to import results into page. Embed results into existing site by using server side processing – This is how I have previously integrated search into a site using a combination of bespoke dev and the GSALib project. I would be interested to hear if anyone has other suggestions, and were people have benefited or regretted using the above approaches.

    Read the article

  • Python Daemon Subprocess not working at boot

    - by Adam Richardson
    I am attempting to write a python daemon that will launch at boot. The goal of the script is to receive a job from our gearman load balancing server and complete the job. I am using the python-daemon module from pypi (http://pypi.python.org/pypi/python-daemon/). The nature of the job that it is completing is converting images in the orf (olympus raw image format) to jpeg. In order to accomplish this an outside program is used, ufraw in this case. The problem comes in when I start the daemon at boot, if I launch from the shell it runs perfectly and completes the work. When it starts at boot it is unable to launch the subprocess command. commandString = '/usr/bin/ufraw-batch --interpolation=four-color --wb=camera --compression=100 --output="' + outfile + '" --out-type=jpg --overwrite "' + infile + '"' args = shlex.split(commandString) process = subprocess.Popen(args).wait() I am not sure what I am doing wrong. Thanks for any help.

    Read the article

  • make reference to an empty query in flex

    - by Adam
    a bit of a dumb questions I'm sure I'm trying to allow user to set an item to be default. I've got a function that run a query to first find the current default item. Then runs a second query that unsets the current default item. Then a third query runs to set the new user selected item to be the default. This seem to work fine when a default item has been perviously selected, but when I try to set the default item initially I get the good old "Cannot access a property or method of a null object reference." error. This is because the first query that runs returns no items I'm sure. So I need to write an if statement that if the first query returns nothing to skip the second and go right to the third. The only problem is I can't make a reference to a null object. So how do I go about writing this statement. Thanks

    Read the article

  • Programmatically access currency exchange rates

    - by Adam Pierce
    I'm setting up an online ordering system but I'm in Australia and for international customers I'd like to show prices in US dollars or Euros so they don't have to make the mental effort to convert from Australian dollars. Does anyone know if I can pull up to date exchange rates off the net somewhere in an easy-to-parse format I can access from my PHP script ? UPDATE: I have now written a PHP class which implements this. You can get the code from my website.

    Read the article

  • PIC C - Sending 200 values over USB, but it only sends 25 of them...

    - by Adam
    I have a PIC18F4455 microcontroller which I am trying to use to send 200 values over USB. Basically I am using a for loop and a printf statement to print the values to the usb output stream. However, when the code executes I see in my serial port monitor that it is only sending the first 25 values, then stopping. My PIC C code is below. It will send out the 25th value (and the comma), but not send anything after and not send a newline character. I'm trying to get it to send all the values, then a newline character at the end. I am sending them all as characters because I can convert them on the PC end of it. //print #3 for (i = 0; i <= 199; i++){if (data[i]=='\0' || data[i]=='\n'){data[i]++;}} for (i = 0; i < 199; i++){printf(usb_cdc_putc, "%c,", data[i]);} printf(usb_cdc_putc, "%c\n", data[199]);

    Read the article

  • How to list Activities which match an intent?

    - by Adam
    I have a few separate applications which are all launched purely through a main application. I am wondering if I'd be able to use intents to retrieve a list of all the sub-applications which match some discovery intent. The main application currently needs to know what Intents to use to START these sub-applications, but is there a way to use intents to see if other Activities on the device match a set of intent-filters?

    Read the article

  • Are fluid websites worth making anymore?

    - by Adam
    Hey guys, I'm making a website now and I am trying to decide if I should make it fluid or not. Fixed width websites are much easier to make and also much easier to make them appear consistent. To be honest though, I personally prefer looking at fluid websites that stretch to the full width of my monitor. My question comes from the fact that in most modern browsers you can hold control and scroll your mouse wheel to basically resize any website. So is creating a fluid website worth the trouble?

    Read the article

  • Filtering on a left join in SQLalchemy

    - by Adam Ernst
    Using SQLalchemy I want to perform a left outer join and filter out rows that DO have a match in the joined table. I'm sending push notifications, so I have a Notification table. This means I also have a ExpiredDeviceId table to store device_ids that are no longer valid. (I don't want to just delete the affected notifications as the user might later re-install the app, at which point the notifications should resume according to Apple's docs.) CREATE TABLE Notification (device_id TEXT, time DATETIME); CREATE TABLE ExpiredDeviceId (device_id TEXT PRIMARY KEY, expiration_time DATETIME); Note: there may be multiple Notifications per device_id. There is no "Device" table for each device. So when doing SELECT FROM Notification I should filter accordingly. I can do it in SQL: SELECT * FROM Notification LEFT OUTER JOIN ExpiredDeviceId ON Notification.device_id = ExpiredDeviceId.device_id WHERE expiration_time == NULL But how can I do it in SQLalchemy? sess.query( Notification, ExpiredDeviceId ).outerjoin( (ExpiredDeviceId, Notification.device_id == ExpiredDeviceId.device_id) ).filter( ??? ) Alternately I could do this with a device_id NOT IN (SELECT device_id FROM ExpiredDeviceId) clause, but that seems way less efficient.

    Read the article

  • Simple multi-threading - combining statements to two lines.

    - by Adam
    If I have: ThreadStart starter = delegate { MessageBox.Show("Test"); }; new Thread(starter).Start(); How can I combine this into one line of code? I've tried: new Thread(delegate { MessageBox.Show("Test"); }).Start(); But I get this error: The call is ambiguous between the following methods or properties: 'System.Threading.Thread.Thread(System.Threading.ThreadStart)' and 'System.Threading.Thread.Thread(System.Threading.ParameterizedThreadStart)'

    Read the article

  • Illegal token on right side of ::

    - by Adam Haile
    I have the following template declaration: template <typename T> void IterTable(int& rIdx, std::vector<double>& rVarVector, const std::vector<T>& aTable, const T aValue, T aLowerBound = -(std::numeric_limits<T>::max()), //illegal token on right side of '::' shows here bool aLeftOpen = true) const; Which throws the illegal token error as noted, on the line with "-(std::numeric_limits::max())". I got this code from some old linux source that I'm trying to compile on Windows. Any idea what the issue is?

    Read the article

  • jquery masonry on ul with nested ul

    - by Adam Wright
    I'm trying to create a footer nav of a sitemap with levels nested within each other. i want to use masonry so the padding and margin is consistant and not changed depending on nested items. its firing masonry but its adding the relative style to the nested ul if i change the masonry call to select just the first() ul then nested li appear on one line. any ideas? <div id="links"> <ul ><li class="box"><a href="/Industries.aspx" >Industries</a></li><li class="box"><a href="/Services.aspx" >Services</a></li><li class="box"><a href="/Quality---Regulatory.aspx" >Quality &amp; Regulatory</a></li><li class="box"><a href="/About.aspx" >About</a><ul ><li class="box"><a href="/About/Our-Story.aspx" >Our Story</a></li><li class="box"><a href="/About/Our-Mission.aspx" >Our Mission</a></li><li class="box"><a href="/About/Our-Core-Values.aspx" >Our Core Values</a></li></ul></li><li class="box"><a href="/News.aspx" >News</a><ul ><li class="box"><a href="/News/Events.aspx" >Events</a></li></ul></li><li class="box"><a href="/Careers.aspx" >Careers</a></li><li class="box"><a href="/Contact.aspx" >Contact</a></li><li class="box"><a href="/tests.aspx" >tests</a></li></ul> </div> <script type="text/javascript"> $('#links ul').masonry({ singleMode: true, // Disables measuring the width of each floated element. // Set to true if floated elements have the same width. // default: false columnWidth: 182, // Width in pixels of 1 column of your grid. // default: outer width of the first floated element. itemSelector: '.box:visible', // Additional selector to specify which elements inside // the wrapping element will be rearranged. // Required for Infinite Scroll with window resizing. resizeable: true, // Binds a Masonry call to window resizes // so layout appears fluid. // default: true animate: false, // Animates layout rearrangements. // default: false saveOptions: true // Masonry will use the options from previous Masonry // calls by default, so you only have to enter in options once // default: true }); </script>

    Read the article

  • How do I use InputType=numberDecimal with the "phone" soft keypad?

    - by Adam Dunn
    For an EditText box, the user should only be entering valid numbers, so I am using android:inputType="numberDecimal". Unfortunately, the soft keyboard that Android brings up has numbers only along the top row, while the next three rows have various other symbols (dollar sign, percent sign, exclamation mark, space, etc). Since the numberDecimal only accepts numbers 0-9, negative sign, and decimal point, it would make more sense to use the "phone" soft keyboard (0-9 in a 3x3 grid, plus some other symbols). This would make the buttons larger and easier to hit (since it's a 4x4 grid rather than a 10x4 grid in the same screen area). Unfortunately, using android:inputType="phone" allows non-numeric characters such as parentheses I have attempted to use android:inputType="numberDecimal|phone", but the numberDecimal aspect of the bit flag seems to be ignored. I have also tried using android:inputType="phone" in combination with android:digits="0123456789-.", but that still allows multiple negative signs or decimal points (inputType="number" has really good error checking for things like that, and won't let the user even type it in). I have also tried using android:inputType="phone" in the xml layout file, while using a DigitsKeyListener in the java code, but then that just uses the default number soft keyboard (the one that has numbers only along top row) (it appears to set InputType.TYPE_CLASS_NUMBER, which voids the InputType.TYPE_CLASS_PHONE set by the xml layout). Writing a custom IME wouldn't work, since the user would have to select the IME as a global option outside the app. Is there any way to use the "phone" style soft keyboard while also using the "number" restrictions on what is entered?

    Read the article

  • displaying a saved buffer in OpenGL ES

    - by Adam
    Hi everyone, So basically I have a screenshot that I've saved that I want to later display on the screen. I've saved it with: glReadPixels(0, 0, self.bounds.size.width, self.bounds.size.height, GL_RGBA, GL_UNSIGNED_BYTE, savedBuffer); And later I'm trying to write it to the screen with: GLuint RenderedTex; glGenTextures(1, &RenderedTex); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, RenderedTex); glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, self.bounds.size.width, self.bounds.size.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, savedBuffer); glDisable(GL_TEXTURE_2D); I'm pretty new to OpenGL so I don't know if I'm doing things right... actually I know I'm not, because nothing shows up. Also not sure how to dispose of the texture when I'm done with it. Anyone know the correct way to do this? Edit: I think I might be having a problem loading the texture because it's not a power of 2, it's 320x480... also, I think this code is just loading the texture, but not drawing it, I'd need a call to glDrawArrays(GL_TRIANGLE_STRIP, 0, 4) in there somewhere...

    Read the article

  • Alignment of View Elements within a LinearLayout

    - by Adam
    I hate to ask this question; for some reason I can't figure it out on my own. I have a vertical LinearLayout that contains a custom View that I've defined in my app and and a TextView. I'd like my custom View to be aligned on the top of the screen and the TextView to be aligned at the bottom of the screen. Unfortunately, no matter what changes I make to the attributes of the XML file, my custom View always seems to be centered vertically when I run the emulator. The xml is like the following: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="top"> <CustomView android:id="@+id/customID" android:layout_width="wrap_content" android:layout_height="wrap_content" tileSize="24" android:focusableInTouchMode="true" android:layout_gravity="top"/> <TextView android:id="@+id/text" android:text="@string/droidtactoe_layout_text" android:visibility="visible" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal" android:textSize="24sp" android:textColor="#00000000" android:layout_gravity="bottom"/> </LinearLayout>

    Read the article

  • Orbital equations, and power required to run them

    - by Adam Davis
    Due to a discussion on the SO IRC today, I'm curious about orbital mechanics, and The equations needed to solve orbital problems The computing power required to solve complex problems The question in particular is calculating when the Earth will plow into the Sun (or vice versa, depending on the frame of reference). I suspect that all the gravitational pulls within our solar system may need to be calculated, which makes me wonder what type of computer cluster is required, or can this be done on a single box? I don't have the experience to do a back of the napkin test here, but perhaps you do? Also, much thx to Gortok for the original inspiration (see comments).

    Read the article

< Previous Page | 35 36 37 38 39 40 41 42 43 44 45 46  | Next Page >