Rectangle 27 8

In summary, the final solution is:

ErrorDocument 401 /misc/myerror.html
ErrorDocument 403 /misc/myerror.html

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I posted more about the cause of this problem in my specific situation, involving Wordpress and WebDAV on Dreamhost, which I expect many others to be having on my site.

apache - How do I ignore a directory in mod_rewrite? - Stack Overflow

apache mod-rewrite
Rectangle 27 6

Here is the final solution:

function getval( callback ){
    jQuery.getJSON('http://data.mtgox.com/api/1/BTCUSD/ticker', function(data) {
        // We can't use .return because return is a JavaScript keyword.
        callback(data['return'].avg.value);
    });
}

$(function () {
        $(document).ready(function() {
        getval( function ( value ) { 
            alert( 'Do something with ' + value + ' here!' );
        } );
    });

});

javascript - return value from getJSON function - Stack Overflow

javascript jquery getjson
Rectangle 27 152

I was able to solve this with Jon Steinmetz suggestion. If any one cares, here's the final solution :

int radius = myRect.size.width;
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.mapView.bounds.size.width, self.mapView.bounds.size.height) cornerRadius:0];
UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius];
[path appendPath:circlePath];
[path setUsesEvenOddFillRule:YES];

CAShapeLayer *fillLayer = [CAShapeLayer layer];
fillLayer.path = path.CGPath;
fillLayer.fillRule = kCAFillRuleEvenOdd;
fillLayer.fillColor = [UIColor grayColor].CGColor;
fillLayer.opacity = 0.5;
[view.layer addSublayer:fillLayer];
let radius = myRect.size.width
let path = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: self.mapView.bounds.size.width, height: self.mapView.bounds.size.height), cornerRadius: 0)
let circlePath = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: 2 * radius, height: 2 * radius), cornerRadius: radius)
path.append(circlePath)
path.usesEvenOddFillRule = true

let fillLayer = CAShapeLayer()
fillLayer.path = path.cgPath
fillLayer.fillRule = kCAFillRuleEvenOdd
fillLayer.fillColor = Color.background.cgColor
fillLayer.opacity = 0.5
view.layer.addSublayer(fillLayer)

glad it helped, even after year and half :)

For added flexibility, make your view subclass "IBDesignable". It's really easy! To get started, plug the above code into the answer I gave to this question: stackoverflow.com/questions/14141081/

As a novice iOS developer I've spent few hours trying to figure out, why this code produces weird results. Finally I found, that added sublayers must be removed if overlay mask is recalculated at some point. This is possible via view.layer.sublayers property. Thank you very much for answer!

ios - CALayer with transparent hole in it - Stack Overflow

ios objective-c calayer quartz-core
Rectangle 27 149

I was able to solve this with Jon Steinmetz suggestion. If any one cares, here's the final solution :

int radius = myRect.size.width;
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.mapView.bounds.size.width, self.mapView.bounds.size.height) cornerRadius:0];
UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius];
[path appendPath:circlePath];
[path setUsesEvenOddFillRule:YES];

CAShapeLayer *fillLayer = [CAShapeLayer layer];
fillLayer.path = path.CGPath;
fillLayer.fillRule = kCAFillRuleEvenOdd;
fillLayer.fillColor = [UIColor grayColor].CGColor;
fillLayer.opacity = 0.5;
[view.layer addSublayer:fillLayer];
let radius = myRect.size.width
let path = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: self.mapView.bounds.size.width, height: self.mapView.bounds.size.height), cornerRadius: 0)
let circlePath = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: 2 * radius, height: 2 * radius), cornerRadius: radius)
path.append(circlePath)
path.usesEvenOddFillRule = true

let fillLayer = CAShapeLayer()
fillLayer.path = path.cgPath
filllayer.fillRule = kCAFillRuleEvenOdd
filllayer.fillColor = Color.background.cgColor
filllayer.opacity = 0.5
view.layer.addSublayer(fillLayer)

glad it helped, even after year and half :)

For added flexibility, make your view subclass "IBDesignable". It's really easy! To get started, plug the above code into the answer I gave to this question: stackoverflow.com/questions/14141081/

