Search Results

Search found 419 results on 17 pages for 'captain planet'.

Page 5/17 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Graceful DOS Command Error-Handling w/PHP popen()

    - by Captain Obvious
    PHP 5.2.13 on Windows 2003 I am using the DOS Start /B command to launch a background application using the PHP popen() function: popen("start /B {$_SERVER['HOMEPATH']}/{$app}.exe > {$_SERVER['HOMEPATH']}/bg_output.log 2>&1 & echo $!", 'r'); The popen() function launches a cmd.exe process that runs the specified command; however, if the command fails (e.g. the {$app}.exe doesn't exist or is locked in the above example), the cmd.exe process never returns, and PHP hangs indefinitely as a result. Calling the failing DOS command directly using the Command Prompt results in an Error prompt that requires clicking the OK button. I assume this error confirmation requirement is what's preventing the cmd.exe process from returning to PHP both from the Command Prompt (using both CGI and CLI) and the web (using Apache 2.0 handler w/Apache 2.2). Is there a way to configure PHP, Apache, and/or Win 2003 to return the DOS error to the originating call rather than waiting for confirmation?

    Read the article

  • Graceful DOS Command Error-Handling

    - by Captain Obvious
    PHP 5.2.13 on Windows 2003 I am using the DOS Start /B command to launch a background application using the PHP popen() function: popen("start /B {$_SERVER['HOMEPATH']}/{$app}.exe > {$_SERVER['HOMEPATH']}/bg_output.log 2>&1 & echo $!", 'r'); The popen() function launches a cmd.exe process that runs the specified command; however, if the command fails (e.g. the {$app}.exe doesn't exist or is locked in the above example), the cmd.exe process never returns, and PHP hangs indefinitely as a result. Calling the failing DOS command directly using the Command Prompt results in an Error prompt that requires clicking the OK button. I assume this error confirmation requirement is what's preventing the cmd.exe process from returning to PHP both from the Command Prompt (using both CGI and CLI) and the web (using Apache 2.0 handler w/Apache 2.2). Is there a way to write the DOS command or configure the server or cmd.exe app itself to return the DOS error to the originating call rather than waiting for confirmation?

    Read the article

  • Need sorted dictionary designed to find values with keys less or greater than search value

    - by Captain Comic
    Hi I need to have objects sorted by price (decimal) value for fast access. I need to be able to find all objects with price more then A or less than B. I was thinkg about SortedList, but it does not provide a way to find ascending or descending enumerator starting from given key value (say give me all objects with price less than $120). Think of a system that accepts items for sell from users and stores them into that collection. Another users want to find items cheaper than $120. Basically what i need is tree-based collection and functionality to find node that is smaller\greater\equal to provided key. Please advice.

    Read the article

  • Exception of Binding form data to object

    - by Captain Kidd
    I'm practising Spring MVC.But fail to populate command object in Controller when I use spring standard tag. For example: "form:input path="password"" But I perfectly do this with HTML standard tag. Like: "input type="text" name="password"" I wonder the way how to use Spring tag binding data. In addition, I think configuration and coding is right in my sample. protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { UserFormBean b = (UserFormBean)command; System.out.println("s"); return super.onSubmit(request, response, command, errors); } <form:form commandName="command" action="/SpringFrame/register.html"> <form:input path="password"/> <!-- <input type="text" name="password"/> --> <input type="submit"/> </form:form>

    Read the article

  • Issue about Tomcat 5.5 "ROOT" directory.

    - by Captain Kidd
    Now I specify a directory name for "appBase" attribute on "{TomcatHome}/config/server.xml". <host appBase="d:/aaa"> <Context docBase="d:/aaa/bbb"> </Context> </host> When I navigate URL to "http://localhost:8080", TOMCAT think "d:/aaa/ROOT" as application directory. I want to know how can I modify this mechanism to make TOMCAT auto search my specified directory. For example: When I input "http://localhost:8080", TOMCAT would search "d:/aaa/{SpecifiedDirectoryName}/"

    Read the article

  • Trying to output a list using class

    - by captain morgan
    Am trying to get the moving average of a price..but i keep getting an attribute error in my Moving_Average class. ('Moving_Average' object has no attribute 'days'). Here is what I have: class Moving_Average: def calculation(self, alist:list,days:int): m = self.days prices = alist[1::2] average = [0]* len(prices) signal = ['']* len(prices) for m in range(0,len(prices)-days+1): average[m+2] = sum(prices[m:m+days])/days if prices[m+2] < average[m+2]: signal[m+2]='SELL' elif prices[m+2] > average[m+2] and prices[m+1] < average[m+1]: signal[m+2]='BUY' else: signal[m+2] ='' return average,signal def print_report(symbol:str,strategy:str): print('SYMBOL: ', symbol) print('STRATEGY: ', strategy) print('Date Closing Strategy Signal') def user(): strategy = ''' Which of the following strategy would you like to use? * Simple Moving Average [S] * Directional Indicator[D] Please enter your choice: ''' if signal_strategy in 'Ss': days = input('Please enter the number of days for the average') days = int(days) strategy = 'Simple Moving Average {}-days'.format(str(days)) m = Moving_Average() ma = m.calculation(gg, days) print(ma) gg is an list that contains date and prices. [2013-10-01,60,2013-10-02,60] The output is supposed to look like: Date Price Average Signal 2013-10-01 60.0 2013-10-02 60.0 60.00 BUY

    Read the article

  • paintComponent method is not displaying anything on the panel

    - by Captain Gh0st
    I have been trying to debug this for hours. The program is supposed to be a grapher that graphs coordinates, but i cannot get anything to display not even a random line, but if i put a print statement there it works. It is a problem with the paintComponent Method. When I out print statement before g.drawLine then it prints, but it doesn't draw any lines even if i put a random line with coordinates (1,3), (2,4). import java.awt.*; import java.util.*; import javax.swing.*; public abstract class XYGrapher { abstract public Coordinate xyStart(); abstract public double xRange(); abstract public double yRange(); abstract public Coordinate getPoint(int pointNum); public class Paint extends JPanel { public void paintGraph(Graphics g, int xPixel1, int yPixel1, int xPixel2, int yPixel2) { super.paintComponent(g); g.setColor(Color.black); g.drawLine(xPixel1, yPixel1, xPixel2, yPixel2); } public void paintXAxis(Graphics g, int xPixel, int pixelsWide, int pixelsHigh) { super.paintComponent(g); g.setColor(Color.green); g.drawLine(xPixel, 0, xPixel, pixelsHigh); } public void paintYAxis(Graphics g, int yPixel, int pixelsWide, int pixelsHigh) { super.paintComponent(g); g.setColor(Color.green); g.drawLine(0, yPixel, pixelsWide, yPixel); } } public void drawGraph(int xPixelStart, int yPixelStart, int pixelsWide, int pixelsHigh) { JFrame frame = new JFrame(); Paint panel = new Paint(); panel.setPreferredSize(new Dimension(pixelsWide, pixelsHigh)); panel.setMinimumSize(new Dimension(pixelsWide, pixelsHigh)); panel.setMaximumSize(new Dimension(pixelsWide, pixelsHigh)); frame.setLocation(frame.getToolkit().getScreenSize().width / 2 - pixelsWide / 2, frame.getToolkit().getScreenSize().height / 2 - pixelsHigh / 2); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.add(panel); frame.pack(); frame.setVisible(true); double xRange = xRange(); double yRange = yRange(); Coordinate xyStart = xyStart(); int xPixel = xPixelStart - (int) (xyStart.getX() * (pixelsWide / xRange)); int yPixel = yPixelStart + (int) ((xyStart.getY() + yRange) * (pixelsHigh / yRange)); System.out.println(xPixel + " " + yPixel); if(yPixel > 0 && (yPixel < pixelsHigh)) { System.out.println("y"); panel.paintYAxis(panel.getGraphics(), yPixel, pixelsWide, pixelsHigh); } if(xPixel > 0 && (xPixel < pixelsHigh)) { System.out.println("x"); panel.paintXAxis(panel.getGraphics(), xPixel, pixelsWide, pixelsHigh); } for(int i = 0; i>=0; i++) { Coordinate point1 = getPoint(i); Coordinate point2 = getPoint(i+1); if(point2 == null) { break; } else { if(point1.drawFrom() && point2.drawTo()) { int xPixel1 = (int) (xPixelStart + (point1.getX() - xyStart.getX()) * (pixelsWide / xRange)); int yPixel1 = (int) (yPixelStart + (xyStart.getY() + yRange-point1.getY()) * (pixelsHigh / yRange)); int xPixel2 = (int) (xPixelStart + (point2.getX() - xyStart.getX()) * (pixelsWide / xRange)); int yPixel2 = (int) (yPixelStart + (xyStart.getY() + yRange - point2.getY()) * (pixelsHigh / yRange)); panel.paintGraph(panel.getGraphics(), xPixel1, yPixel1, xPixel2, yPixel2); } } } frame.pack(); } } This is how i am testing it is supposed to be a square, but nothing shows up. public class GrapherTester extends XYGrapher { public Coordinate xyStart() { return new Coordinate(-2,2); } public double xRange() { return 4; } public double yRange() { return 4; } public Coordinate getPoint(int pointNum) { switch(pointNum) { case 0: return new Coordinate(-1,-1); case 1: return new Coordinate(1,-1); case 2: return new Coordinate(1,1); case 3: return new Coordinate(-1,1); case 4: return new Coordinate(-1,-1); } return null; } public static void main(String[] args) { new GrapherTester().drawGraph(100, 100, 500, 500); } } Coordinate class so if any of you want to run and try it out. That is all you would need. public class Coordinate { float x; float y; boolean drawTo; boolean drawFrom; Coordinate(double x, double y) { this.x = (float) x; this.y = (float) y; drawFrom = true; drawTo = true; } Coordinate(double x, double y, boolean drawFrom, boolean drawTo) { this.x = (float) x; this.y = (float) y; this.drawFrom = drawFrom; this.drawTo = drawTo; } public double getX() { return x; } public double getY() { return y; } public boolean drawTo() { return drawTo; } public boolean drawFrom() { return drawFrom; } }

    Read the article

  • How to apply formula to cell based on IF condition in Excel

    - by Captain Comic
    Hi I have an Excel spreadsheed like the one shown below A B 10.02.2007 10 10.03.2007 12 Column A is date and B is price of share Now in another sreadsheet I need to create a new column called return In this column i need to place formula like = ln(B2/B1) but on condition that this formula is only applied date in column A is in range StartDate < currentDate < EndDate. So I want to apply my formula only to specific period say only to 2007 year have new column placed in another spreadsheet starting from given location say A1 Please suggest

    Read the article

  • Class architecture, no friends allowed

    - by Captain Comic
    The question of why there are no friends in C# has been extensively discussed. I have the following design problems. I have a class that has only one public function AddOrder(Order ord). Clients are allowed to call only this function. All other logic must be hidden. Order class is listening to market events and must call other other function of TradingSystem ExecuteOrder, so I have to make it public as well. Doing that I will allow clients of Trading system to call this function and I don't want that. class TradingSystem { // Trading system stores list of orders List<Order> _orders; // this function is made public so that Order can call ir public ExecuteOrder(Order ord) { } // this function is made public for external clients public AddOrder(OrderRequest ordreq) { // create order and pass it this order.OnOrderAdded(this); } } class Order { TradingSystem _ts; public void OnOrderAdded(TradingSystem ts) { _ts = ts; } void OnMarketEvent() { _ts.ExecuteOrder() } }

    Read the article

  • Could not find any resources appropriate for the specified culture or the neutral culture.

    - by Captain Comic
    I have created an assembly and later renamed it. Then i started getting runtime errors when calling toolsMenuName = resourceManager.GetString(resourceName); The resourceName variable is "enTools" at runtime. Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Jfc.TFSAddIn.CommandBar.resources" was correctly embedded or linked into assembly "Jfc.TFSAddIn" at compile time, or that all the satellite assemblies required are loadable and fully signed. The code: string resourceName; ResourceManager resourceManager = new ResourceManager("Jfc.TFSAddIn.CommandBar", Assembly.GetExecutingAssembly()); CultureInfo cultureInfo = new CultureInfo(_applicationObject.LocaleID); if(cultureInfo.TwoLetterISOLanguageName == "zh") { System.Globalization.CultureInfo parentCultureInfo = cultureInfo.Parent; resourceName = String.Concat(parentCultureInfo.Name, "Tools"); } else { resourceName = String.Concat(cultureInfo.TwoLetterISOLanguageName, "Tools"); } // EXCEPTION IS HERE toolsMenuName = resourceManager.GetString(resourceName); I can see the file CommandBar.resx included in the project, i can open it and can see the "enTools" string there.

    Read the article

  • Designing WCF interface: no out or ref parameters

    - by Captain Comic
    I have a WCF service and web client. Web service implements one method SubmitOrders. This method takes a collection of orders. The problem is that service must return an array of results for each order - true or false. Marking WCF paramters as out or ref makes no sense. What would you recommend? [ServiceContact] public bool SubmitOrders(OrdersInfo) [DataContract] public class OrdersInfo { Order[] Orders; }

    Read the article

  • StreamInsight on the Brain - can you help?

    - by sqlartist
    I just came across this guy who is once again in the news as the world's first cyborg. I read all about this research some years back when he implanted a chip into his arm to allow him to open doors in his research lab. Now, without really advancing the research he is claiming that a virus could be implanted onto these implanted devices. Captain Cyborg sidekick implants virus-infected chip - http://www.theregister.co.uk/2010/05/26/captain_cyborg_cyberfud/ This is of interest to me as I actually...(read more)

    Read the article

  • problem adding bumpmap to textured gluSphere in JOGL

    - by ChocoMan
    I currently have one texture on a gluSphere that represents the Earth being displayed perfectly, but having trouble figuring out how to implement a bumpmap as well. The bumpmap resides in "res/planet/earth/earthbump1k.jpg".Here is the code I have for the regular texture: gl.glTranslatef(xPath, 0, yPath + zPos); gl.glColor3f(1.0f, 1.0f, 1.0f); // base color for earth earthGluSphere = glu.gluNewQuadric(); colorTexture.enable(); // enable texture colorTexture.bind(); // bind texture // draw sphere... glu.gluDeleteQuadric(earthGluSphere); colorTexture.disable(); // texturing public void loadPlanetTexture(GL2 gl) { InputStream colorMap = null; try { colorMap = new FileInputStream("res/planet/earth/earthmap1k.jpg"); TextureData data = TextureIO.newTextureData(colorMap, false, null); colorTexture = TextureIO.newTexture(data); colorTexture.getImageTexCoords(); colorTexture.setTexParameteri(GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR); colorTexture.setTexParameteri(GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); colorMap.close(); } catch(IOException e) { e.printStackTrace(); System.exit(1); } // Set material properties gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR); gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST); colorTexture.setTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S); colorTexture.setTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T); } How would I add the bumpmap as well to the same gluSphere?

    Read the article

  • Integration error in high velocity

    - by Elektito
    I've implemented a simple simulation of two planets (simple 2D disks really) in which the only force is gravity and there is also collision detection/response (collisions are completely elastic). I can launch one planet into orbit of the other just fine. The collision detection code though does not work so well. I noticed that when one planet hits the other in a free fall it speeds backward and goes much higher than its original position. Some poking around convinced me that the simplistic Euler integration is causing the error. Consider this case. One object has a mass of 1kg and the other has a mass equal to earth. Say the object is 10 meters above ground. Assume that our dt (delta t) is 1 second. The object goes to the height of 9 meters at the end of the first iteration, 7 at the end of the second, 4 at the end of the third and 0 at the end of the fourth iteration. At this points it hits the ground and bounces back with the speed of 10 meters per second. The problem is with dt=1, on the first iteration it bounces back to a height of 10. It takes several more steps to make the object change its course. So my question is, what integration method can I use which fixes this problem. Should I split dt to smaller pieces when velocity is high? Or should I use another method altogether? What method do you suggest? EDIT: You can see the source code here at github:https://github.com/elektito/diskworld/

    Read the article

  • Doing a passable 4X game AI

    - by Extrakun
    I am coding a rather "simple" 4X game (if a 4X game can be simple). It's indie in scope, and I am wondering if there's anyway to come up with a passable AI without having me spending months coding on it. The game has three major decision making portions; spending of production points, spending of movement points and spending of tech points (basically there are 3 different 'currency', currency unspent at end of turn is not saved) Spend Production Points Upgrade a planet (increase its tech and production) Build ships (3 types) Move ships from planets to planets (costing Movement Points) Move to attack Move to fortify Research Tech (can partially research a tech i.e, as in Master of Orion) The plan for me right now is a brute force approach. There are basically 4 broad options for the player - Upgrade planet(s) to its his production and tech output Conquer as many planets as possible Secure as many planets as possible Get to a certain tech as soon as possible For each decision, I will iterate through the possible options and come up with a score; and then the AI will choose the decision with the highest score. Right now I have no idea how to 'mix decisions'. That is, for example, the AI wishes to upgrade and conquer planets at the same time. I suppose I can have another logic which do a brute force optimization on a combination of those 4 decisions.... At least, that's my plan if I can't think of anything better. Is there any faster way to make a passable AI? I don't need a very good one, to rival Deep Blue or such, just something that has the illusion of intelligence. This is my first time doing an AI on this scale, so I dare not try something too grand too. So far I have experiences with FSM, DFS, BFS and A*

    Read the article

  • Building a List of All SharePoint Timer Jobs Programmatically in C#

    - by Damon Armstrong
    One of the most frustrating things about SharePoint is that the difficulty in figuring something out is inversely proportional to the simplicity of what you are trying to accomplish.  Case in point, yesterday I wanted to get a list of all the timer jobs in SharePoint.  Having never done this nor having any idea of exactly how to do this right off the top of my head, I inquired to Google.  I like to think my Google-fu is fair to good, so I normally find exactly what I’m looking for in the first hit.  But on the topic of listing all SharePoint timer jobs all it came up with a PowerShell script command (Get-SPTimerJob) and nothing more. Refined search after refined search continued to turn up nothing. So apparently I am the only person on the planet who needs to get a list of the timer jobs in C#.  In case you are the second person on the planet who needs to do this, the code to do so follows: SPSecurity.RunWithElevatedPrivileges(() => {    var timerJobs = new List();    foreach (var job in SPAdministrationWebApplication.Local.JobDefinitions)    {       timerJobs.Add(job);    }    foreach (SPService curService in SPFarm.Local.Services)    {       foreach (var job in curService.JobDefinitions)       {          timerJobs.Add(job);       }     } }); For reference, you have the two for loops because the Central Admin web application doesn’t end up being in the SPFarm.Local.Services group, so you have to get it manually from the SPAdministrationWebApplication.Local reference.

    Read the article

  • Square game map rendered as sphere with OpenGL

    - by Roflha
    Okay so I have been trying to find a good way to do this for a while now and so far I have nothing. For a hobby project of mine I have created a finite voxel world (similar to minecraft), but as I said, mine is finite. When you reach the edge of it, you are sent to the other side. That is all working fine along with rendering the far side of the map, but I want to be able to render this grid as a sphere. Looking down from above, the world is a square. I basically want to be able to represent a portion of that square as a sphere, as if you were looking at a planet. Right now I am experimenting with taking a circular section of the map, and rendering that, but it look to flat (no curvature around the edges). My question then, is what would be the best way to add some curvature to the edges of a 2d circle to make it look like a hemisphere. However, I am not overly attached to this implementation so if somebody has some other idea for representing the square as a planet, I am all ears.

    Read the article

  • Building a List of All SharePoint Timer Jobs Programmatically in C#

    - by Damon
    One of the most frustrating things about SharePoint is that the difficulty in figuring something out is inversely proportional to the simplicity of what you are trying to accomplish.  Case in point, yesterday I wanted to get a list of all the timer jobs in SharePoint.  Having never done this nor having any idea of exactly how to do this right off the top of my head, I inquired to Google.  I like to think my Google-fu is fair to good, so I normally find exactly what I'm looking for in the first hit.  But on the topic of listing all SharePoint timer jobs all it came up with a PowerShell script command (Get-SPTimerJob) and nothing more. Refined search after refined search continued to turn up nothing. So apparently I am the only person on the planet who needs to get a list of the timer jobs in C#.  In case you are the second person on the planet who needs to do this, the code to do so follows: SPSecurity.RunWithElevatedPrivileges(() => {    var timerJobs = new List();    foreach (var job in SPAdministrationWebApplication.Local.JobDefinitions)    {       timerJobs.Add(job);    }    foreach (SPService curService in SPFarm.Local.Services)    {       foreach (var job in curService.JobDefinitions)       {          timerJobs.Add(job);       }     } }); For reference, you have the two for loops because the Central Admin web application doesn't end up being in the SPFarm.Local.Services group, so you have to get it manually from the SPAdministrationWebApplication.Local reference.

    Read the article

  • javascript won't execute nested for loop

    - by mcdwight6
    thanks in advance for all your help! i'm fairly new to javascript, but i have a fairly strong background in java, so i thought i would try it out on this project i'm working on. essentially, what i'm trying to do is read data from an xml file and create the html code for the page i'm making. i used the script from w3schools found here. I've altered it and gotten it to pull the data from my own xml and even to do the more basic generation of the html code i need. Here's the html i'm using inside <script> tags: var s = swDoc.getElementsByTagName("planet"); var plShowsArr = s[i].getElementsByTagName("show"); var plGamesArr = s[i].getElementsByTagName("videoGame"); for (i=0;i<s.length;i++) { // test section all works document.write("<div><table border = \"1\">"); document.write("<tr><td>"+ s[i].getElementsByTagName("showText")[0].childNodes[0].nodeValue + "</td><td>" + s[i].getElementsByTagName("showUrl")[0].childNodes[0].nodeValue + "</td></tr>"); document.write("<tr><td>" + s[i].getElementsByTagName("gameText")[0].childNodes[0].nodeValue + "</td><td>" + s[i].getElementsByTagName("gameUrl")[0].childNodes[0].nodeValue + "</td></tr>"); document.write("</tr></table></div>"); // end test section document.write("<div class=\"appearances-row\"><ol class=\"shows\">shows list"); for(j=0;j<plShows.length;j++){ document.write("nested for"); var showUrl = s[i].getElementsByTagName("showUrl")[j].childNodes[0].nodeValue; var showText = s[i].getElementByTagName("showText")[j].childNodes[0].nodeValue; document.write("<li><a href=\""+showUrl+"\">"+showText+"</a></li>"); } the code breaks at the nested for loop at the end, where it finished the document.write and prints "shows list" to the page, but then never gets to the document.write inside. if it helps, the xml contains a list of planets from the star wars universe organized like this: <planets> <planet> <planetName>planet</planetName> <description>some text</description> <appearances> <show> <showUrl>url</showUrl> <showText>hyperlink text</showText> </show> <videoGame> <gameUrl>url</gameUrl> <gameText>hyperlink text</gameText> </videoGame> </appearances> <locationsOfInterest> <location>location name</location> </locationsOfInterest> <famousCharactersRelatedTo> <character>a character</character> </famousCharactersRelatedTo> <externalLinks> <link> <linkUrl>url</linkUrl> <linkText>hyperlink text</linkText> </link> </externalLinks> </planet>

    Read the article

  • Building a List of All SharePoint Timer Jobs Programmatically in C#

    - by Damon
    One of the most frustrating things about SharePoint is that the difficulty in figuring something out is inversely proportional to the simplicity of what you are trying to accomplish.  Case in point, yesterday I wanted to get a list of all the timer jobs in SharePoint.  Having never done this nor having any idea of exactly how to do this right off the top of my head, I inquired to Google.  I like to think my Google-fu is fair to good, so I normally find exactly what I'm looking for in the first hit.  But on the topic of listing all SharePoint timer jobs all it came up with a PowerShell script command (Get-SPTimerJob) and nothing more. Refined search after refined search continued to turn up nothing. So apparently I am the only person on the planet who needs to get a list of the timer jobs in C#.  In case you are the second person on the planet who needs to do this, the code to do so follows: SPSecurity.RunWithElevatedPrivileges(() => {    var timerJobs = new List();    foreach (var job in SPAdministrationWebApplication.Local.JobDefinitions)    {       timerJobs.Add(job);    }    foreach (SPService curService in SPFarm.Local.Services)    {       foreach (var job in curService.JobDefinitions)       {          timerJobs.Add(job);       }     } }); For reference, you have the two for loops because the Central Admin web application doesn't end up being in the SPFarm.Local.Services group, so you have to get it manually from the SPAdministrationWebApplication.Local reference.

    Read the article

  • Silverlight databinding error

    - by Petezah
    I found an example online that explains how to perform databinding to a ListBox control using LINQ in WPF. The example works fine but when I replicate the same code in Silverlight it doesn't work. Is there a fundamental difference between Silverlight and WPF that I'm not aware of? Here is an Example of the XAML: <ListBox x:Name="listBox1"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Name}" FontSize="18"/> <TextBlock Text="{Binding Role}" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> Here is an example of my code behind: private void UserControl_Loaded(object sender, RoutedEventArgs e) { string[] names = new string[] { "Captain Avatar", "Derek Wildstar", "Queen Starsha" }; string[] roles = new string[] { "Hero", "Captain", "Queen of Iscandar" }; listBox1.ItemSource = from n in names from r in roles select new { Name = n, Role = r} }

    Read the article

  • Integrating legacy Ajax script in CakePHP

    - by octavian
    Hi, I have a legacy script that I would like to integrate in a cakephp app. The script makes use of $_POST and such and since I'm quite a noob I would need some help for the integration. Here is how the script looks like: THE JAVASCRIPT: prototype.js builder.js (these two are from the prototype fw) lib.js (makes a ajax requests to remote.php) THE PHP remote.php (contains FastJSON class and $_POST vars) if ($_POST['cmd'] == 'SAVETEAM' && $_POST['info']) { $INFO = json_decode(str_replace('\"', '"', $_POST['info'])); $nr = 1; $SORT = array($INFO->GK, $INFO->DEF, $INFO->MID, $INFO->FOR, $INFO->RZ); foreach ($SORT as $STD) foreach ($STD as $v) mysql_query("UPDATE players_teams SET fieldposition = ".$nr++." WHERE player_id = {$v->player_id} AND team_id = {$v->team_id}") or die(mysql_error()); // CAPTAION mysql_query("UPDATE `teams` SET captain = '{$_POST['captain']}' WHERE `user_id` = {$_POST['userid']}") or die(mysql_error()); } transfers.php (containts the form that uses the javascript and link to the JS) I have really no idea how to structure the files and calls in cakephp. Currently I have "Undefined index: cmd [APP/vendors/remote.php, line 230]" errors since I use $_POST['cmd'] (I placed remote.php in Vendors and included it, the JS was just included old fashion way, as a link and appears in the source code). How can I make this work? I'm sorry but I'm not familiar with AJAX and Cake... If you want a full look at the code, here it is: http://octavian.be/thecode.zip Thank you for reading and helping me out.

    Read the article

  • Getting dialogue snippets from text using regular expressions

    - by sheldon
    I'm trying to extract snippets of dialogue from a book text. For example, if I have the string "What's the matter with the flag?" inquired Captain MacWhirr. "Seems all right to me." Then I want to extract "What's the matter with the flag?" and "Seem's all right to me.". I found a regular expression to use here, which is "[^"\\]*(\\.[^"\\]*)*". This works great in Eclipse when I'm doing a Ctrl+F find regex on my book .txt file, but when I run the following code: String regex = "\"[^\"\\\\]*(\\\\.[^\"\\\\]*)*\""; String bookText = "\"What's the matter with the flag?\" inquired Captain MacWhirr. \"Seems all right to me.\""; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(bookText); if(m.find()) System.out.println(m.group(1)); The only thing that prints is null. So am I not converting the regex into a Java string properly? Do I need to take into account the fact that Java Strings have a \" for the double quotes?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >