I'm trying to add an image inside a circular CAShapeLayer so i started by creating a circle like so :

let circleContainer = UIBezierPath(arcCenter: pCenter, radius: radius - 10, startAngle: 0, endAngle: CGFloat(M_PI * 2), clockwise: true)
let imageSubLayer = CAShapeLayer()
imageSubLayer.path = circleContainer.CGPath

self.view.layer.addSublayer(imageSubLayer)

then to add the image i did:

let imageLayer = CALayer()
imageLayer.contents = UIImage(named: "pic")?.CGImage
imageSubLayer.addSublayer(imageLayer)

//I've also tried adding the image directly to the circular CAShapeLayer like so but without any success:
imageSubLayer.contents = UIImage(named: "pic")?.CGImage

the problem is: the circleContainer is always showing black color when i run the app (see image below). what am i doing wrong ? thanks in advance!

enter image description here

I load a webpage to WKWebview using NSURLRequestReturnCacheDataElseLoad cache policy.There is no need for me to clear the cache unless the server explicitly tells me to do it.But I am facing trouble clearing the cache , once the server tells me to do it.

Most of the answers and articles suggests that removeAllCachedResponses works , though there are several complaints circulating around about NSURLCache not working properly with NSURLSession or UIWebView .I couldn't get it to work for me either in iOS 8.3 or 9.3 simulators.

So I used the following code to clear all the files in cache directory Programatically. The cached files of website that I use in my WKWebview resides in Application/Cache/bundleidentifier. Though , I try and delete all the files I can.When I run the code , I get an error trying to delete /Snapshots .Now this made me wonder what are some other files in cache directory that I should not tamper with ? I know the SDWebImage cache and few other files resides in this directory.But, I need to clear the SDWebImage cache anyways.

Here is the code I used to clear cache directory :

public func clearCache(){
    let cacheURL =  NSFileManager.defaultManager().URLsForDirectory(.CachesDirectory, inDomains: .UserDomainMask).first!
    let fileManager = NSFileManager.defaultManager()
    do {
        // Get the directory contents urls (including subfolders urls)
        let directoryContents = try NSFileManager.defaultManager().contentsOfDirectoryAtURL( cacheURL, includingPropertiesForKeys: nil, options: [])
        for file in directoryContents {
            do {
                  try fileManager.removeItemAtURL(file)
                }
                catch let error as NSError {
                    debugPrint("Ooops! Something went wrong: \(error)")
                }

            }
    } catch let error as NSError {
        print(error.localizedDescription)
    }
}

Now , is this a good practice ? Are there any obvious methods that I am missing to achieve the same?

I created an iOS app for a small company approximately one year ago. It is a small app to help the employees, so the easiest method of distribution seemed to be ad hoc. I simply had the .ipa file available for download and had the users trust my developer account.

I accidentally forgot to renew my apple developer account, and now the app will not open on anyone's phone.

I'm trying to figure out the best method to solve this issue. If I renew my developer account, would I have to redistribute the app to everyone?

Thanks in advance for help.

Is there any way to handle the ios application when it is killed or any way to open my app programatically in ios 9.

I want to develop a simple app about gravity as an exercise. But I have no idea about gravity in iOS. Could you help me?

The app (game) I want to develop should be like this: At first there is a ball on the top of the display. After the player clicked the ball, it starts to falling down. And everytime it falls down the display, it comes back on the top of the screen, just an endless fall. The next thing I want is speeding up his speed. Lets say, every 10 time he appears at the top again, he gains +1 speed.

I have no Idea how I can code this. I would be really happy, if you would just give me all the stuff I need, with explanation, so I can code it "myself" and still learn something.

I am trying to have all the users' locations stored in cloudkit, then downloaded by each device. I marked on the code in storeLocation where I get the error:

"Cannot convert value of type '(NSError?, [CKRecord]?)' (aka '(Optional, Optional>)') to expected argument type '(error: NSError?, records: [CKRecord]?) -> Void'"

//saves location in cloud kit //currently works well:

var locArray = [CKRecord]()
func storeLocation(location:CLLocation) {
        let locationRecord = CKRecord(recordType: "location")
        locationRecord.setObject(location, forKey: "location")
        let publicData = CKContainer.defaultContainer().publicCloudDatabase
        publicData.saveRecord(locationRecord) { (records, error) in
            if error != nil {
                print("error saving locations: \(error)")
            } else {
                print("Locations saved: \(records)")
                loadLocation((error, self.locArray)) //where I get error******
            }
        }
    }

