Daily Archives

Articles indexed Saturday June 16 2012

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

  • Small-Scale Physics Engine

    - by user1276078
    I'm entering Android game development, and I already have a computer version of a game I want to publish. The thing is, I want to make this as good as it can be. With that said, I need a physics engine, really to only do one thing. That one thing is to make a parabolic movement of my main character as he's jumping in the air. Currently, my computer version simply makes the guy move up at a 45 degree angle, and as soon as it hits the ceiling, down at a 45 degree angle. I need a physics engine/library that would accomplish that, it has to be in java since that's my best language, it has to be 2D, and it has to be able to work on Android. Which physics engine/library could accomplish all of that?

    Read the article

  • How To Smoothly Animate From One Camera Position To Another

    - by www.Sillitoy.com
    The Question is basically self explanatory. I have a scene with many cameras and I'd like to smoothly switch from one to another. I am not looking for a cross fade effect but more to a camera moving and rotating the view in order to reach the next camera point of view and so on. To this end I have tried the following code: firstCamera.transform.position.x = Mathf.Lerp(firstCamera.transform.position.x, nextCamer.transform.position.x,Time.deltaTime*smooth); firstCamera.transform.position.y = Mathf.Lerp(firstCamera.transform.position.y, nextCamera.transform.position.y,Time.deltaTime*smooth); firstCamera.transform.position.z = Mathf.Lerp(firstCamera.transform.position.z, nextCamera.transform.position.z,Time.deltaTime*smooth); firstCamera.transform.rotation.x = Mathf.Lerp(firstCamera.transform.rotation.x, nextCamera.transform.rotation.x,Time.deltaTime*smooth); firstCamera.transform.rotation.z = Mathf.Lerp(firstCamera.transform.rotation.z, nextCamera.transform.rotation.z,Time.deltaTime*smooth); firstCamera.transform.rotation.y = Mathf.Lerp(firstCamera.transform.rotation.y, nextCamera.transform.rotation.y,Time.deltaTime*smooth); But the result is actually not that good.

    Read the article

  • Image 1 becomes image 2 with sliding effect from left to right?

    - by Paul
    I would like to show a second image appearing while a "door" is closing on my character. I've got my character in the middle of the screen and a door coming from the left. When the door passes my character, I would like to have this second image appearing little by little. So far, I've gotten by with fadingOut the character and then fadingIn my second image of the character at the same position when the door is completely closed, but I would like to have both of them at the same time. (the effect that image 1 becomes image 2 when the door is sliding from left to right). Would you know how to do this with Cocos2d? Here are the images : at first, the character is blue, and the door is coming from the left : Then, behind the black door, the character becomes red, but only behind this door, so it stays blue when the door is not on him, and will become completely red when the door passes the character : EDIT : with this code, the black door hides the red and blue rectangles : (And if i add each of my layers at a different depth, and only use GL_LESS, same thing) blue.position = ccp( size.width*0.5 , size.height/2 ); red.position = ccp( size.width*0.46 , size.height/2 ); black.position = ccp( size.width*0.1 , size.height/2 ); glEnable(GL_DEPTH_TEST); [batch addChild:red z:0]; [batch addChild:black z:2]; glDepthFunc(GL_GREATER); [batch addChild:blue z:1]; glDepthFunc(GL_LESS); id action1 = [CCMoveTo actionWithDuration:3 position:ccp(size.width,size.height/2)]; [black runAction: [CCSequence actions:action1, nil]];

    Read the article

  • why does setting stderr=subprocess.STDOUT fix a subprocess.check_output call?

    - by ShankarG
    I have a python script running on a small server that is called in three different ways - from within another python script, by cron, or by gammu-smsd (an SMS daemon with the wonderful mobile utility [gammu]). The script is for maintenance and contained the following kludge to measure used space on the system (presumably this is possible from within Python, but this was quick and dirty): reportdict['Used Space'] = subprocess.check_output(["df / | tail -1 | awk '{ print $5; }'"], shell=True)[0:-1] Oddly enough this line would only fail when the script was called by a shell script running from gammu-smsd. The line would fail with a CalledProcessError exception saying "returned exit status 2", even though the output attribute of the CalledProcessError object contained the correct output. The only command in the sequence of shell commands that would give such an error status would be awk, with status 2 indicating a fatal error. If the python script with this line was called by cron, by another python script, or from the command line, this line would work fine. I broke my head trying to fix the environment for the script, thinking this must be the problem. Finally though I put in stderr=subprocess.STDOUT, like so: reportdict['Used Space'] = subprocess.check_output(["df / | tail -1 | awk '{ print $5; }'"], stderr=subprocess.STDOUT, shell=True)[0:-1] This was a debug measure to help me figure out if some output was coming on stderr. But after this the script started working, even when called from gammu-smsd! Why might this be the case? I ask for future reference when using subprocess...

    Read the article

  • Lombok with Play 2

    - by Alex Povar
    What about Lombok integration with Play Framework 2? I really like Lombok it make my code more readable and less boilerplate. And Play Framework is wonderful too. But there is a great trouble in case if you going to mixup them. Main reason is that scala temlates in play project compiled before domain classes. So Lombok, which itself is compiler's hack do not generate accessors for that time. The question is: if it any ways to make it work? I found some discussions in Google Groups, but they do not provide any reasonable solution. So have you got any success with it? And.. why guys from Play Framework project do not provide some Lombok-like solution? Anyway Play is full of code-generation magic and shadow compiling... so, why not?

    Read the article

  • How to Extract data asocaited with attribute of XML file using python 3.2

    - by user1460383
    I have this xml format..... <event timestamp="0.447463" bustype="LIN" channel="LIN 1"> <col name="Time"/> <col name="Start of Frame">0.440708</col> <col name="Channel">LIN 1</col> <col name="Dir">Tx</col> <col name="Event Type">LIN Frame (Diagnostic Request)</col> <col name="Frame Name">MasterReq_DB</col> <col name="Id">3C</col> <col name="Data">81 06 04 04 FF FF 50 4C</col> <col name="Publisher">TestMaster (simulated)</col> <col name="Checksum">D3 &quot;Classic&quot;</col> <col name="Header Duration">2.090 ms (40.1 bits)</col> <col name="Resp. Duration">4.688 ms (90.0 bits)</col> <col name="Time difference">0.049987</col> <empty/> </event> In above xml, i need to extract data associated with attribute 'name' Am able to get all names but am unable to fetch MasterReq_DB< field Please help me ... Thanks in advance

    Read the article

  • How do I do an AJAX post to a url within a class library but not the same IIS Web Application?

    - by Mark Adesina
    I have been working with ajax and there has been no problems below is how my ajax post code look like: $.ajax({ type: "POST", url: '<%=ResolveUrl("TodoService.asmx/CreateNewToDo")%>', data: jsonData, contentType: "application/json; charset=utf-8", datatype: "json", success: function () { //if (msg.d) { $('#ContentPlaceHolder1_useridHiddenField').val(""); $('#ContentPlaceHolder1_titleTextBox').val(""); $('#ContentPlaceHolder1_destTextBox').val(""); $('#ContentPlaceHolder1_duedateTextBox').val(""); alert('Your todo has been saved'); // } }, error: function (msg) { alert('There was an error processing your request'); } }); However, the problem came up when I try to get the url to a webservice that is located in a class library within the same solution.

    Read the article

  • How to populate JList with data from another JList

    - by Zhen Le
    I have a MySQL database which contains data i would like to populate into a JList in my java program. I have two JList, one which is fill with Events Title and the second is to be fill with Guest Name. What i would like is when the user click on any of the Events Title, the second JList will show all the Guest Name that belong to that Event. I have already successfully populate the first JList with all the Events Title. What I'm having trouble with is when the user click on the Events Title, the Guests Name will show twice on the second JList. How can i make it to show only once? Here is what i got so far... Java Class private JList getJListEvents() { if (jListEvents == null) { jListEvents = new JList(); Border border = BorderFactory.createTitledBorder(BorderFactory.createBevelBorder(1, Color.black, Color.black), "Events", TitledBorder.LEFT, TitledBorder.TOP); jListEvents.setBorder(border); jListEvents.setModel(new DefaultListModel()); jListEvents.setBounds(new Rectangle(15, 60, 361, 421)); Events lEvents = new Events(); lEvents.loadEvents(jListEvents); jListEvents.addListSelectionListener(new ListSelectionListener(){ public void valueChanged(ListSelectionEvent e){ EventC eventC = new EventC(); //eventC.MonitorRegDetailsInfo(jListEvents, jTextFieldEventName, jTextFieldEventVenue, jTextFieldEventDate, jTextFieldEventTime, jTextAreaEventDesc); //eventC.MonitorRegPackageInfo(jListEvents, jTextFieldBallroom, jTextFieldBallroomPrice, jTextFieldMeal, jTextFieldMealPrice, jTextFieldEntertainment, jTextFieldEntertainmentPrice); eventC.MonitorRegGuest(jListEvents, jListGuest); } }); } return jListEvents; } Controller Class public void MonitorRegGuest(JList l, JList l2){ String event = l.getSelectedValue().toString(); Events retrieveGuest = new Events(event); retrieveGuest.loadGuests(l2); } Class with all the sql statement public void loadGuests(JList l){ ResultSet rs = null; ResultSet rs2 = null; ResultSet rs3 = null; MySQLController db = new MySQLController(); db.getConnection(); String sqlQuery = "SELECT MemberID FROM event WHERE EventName = '" + EventName + "'"; try { rs = db.readRequest(sqlQuery); while(rs.next()){ MemberID = rs.getString("MemberID"); } } catch (SQLException e) { e.printStackTrace(); } String sqlQuery2 = "SELECT GuestListID FROM guestlist WHERE MemberID = '" + MemberID + "'"; try { rs2 = db.readRequest(sqlQuery2); while(rs2.next()){ GuestListID = rs2.getString("GuestListID"); } } catch (SQLException e) { e.printStackTrace(); } String sqlQuery3 = "SELECT Name FROM guestcontact WHERE GuestListID = '" + GuestListID + "'"; try { rs3 = db.readRequest(sqlQuery3); while(rs3.next()){ ((DefaultListModel)l.getModel()).addElement(rs3.getString("Name")); } } catch (SQLException e) { e.printStackTrace(); } db.terminate(); } Thanks in advance!

    Read the article

  • How to convert a BufferedImage to 8 bit?

    - by Zach Sugano
    I was looking at the ImageConverter class, trying to figure out how to convert a BufferedImage to 8-bit color, but I have no idea how I would do this. I was also searching around the internet and I could find no simple answer, they were all talking about 8 bit grayscale images. I simply want to convert the colors of an image to 8 bit... nothing else, no resizing no nothing. Does anyone mind telling me how to do this.

    Read the article

  • Set Icon in Button LWUIT Java ME

    - by Muhamad Burhanudin
    Please help me, to set icon button : /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package tajwed; import javax.microedition.midlet.*; import com.sun.lwuit.*; import com.sun.lwuit.animations.*; import com.sun.lwuit.events.*; import com.sun.lwuit.layouts.BoxLayout; import com.sun.lwuit.plaf.*; import java.io.IOException; import java.util.Hashtable; /** * @author Muhamad BUrhanudin */ public class tajwedMidlet extends MIDlet implements ActionListener{ Form mHomeForm; Form mAwayForm; Form mMenuTajwid; Command mExitCommand; Button btMenu; Button btNunSukun, btMimSukun, btNunTasjid; Button btLamtarif, btIdgham, btMaad, btRaa; Button btHelp; Button btExit; Command mBackCommand; public void startApp() { Display.init(this); installTheme(); createUI(); mHomeForm.show(); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void actionPerformed(ActionEvent ae) { mAwayForm.setTransitionInAnimator( Transition3D.createCube(400, false)); mMenuTajwid.setTransitionInAnimator( Transition3D.createCube(400, false)); mMenuTajwid.setTransitionOutAnimator( Transition3D.createCube(400, true)); mAwayForm.setTransitionOutAnimator( Transition3D.createCube(400, true)); if ((ae.getSource()==btMenu)|| (ae.getSource()==btHelp)) { //mAwayForm.show(); if(ae.getSource()== btMenu) { mMenuTajwid.show(); } } else if (ae.getSource() == mBackCommand) { mHomeForm.show(); } else if ((ae.getCommand() == mExitCommand) || (ae.getSource()== btExit)) notifyDestroyed(); } private void installTheme() { UIManager uim = UIManager.getInstance(); Hashtable ht = new Hashtable(); ht.put("sel#" + Style.BG_COLOR, "ffffff"); ht.put(Style.BG_COLOR, "d5fff9"); ht.put(Style.FG_COLOR, "000000"); uim.setThemeProps(ht); } private void createUI() { // Set up screen for transitions. mAwayForm = new Form("Away"); mAwayForm.addComponent(new Label("Choose Back to return to the home screen.")); mMenuTajwid = new Form("MENU DASAR TAJWID"); // mMenuTajwid mMenuTajwid.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); btNunSukun = new Button("Hukum Nun Sukun & Tanwin"); btNunSukun.addActionListener(this); mMenuTajwid.addComponent(btNunSukun); btMimSukun = new Button("Hukum Mim Sukun"); btMimSukun.addActionListener(this); mMenuTajwid.addComponent(btMimSukun); btNunTasjid = new Button("Hukum Nun Tasydid & Min Tasydid"); btNunTasjid.addActionListener(this); mMenuTajwid.addComponent(btNunTasjid); btLamtarif = new Button("Hukum Laam Ta'rief"); btLamtarif.addActionListener(this); mMenuTajwid.addComponent(btLamtarif); btIdgham = new Button("Idgham"); btIdgham.addActionListener(this); mMenuTajwid.addComponent(btIdgham); btMaad = new Button("Maad"); btMaad.addActionListener(this); mMenuTajwid.addComponent(btMaad); btRaa = new Button("Raa'"); btRaa.addActionListener(this); mMenuTajwid.addComponent(btRaa); mBackCommand = new Command("Back"); mMenuTajwid.addCommand(mBackCommand); mMenuTajwid.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier. // Set up main screen. mHomeForm = new Form("Java Mobile Learning"); mHomeForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS)); btMenu = new Button("TAJWID LEARNING"); btMenu.addActionListener(this); mHomeForm.addComponent(btMenu); try { btHelp = new Button("HELP",Image.createImage("/help.ico")); btHelp.addActionListener(this); mHomeForm.addComponent(btHelp); } catch(IOException e) { } btExit = new Button("EXIT"); btExit.addActionListener(this); mHomeForm.addComponent(btExit); mExitCommand = new Command("Keluar"); mHomeForm.addCommand(mExitCommand); mHomeForm.addCommandListener(this); // Use setCommandListener() with LWUIT 1.3 or earlier. } }

    Read the article

  • iOS: click counter for row in tableview

    - by roger.arliner21
    I am developing and tableView in which in each row I have to display the click counter and row number.Each cell must have an initial click counter value of 0 when application is initialized. Then increment the click counter value within a cell whenever a user clicks on the cell. I have take 26 fixed rows. I have taken tableData.plist file as in the attached image. I am initializing the self.dataArray with the plist . Now I want to do implementation in the didSelectRowAtIndexPath delegate method,if any row is tapped that row's click counter should increment. - (void)viewDidLoad { [super viewDidLoad]; NSString *path = [[NSBundle mainBundle] pathForResource:@"tableData" ofType:@"plist"]; self.dataArray = [NSMutableArray arrayWithContentsOfFile:path];//array initialized with plist } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.dataArray count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *kCustomCellID = @"MyCellID"; UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(160.0f, 2.0f, 30.0f, 20.0f)]; UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(160.0f, 24.0f, 30.0f, 30.0f)]; label2.textColor = [UIColor grayColor]; UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:kCustomCellID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:kCustomCellID] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } if([self.dataArray count]>indexPath.row) { label1.text = [[self.dataArray objectAtIndex:indexPath.row] objectForKey:@"Lable1"]; label2.text =[[self.dataArray objectAtIndex:indexPath.row] objectForKey:@"Lable2"]; } else { label1.text = @""; label2.text =@""; } [cell.contentView addSubview:label1]; [cell.contentView addSubview:label2]; [label1 release]; [label2 release]; return cell; } #pragma mark - #pragma mark Table view delegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //implementation for row counter incrementer. }

    Read the article

  • treeview size in wpf

    - by AComputert
    please let me know how can I re size height of tree view control when screen resolution is changed? please see this code: <TreeView Name="treeView1" Height="150" VerticalAlignment="Top"> <TreeViewItem Header="Root" IsExpanded="True"> <TreeViewItem Header="Item 1"></TreeViewItem> <TreeViewItem Header="Item 2"></TreeViewItem> <TreeViewItem Header="Item 3"></TreeViewItem> <TreeViewItem Header="Item 4"></TreeViewItem> <TreeViewItem Header="Item 5"></TreeViewItem> <TreeViewItem Header="Item 6"></TreeViewItem> <TreeViewItem Header="Item 7"></TreeViewItem> <TreeViewItem Header="Item 8"></TreeViewItem> <TreeViewItem Header="Item 9"></TreeViewItem> <TreeViewItem Header="Item 10"></TreeViewItem> <TreeViewItem Header="Item 11"></TreeViewItem> <TreeViewItem Header="Item 12"></TreeViewItem> <TreeViewItem Header="Item 13"></TreeViewItem> <TreeViewItem Header="Item 14"></TreeViewItem> <TreeViewItem Header="Item 15"></TreeViewItem> <TreeViewItem Header="Item 16"></TreeViewItem> <TreeViewItem Header="Item 17"></TreeViewItem> <TreeViewItem Header="Item 18"></TreeViewItem> <TreeViewItem Header="Item 19"></TreeViewItem> <TreeViewItem Header="Item 20"></TreeViewItem> <TreeViewItem Header="Item 21"></TreeViewItem> <TreeViewItem Header="Item 22"></TreeViewItem> <TreeViewItem Header="Item 23"></TreeViewItem> <TreeViewItem Header="Item 24"></TreeViewItem> <TreeViewItem Header="Item 24"></TreeViewItem> </TreeViewItem> </TreeView> in some screen resolutions i can see all nodse and in some resolutions i see a scroll bar. I want to see all nodes without scroll bar.

    Read the article

  • Problems when trying to submit iphone app

    - by ryug
    I'm a fairly new developer. When I try to submit my iphone app with xcode, I've got error as follows; Code Sign error: The identity 'iPhone Distribution' doesn't match any valid, non-expired certificate/private key pair in the default keychain After searching, I found out that I have to create a Distribution Provisioning Profile. However, my distribution provisioning profile doesn't work, even though my Development Provisioning Profile works perfectly. Could someone please help me with this problem? I'm stuck all day... and please forgive me that my English is not great. Thank you in advance.

    Read the article

  • Error when opening .tar.gz via Shell to install Apache Maven

    - by adamsquared
    Thank you in advance for the help. My Goal: To install apache maven per its websites instructions (http://maven.apache.org/download.html), in order to install the JUNG package according to its install instructions (http://sourceforge.net/apps/trac/jung/wiki/JUNGManual), so I can use the JUNG classes in various Java GUIs. The Problem: I get an error message when I try to extract the apache-maven .gz (install?) file in shell. Background: I'm trying to install the JUNG (http://jung.sourceforge.net/index.html) package to my system's Java, so I can write object-oriented code using various GUIs (Ecliplse, Dr. Java) using the classes in JUNG. I don't understand how the building/installing process works, and how I can get what I build/install to work on various GUIs and the command line. I'm new to shell and the command line, and mostly have experience using a simple IDE (DrJava, Python IDLE, R GUI) to write and compile object-oriented code. Machine: Mac OSX 10.5.8 32-bit. The Instructions: For the maven building Extract the distribution archive, i.e. apache-maven-3.0.4-bin.tar.gz to the directory you wish to install Maven 3.0.4. These instructions assume you chose /usr/local/apache-maven. The subdirectory apache-maven-3.0.4 will be created from the archive. ... for the JUNG installation Appendix: How to Build JUNG This is a brief intro to building JUNG jars with maven2 (the build system that JUNG currently uses). First, ensure that you have a JDK of at least version 1.5: JUNG 2.0+ requires Java 1.5+. Ensure that your JAVA_HOME variable is set to the location of the JDK. On a Windows platform, you may have a separate JRE (Java Runtime Environment) and JDK (Java Development Kit). The JRE has no capability to compile Java source files, so you must have a JDK installed. If your JAVA_HOME variable is set to the location of the JRE, and not the location of the JDK, you will be unable to compile. Get Maven Download and install maven2 from maven.apache.org: http://maven.apache.org/download.html At time of writing (early December 2009), the latest version was maven-2.2.1. Install the downloaded maven2 (there are installation instructions on the Maven website). Follow the installation instructions and confirm a successful installation by typing 'mvn --version' in a command terminal window. Get JUNG ... What I Did: I downloaded the file apache-maven-2.2.1-bin.tar.gz. The JUNG website specified to use apache maven 2. I wanted to stick to the recommended installation instructions, but I couldn't get to /usr on my GUI (i've noticed you click on the MacHD symbol on the desktop its missing several directories/folders that you can see using the shell using the ls command at root directory I couldn't find a way to access the file using my mac GUI. Therefore, I used the shell to navigate to the root directory and then to /usr/local, and used the mkdir command to make the directory apache-maven and entered it. I then moved the file using the mv command. Next I tried extracting the file using tar -zxvf apache-maven-2.2.1-bin.tar.gz. The Error Message: tar: apache-maven-2.2.1/direcoryandfile: Cannot open: No such file or directory ... apache-maven-2.2.1/lib/ext: Cannot mkdir: No such file or directory apache-maven-2.2.1/lib/ext/README.txt tar: apache-maven-2.2.1/lib/ext/README.txt: Cannot open: No such file or directory tar: Error exit delayed from previous errors From what I can tell the archive file is missing some directories or something. I tried deleting the file, redownloading the .tar.gz file from a different mirror and repeating the process. Same result. Thanks again for the help

    Read the article

  • How to stop calling the Activity again when device orientation is changed??

    - by user1460323
    My app uses Barcode Scanner. I want to launch the scanner when I open the app so I have it in the onCreate method. The problem is that if I have it like that, when I turn the device it calls again onCreate and calls another scanner. Also I have the first activity that calls the scanner. it has a menu so if he user presses back, it goes to that menu. If I turn the screen on that menu, it goes to barcode scanner again. To solve it I have a flag that indicates if it is the first time I call the scanner, if it's not I don't call it again. Now the problem is that if I go out of the app and go in again it doesn't go to the scanner, it goes to the menu, becasuse is not the first time I call it. Any ideas?? Is there a way to change the flag when I go out of my main activity or any other solution?? My code. private static boolean first = true; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); integrator = new IntentIntegrator(this); if (first) { first = false; integrator.initiateScan(); } }

    Read the article

  • How to set parameters of CGContextAddArcToPoint method using a slider

    - by Manish Sahni
    am making an app in which i have to control a smile of a face like graphics. For example if i slide the slider down(to a value less than middle) it should give the arc a sad face(like :-( ) effect and if i slide the slider up the arc should give the effect of smile(like :-) ).initially lips are like :-| . I need to control the lips which is an arc using a slider? smileSliderViewController.h #import <UIKit/UIKit.h> @interface smileSliderViewController : UIViewController { IBOutlet UISlider *slider; } -(IBAction)valueChange:(id)sender; @end smileSliderViewController.m #import "smileSliderViewController.h" //#import "smile.h" @implementation smileSliderViewController -(IBAction)valueChange:(id)sender { int value = (int)(slider.value); if(value>0 && value<25) { //value--; CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); CGFloat components[] = {0.0,0.0,1.0,1.0}; CGColorRef color = CGColorCreate(colorspace, components); CGContextSetStrokeColorWithColor(context, color); CGContextMoveToPoint(context, 120,180); CGContextAddArcToPoint(context, 190 , 170, 270, 200, 0 ); CGContextStrokePath(context); } } smile.h #import <UIKit/UIKit.h> #import "smile.m" @interface smile : UIView { IBOutlet UISlider *slider; } @end smile.m #import "smile.h" #import "smileSliderViewController.h" @implementation smile - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code } return self; } - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); //CGContextSetStrokeColor(context, [UIColor redColor].CGColor); CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); CGFloat components[] = {0.0,0.0,1.0,1.0}; CGColorRef color = CGColorCreate(colorspace, components); CGContextSetStrokeColorWithColor(context, color); CGRect rectangle = CGRectMake(60, 20, 200,200); CGContextAddEllipseInRect(context, rectangle); CGContextStrokePath(context); /*CGRect rectangle1 = CGRectMake(130,170,50,10); CGContextAddRect(context,rectangle1); CGContextStrokePath(context);*/ /*CGContextMoveToPoint(context,100,200); CGContextAddArcToPoint(context,120,150,400,150,70 ); CGContextStrokePath(context);*/ /*CGContextMoveToPoint(context, 100,100); CGContextAddArcToPoint(context, -100,200, -400,200, 80); CGContextStrokePath(context);*/ CGContextSetStrokeColorWithColor(context,color); CGRect rectangle2 = CGRectMake(80, 90, 50, 8); CGContextAddEllipseInRect(context, rectangle2); CGContextStrokePath(context); CGContextSetStrokeColorWithColor(context,color); CGRect rectangle3 = CGRectMake(180, 90, 50, 8); CGContextAddEllipseInRect(context, rectangle3); CGContextStrokePath(context); CGContextSetStrokeColorWithColor(context,color); CGContextMoveToPoint(context, 155,120); CGContextAddLineToPoint(context, 155,160); CGContextStrokePath(context); /*CGContextSetStrokeColorWithColor(context, color); CGRect rectangle4 = CGRectMake(130, 180, 50,8); CGContextAddEllipseInRect(context, rectangle4); CGContextStrokePath(context);*/ /*CGContextSetStrokeColorWithColor(context,color); CGContextMoveToPoint(context, 120,180); CGContextAddLineToPoint(context, 190,180); CGContextStrokePath(context);*/ int value = (int)(slider.value); if(value == 25) { CGContextMoveToPoint(context, 120,180); CGContextAddArcToPoint(context, 190 , 180, 250 , 180, 0 ); CGContextStrokePath(context); } }

    Read the article

  • is it possible to use a python scrapper in a website?

    - by Tom
    I want to scrap a website and use that content in a website of my own. I am just wondering if that can be done with python 2.7, and if so how? If not, do I have to use JavaScript to scrap it? And do you have a good place to learn how to do that or good libraries for it. For those of you wondering, the website I am scrapping is legal, and they allow for this to be done. I have searched all over but apparently nobody tries to implement these scrappers that they write. I can write a web scrapper in python just fine. Say my scrapper scraps a name from a wikipedia page (John Doe for example), how can I use that name that I get in my website? Another update, I have found pjsrape and PhantomJS. I have only found one stack overflow post and the github examples with aren't very intuitive. If anybody has any experience or better ways to do it I would very much appreciate it

    Read the article

  • WP7 - selling extensions

    - by coder89
    I'm trying to create some application for Windows Phone = 7.1 During plannin my work and specyfiong technical requirements I've come across one problem. I wan't to have free application with basic functionality. And then it should be extendable with some non-free extensions (dlls?, databases?, SaaS?) Is it possible at the moment to use some MS api/app/etc. to be able to publish such extensions and sell them? What is the best way to do this if there is more than one solution? Thank you for any help.

    Read the article

  • Sublime Text 2 Keyboard shortcut to open file in Chrome/firefox in windows

    - by samdroid
    I followed the instruction for windows 7 to setup chrome. No luck! { "cmd":["C:\Program Files (x86)\Google\Chrome\Application", "$C:\Users\gmu\Desktop\June_15_2012"] } after entering the file location/path under what format should I have to save. I am a noobie. sorry to ask this question. Anything helps! If I press f7 getting the following message Error trying to parse build system: Invalid escape in C:\Users\gmu\AppData\Roaming\Sublime Text2\Packages\User\Chrome.sublime-build:2:9 Thanks

    Read the article

  • Filtering string in Python

    - by Ecce_Homo
    I am making algorithm for checking the string (e-mail) - like "E-mail addres is valid" but their are rules. First part of e-mail has to be string that has 1-8 characters (can contain alphabet, numbers, underscore [ _ ]...all the parts that e-mail contains) and after @ the second part of e-mail has to have string that has 1-12 characters (also containing all legal expressions) and it has to end with top level domain .com EDIT email = raw_input ("Enter the e-mail address:") length = len (email) if length > 20 print "Address is too long" elif lenght < 5: print "Address is too short" if not email.endswith (".com"): print "Address doesn't contain correct domain ending" first_part = len (splitting[0]) second_part = len(splitting[1]) account = splitting[0] domain = splitting[1] for c in account: if c not in "abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.": print "Invalid char", "->", c,"<-", "in account name of e-mail" for c in domain: if c not in "abcdefghijklmopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.": print "Invalid char", "->", c,"<-", "in domain of e-mail" if first_part == 0: print "You need at least 1 character before the @" elif first_part> 8: print "The first part is too long" if second_part == 4: print "You need at least 1 character after the @" elif second_part> 16: print "The second part is too long" else: # if everything is fine return this print "E-mail addres is valid" EDIT: After reproting what is wrong with our input, now I need to make Python recognize valid address and return ("E-mail adress is valid") This is the best i can do with my knowledge....and we cant use regular expressions, teacher said we are going to learn them later.

    Read the article

  • CherryPy always returning HTTP 200 [closed]

    - by DarkArctic
    I'm having a bit of a problem when browsing to a non-existent resource. I get a response code of 200 instead of 404. I'm using the MethodDispatcher and I have a class that overloads the __getattr__ method to instantiate a resource if a child exists or to return AttributeError if one doesn't. My class is always returning the AttributeError correctly, but the data I actually get is always from the last good resource. Here's a simplified (except for __getattr__) version of my class: class BaseResource(object): exposed = True def __init__(self, name): self.children = [] # Pretend this has child resources def __getattr__(self, name): if name in self._children: uuid, application, obj_type, server = self._children[name] try: resource = getattr(app[application], obj_type) except AttributeError as e: raise cherrypy.HTTPError(500, e) return resource(uuid) else: raise AttributeError('Child with name \'{}\' could not be found.'.format(name)) def GET(self): cherrypy.log.error('*** {} not found, raising AttributeError'.format(name)) return 'GET request for {}'.format(self._name) So fetching I get the following when I browse to the following resources: http://localhost:8000/users - This resource exists, so it returns it correctly. http://localhost:8000/users/fake - This returns the "users" resource giving an HTTP 200. http://localhost:8000/users/fake/reallyfake - This returns the "users" resource again. So my question is, where can I start looking to find out why my code isn't returning a 404 for a non-existent resource. I'm sure I've done something wrong, but I'm not sure what. Whatever I did wrong I've undone and I'm now getting a 404 returned correctly. I'm sorry I can't give any detail on what the issue was, but I'm honestly not sure what I did.

    Read the article

  • Fade unfocused GNU Emacs frame (X window)

    - by Mischa Arefiev
    Is it possible to make GNU Emacs 24 dim unfocused windows a bit? For example, I can set my rxvt-unicode clients to become darker when their windows don't have focus with this string in ~/.Xdefaults: URxvt*fading: 50 It greatly reduces discomfort when you have a lot of terminal windows on 2+ monitors. I would like a similar feature in Emacs, but couldn't google up anything. Here is how it looks like with urxvt (png, 1.43 MB)

    Read the article

  • How to setup apache multi-site with multi-domain on ec2

    - by Esh
    Say I have two document roots domain1/ and domain2/ I know how to access those two roots from my own computer if they are hosted on the same computer. My question is that if I want to do the same thing on my ec2 server, how should I configure my elastic ips to those two roots? I know by default the elastic ip will only associate to the root with the name localhost(127.0.0.1). Anyone could give me a detailed answer? An example would help, thanks!

    Read the article

  • vsftpd: ECONNREFUSED with "allow_writeable_chroot=YES"

    - by heinob
    When setting up vsftpd I am trapped. When I leave the ftpuser's home directory without write permission I can login and all is fine despite the fact, that I cannot write (of course). When I add write permission I get something like cannot change to directory with write permissions if user is chrooted Then I added allow_writeable_chroot=YES to vsftpd.conf. But now I get ECONNREFUSED - Connection refused by server I am lost. What am I doing wrong?

    Read the article

  • How to run a DHCP service on Windows 7 Home

    - by Joshua Lim
    I'm trying to setup a DHCP server on Windows 7 Home, tried using a couple of freeware which I found on the Internet but none seemed to work. What I did: On the Windows 7 machine which I install the DHCP Server with the range 192.168.1.12-192.168.1.256. I set the Gigabit Ethernet adapter to a static IP address of 192.168.1.11 and subnet mask of 255.255.255.0. When I did an IP config, it showed. Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Broadcom NetLink (TM) Gigabit Ethernet Physical Address. . . . . . . . . : 8C-73-6E-75-A7-56 DHCP Enabled. . . . . . . . . . . : No Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::196d:b6bb:8f93:2555%12(Preferred) IPv4 Address. . . . . . . . . . . : 192.168.1.11(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1 fec0:0:0:ffff::2%1 fec0:0:0:ffff::3%1 NetBIOS over Tcpip. . . . . . . . : Enabled I connected another Window 7 machine to the "DHCP server" using a cross cable and set network adapter on that machine to automatically detect IP address. The client fails to acquire the correct IP address from the DHCP server and showed the autoconfigured IPv4 address instead. Here's the information returned by config /all on the client machine. Ethernet adapter Local Area Connection: Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Atheros AR8152/8158 PCI-E Fast Ethernet Controller (NDIS 6.20) Physical Address. . . . . . . . . : 54-04-A6-40-96-4B DHCP Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes Link-local IPv6 Address . . . . . : fe80::4885:4082:5572:5a85%12(Preferred) Autoconfiguration IPv4 Address. . : 169.254.90.133(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.0.0 Default Gateway . . . . . . . . . : DHCPv6 IAID . . . . . . . . . . . : 341050534 DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-17-54-78-12-00-08-CA-46-4C-5A DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1 fec0:0:0:ffff::2%1 fec0:0:0:ffff::3%1 NetBIOS over Tcpip. . . . . . . . : Enabled DHCP client are running on both machines. I've tried many times but failed. Googling also returned no useful information for my scenario. Have I missed out any step? Thanks.

    Read the article

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