As a novice iOS developer I've spent few hours trying to figure out, why this code produces weird results. Finally I found, that added sublayers must be removed if overlay mask is recalculated at some point. This is possible via view.layer.sublayers property. Thank you very much for answer!

ios - CALayer with transparent hole in it - Stack Overflow

ios objective-c calayer quartz-core
Rectangle 27 149

I was able to solve this with Jon Steinmetz suggestion. If any one cares, here's the final solution :

int radius = myRect.size.width;
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, self.mapView.bounds.size.width, self.mapView.bounds.size.height) cornerRadius:0];
UIBezierPath *circlePath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius];
[path appendPath:circlePath];
[path setUsesEvenOddFillRule:YES];

CAShapeLayer *fillLayer = [CAShapeLayer layer];
fillLayer.path = path.CGPath;
fillLayer.fillRule = kCAFillRuleEvenOdd;
fillLayer.fillColor = [UIColor grayColor].CGColor;
fillLayer.opacity = 0.5;
[view.layer addSublayer:fillLayer];
let radius = myRect.size.width
let path = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: self.mapView.bounds.size.width, height: self.mapView.bounds.size.height), cornerRadius: 0)
let circlePath = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: 2 * radius, height: 2 * radius), cornerRadius: radius)
path.append(circlePath)
path.usesEvenOddFillRule = true

let fillLayer = CAShapeLayer()
fillLayer.path = path.cgPath
filllayer.fillRule = kCAFillRuleEvenOdd
filllayer.fillColor = Color.background.cgColor
filllayer.opacity = 0.5
view.layer.addSublayer(fillLayer)

glad it helped, even after year and half :)

For added flexibility, make your view subclass "IBDesignable". It's really easy! To get started, plug the above code into the answer I gave to this question: stackoverflow.com/questions/14141081/

As a novice iOS developer I've spent few hours trying to figure out, why this code produces weird results. Finally I found, that added sublayers must be removed if overlay mask is recalculated at some point. This is possible via view.layer.sublayers property. Thank you very much for answer!

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

ios - CALayer with transparent hole in it - Stack Overflow

ios objective-c calayer quartz-core
Rectangle 27 9

So here is the final solution that took care of it:

Intent myIntent = new Intent();
myIntent.setClassName("com.myProject", "com.myProject.Activity2");
startActivityForResult(myIntent, 600);

For some reason Android requires the fully qualified name for the second parameter in addition to the package name given by the first parameter. Now it works! :)

Thank you very much for coming back and posting your solution. I have been stuck on this problem for a long time and I too tried all of the solutions you came across in your question to no avail. This fixed it and made my day a heck of a lot better =)

I use startActivityForResult WITHOUT setClassName or fully qualified names all over my projects and they all work perfectly except for one case. So I tried your solution in that case and it didn't make any difference.

Sadly this haven't solved my issue, neither did the other answers!

This solved it for me too, in the specific case of communicating between two separate applications.

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

Android onActivityResult called early - Stack Overflow

android android-intent android-activity
Rectangle 27 31

The final solution is combining the symlink- and the rename-approach:

mkdir alpha_real
ln -s alpha_real alpha

# now use "alpha"

mkdir beta_real
ln -s beta_real tmp 

# atomically rename "tmp" to "alpha"
# use -T to actually replace "alpha" instead of moving *into* "alpha"
mv -T tmp alpha

Of course, the application accessing alpha has to be able to deal with symlinks changing in the path.

-T
mv

linux - Moving a directory atomically - Stack Overflow

linux bash atomic
Rectangle 27 3

My final solution was something like this:

public class MyTableClass
{
    public int Id { get; set; }

    [Column(TypeName = "jsonb")]
    public string Data { get; set; }
}
Data = table.Column<string>(type: "jsonb", nullable: true),

When updated the database with migrations, the Data column was created correctly with jsonb type.

c# - Entity Framework Core jsonb column type - Stack Overflow

c# postgresql entity-framework-core npgsql
Rectangle 27 4

The final solution ended up looking like this:

jQuery.fn.linker = function () {
    $(this).contents()
        .filter(function() { return this.nodeType != Node.TEXT_NODE; })
        .each(function () { $(this).linker(); });
    $(this).contents()
        .filter(function() { return this.nodeType == Node.TEXT_NODE; })
        .each(function () {
            $(this).replaceWith(
                $(this).text().replace(/(00\d+)/g, '<a href="#$1">$1</a>')
            );
        });
}
$(document).ready(function () {
    $('body').linker();
});

The .isbnlink() in your fiddle should be .linker() I guess (or you forgot to include that extension), and wrapping whole text Nodes may come with extra white space, so take your time to review those. +1 for the awesome plugin code though. You can $.trim the $.trim($(this).text()) inside the href if you need to remove those extra white spaces.

@FabrcioMatt Thanks for the tips. I actually was working on solving that whitespace issue. I think I have it figured out now. I edited my answer with what I ended up with. I had to construct a new DOM element in order to only alter the matched substring.

Looks good. =] Just one thing though, duplicate IDs (multiple spans with id="link") are invalid markup (means it won't validate on w3c validator and you may run in problems if you ever try a #link selector with jQuery or CSS), and also jQuery automatically does the parsing for you when you supply a HTML string to replaceWith. I removed the duplicated IDs and simplified the DOM parsing part: fiddle.

@FabrcioMatt Great work with replaceWith parsing the HTML properly! You can actually simplify it even further and remove the <span> element entirely. I have updated my answer.

Yup, very nicely done. I assume the first $(this).contents().filter is to make the function recursive or something? Awesome work.

javascript - jQuery: How to wrap RegEx matched plain text in an anchor...

javascript jquery html regex
Rectangle 27 4

Here are the "blocks" to write the final solution:

It can contain only alphabetic characters - Use ^[a-zA-Z]+$ it can contain alphabetic and numeric - Use ^[a-zA-Z0-9]+$ It can contain alphabetic numeric and mentioned special characters - Use ^[a-zA-Z0-9_@.]+$ It cannot contain space - Use ng-trim="false" (see this SO thread)

var app = angular.module("app", []);
<html ng-app="app">

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
</head>

<body>
  <form name="form">
    <p>Enter text to validate:</p>
    <input type="text" ng-model="name" name="name" ng-pattern="/^[a-zA-Z0-9_@.]+$/" ng-trim="false" />
    <div ng-show="form.name.$error.pattern">Text doesn't match with ng-pattern!</div>
  </form>
</body>

</html>

javascript - Angular ng-pattern regex not working - Stack Overflow

javascript angularjs regex ng-pattern
Rectangle 27 4

Here are the "blocks" to write the final solution:

It can contain only alphabetic characters - Use ^[a-zA-Z]+$ it can contain alphabetic and numeric - Use ^[a-zA-Z0-9]+$ It can contain alphabetic numeric and mentioned special characters - Use ^[a-zA-Z0-9_@.]+$ It cannot contain space - Use ng-trim="false" (see this SO thread)

var app = angular.module("app", []);
<html ng-app="app">

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
</head>

<body>
  <form name="form">
    <p>Enter text to validate:</p>
    <input type="text" ng-model="name" name="name" ng-pattern="/^[a-zA-Z0-9_@.]+$/" ng-trim="false" />
    <div ng-show="form.name.$error.pattern">Text doesn't match with ng-pattern!</div>
  </form>
</body>

</html>

javascript - Angular ng-pattern regex not working - Stack Overflow

javascript angularjs regex ng-pattern
Rectangle 27 28

I finally found a "solution":

Add a new .natstepfilter to C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Packages\Debugger\Visualizers

<?xml version="1.0" encoding="utf-8"?>
<StepFilter xmlns="http://schemas.microsoft.com/vstudio/debugger/natstepfilter/2010">
  <Function><Name>boost::.*</Name><Action>NoStepInto</Action></Function>
  <Function><Name>std::.*</Name><Action>NoStepInto</Action></Function>
</StepFilter>

I'm not positive the "boost::.*" format is right in this specific example, but it should be this or something similar. You can look at the other .natstepfilter files in the folder for some more clues.

Unfortunately, according to a post I found, doing this does not work when debugging mixed-mode (e.g., C++/C#) applications, which is what I'm doing. I'll leave up this question for other persons trying to figure out how to implement this functionality and for anyone that might know a way to do this in mixed mode.

.natstepfilter can be also placed into user profile directories - the same as .natvis (see this article code.msdn.microsoft.com/windowsdesktop/) - it gives some explanation

you should mark this as the answer, as this is definitely the new way VS is handling StepOver

c++ - Has the VS2012 NativeDE\StepOver registry entry that prevents st...

c++ visual-studio debugging visual-c++ visual-studio-2012
Rectangle 27 21

I finally found a solution to this.

To support the iPhone 3G and other arm6 devices, you need to specify arm6 and arm7 in in the Architectures list, and set the device requirements to only arm6 in the plist.

Where exactly is this setting? In a fresh set-up of Xcode 4.2 I can see 'Valid Architectures' which has defaulted to 'armv6 armv7', and I see a 'Archtectures' which seems to be set to some kind of substitution variable: '$(ARCHS_STANDARD_32_BIT)' which shows as 'Standard (armv7)'. Best way to change this?

iphone - No provisioned iOS devices are available with a compatible iO...

iphone ios-provisioning
Rectangle 27 21

I finally found a solution to this.

To support the iPhone 3G and other arm6 devices, you need to specify arm6 and arm7 in in the Architectures list, and set the device requirements to only arm6 in the plist.

Where exactly is this setting? In a fresh set-up of Xcode 4.2 I can see 'Valid Architectures' which has defaulted to 'armv6 armv7', and I see a 'Archtectures' which seems to be set to some kind of substitution variable: '$(ARCHS_STANDARD_32_BIT)' which shows as 'Standard (armv7)'. Best way to change this?

iphone - No provisioned iOS devices are available with a compatible iO...

iphone ios-provisioning
Rectangle 27 14

After hours of struggling, this is final solution that helped me (tested from fiddler):

  • Choose "Add module mapping" option on the right side of the panel
  • Click on "Request restrictions" and go to Verbs tab

End voila, fiddler no longer answers with 405 but with happy 200.

Buhtla, if this is the answer that solved the problem for you, mark it as such with the green checkmark. This is allowed (and encouraged) on SO.

Helped me after searching all morning for a fix - thanks

How did you find out about this @buhtla? It worked for me: big thanks! But I think it would also be helpful to post the URL from where you got this information and, please, mark as answer because it will be easier for others to find the solution.

I'm very glad I helped you guys! It passed quite some time after I had this problem, but I remember I found out this solution on my own. Maybe there are some pages that have this same resolution of the problem described, but I'm not aware of them.

Worked for me as well, you are great!

c# - IIS 7.5, Web Service and HTTP 405 error - Stack Overflow

c# wcf iis http-post
Rectangle 27 168

Since Apple has now clarified that static struct variables are initialized both lazy and wrapped in dispatch_once (see the note at the end of the post), I think my final solution is going to be:

class WithSingleton {
    class var sharedInstance :WithSingleton {
        struct Singleton {
            static let instance = WithSingleton()
        }

        return Singleton.instance
    }
}

This takes advantage of the automatic lazy, thread-safe initialization of static struct elements, safely hides the actual implementation from the consumer, keeps everything compactly compartmentalized for legibility, and eliminates a visible global variable.

Apple has clarified that lazy initializer are thread-safe, so there's no need for dispatch_once or similar protections

The lazy initializer for a global variable (also for static members of structs and enums) is run the first time that global is accessed, and is launched as dispatch_once to make sure that the initialization is atomic. This enables a cool way to use dispatch_once in your code: just declare a global variable with an initializer and mark it private.

I would add that a good practice would be to declare the initializer as private: private init() {}, to further enforce the fact that this class is not meant to be externally instantiated.

so static struct var initialization is lazy and thread safe, what if that static struct var is a dictionary for multitons, then we have to manually synchronize/queue calls to it for each access, right?

If I understand your question correctly, dictionary and array accesses are not inherently thread-safe, so you will need to use some form of thread synchronization.

@DavidBerry How should I call a function inside this singleton class? I need a function to be called on the first call of myClass.sharedInstance.

Using a dispatch_once singleton model in Swift - Stack Overflow

swift singleton dispatch
Rectangle 27 168

Since Apple has now clarified that static struct variables are initialized both lazy and wrapped in dispatch_once (see the note at the end of the post), I think my final solution is going to be:

class WithSingleton {
    class var sharedInstance :WithSingleton {
        struct Singleton {
            static let instance = WithSingleton()
        }

        return Singleton.instance
    }
}

This takes advantage of the automatic lazy, thread-safe initialization of static struct elements, safely hides the actual implementation from the consumer, keeps everything compactly compartmentalized for legibility, and eliminates a visible global variable.

Apple has clarified that lazy initializer are thread-safe, so there's no need for dispatch_once or similar protections

The lazy initializer for a global variable (also for static members of structs and enums) is run the first time that global is accessed, and is launched as dispatch_once to make sure that the initialization is atomic. This enables a cool way to use dispatch_once in your code: just declare a global variable with an initializer and mark it private.

I would add that a good practice would be to declare the initializer as private: private init() {}, to further enforce the fact that this class is not meant to be externally instantiated.

so static struct var initialization is lazy and thread safe, what if that static struct var is a dictionary for multitons, then we have to manually synchronize/queue calls to it for each access, right?

If I understand your question correctly, dictionary and array accesses are not inherently thread-safe, so you will need to use some form of thread synchronization.

@DavidBerry How should I call a function inside this singleton class? I need a function to be called on the first call of myClass.sharedInstance.

Using a dispatch_once singleton model in Swift - Stack Overflow

swift singleton dispatch
Rectangle 27 5

Alright, after a lengthy discussion in the comments, I came up with this final solution:

var pointerEl = document.getElementById("pointer");
var canvasEl = document.getElementById("canvas");
var canvas = {
    width: canvasEl.offsetWidth,
    height: canvasEl.offsetHeight,
    top: canvasEl.offsetTop,
    left: canvasEl.offsetLeft
};
canvas.center = [canvas.left + canvas.width / 2, canvas.top + canvas.height / 2];
canvas.radius = canvas.width / 2;


window.onmousemove = function(e) {
    var result = limit(e.x, e.y);
        pointer.style.left = result.x + "px";
        pointer.style.top = result.y + "px";
}

function limit(x, y) {
    var dist = distance([x, y], canvas.center);
    if (dist <= canvas.radius) {
        return {x: x, y: y};
    } 
    else {
        x = x - canvas.center[0];
        y = y - canvas.center[1];
        var radians = Math.atan2(y, x)
           return {
               x: Math.cos(radians) * canvas.radius + canvas.center[0],
               y: Math.sin(radians) * canvas.radius + canvas.center[1]
           }
        } 
    }

function distance(dot1, dot2) {
    var x1 = dot1[0],
        y1 = dot1[1],
        x2 = dot2[0],
        y2 = dot2[1];
    return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
}

The solution uses this other jsfiddle.

javascript - Limit drag movements to a circular SVG boundary - Stack O...

javascript svg d3.js drag
Rectangle 27 4

Thanks for the answers guys, this is the final solution that I was looking for.

$text = preg_replace("/<a[^>]+\><img[^>]+\><\/a>\n/i", "", $text);

$text = preg_replace("/<img[^>]+\>/i", "", $text);

It's easy to construct valid HTML that makes those regexes misbehave.

Although it is not quite easy, still the regexes are useful for use in your own page or something you (or someone near you) control.

php - REGEX to find and replace IMG elements - Stack Overflow

php regex
Rectangle 27 4

No final solution here :/ Just some thoughts how to "cleanly" solve this problem...

Updated version (jQuery 1.11 + Bootstrap 3.1.1 + class="col-xs-" instead of class="col-md-") of your original JSFiddle: http://jsfiddle.net/tkrotoff/N99h7/

So if we want to keep the popover on the inputs (semantically better):

  • .popover { position: fixed; }: but then each time you scroll the page, the popover will not follow the scroll
.popover { width: 100%; }
<div class="col-*">
.popover-content { white-space: nowrap; }
max-width

Maybe, using very recent browsers, the new CSS width values can solve the problem, I didn't try.

css - Changing the width of Bootstrap popover - Stack Overflow

css twitter-bootstrap twitter-bootstrap-3 popover