//fetches location from cloud kit:

func loadLocation(completion: (error:NSError?, records:[CKRecord]?) -> Void)
{
    let query = CKQuery(recordType: "Location", predicate: NSPredicate(value: true))
    CKContainer.defaultContainer().publicCloudDatabase.performQuery(query, inZoneWithID: nil){
        (records, error) in
        if error != nil {
            print("error fetching locations")
            completion(error: error, records: nil)
        } else {
            print("found locations: \(records)")
            completion(error: nil, records: records)
        }
    }
}

I can detect a collision with the main body. how do I do collision detection for a child of another sprite?

I've been having an issue with my iOS app receiving duplicated over ever push notification. After doing some digging around StackOverflow, I figured out the issue could be because didRegisterUserNotificationSettings was being called twice.

So, I set a breakpoint on didRegisterUserNotificationSettings, and indeed, it is being called twice every time the app is launched.

The problem is, I'm only calling it once! Can someone please help me here and tell me why the delegate method didRegisterUserNotificationSettings is being called twice in the use case below:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {


    self.oneSignal = [[OneSignal alloc] initWithLaunchOptions:launchOptions
                                                        appId:@"d9b06a5a-ce3e-418c-8589-06fe6101e32a" handleNotification:nil];

    [self.oneSignal IdsAvailable:^(NSString* userId, NSString* pushToken) {
        NSLog(@"UserId:%@", userId);
        [[NSUserDefaults standardUserDefaults]setObject:userId forKey:@"onesiganal_userid"];

        if (pushToken != nil)
            NSLog(@"pushToken:%@", pushToken);

    }];

    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];

    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];


    return [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];

}

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {

    NSString *devToken = [[[[deviceToken description] stringByReplacingOccurrencesOfString:@"<"withString:@""] stringByReplacingOccurrencesOfString:@">" withString:@""] stringByReplacingOccurrencesOfString: @" " withString: @""];

    [[NSUserDefaults standardUserDefaults]setObject:devToken forKey:kUserDeviceTokenKey];
    [[NSUserDefaults standardUserDefaults] synchronize];


}

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
    //firing twice!
    NSLog("check");

}

trying to open safari on IOS & OSX, have tried both

webbrowser.open('www.google.com')

and

os.system("open /Applications/Safari.app www.google.com" )

neither work

Any Ideas or pointers please, much appreciated

I have created one view controller and after created a pop up view. i want to created new pop up view in the second view controller, How to do this

I using the SocialSharing-PhoneGap-Plugin . Currently, and I am able to share a link to a page in my app on social media. However, HandleOpenURL() is not getting invoke when the app is close.. It is getting triggered if the app is in the foreground or background

for example. if a user select an external link to my app.They are redirected to the specific page only if the app is in the foreground or background otherwise they get the default page

My app is hybrid and I am using angular framework. The function HandleOpenURL is in the apprun() function . I also moved it to the head section but it never getting call when the app is close

I have tried many workaround but no luck... The function is simple

window.handleOpenURL = function (url) {
  console.log('app opened from url: ' + url);
  AppUriService.gotoAppUri(url);
};

Thanks

in the title you can see the original question that I was going to enter on StackOverflow. Before doing so, I consulted various websites and various answers on StackOverflow, but was unable to figure out how to get the HomeTimeline Twitter, namely stream you see when you log in to your Twitter account via the Web or via Android client.

My first approach to obtain a functional twitter app was to use "Fabric", a plugin that can be installed in Android Studio from File-> Settings-> Plugins. This plugin makes it very easy to connect, log in and authorize the app in their account in Twitter. In addition, it very easy to get, for example, the UserTimeline ie tweets that you send to Twitter.

But I'm interested to the HomeTimeline, not the UserTimeline.

To get the HomeTimeline using Fabric, many of the answers I found were referring to functions of "REST" Twitter API, also accessible through Fabric, but how to use suggested in the various answers were referring to an old version of Fabric API. Using the same code with the new version of the plugin were causing compilation errors.

So, before asking the community to StackOverflow the demand reported in the title, I tried to solve the problem alone. I found a solution that seems to work and I am going to share with you, to get tips and advice.

