Search Results

Search found 481 results on 20 pages for 'charles knapp'.

Page 14/20 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Pass object or id

    - by Charles
    This is just a question about best practices. Imagine you have a method that takes one parameter. This parameter is the id of an object. Ideally, I would like to be able to pass either the object's id directly, or just the object itself. What is the most elegant way to do this? I came up with the following: def method_name object object_id = object.to_param.to_i ### do whatever needs to be done with that object_id end So, if the parameter already is an id, it just pretty much stays the same; if it's an object, it gets its id. This works, but I feel like this could be better. Also, to_param returns a string, which could in some cases return a "real" string (i.e. "string" instead of "2"), hence returning 0 upon calling to_i on it. This could happen, for example, when using the friendly id gem for classes. Active record offers the same functionality. It doesn't matter if you say: Table.where(user_id: User.first.id) # pass in id or Table.where(user_id: User.first) # pass in object and infer id How do they do it? What is the best approach to achieve this effect?

    Read the article

  • How can I reference only a portion of a TextArea's htmlText block?

    - by Charles Shoults
    I have a number of very poor-quality pdf documents that look like 80's photocopies, which I'm rebuilding in Flash (Flex Builder 3 MXML application), representing paragraphs of text in TextAreas so that selected portions can be bold or italic, or whatever I need. I need a way to apply toolTips or event listeners to individual words within the block of text to link those words to a glossary. I'm perfectly happy to create a definition panel that is populated and made visible with a mouseOver, but don't know how to do it to just a portion of the text. Is there a good / clean / easy way to do this?

    Read the article

  • Javascript Replace Child/Loop issue

    - by Charles John Thompson III
    I have this really bizarre issue where I have a forloop that is supposed to replace all divs with the class of "original" to text inputs with a class of "new". When I run the loop, it only replaces every-other div with an input, but if I run the loop to just replace the class of the div and not change the tag to input, it does every single div, and doesn't only do every-other. Here is my loop code, and a link to the live version: live version here function divChange() { var divs = document.getElementsByTagName("div"); for (var i=0; i<divs.length; i++) { if (divs[i].className == 'original') { var textInput = document.createElement('input'); textInput.className = 'new'; textInput.type = 'text'; textInput.value = divs[i].innerHTML; var parent = divs[i].parentNode; parent.replaceChild(textInput, divs[i]); } } }

    Read the article

  • Getting started with MIT Proto

    - by Charles
    MIT Proto lacks a basic getting started guide. How do I find a shell that accepts commands like (def foo...) and proto -n 1000 -l -m ...? http://groups.csail.mit.edu/stpg/proto.html I can run in my bash shell: ./proto -n 1000 -s 0.1 -T -l "(red (gradient (= (mid) 0)))" I can't figure out how to run e.g. channel.proto: (def channel (src dst width) (let* ((d (distance src dst)) (trail (<= (+ (gradient src) (gradient dst)) (+ d 0.01))) ;; float error ;; (trail (= (+ (gradient src) (gradient dst)) d)) ) (dilate trail width))) ;; To see a channel calculated from geometric primitives, run: ;; proto -n 1000 -l -m -s 0.5 "(blue (channel (sense 1) (sense 2) 10))" ;; click on a device and hit 't' to set up the source, then click on ;; another device and hit 'y' to designate the destination. At first ;; every device will be blue, but then it should clear and you should ;; see a thick blue path connecting the two devices you selected. Thanks! P.S. Somebody please tag this mit-proto. I can't.

    Read the article

  • read in bash on tab-delimited file without empty fields collapsing

    - by Charles Duffy
    I'm trying to read a multi-line tab-separated file in bash. The format is such that empty fields are expected. Unfortunately, the shell is collapsing together field separators which are next to each other, as so: # IFS=$'\t' # read one two three <<<$'one\t\tthree' # printf '<%s> ' "$one" "$two" "$three"; printf '\n' <one> <three> <> ...as opposed to the desired output of <one> <> <three>. Can this be resolved without resorting to a separate language (such as awk)?

    Read the article

  • Using CSS to positon text after an image

    - by Charles L
    I've trying to do something that I'm sure is simple, but I can't do it. All I want to do is have an image and then some text after that image, and be able to control accurately the amount of space between the image and the text. Here's my code: http://pastebin.com/fx17XUaR I couldn't work out how to paste it in here directly. In my style sheet, wrap has these attributes: .wrap { //text-align: left; width: 1100px; height: 870px; background-color: white; color: black; padding: 10px; margin: auto; I want my text to look like this directly below the image: Username Age Location Currently, I just add loads of break tags to control where I have the text, but that's messy and there must be a better way. Thanks in advance for any help.

    Read the article

  • Render multiple layers in XNA

    - by Charles
    I'm using XNA, and I've run into a little problem. I need to support multiple layers, each with a distinct z order (I call these "viewports"). A picture is worth a thousand words, so here's what it should look like: There are several things to notice here. Sprites do not render outside of their viewport, as you can see with Sprite B. Also, notice how the viewports are rendered - it's very similar to "layers" in Photoshop. Although Sprite C is has a z order of -1000, C still renders above Sprite A because its viewport's z-order is a greater than A's viewport's z-order. There's one last detail that I couldn't display very well in the above picture. Each viewport needs to optionally render a color over its region of the screen - you could think of it as a "tinting" affect. I'm completely at a loss when it comes to doing this the best way in XNA, so I could really use a short snippet of C#/VB.NET code that demonstrates this in action. Any help would be greatly appreciated.

    Read the article

  • A question of style/readability regarding the C# "using" statement

    - by Charles
    I'd like to know your opinion on a matter of coding style that I'm on the fence about. I realize there probably isn't a definitive answer, but I'd like to see if there is a strong preference in one direction or the other. I'm going through a solution adding using statements in quite a few places. Often I will come across something like so: { log = new log(); log.SomeProperty = something; // several of these log.Connection = new OracleConnection("..."); log.InsertData(); // this is where log.Connection will be used ... // do other stuff with log, but connection won't be used again } where log.Connection is an OracleConnection, which implements IDisposable. The neatnik in me wants to change it to: { log = new log(); using (OracleConnection connection = new OracleConnection("...")) { log.SomeProperty = something; log.Connection = conn; log.InsertData(); ... } } But the lover of brevity and getting-the-job-done-slightly-faster wants to do: { log = new log(); log.SomeProperty = something; using (log.Connection = new OracleConnection("...")) log.InsertData(); ... } For some reason I feel a bit dirty doing this. Do you consider this bad or not? If you think this is bad, why? If it's good, why?

    Read the article

  • Using read in bash without empty fields collapsing

    - by Charles Duffy
    I'm trying to read a multi-line tab-separated file in bash. The format is such that empty fields are expected. Unfortunately, the shell is collapsing together field separators which are next to each other, as so: # IFS=$'\t' # read one two three <<<$'one\t\tthree' # printf '<%s> ' "$one" "$two" "$three"; printf '\n' <one> <three> <> ...as opposed to the desired output of <one> <> <three>. Can this be resolved without resorting to a separate language (such as awk)?

    Read the article

  • Reason for .Net UI Element Thread-restriction

    - by Charles Bretana
    We know that it is not possible to execute code that manipulates the properties of any UI element from any thread other than the thread the element was instantiated on... My question is why? I remember that when we used COM user interface elements, (in COM/VB6 days), that all UI elements were created using COM classes and co-classes that stored their resources using a memory model referred to as Thread-Local-Storage (TLS) , but as I recall, this was required because of something relaetd to the way COM components were constructed, and should not be relevant to .Net UI elements. Wha's the underlying reason why this restriction still exists? Is it because the underlying Operating System still uses COM-based Win32 API classes for all UI elements, even the ones manipulated in a managed .Net application ??

    Read the article

  • How to find the exact name of the view in asp.net mvc (including the case)

    - by Charles Prakash Dasari
    I have a control in ASP.NET MVC that spits out JavaScript in the page header (in the view page). I derive some values from the current view name (including its case). Let's say we are talking about the path: /Home/Index - my control spits out JavaScript to call a function with the view name - in its exact case - e.g. someFunction('Index'). Now when I try to navigate to my view using '/home/index', the view name is returned as 'index' which is causing issues in my JavaScript as I rely on the casing for it on the JS side. Is there any way to know the exact view name (as it was defined) from the path that got mapped into this view.

    Read the article

  • With paperclip, how can I change the image location to a ":parent_model_id/:id" folder format?

    - by Jamis Charles
    Given that I have a Listing model that has many images and each image has one attachment, how can I have the listing_id be part of the folder structure? Like so: system/photos/[listing_id]/:id I know that using :id will output the id of the image record. Here's what I currently have: class Image < ActiveRecord::Base belongs_to :listing #Rails ActiveRecord Relation. An image belongs to a post. # paperclip data has_attached_file :photo, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :url => "/public/system/:class/:attachment/:id/:style_:filename" end

    Read the article

  • Generating incremental numeric column values during INSERT SELECT statement

    - by Charles
    I need to copy some data from one table to another in Oracle, while generating incremental values for a numeric column in the new table. This is a once-only exercise with a trivial number of rows (100). I have an adequate solution to this problem but I'm curious to know if there is a more elegant way. I'm doing it with a temporary sequence, like so: CREATE SEQUENCE temp_seq START WITH 1; INSERT INTO new_table (new_col, copied_col1, copied_col2) SELECT temp_seq.NEXTVAL, o.* FROM (SELECT old_col1, old_col2 FROM old_table) o; DROP SEQUENCE temp_seq; Is there way to do with without creating the sequence or any other temporary object? Specifically, can this be done with a self-contained INSERT SELECT statement? There are similar questions, but I believe the specifics of my question are original to SO.

    Read the article

  • Bash file descriptor leak

    - by Charles Duffy
    I get a file descriptor leak when running the following code: function get_fd_count() { local fds cd /proc/$$/fd; fds=( * ) # avoid a StackOverflow source colorizer bug echo "${#fds[@]}" } function fd_leak_func() { echo ">> Current FDs: $(get_fd_count)" read retval new_state < <(set +e; new_state=$(echo foo); retval=$?; printf "%d %s\n" $retval $new_state) } function parent_func() { while fd_leak_func; do :; done } parent_func Tested on both 3.2.25 and 4.0.28. Taking the while loop out of parent_func and running it at top level makes the problem go away. What's going on here? More to the point, are workarounds available?

    Read the article

  • Timeout loading application on GAE using web2py

    - by Charles P.
    I am uploading an app to GAE. Through some experimentation I've found that if I don't include wsgihandler.py, the app loads very slowly. It feels like it's looking for this file and them timing out. Besides the slow loading, everything works perfectly without wsgihandler.py, so I want to know if there is a simple way to remove the references to the file. I tried poking around the files, but it doesn't look like there are direct references. Also, I asked before what I need at a minimum to get an application to work, and I found that I need: web2py/app.yaml web2py/gaehandler.py web2py/VERSION web2py/gluon/* (and subfolders, this is web2py) web2py/applications/theoneappyouwanttodeploy/* (and subfolders)

    Read the article

  • jQuery dont see onclick event on link inside infowindow in google maps v3

    - by Charles
    i have such problem that jQuery onclick event dont see click on link inside google map in infowindow. Thats how my infowindow link looks like: <a href="http://example.com/#ui-accordion-accordion-header-7" class="pull-right move-to-acc" id="itemH">See Details</a> Under map i have acordion list with detailed information about point so im trying to catch click on that link : jQuery("#itemH").click(function(event){ alert("qq"); }); When i click on marker infowindow open and i click on link but alert dont show up - im just moved to div #ui-accordion-accordion-header-7 What im doing wrong ? Thx for help

    Read the article

  • Silverlight for Windows Embedded Tutorial (step 5 and a bit of Windows Phone 7)

    - by Valter Minute
    If you haven’t spent the last week in the middle of the Sahara desert or traveling on a sled in the north pole area you should have heard something about the launch of Windows Phone 7 Series (or Windows Phone Series 7, or Windows Series Phone 7 or something like that). Even if you are in the middle of the desert or somewhere around the north pole you may have been reached by the news, since it seems that WP7S (using the full name will kill my available bandwidth!) is generating a lot of buzz in the development and IT communities. One of the most important aspects of this new platform is that it will be programmed using a new set of tools and frameworks, completely different from the ones used on older releases of Windows Mobile (or SmartPhone, or PocketPC or whatever…). WP7S applications can be developed using Silverlight or XNA. If you want to learn something more about WP7S development you can download the preview of Charles Petzold’s book about it: http://www.charlespetzold.com/phone/index.html Charles Petzold is also the author of “Programming Windows”, the first book I ever read about programming on Windows (it was Windows 3.0 at that time!). The fact that even I was able to learn how to develop Windows application is a proof of the quality of Petzold’s work. This book is up to his standards and the 150pages preview is already rich in technical contents without being boring or complicated to understand. I may be able to become a Windows Phone developer thanks to mr. Petzold. Mr. Petzold uses some nice samples to introduce the basic concepts of Silverlight development on WP7S. On this new platform you’ll use managed code to develop your application, so those samples can’t be ported on Windows CE R3 as they are, but I would like to take one of the first samples (called “SilverlightTapHello1”) and adapt it to Silverlight for Windows Embedded to show that even plain old native code can be used to develop “cool” user interfaces! The sample shows the standard WP7S title header and a textbox with an hello world message inside it. When the user touches the textbox, it will change its color. When the user touches the background (Grid) behind it, its default color (plain old White) will be restored. Let’s see how we can implement the same features on our embedded device! I took the XAML code of the sample (you can download the book samples here: http://download.microsoft.com/download/1/D/B/1DB49641-3956-41F1-BAFA-A021673C709E/CodeSamples_DRAFTPreview_ProgrammingWindowsPhone7Series.zip) and changed it a little bit to remove references to WP7S or managed runtime. If you compare the resulting files you will see that I was able to keep all the resources inside the App.xaml files and the structure of  MainPage.XAML almost intact. This is the Silverlight for Windows Embedded version of MainPage.XAML: <UserControl x:Class="SilverlightTapHello1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Navigation" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" Width="640" Height="480">   <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions>   <!--TitleGrid is the name of the application and page title--> <Grid x:Name="TitleGrid" Grid.Row="0"> <TextBlock Text="SILVERLIGHT TAP HELLO #1" x:Name="textBlockPageTitle" Style="{StaticResource PhoneTextPageTitle1Style}"/> <TextBlock Text="main page" x:Name="textBlockListTitle" Style="{StaticResource PhoneTextPageTitle2Style}"/> </Grid>   <!--ContentGrid is empty. Place new content here--> <Grid x:Name="ContentGrid" Grid.Row="1" MouseLeftButtonDown="ContentGrid_MouseButtonDown" Background="{StaticResource PhoneBackgroundBrush}"> <TextBlock x:Name="TextBlock" Text="Hello, Silverlight for Windows Embedded!" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Grid> </Grid> </UserControl> If you compare it to the WP7S sample (not reported here to avoid any copyright issue) you’ll notice that I had to replace the original phoneNavigation:PhoneApplicationPage with UserControl as the root node. This make sense because there is not support for phone applications on CE 6. I also had to specify width and height of my main page (on the WP7S device this will be adjusted by the OS) and I had to replace the multi-touch event handler with the MouseLeftButtonDown event (no multitouch support for Windows CE R3, still). I also changed the hello message, of course. I used XAML2CPP to generate the boring part of our application and then added the initialization code to WinMain: int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { if (!XamlRuntimeInitialize()) return -1;   HRESULT retcode;   IXRApplicationPtr app; if (FAILED(retcode=GetXRApplicationInstance(&app))) return -1; XRXamlSource dictsrc;   dictsrc.SetResource(hInstance,TEXT("XAML"),IDR_XAML_App);   if (FAILED(retcode=app->LoadResourceDictionary(&dictsrc,NULL))) return -1;   MainPage page;   if (FAILED(page.Init(hInstance,app))) return -1;   UINT exitcode;   if (FAILED(page.GetVisualHost()->StartDialog(&exitcode))) return -1;   return exitcode; }   You may have noticed that there is something different from the previous samples. I added the code to load a resource dictionary. Resources are an important feature of XAML that allows you to define some values that could be replaced inside any XAML file loaded by the runtime. You can use resources to define custom styles for your fonts, backgrounds, controls etc. and to support internationalization, by providing different strings for different languages. The rest of our WinMain isn’t that different. It creates an instances of our MainPage object and displays it. The MainPage class implements an event handler for the MouseLeftButtonDown event of the ContentGrid: class MainPage : public TMainPage<MainPage> { public:   HRESULT ContentGrid_MouseButtonDown(IXRDependencyObject* source,XRMouseButtonEventArgs* args) { HRESULT retcode; IXRSolidColorBrushPtr brush; IXRApplicationPtr app;   if (FAILED(retcode=GetXRApplicationInstance(&app))) return retcode;   if (FAILED(retcode=app->CreateObject(IID_IXRSolidColorBrush,&brush))) return retcode;   COLORREF color=RGBA(0xff,0xff,0xff,0xff);   if (args->pOriginalSource==TextBlock) color=RGBA(rand()&0xFF,rand()&0xFF,rand()&0xFF,0xFF);   if (FAILED(retcode=brush->SetColor(color))) return retcode;   if (FAILED(retcode=TextBlock->SetForeground(brush))) return retcode; return S_OK; } }; As you can see this event is generated when a used clicks inside the grid or inside one of the objects it contains. Since our TextBlock is inside the grid, we don’t need to provide an event handler for its MouseLeftButtonDown event. We can just use the pOriginalSource member of the event arguments to check if the event was generated inside the textblock. If the event was generated inside the grid we create a white brush,if it’s inside the textblock we create some randomly colored brush. Notice that we need to use the RGBA macro to create colors, specifying also a transparency value for them. If we use the RGB macro the resulting color will have its Alpha channel set to zero and will be transparent. Using the SetForeground method we can change the color of our control. You can compare this to the managed code that you can find at page 40-41 of Petzold’s preview book and you’ll see that the native version isn’t much more complex than the managed one. As usual you can download the full code of the sample here: http://cid-9b7b0aefe3514dc5.skydrive.live.com/self.aspx/.Public/SilverlightTapHello1.zip And remember to pre-order Charles Petzold’s “Programming Windows Phone 7 series”, I bet it will be a best-seller! Technorati Tags: Silverlight for Windows Embedded,Windows CE

    Read the article

  • Oracle Supply Chain Sessions at Collaborate 2010

    - by Paul Homchick
    Oracle SCM executives will be presenting more than thirty sessions at the Collaborate 2010 Oracle Users' Group Conference in Las Vegas, Nevada, April 18-22.Charles Phillips, President of Oracle will give a keynote address on Monday "Transforming Customer Value -- Delivering Highest Customer Service."A list of the Oracle SCM sessions to be presented at Collaborate 2010 is presented after the break...

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20  | Next Page >