Search Results

Search found 469 results on 19 pages for 'pat mitchell'.

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

  • Remove special chars from URL

    - by John Jones
    Hi, I have a product database and I am displaying trying to display them as clean URLs, below is example product names: PAUL MITCHELL FOAMING POMADE (150ml) American Crew Classic Gents Pomade 85g Tigi Catwalk Texturizing Pomade 50ml What I need to do is display like below in the URL structrue: www.example.com/products/paul-mitchell-foaming-gel(150ml) The problem I have is I want to do the following: Remove anything with braquets(and the braquets) Remove any numbers next to g or ml e.g. 400ml, 10g etc... I have been banging my head trying different string replaces but cant get it right, I would really appreciate some help. Cheers

    Read the article

  • SharePoint SLK and T-SQL xp_cmdshell safety

    - by Mitchell Skurnik
    I am looking into a TSQL command called "xp_cmdshell" to use to monitor a change to a the SLK (SharePoint Learning Kit) database and then execute a batch or PowerShell script that will trigger some events that I need. (It is bad practice to modify SharePoint's database directly, so I will be using its API) I have been reading on various blogs and MSDN that there are some security concerns with this approach. The sites suggest that you limit security so the command can be executed by only a specific user role. What other tips/suggestions would you recommend with using "xp_cmdshell"? Or should I go about this another way and create a script or console application that constantly checks if a change has been made? I am running Server 2008 with SQL 2008.

    Read the article

  • How to take a collection of bytes and pull typed values out of it?

    - by Pat
    Say I have a collection of bytes var bytes = new byte[] {0, 1, 2, 3, 4, 5, 6, 7}; and I want to pull out a defined value from the bytes as a managed type, e.g. a ushort. What is a simple way to define what types reside at what location in the collection and pull out those values? One (ugly) way is to use System.BitConverter and a Queue or byte[] with an index and simply iterate through, e.g.: int index = 0; ushort first = System.BitConverter.ToUint16(bytes, index); index += 2; // size of a ushort int second = System.BitConverter.ToInt32(bytes, index); index += 4; ... This method gets very, very tedious when you deal with a lot of these structures! I know that there is the System.Runtime.InteropServices.StructLayoutAttribute which allows me to define the locations of types inside a struct or class, but there doesn't seem to be a way to import the collection of bytes into that struct. If I could somehow overlay the struct on the collection of bytes and pull out the values, that would be ideal. E.g. Foo foo = (Foo)bytes; // doesn't work because I'd need to implement the implicit operator ushort first = foo.first; int second = foo.second; ... [StructLayout(LayoutKind.Explicit, Size=FOO_SIZE)] public struct Foo { [FieldOffset(0)] public ushort first; [FieldOffset(2)] public int second; } Any thoughts on how to achieve this?

    Read the article

  • Count the number of dates between two dates

    - by Matt Mitchell
    I'm looking to count the dates covered (inclusive) between two DateTimes (not .TotalDays) For example: 2012-2-1 14:00 to 2012-2-2 23:00 -> 2 2012-2-1 14:00 to 2012-2-2 10:00 -> 2 2012-2-1 14:00 to 2012-2-1 15:00 -> 1 2012-1-1 00:00 to 2012-12-31 23:59 -> 366 I can get this functionality with the code below: DateTime dt1 = new DateTime(2000,1,2,12,00,00); DateTime dt2 = new DateTime(2000,1,3,03,00,00); int count = 0; for (DateTime date = dt1; date.Date <= dt2.Date; date = date.AddDays(1)) count++; return count; Is there a better way?

    Read the article

  • ndarray field names for both row and column?

    - by Graham Mitchell
    I'm a computer science teacher trying to create a little gradebook for myself using NumPy. But I think it would make my code easier to write if I could create an ndarray that uses field names for both the rows and columns. Here's what I've got so far: import numpy as np num_stud = 23 num_assign = 2 grades = np.zeros(num_stud, dtype=[('assign 1','i2'), ('assign 2','i2')]) #etc gv = grades.view(dtype='i2').reshape(num_stud,num_assign) So, if my first student gets a 97 on 'assign 1', I can write either of: grades[0]['assign 1'] = 97 gv[0][0] = 97 Also, I can do the following: np.mean( grades['assign 1'] ) # class average for assignment 1 np.sum( gv[0] ) # total points for student 1 This all works. But what I can't figure out how to do is use a student id number to refer to a particular student (assume that two of my students have student ids as shown): grades['123456']['assign 2'] = 95 grades['314159']['assign 2'] = 83 ...or maybe create a second view with the different field names? np.sum( gview2['314159'] ) # total points for the student with the given id I know that I could create a dict mapping student ids to indices, but that seems fragile and crufty, and I'm hoping there's a better way than: id2i = { '123456': 0, '314159': 1 } np.sum( gv[ id2i['314159'] ] ) I'm also willing to re-architect things if there's a cleaner design. I'm new to NumPy, and I haven't written much code yet, so starting over isn't out of the question if I'm Doing It Wrong. I am going to be needing to sum all the assignment points for over a hundred students once a day, as well as run standard deviations and other stats. Plus, I'll be waiting on the results, so I'd like it to run in only a couple of seconds. Thanks in advance for any suggestions.

    Read the article

  • How do I know if a drag/drop has been cancelled in WPF

    - by Jon Mitchell
    I'm writing a user control in WPF which is based on a ListBox. One of the main pieces of functionality is the ability to reorder the list by dragging the items around. When a user drags an item I change the items Opacity to 50% and physically move the item in an ObservableCollection in my ViewModel depending on where the user wants it. On the drop event I change the Opacity back to 100%. The problem I've got is that if the user drags the item off my control and drops it somewhere else then I need to change the Opacity back to 100% and move the item back to where it was when the user started the drag. Is there an event I can handle to capture this action? If not is there any other cunning way to solve this problem?

    Read the article

  • Should I bother with C++ or go straight to C#?

    - by Pat Riley
    I have been writing embedded C applications for almost 20 years. In the last few years I have written quite a few PC based GUI interfaces in Visual C so I could interface my embedded systems to a PC. Although my primary work will still be in deeply embedded C, I have finally decided to move my PC based tools into Ruby - (for quick scripting type stuff) and C++ or C# for GUI based interfaces and applications. Should I bother with C++ or just move straight to C#?

    Read the article

  • Differences between Zend Framework 1.8 and 1.10

    - by Pat
    I want to start learning Zend Framework. My only concern is that the most recent ZF book on Amazon with good reviews teaches version 1.8 of the framework, which is now about a year old. Do you think it would be a good idea to still pick up that book or is it too old now?

    Read the article

  • touchesEnded:withEvent: from UIScrollView First Responder

    - by Matthew Mitchell
    I've made a UIScrollView the first responder. I need to maintain touch events to a touchesEnded:withEvent: method on a view behind it. I've tried using the nextResponder method and that failed. I've tried forwarding touchesEnded:withEvent to the view behind it and that fails. How do I get this to work? The UIScrollView wont work unless it is the first responder or gets events some other way. Thank you for any help. Shame Apple's documentation and APIs are terrible in areas.

    Read the article

  • Timing issues with playback of the HTML5 Audio API

    - by pat
    I'm using the following code to try to play a sound clip with the HTML5 Audio API: HTMLAudioElement.prototype.playClip = function(startTime, stopTime) { this.stopTime = stopTime; this.currentTime = startTime; this.play(); $(this).bind('timeupdate', function(){ if (this.ended || this.currentTime >= stopTime) { this.pause(); $(this).unbind('timeupdate'); } }); } I utilize this new playClip method as follows. First I have a link with some data attributes: <a href=# data-stop=1.051 data-start=0.000>And then I was thinking,</a> And finally this bit of jQuery which runs on $(document).ready to hook up a click on the link with the playback: $('a').click(function(ev){ $('a').click(function(ev){ var start = $(this).data('start'), stop = $(this).data('stop'), audio = $('audio').get(0), $audio = $(audio); ev.preventDefault(); audio.playClip(start,stop); }) This approach seems to work, but there's a frustrating bug: sometimes, the playback of a given clip plays beyond the correct data-stop time. I suspect it could have something to do with the timing of the timeupdate event, but I'm no JS guru and I don't know how to begin debugging the problem. Here are a few clues I've gathered: The same behavior appears to come up in both FF and Chrome. The playback of a given clip actually seems to vary a bit -- if I play the same clip a couple times in a row, it may over-play a different amount of time on each playing. Is the problem here the inherent accuracy of the Audio API? My app needs milliseconds. Is there a problem with the way I'm using jQuery to bind and unbind the timeupdate event? I tried using the jQuery-less approach with addEventListener but I couldn't get it to work. Thanks in advance, I would really love to know what's going wrong.

    Read the article

  • How to create unique user key

    - by Grayson Mitchell
    Scenario: I have a fairly generic table (Data), that has an identity column. The data in this table is grouped (lets say by city). The users need an identifier in order for printing on paper forms, etc. The users can only access their cites data, so if they use the identity column for this purpose they will see odd numbers (e.g. a 'New York' user might see 1,37,2028... as the listed keys. Idealy they would see 1,2,3... (or something similar) The problem of course is concurrency, this being a web application you can't just have something like: UserId = Select Count(*)+1 from Data Where City='New York' Has anyone come up with any cunning ways around this problem?

    Read the article

  • Multiple button presses for Android 2.x

    - by Pat
    I am relatively new to this still, and I have been developing a small app that would benefit greatly from a user being able to press 2 buttons at one time. What is the best method for achieving this? I dont think that an OnClickListener works like that, and I have seen examples for doing this with an OnTouch event. However, I do not know how to set up button presses with and OnTouch event.

    Read the article

  • How do you write a recursive stored procedure

    - by Grayson Mitchell
    I simply want a stored procedure that calculates a unique id and inserts it. If it fails it just calls itself to regenerate said id. I have been looking for an example, but cant find one, and am not sure how I should get the sp to call itself, and set the appropriate output parameter. I would also appreciate someone pointing out how to test this sp also. ALTER PROCEDURE [dbo].[DataContainer_Insert] @SomeData varchar(max), @DataContainerId int out AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; BEGIN TRY SELECT @UserId = MAX(UserId) From DataContainer INSERT INTO DataContainer (UserId, SomeData) VALUES (@UserId, SomeData) SELECT @DataContainerId = scope_identity() END TRY BEGIN CATCH --try again exec DataContainer_Insert @DataContainerId, @SomeData END CATCH END

    Read the article

  • What .NET UnmanagedType is Unicode (UTF-16)?

    - by Pat
    I am packing bytes into a struct, and some of them correspond to a Unicode string. The following works fine for an ASCII string: [StructLayout(LayoutKind.Sequential)] private struct PacketBytes { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string MyString; } I assumed that I could do [StructLayout(LayoutKind.Sequential)] private struct PacketBytes { [MarshalAs(UnmanagedType.LPWStr, SizeConst = 32)] public string MyString; } to make it Unicode, but that didn't work. (Since this field is part of a struct with other fields, which I've omitted for clarity, I can't simply change the CharSet of the containing struct.) Any idea what I'm doing wrong?

    Read the article

  • Dojo: Setting a CheckBox label programmatically

    - by Mitchell Flaherty
    Let me preface by saying that I saw this other question on the subject of CheckBox labels that was asked and answered well over a year ago. I was confused by the answers and am hoping that someone can clarify or that there has been new dojo functionality introduced since then that allows me to do this without resorting to HTML. So without further ado, I would like to know how to programmatically create labels for check boxes. I have a check box like so: this.pubBoxId = new dijit.form.CheckBox({ label: "IdChannel", checked: false, channel: that.idChannel }, that.name + "_PBI"); As you can see I've tried to edit the "label" field, but the label never actually shows up on the page. I have multiple CheckBoxes that I am adding to a ContentPane and simply want a label to the left or right of the check box. Is there any way I can do this without having to write separate HTML? Also, making a separate ContentPane for each individual label would be a big pain because of how many CheckBoxes I plan to have. Thank you for reading, and let me know if further clarification is needed!

    Read the article

  • How do I simplify my code?

    - by Mitchell Skurnik
    I just finished creating my first major application in C#/Silverlight. In the end the total line count came out to over 12,000 lines of code. Considering this was a rewrite of a php/javascript application I created 2 years that was over 28,000 lines I am actually quite proud of my accomplishment. After reading many questions and answers here on stackoverflow and other sites online, I followed many posters advice: I created classes, procedures, and such for things that I would have a year ago copied and pasted; I created logic charts to figure out complex functions; making sure there are no crazy hidden characters (used tabs instead of spaces); and a few others things; place comments where necessary (I have lots of comments). My application consists of 4 tiles laid out horizontally that have user controls loaded into each slice. You can have between one and four slices loaded at anytime. If you have once slice loaded, the slice takes up the entire artboard...if you have 2 loaded, each take up half, 3 a third, 4 a quarter. Each one of these slices represent (for the sake of this example) a light control. Each slice has 3 slider controls in it. Now when I coded the functionality of the sliders, I used a switch/case statement inside of a public function that would run the command on the specified slice/slider. The made for some duplicate code but I saw no way around it as each slice was named differently. So I would do slice1.my.commands(); slice2.my.commands(); etc. My question to you is how do I clean up my code even futher? (Sadly I cannot post any of my code). Is there any way to take this repetion out of my code?

    Read the article

  • Write to PDF using PHP from android device

    - by Brent Mitchell
    I am trying to write to a pdf file on php server. I have sent variables to the server, create the pdf document, then have my phone download the document to view on device. The variables seem not to write on the php file. I have my code below public void postData() { try { Calculate calc = new Calculate(); HttpClient mClient = new DefaultHttpClient(); StringBuilder sb=new StringBuilder("myurl.com/pdf.php"); HttpPost mpost = new HttpPost(sb.toString()); String value = "1234"; List nameValuepairs = new ArrayList(1); nameValuepairs.add(new BasicNameValuePair("id",value)); mpost.setEntity(new UrlEncodedFormEntity(nameValuepairs)); } catch (UnsupportedEncodingException e) { Log.w(" error ", e.toString()); } catch (Exception e) { Log.w(" error ", e.toString()); } } And my php code to write the variable "value" onto the pdf document: //code to reverse the string if($_POST[] != null) { $reversed = strrev($_POST["value"]); $this->SetFont('Arial','u',50); $this->Text(52,68,$reversed); } I am just trying to write the variable in a random spot, but the variable the if statement is always null and I do not know why. Thanks. Sorry if it is a little sloppy.

    Read the article

  • IIS7 URL Rewriting: How not to drop HTTPS protocol from rewritten URL?

    - by Scott Mitchell
    I'm working on a website that's using IIS 7's URL rewriting feature to do a permanent redirect from example.com to www.example.com, as well as rewrites from similar domain names to the "main" one, such as from www.examples.com to www.example.com. This rewrite rule - shown below - has worked well for sometime now. However, we recently added HTTPS support and noticed that if users visit one of the URLs to be rewritten to www.example.com then HTTPS is dropped. For instance, if a user visits https://example.com they get redirected to http://www.example.com, whereas we would like them to be sent to https://www.example.com. Here is the rewrite rule of interest (in Web.config): <rule name="Canonical Host Name" stopProcessing="true"> <match url="(.*)" /> <conditions logicalGrouping="MatchAny"> <add input="{HTTP_HOST}" pattern="^example\.com$" /> <add input="{HTTP_HOST}" pattern="^(www\.)?example\.net$" /> <add input="{HTTP_HOST}" pattern="^(www\.)?example\.info$" /> <add input="{HTTP_HOST}" pattern="^(www\.)?examples\.com$" /> </conditions> <action type="Redirect" url="http://www.example.com/{R:1}" redirectType="Permanent" /> </rule> As you can see, the action element's url attribute points directly to http://, so I get why https://example.com is redirected to http://www.example.com. My question is, how do I fix this? I tried (naively) to just drop the http:// part from the url attribute, but that didn't work. Thanks!

    Read the article

  • How to inherit methods from a parent class in C++

    - by Pat
    When inheriting classes in C++ I understand members are inherited. But how does one inherit the methods as well? For example, in the below code, I'd like the method "getValues" to be accessible not through just CPoly, but also by any class that inherits it. So one can call "getValues" on CRect directly. class CPoly { private: int width, height; public: void getValues (int* a, int* b) { *a=width; *b=height;} }; class CRect: public CPoly { public: int area () { return (width * height); } }; In other words, is there any way to inherit methods for simple generic methods like getters and setters?

    Read the article

  • Limiting Row Selection in JTable

    - by Pat
    Is there an easy way to limit the total selection of rows in a JTable? I mean I'd like to allow the user to use shift and ctrl to select a maximum of X rows. If he clicks again on a row it would cancel out all the selections. Sort of how it currently behaves, but while limiting the total amount of selected rows. Here's my current implementation, I'm kind of clueless on how to limit the selection graphically. public class RoomsListView extends AbstractViewPanel { public RoomsListView(DefaultController controller) { this.controller = controller; initUI(); } private void initUI() { tableT = new JTable(RoomsModel.getInstance()); sorter = new TableRowSorter<RoomsModel>(RoomsModel.getInstance()); tableT.setRowSorter(sorter); tableT.setPreferredScrollableViewportSize(new Dimension(CUSTOM_TABLE_WIDTH, CUSTOM_TABLE_HEIGHT)); tableT.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { rowClickedPerformed(e); } }); } private void rowClickedPerformed(MouseEvent e) { } public void modelPropertyChange(PropertyChangeEvent evt) { } public JTable getTable() { return tableT; } private final int CUSTOM_TABLE_WIDTH = -1; private final int CUSTOM_TABLE_HEIGHT = 150; private JTable tableT; private DefaultController controller; private TableRowSorter<RoomsModel> sorter; }

    Read the article

  • Throwing an AggregateException in my own code

    - by Pat
    How should I go about collecting exceptions and putting them into an AggregateException to re-throw? For my specific code, I have a loop and will have zero or more exceptions thrown from a part of the code. I was hoping to just add the new exceptions to the AggregateException as they arise, but the documentation sort of indicates that it should be constructed with all the Exceptions at once (there is no method to add an Exception to the object). And what about creating a new AE every time and just including the previous AE in the list of exceptions? Seems a hokey way to do it. Any better ideas?

    Read the article

  • fgets equilvilant in C++

    - by mitchell
    what is the C++ equivilant to the c function fgets? I have looked at getline from ifstream, but when it comes to a end of line character, '\n', it terminates at and discards it, I am looking for a function that just terminates at the end line character but adds the end of line character to the char array. thanks in advance

    Read the article

  • Why does the compiler give an ambiguous invocation error when passing inherited types?

    - by Matt Mitchell
    What is happening in the C# compiler to cause the following ambiguous invocation compilation error? The same issue applies to extension methods, or when TestClass is generic and using instance rather than static methods. class Type1 { } class Type2 : Type1 {} class TestClass { public static void Do<T>(T something, object o) where T : Type1 {} public static void Do(Type1 something, string o) {} } void Main() { var firstInstance = new Type1(); TestClass.Do(firstInstance, new object()); // Calls Do(Type1, obj) TestClass.Do(firstInstance, "Test"); // Calls Do<T>(T, string) var secondInstance = new Type2(); TestClass.Do(secondInstance, new object()); // Calls Do(Type1, obj) TestClass.Do(secondInstance, "Test"); // "The call is ambiguous" compile error }

    Read the article

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