The sources are of gitub: https://github.com/felmur/TwitterTest

With this demo app, you can:

1) run your personal account log in to Twitter 2) view your HomeTimeLine (the stream of your down payment twitter) 3) put "like" to tweets in your stream 4) post a new tweet 5) click on a tweet to view it in full screen

For now, I haven't found a way to retweet or citate a tweet. If anyone knows this, please leave a reply.

What I have: A list of geocoordinates(from osm) and ways/road which use those. All needed maptiles, mercator coordinates, etc.

What I want: A list of maptiles which get intersected by those ways.

Does anyone know a algorithm for achieving that? When possible also one which is capable of not only ways but also polygons ( parks, buildings, etc ). I also don't want to use external software because I will embed the algorithm in a bigger project.

It should go kinda like that:

[Coordinates of the roads/buildings] + [ List of all maptiles ] = [ List of maptiles which get intersected ]

I am a member of a small team which is part of a larger team of developers working with Git. We (the larger team) have a main branch in a central repository into which we commit our work for the next release (let's call it 1.0). The smaller team has been tasked with developing a feature (upgrading an existing one, actually) that will not make it into release 1.0, but a later release (1.1). I'm wondering how to manage the development of this feature in Git. I have looked at several Git workflows but could not find one that really fits.

First, we're working on this feature as a team, so I thought it would be appropriate to maintain a remote feature branch on the central repository which we'll all push to and then merge with the main branch when the feature is done. But releasing 1.0 could take a few months and that means we'll be isolated from the main branch for a long time, which would probably make merging back into main very hard. Ideally I would want to pull changes from main into our feature branch daily/weekly (as to deal with conflicts early on and not in one go after several months) but I've read this is not recommended in Git (to my understanding, merging from main to a feature branch or rebasing a public branch is discouraged).

I've seen a similar question but the accepted answer just says to not work this way. As I am not the one deciding our releases, this is not a solution that works for me. Relating to this, even if I think the code is stable I cannot commit it to main, because QA doesn't have time to check the feature for the 1.0 release and the code changes might introduce a bug. I know about automatic regression testing and continuous integration and I'm pushing hard for both, but right now these things aren't possible.

What is the best way to handle this?

Im writting a web-page in Ruby on Rails , so i can learn the language and framework better.

I have a User model which has_many Classifieds models which has_many Photos which accept_attachment :image.

So the whole thing works fine , the User creates the Classified , adds details and photos . User model and Classifieds model CRUD are implemented and running!

Now that the basic functionality is ok , i want to start implementing categorization and search.

One option is to create a Category model which has_many Subcategories.

Another option has to do with Tags like this tutorial provides: https://www.sitepoint.com/tagging-scratch-rails/

Keep in mind that this is not a general classifieds site, it's specifically for musicians and musical instruments / services.

When using the site , you should be able to browse classifieds

  1. By searching
  2. By navigating from a navbar which will have the categories.

What is the best way to tackle this ?

  1. Should i have a lot of predifined tables in my db (subcategories) from which i auto fill forms on classified creation?
  2. Should i just implement Tags , and just save the forms (which gives the user more flexibility on data entry)?

Generally im kind of scratching my head about this and what would be the best way to do it.

Thanks in advance :)

If I have all my business logic in code and make use of Entity Framework, in what situations (if any) would I be better moving some business logic to a stored procedure, instead of keeping it all in code?

To be clear, I mean in conjunction with the current setup (business logic in code), not instead of. I have seen a number of similar questions that are asking for the pros and cons of having all business logic in stored procedures, but I haven't found much regarding using stored procedures sparingly for edge case logic, while keeping the rest of the business logic in code.

If it makes a difference, I am using MSSQL and Entity Framework.


These are the situations where I have used stored procedures before:

  • A complicated report that was taking minutes to run (this was a page in a web app). I found I could write SQL that was much more efficient (only taking seconds to run) than what LINQ was providing.
  • A web application needed to read and write to a few tables on a separate database which contained a lot of other, sensitive information that was irrelevant to the application. Rather than giving it access to everything, I used a stored procedure that only does what is needed, and only returns limited information. The web application could then be given access to this stored procedure only, without access to any tables etc.

Other posts I have looked at before asking this question:

I have WinForms GUI application, which can work in two "states" with different functionality, but these states share GUI controls. I am dividing these states by using enum almost in every method, like:

    private void picBox_MouseDown(object sender, MouseEventArgs e)
    {
        if (picBox.Image == null)
            return;

        xDown = e.X;
        yDown = e.Y;

        if (appState == AppState.Annotating)
        {
            PointF ptImg = new PointF((xDown - absImgPos.X) * scale,
                (yDown - absImgPos.Y) * scale);
            annotateEngine.AddPoint(e.Location, ptImg);
        }
        else if (appState == AppState.Cropping)
        {
            picBox.Invalidate();
        }
    }

I want to make something like IAppState and than implement it for my states AnnotatingState::IAppState and CroppingState::IAppState, with some methods which should affect GUI:

interface IAppState
{
    void OnLoadImages();
    void OnSave();
    void OnPathChanged();
    void OnMouseDown();
    void OnMouseUp();
}

Can you suggest some suitable pattern?

Here's an intro

Voyager 1 reached interstellar space in August 2012 and is the most distant human-made object in existence. Launched just shortly after its twin spacecraft, Voyager 2, in 1977, Voyager 1 explored the Jovian and Saturnian systems discovering new moons, active volcanoes and a wealth of data about the outer solar system.

Voyagers 1 and 2 were designed to take advantage of a rare planetary alignment that occurs only once in 176 years and remain the most well traveled spacecraft in history. Both spacecraft carry a sort of time capsule called the Golden Record, a 12-inch gold-plated copper disk containing sounds and images selected to portray the story of our world to extraterrestrials.

I presume that vast majority of people that were building software for this missions are now retired, but in last 35 years programming, programming languages advanced so far.

So, it launched in 1977. After 35 years, Voyager reached interstellar space. How many lines of code are there and in what language is it written? What was development process behind this missions (that are still active)?.

So, what was the greater plan with code in this mission, and in which language is code base written?

how is the commentary generated in cricbuzz site?.

The site generates commentary in a ball by ball basis for every cricket game. I want to know if they either use any specific voice recognition software for this or simply type the commentary?

The second choice doesn't seem probable if we consider the speed and quality at which the commentary is generated.

If they indeed use a software, what software is that?

P.S: If this type of question is not allowed in this site, please suggest me where this question can be answered? cheers

I'd like to figure out what's wrong with a Selenium test that is failing with PhantomJS driver but succeding with the chrome Driver.

> phantomjs --version
2.1.1

I'd like to download some browser which matches the Webkit engine used by PhantomJS 2.1.1 to reproduce the test manually and figure out what's failing, but I don't know how to figure out which version to download given the following information:

> phantomjs useragent.js
The default user agent is Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1
Your Http User Agent string is: SpecialAgent

Any idea on how to proceed, or alternative approaches?

I'm currently assigned a task, where I have to program a bidirectional synchronisation between 2 ERP-related software, one providing webservices (Visual Studio Web Reference) and the other one providing a REST API.

I managed to match the fields of the APIs together, so I could potentially start creating objects in both APIs, using the same data. However, I reached the point of the actual sync, and it's harder than I thought.

In my head, everything goes fine.

Grabbing the data -> determine, what change it is on which side -> sync the data from the source system to the target system

But in actual coding, I'm encountering some serious problems:

  • Both APIs don't have any way to tell, when data was modified the last time, making it hard to determine, what kind of change it is (I thought about having a list of the previous sync to compare, but that leads to a different problem)
  • There's a priority on the system with the REST API, so if there are 2 changes at the same time, the change in the REST API would count
  • In which order should they be sync'ed? If there's a focus on the REST API, then the REST API would need to apply their changes after the webservice one, right?
  • The sync software would run on a server, at the moment in a permanent loop of getting the data, comparing and applying the changes. I'd love to only sync the changed data, but that wouldn't be possible, regarding the problem, that there's no way for me to determine, what change occured (something was created, something was changed, something was deleted)

Can you give me advice on how to accomplish this, in a reliable and resource-friendly way?

The webservice API is a lot slower than the REST API, meaning there's an interval, where nothing gets sync'ed (it may sound stupid, but I thought I could solve this problem single-threaded). Could I potentially need multi-threading here? The webservice API is rate limited to 10000/hr, dunno if this could get a problem.