May be I'm too late here. But I hope this would help someone. First separate those two elements.
renderLogout(){
<div>
<LogoutButton onClick={this.handleLogoutClick} />
<div>
}
renderLogin(){
<div>
<LoginButton onClick={this.handleLoginClick} />
<div>
}
Then you can call these functions from render function using if else statement.
render(){
if(this.state.result){
return this.renderResult();
}else{
return this.renderQuiz();
}}
This works for me. :)
The data URI format is:
data:<headers>;<encoding>,<data>
So, you need only append your data to the "data:image/jpeg;," string:
var your_binary_data = document.body.innerText.replace(/(..)/gim,'%$1'); // parse text data to URI format
window.open('data:image/jpeg;,'+your_binary_data);
My complex solution (or tutorial) for rss-feed (get in RSSItems) works only on device:
#define CACHE_DIR [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]
for (RSSItem *item in _dataSource) {
url = [NSURL URLWithString:[item link]];
request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"GET"];
[NSURLConnection sendAsynchronousRequest:request
queue:queue
completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
@autoreleasepool {
if (!error) {
NSString *html = [[NSString alloc] initWithData:data
encoding:NSWindowsCP1251StringEncoding];
{
NSError *error = nil;
HTMLParser *parser = [[HTMLParser alloc] initWithString:html error:&error];
if (error) {
NSLog(@"Error: %@", error);
return;
}
HTMLNode *bodyNode = [parser body];
NSArray *spanNodes = [bodyNode findChildTags:@"div"];
for (HTMLNode *spanNode in spanNodes) {
if ([[spanNode getAttributeNamed:@"class"] isEqualToString:@"page"]) {
NSString *absStr = [[response URL] absoluteString];
for (RSSItem *anItem in _dataSource)
if ([absStr isEqualToString:[anItem link]]){
NSArray *spanNodes = [bodyNode findChildTags:@"img"];
for (HTMLNode *spanNode in spanNodes){
NSString *imgUrl = [spanNode getAttributeNamed:@"src"];
if (imgUrl){
[anItem setImage:imgUrl];
break;
}
}
[anItem setHtml:[spanNode rawContents]];
[self subProcessRSSItem:anItem];
}
}
}
[parser release];
}
if (error) {
NSLog(@"Error: %@", error);
return;
}
[[NSNotificationCenter defaultCenter] postNotificationName:notification_updateDatasource
object:self
userInfo:nil];
}else
NSLog(@"Error",[error userInfo]);
}
}];
and
- (void)subProcessRSSItem:(RSSItem*)item{
NSString *html = [item html];
if (html) {
html = [html stringByReplacingOccurrencesOfString:@"<div class=\"clear\"></div>"
withString:@""];
html = [html stringByReplacingOccurrencesOfString:@"<p class=\"link\">"
withString:@""];
html = [html stringByReplacingOccurrencesOfString:@"<div class=\"page\">"
withString:@""];
html = [html stringByReplacingOccurrencesOfString:@"</div>"
withString:@""];
NSArray *array1 = [html componentsSeparatedByString:@"<a"];
if ([array1 count]==2) {
NSArray *array2 = [html componentsSeparatedByString:@"a>"];
html = [[array1 objectAtIndex:0] stringByAppendingString:[array2 objectAtIndex:1]];
}
NSURL *url;
NSString *fileName;
NSString *filePath;
BOOL success;
if ([item image]) {
url = [NSURL URLWithString:
[hostString stringByAppendingString:[item image]]];
NSData *imageData = [NSData dataWithContentsOfURL:url];
fileName = [[[url relativePath] componentsSeparatedByString:@"/"] lastObject];
filePath = [NSString stringWithFormat:@"%@/%@",
CACHE_DIR,
fileName];
//save image locally
success = [[NSFileManager defaultManager] createFileAtPath:filePath
contents:imageData
attributes:nil];
//replace links
html = [html stringByReplacingOccurrencesOfString:[item image]
withString:filePath];
[item setImage:fileName];
//????????? ?????????? ??????????, ??????? ???????? ??????????? ??????
[[NSNotificationCenter defaultCenter] postNotificationName:notification_updateRow
object:self
userInfo:[NSDictionary dictionaryWithObject:@([_dataSource indexOfObject:item])
forKey:@"row"]];
}
//finalize html
html = [NSString stringWithFormat:@"<html><body>%@</body></html>",html];
fileName = [[[item link] componentsSeparatedByString:@"/"] lastObject];
filePath = [NSString stringWithFormat:@"%@/%@",
CACHE_DIR,
fileName];
success = [[NSFileManager defaultManager] createFileAtPath:filePath
contents:[html dataUsingEncoding:NSUTF8StringEncoding]
attributes:nil];
[item setHtml:
(success)?filePath:nil];//for direct download in other case
}
}
on View controller
- (void)viewDidAppear:(BOOL)animated{
RSSItem *item = [[DataSingleton sharedSingleton] selectedRSSItem];
NSString* htmlString = [NSString stringWithContentsOfFile:[item html]
encoding:NSUTF8StringEncoding error:nil];
NSURL *baseURL = [NSURL URLWithString:CACHE_DIR];
[_webView loadHTMLString:htmlString
baseURL:baseURL];
}
rss item class
#import <Foundation/Foundation.h>
@interface RSSItem : NSObject
@property(nonatomic,retain) NSString *title;
@property(nonatomic,retain) NSString *link;
@property(nonatomic,retain) NSString *guid;
@property(nonatomic,retain) NSString *category;
@property(nonatomic,retain) NSString *description;
@property(nonatomic,retain) NSString *pubDate;
@property(nonatomic,retain) NSString *html;
@property(nonatomic,retain) NSString *image;
@end
part of any html with image
<html><body>
<h2>blah-blahTC One Tab 7</h2>
<p>blah-blah ??? One.</p>
<p><img width="600" height="412" alt="" src="/Users/wins/Library/Application Support/iPhone Simulator/5.0/Applications/2EAD8889-6482-48D4-80A7-9CCFD567123B/Library/Caches/htc-one-tab-7-concept-1(1).jpg"><br><br>
blah-blah (Hasan Kaymak) blah-blah HTC One Tab 7, blah-blah HTC One. <br><br>
blah-blah
microSD.<br><br>
blah-blah Wi-Fi to 4G LTE.</p>
</p>
</body></html>
image saved for name htc-one-tab-7-concept-1(1).jpg
As this is one of the first hits in the search engines, and none of the above seems to work for MongoDB 3.x, here is one regex search that does work:
db.users.find( { 'name' : { '$regex' : yourvalue, '$options' : 'i' } } )
No need to create and extra index or alike.
You can use the below command to check the list of all services.
ps aux
To check your own service:
ps aux | grep postgres
There are three possibilities:
1) If you are referring old DLL then it cant be used. So you have refer new DLL
2) If you are using it in different namespace and trying to use the other namespace's dll then it wont refer this method.
3) You may need to rebuild the project
I think third option might be the cause for you. Please post more information in order to understand exact problem of yours.
Starting with Spring 4.1, We can directly set the property in application.yml using the @TestPropertySource annotation.
@RunWith(SpringRunner.class)
@SpringBootTest
@TestPropertySource(properties = {"yoursection.yourparameter=your_value"})
public MyIntTest
{
//your test methods
}
Just convert your yaml parameters into complete property structure. For example: If content of application.yml is like below
yoursection:
yourparameter:your_value
Then value to go inside the @TestPropertySource will be,
yoursection.yourparameter=your_value
Plese try this:
var sizeInKB = input.files[0].size/1024; //Normally files are in bytes but for KB divide by 1024 and so on
var sizeLimit= 30;
if (sizeInKB >= sizeLimit) {
alert("Max file size 30KB");
return false;
}
Loading a python3 generated *.pyc
file with python2 also causes this error.
In pure JS adding next option to select is easier and more direct
mySelect.innerHTML+= `<option value="${key}">${value}</option>`;
let selectValues = { "1": "test 1", "2": "test 2" };
for(let key in selectValues) {
mySelect.innerHTML+= `<option value="${key}">${selectValues[key]}</option>`;
}
_x000D_
<select id="mySelect">
<option value="0" selected="selected">test 0</option>
</select>
_x000D_
Value of string::npos is 18446744073709551615. Its a value returned if there is no string found.
If I understand you correctly, you need to use -SearchBase:
Get-ADUser -SearchBase "OU=Accounts,OU=RootOU,DC=ChildDomain,DC=RootDomain,DC=com" -Filter *
Note that Get-ADUser defaults to using
-SearchScope Subtree
so you don't need to specify it. It's this that gives you all sub-OUs (and sub-sub-OUs, etc.).
Use the Path
class from System.IO
. It contains useful calls for manipulating file paths, including GetDirectoryName
which does what you want, returning the directory portion of the file path.
Usage is simple.
string directoryPath = Path.GetDirectoryName(filePath);
The caret character works, however the next line should not start with double quotes. e.g. this will not work:
C:\ ^
"SampleText" ..
Start next line without double quotes (not a valid example, just to illustrate)
First of all you should fix modal HTML structure. Now it's not correct, you don't need class .hide
:
<div id="edit-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body edit-content">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Then links should point to this modal via data-target
attribute:
<a href="#myModal" data-toggle="modal" id="1" data-target="#edit-modal">Edit 1</a>
Finally Js part becomes very simple:
$('#edit-modal').on('show.bs.modal', function(e) {
var $modal = $(this),
esseyId = e.relatedTarget.id;
$.ajax({
cache: false,
type: 'POST',
url: 'backend.php',
data: 'EID=' + essayId,
success: function(data) {
$modal.find('.edit-content').html(data);
}
});
})
So you have committed your local changes to your local repository. Then in order to get remote changes to your local repository without making changes to your local files, you can use git fetch
. Actually git pull
is a two step operation: a non-destructive git fetch
followed by a git merge
. See What is the difference between 'git pull' and 'git fetch'? for more discussion.
Detailed example:
Suppose your repository is like this (you've made changes test2
:
* ed0bcb2 - (HEAD, master) test2
* 4942854 - (origin/master, origin/HEAD) first
And the origin
repository is like this (someone else has committed test1
):
* 5437ca5 - (HEAD, master) test1
* 4942854 - first
At this point of time, git will complain and ask you to pull first if you try to push your test2
to remote repository. If you want to see what test1 is without modifying your local repository, run this:
$ git fetch
Your result local repository would be like this:
* ed0bcb2 - (HEAD, master) test2
| * 5437ca5 - (origin/master, origin/HEAD) test1
|/
* 4942854 - first
Now you have the remote changes in another branch, and you keep your local files intact.
Then what's next? You can do a git merge
, which will be the same effect as git pull
(when combined with the previous git fetch
), or, as I would prefer, do a git rebase origin/master
to apply your change on top of origin/master
, which gives you a cleaner history.
[attr.disabled]="valid == true ? true : null"
You have to use null
to remove attr from html element.
You could use one of the below solutions:
$items = Item::whereIn('id', [1,2,..])->get();
or:
$items = DB::table('items')->whereIn('id',[1,2,..])->get();
Another way to get the same result:
date <- strptime(v,format="%Y%m%d")
The "up" affordance indicator is provided by a drawable specified in the homeAsUpIndicator
attribute of the theme. To override it with your own custom version it would be something like this:
<style name="Theme.MyFancyTheme" parent="android:Theme.Holo">
<item name="android:homeAsUpIndicator">@drawable/my_fancy_up_indicator</item>
</style>
If you are supporting pre-3.0 with your application be sure you put this version of the custom theme in values-v11
or similar.
Here is how you allow extra HTTP Verbs using the IIS Manager GUI.
In IIS Manager, select the site you wish to allow PUT or DELETE for.
Click the "Request Filtering" option. Click the "HTTP Verbs" tab.
Click the "Allow Verb..." link in the sidebar.
In the box that appears type "DELETE", click OK.
Click the "Allow Verb..." link in the sidebar again.
In the box that appears type "PUT", click OK.
(EDIT: This does not work in scala 2.9 and maybe not 2.8 either)
Use trunk:
scala> io.File("/etc/passwd").slurp
res0: String =
##
# User Database
#
... etc
The easiest way to accomplish this is to package the desired font(s) with your application. To do this, simply create an assets/ folder in the project root, and put your fonts (in TrueType, or TTF, form) in the assets. You might, for example, create assets/fonts/ and put your TTF files in there.
Then, you need to tell your widgets to use that font. Unfortunately, you can no longer use layout XML for this, since the XML does not know about any fonts you may have tucked away as an application asset. Instead, you need to make the change in Java code, by calling Typeface.createFromAsset(getAssets(), “fonts/HandmadeTypewriter.ttf”), then taking the created Typeface object and passing it to your TextView via setTypeface().
For more reference here is the tutorial where I got this:
You can force the input to contain only positive integer by adding onkeypress
within the input
tag.
<input type="number" onkeypress="return event.charCode >= 48" min="1" >
_x000D_
Here, event.charCode >= 48
ensures that only numbers greater than or equal to 0 are returned, while the min
tag ensures that you can come to a minimum of 1 by scrolling within the input bar.
You are reinventing the wheel.
If you need persistence and other enterprise features use JMS (I'd suggest ActiveMq).
If you need fast in-memory queues use one of the impementations of java's Queue.
If you need to support java 1.4 or earlier, use Doug Lea's excellent concurrent package.
Since AmazonDynamoDBClient(credentials) is deprecated i use this.
init {
val cp= AWSStaticCredentialsProvider(BasicAWSCredentials(ACCESS_KEY, SECRET_KEY))
val client = AmazonDynamoDBClientBuilder.standard().withCredentials(cp).withRegion(Regions.US_EAST_1).build()
dynamoDB = DynamoDB(client)
}
The link you gave seems to be attempting something different to the test you are trying to avoid repeating.
if (a == null || a=='')
tests if the string is an empty string or null. The article you linked to tests if the string consists entirely of whitespace (or is empty).
The test you described can be replaced by:
if (!a)
Because in javascript, an empty string, and null, both evaluate to false in a boolean context.
It's already fluid by default. If you want to be fluid for less width instead of col-md-6
use col-sm-6
or col-xs-6
.
In general you add all prerequisite steps to setUp and all clean-up steps to tearDown.
You can read more with examples here.
When a setUp() method is defined, the test runner will run that method prior to each test. Likewise, if a tearDown() method is defined, the test runner will invoke that method after each test.
For example you have a test that requires items to exist, or certain state - so you put these actions(creating object instances, initializing db, preparing rules and so on) into the setUp.
Also as you know each test should stop in the place where it was started - this means that we have to restore app state to it's initial state - e.g close files, connections, removing newly created items, calling transactions callback and so on - all these steps are to be included into the tearDown.
So the idea is that test itself should contain only actions that to be performed on the test object to get the result, while setUp and tearDown are the methods to help you to leave your test code clean and flexible.
You can create a setUp and tearDown for a bunch of tests and define them in a parent class - so it would be easy for you to support such tests and update common preparations and clean ups.
If you are looking for an easy example please use the following link with example
It's somewhat weird to read but yes, the exception will bubble up to the calling code - but only if you await
or Wait()
the call to Foo
.
public async Task Foo()
{
var x = await DoSomethingAsync();
}
public async void DoFoo()
{
try
{
await Foo();
}
catch (ProtocolException ex)
{
// The exception will be caught because you've awaited
// the call in an async method.
}
}
//or//
public void DoFoo()
{
try
{
Foo().Wait();
}
catch (ProtocolException ex)
{
/* The exception will be caught because you've
waited for the completion of the call. */
}
}
Async void methods have different error-handling semantics. When an exception is thrown out of an async Task or async Task method, that exception is captured and placed on the Task object. With async void methods, there is no Task object, so any exceptions thrown out of an async void method will be raised directly on the SynchronizationContext that was active when the async void method started. - https://msdn.microsoft.com/en-us/magazine/jj991977.aspx
Note that using Wait() may cause your application to block, if .Net decides to execute your method synchronously.
This explanation http://www.interact-sw.co.uk/iangblog/2010/11/01/csharp5-async-exceptions is pretty good - it discusses the steps the compiler takes to achieve this magic.
if you want to merge empty array with existing new value. You must initialize it first.
$products = array();
//just example
for($brand_id=1;$brand_id<=3;$brand_id++){
array_merge($products,getByBrand($brand_id));
}
// it will create empty array
print_r($a);
//check if array of products is empty
for($brand_id=1;$brand_id<=3;$brand_id++){
if(empty($products)){
$products = getByBrand($brand_id);
}else{
array_merge($products,getByBrand($brand_id));
}
}
// it will create array of products
Hope its help.
I was looking for a simple answer to solve this myself. here is what I found
This will split the year and month, take one month off and get the first day.
firstDayInPreviousMonth = DateSerial(Year(dtmDate), Month(dtmDate) - 1, 1)
Gets the first day of the previous month from the current
lastDayInPreviousMonth = DateSerial(Year(dtmDate), Month(dtmDate), 0)
More details can be found at: http://msdn.microsoft.com/en-us/library/aa227522%28v=vs.60%29.aspx
If you're using ViewPager
(like my case) you can use:
getSupportActionBar().setTitle(YOURE_TAB_BAR.getTabAt(position).getText());
in onPageSelected
method of your VIEW_PAGER.addOnPageChangeListener
An explicit default initialization can help:
struct foo {
bool a {};
bool b {};
bool c {};
} bar;
Behavior bool a {}
is same as bool b = bool();
and return false
.
Maybe this can help you ? git-diff-tree - Compares the content and mode of blobs found via two tree objects
I wrote a clean functional method of playing sounds:
sounds = {
test : new Audio('/assets/sounds/test.mp3')
};
sound_volume = 0.1;
function playSound(sound) {
sounds[sound].volume = sound_volume;
sounds[sound].play();
}
function stopSound(sound) {
sounds[sound].pause();
}
function setVolume(sound, volume) {
sounds[sound].volume = volume;
sound_volume = volume;
}
It is not possible using just cut
. Here is a way using grep
:
grep -o '[^,]*$'
Replace the comma for other delimiters.
For any case set overflow-x
to hidden
and I prefer to set max-height
in order to limit the expansion of the height of the div. Your code should looks like this:
overflow-y: scroll;
overflow-x: hidden;
max-height: 450px;
var optionTexts = [];
$("ul li").each(function() { optionTexts.push($(this).text()) });
...should do the trick. To get the final output you're looking for, join()
plus some concatenation will do nicely:
var quotedCSV = '"' + optionTexts.join('", "') + '"';
SELECT DISTINCT(salary) FROM emp order by salary asc limit 0 ,3
Above query gives three highest salary with DISTINCT.
Use GREATEST()
E.g.:
SELECT GREATEST(2,1);
Note: Whenever if any single value contains null at that time this function always returns null (Thanks to user @sanghavi7)
Brace yourself, here there's another coming :-)
Today I had to explain to my girlfriend the difference between the expressive power of WS-Security as opposed to HTTPS. She's a computer scientist, so even if she doesn't know all the XML mumbo jumbo she understands (maybe better than me) what encryption or signature means. However I wanted a strong image, which could make her really understand what things are useful for, rather than how they are implemented (that came a bit later, she didn't escape it :-)).
So it goes like this. Suppose you are naked, and you have to drive your motorcycle to a certain destination. In the (A) case you go through a transparent tunnel: your only hope of not being arrested for obscene behaviour is that nobody is looking. That is not exactly the most secure strategy you can come out with... (notice the sweat drop from the guy forehead :-)). That is equivalent to a POST in clear, and when I say "equivalent" I mean it. In the (B) case, you are in a better situation. The tunnel is opaque, so as long as you travel into it your public record is safe. However, this is still not the best situation. You still have to leave home and reach the tunnel entrance, and once outside the tunnel probably you'll have to get off and walk somewhere... and that goes for HTTPS. True, your message is safe while it crosses the biggest chasm: but once you delivered it on the other side you don't really know how many stages it will have to go through before reaching the real point where the data will be processed. And of course all those stages could use something different than HTTP: a classical MSMQ which buffers requests which can't be served right away, for example. What happens if somebody lurks your data while they are in that preprocessing limbo? Hm. (read this "hm" as the one uttered by Morpheus at the end of the sentence "do you think it's air you are breathing?"). The complete solution (c) in this metaphor is painfully trivial: get some darn clothes on yourself, and especially the helmet while on the motorcycle!!! So you can safely go around without having to rely on opaqueness of the environments. The metaphor is hopefully clear: the clothes come with you regardless of the mean or the surrounding infrastructure, as the messsage level security does. Furthermore, you can decide to cover one part but reveal another (and you can do that on personal basis: airport security can get your jacket and shoes off, while your doctor may have a higher access level), but remember that short sleeves shirts are bad practice even if you are proud of your biceps :-) (better a polo, or a t-shirt).
I'm happy to say that she got the point! I have to say that the clothes metaphor is very powerful: I was tempted to use it for introducing the concept of policy (disco clubs won't let you in sport shoes; you can't go to withdraw money in a bank in your underwear, while this is perfectly acceptable look while balancing yourself on a surf; and so on) but I thought that for one afternoon it was enough ;-)
Architecture - WS, Wild Ideas
sum(Santa$Believe)
Check if have not set a open_basedir in php.ini or .htaccess of domain what you use. That will jail you in directory of your domain and php will get only access to execute inside this directory.
$('.input').on('focus', function(){
$(this).val('');
});
$('[type="submit"]').on('click', function(){
$('.input').val('');
});
You have a view model to which your view is strongly typed => use strongly typed helpers:
<%= Html.DropDownListFor(
x => x.SelectedAccountId,
new SelectList(Model.Accounts, "Value", "Text")
) %>
Also notice that I use a SelectList
for the second argument.
And in your controller action you were returning the view model passed as argument and not the one you constructed inside the action which had the Accounts property correctly setup so this could be problematic. I've cleaned it a bit:
public ActionResult AccountTransaction()
{
var accounts = Services.AccountServices.GetAccounts(false);
var viewModel = new AccountTransactionView
{
Accounts = accounts.Select(a => new SelectListItem
{
Text = a.Description,
Value = a.AccountId.ToString()
})
};
return View(viewModel);
}
Apparently Chrome and Safari are wrong: onchange
should only be triggered when the user releases the mouse. To get continuous updates, you should use the oninput
event, which will capture live updates in Firefox, Safari and Chrome, both from the mouse and the keyboard.
However, oninput
is not supported in IE10, so your best bet is to combine the two event handlers, like this:
<span id="valBox"></span>
<input type="range" min="5" max="10" step="1"
oninput="showVal(this.value)" onchange="showVal(this.value)">
Check out this Bugzilla thread for more information.
use this code
window.onhashchange = function() {
//code
}
with jQuery
$(window).bind('hashchange', function() {
//code
});
If you are on windows, many times it will not recognize the device fully and because of driver issues, the device won't show up.
And look for any devices showing an error. Many androids will show as an unknown USB device. Select that device and try to update the drivers for it.
This is an old question, but many anwsers don't perform well or overflow for big numbers. I think D. Nesterov answer is the best one: robust, simple and fast. I just want to add my two cents.
I played around with decimals and also checked out the source code. From the public Decimal (int lo, int mid, int hi, bool isNegative, byte scale)
constructor documentation.
The binary representation of a Decimal number consists of a 1-bit sign, a 96-bit integer number, and a scaling factor used to divide the integer number and specify what portion of it is a decimal fraction. The scaling factor is implicitly the number 10 raised to an exponent ranging from 0 to 28.
Knowing this, my first approach was to create another decimal
whose scale corresponds to the decimals that I wanted to discard, then truncate it and finally create a decimal with the desired scale.
private const int ScaleMask = 0x00FF0000;
public static Decimal Truncate(decimal target, byte decimalPlaces)
{
var bits = Decimal.GetBits(target);
var scale = (byte)((bits[3] & (ScaleMask)) >> 16);
if (scale <= decimalPlaces)
return target;
var temporalDecimal = new Decimal(bits[0], bits[1], bits[2], target < 0, (byte)(scale - decimalPlaces));
temporalDecimal = Math.Truncate(temporalDecimal);
bits = Decimal.GetBits(temporalDecimal);
return new Decimal(bits[0], bits[1], bits[2], target < 0, decimalPlaces);
}
This method is not faster than D. Nesterov's and it is more complex, so I played around a little bit more. My guess is that having to create an auxiliar decimal
and retrieving the bits twice is making it slower. On my second attempt, I manipulated the components returned by Decimal.GetBits(Decimal d) method myself. The idea is to divide the components by 10 as many times as needed and reduce the scale. The code is based (heavily) on the Decimal.InternalRoundFromZero(ref Decimal d, int decimalCount) method.
private const Int32 MaxInt32Scale = 9;
private const int ScaleMask = 0x00FF0000;
private const int SignMask = unchecked((int)0x80000000);
// Fast access for 10^n where n is 0-9
private static UInt32[] Powers10 = new UInt32[] {
1,
10,
100,
1000,
10000,
100000,
1000000,
10000000,
100000000,
1000000000
};
public static Decimal Truncate(decimal target, byte decimalPlaces)
{
var bits = Decimal.GetBits(target);
int lo = bits[0];
int mid = bits[1];
int hi = bits[2];
int flags = bits[3];
var scale = (byte)((flags & (ScaleMask)) >> 16);
int scaleDifference = scale - decimalPlaces;
if (scaleDifference <= 0)
return target;
// Divide the value by 10^scaleDifference
UInt32 lastDivisor;
do
{
Int32 diffChunk = (scaleDifference > MaxInt32Scale) ? MaxInt32Scale : scaleDifference;
lastDivisor = Powers10[diffChunk];
InternalDivRemUInt32(ref lo, ref mid, ref hi, lastDivisor);
scaleDifference -= diffChunk;
} while (scaleDifference > 0);
return new Decimal(lo, mid, hi, (flags & SignMask)!=0, decimalPlaces);
}
private static UInt32 InternalDivRemUInt32(ref int lo, ref int mid, ref int hi, UInt32 divisor)
{
UInt32 remainder = 0;
UInt64 n;
if (hi != 0)
{
n = ((UInt32)hi);
hi = (Int32)((UInt32)(n / divisor));
remainder = (UInt32)(n % divisor);
}
if (mid != 0 || remainder != 0)
{
n = ((UInt64)remainder << 32) | (UInt32)mid;
mid = (Int32)((UInt32)(n / divisor));
remainder = (UInt32)(n % divisor);
}
if (lo != 0 || remainder != 0)
{
n = ((UInt64)remainder << 32) | (UInt32)lo;
lo = (Int32)((UInt32)(n / divisor));
remainder = (UInt32)(n % divisor);
}
return remainder;
}
I haven't performed rigorous performance tests, but on a MacOS Sierra 10.12.6, 3,06 GHz Intel Core i3 processor and targeting .NetCore 2.1 this method seems to be much faster than D. Nesterov's (I won't give numbers since, as I have mentioned, my tests are not rigorous). It is up to whoever implements this to evaluate whether or not the performance gains pay off for the added code complexity.
Well, I guess if you need to remove an element you will make a copy of the array despising the element to be excluded.
// inserting some items
void* element_2_remove = getElement2BRemove();
for (int i = 0; i < vector->size; i++){
if(vector[i]!=element_2_remove) copy2TempVector(vector[i]);
}
free(vector->items);
free(vector);
fillFromTempVector(vector);
//
Assume that getElement2BRemove()
, copy2TempVector( void* ...)
and fillFromTempVector(...)
are auxiliary methods to handle the temp vector.
To UPLOAD a single file, you will need to create a bash script. Something like the following should work on OS X if you have sshpass
installed.
Usage:
sftpx <password> <user@hostname> <localfile> <remotefile>
Put this script somewhere in your path and call it sftpx
:
#!/bin/bash
export RND=`cat /dev/urandom | env LC_CTYPE=C tr -cd 'a-f0-9' | head -c 32`
export TMPDIR=/tmp/$RND
export FILENAME=$(basename "$4")
export DSTDIR=$(dirname "$4")
mkdir $TMPDIR
cp "$3" $TMPDIR/$FILENAME
export SSHPASS=$1
sshpass -e sftp -oBatchMode=no -b - $2 << !
lcd $TMPDIR
cd $DSTDIR
put $FILENAME
bye
!
rm $TMPDIR/$FILENAME
rmdir $TMPDIR
Write Code in Text_KeyPress Event as
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsLetter(e.KeyChar))
{
e.Handled = true;
}
}
Ok for all of you out there that arrived here in desperation searching for the same problem. I hope you will find this quicker then I did ;O.
This is how it is solved. JoostK told me at github that "the first argument to join is the table (or data) you're joining.". And he was right.
Here is the code. Different table and names but you will get the idea right? It t
DB::table('users')
->select('first_name', 'TotalCatches.*')
->join(DB::raw('(SELECT user_id, COUNT(user_id) TotalCatch,
DATEDIFF(NOW(), MIN(created_at)) Days,
COUNT(user_id)/DATEDIFF(NOW(), MIN(created_at))
CatchesPerDay FROM `catch-text` GROUP BY user_id)
TotalCatches'),
function($join)
{
$join->on('users.id', '=', 'TotalCatches.user_id');
})
->orderBy('TotalCatches.CatchesPerDay', 'DESC')
->get();
it pretty much depends on the relative sizes of the new string after every new concatenation.
With the +
operator, for every concatenation a new string is made. If the intermediary strings are relatively long, the +
becomes increasingly slower because the new intermediary string is being stored.
Consider this case:
from time import time
stri=''
a='aagsdfghfhdyjddtyjdhmfghmfgsdgsdfgsdfsdfsdfsdfsdfsdfddsksarigqeirnvgsdfsdgfsdfgfg'
l=[]
#case 1
t=time()
for i in range(1000):
stri=stri+a+repr(i)
print time()-t
#case 2
t=time()
for i in xrange(1000):
l.append(a+repr(i))
z=''.join(l)
print time()-t
#case 3
t=time()
for i in range(1000):
stri=stri+repr(i)
print time()-t
#case 4
t=time()
for i in xrange(1000):
l.append(repr(i))
z=''.join(l)
print time()-t
Results
1 0.00493192672729
2 0.000509023666382
3 0.00042200088501
4 0.000482797622681
In the case of 1&2, we add a large string, and join() performs about 10 times faster. In case 3&4, we add a small string, and '+' performs slightly faster
Based on the solution from bluefeet here is a stored procedure that uses dynamic sql to generate the transposed table. It requires that all the fields are numeric except for the transposed column (the column that will be the header in the resulting table):
/****** Object: StoredProcedure [dbo].[SQLTranspose] Script Date: 11/10/2015 7:08:02 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Paco Zarate
-- Create date: 2015-11-10
-- Description: SQLTranspose dynamically changes a table to show rows as headers. It needs that all the values are numeric except for the field using for transposing.
-- Parameters: @TableName - Table to transpose
-- @FieldNameTranspose - Column that will be the new headers
-- Usage: exec SQLTranspose <table>, <FieldToTranspose>
-- table and FIeldToTranspose should be written using single quotes
-- =============================================
ALTER PROCEDURE [dbo].[SQLTranspose]
-- Add the parameters for the stored procedure here
@TableName NVarchar(MAX) = '',
@FieldNameTranspose NVarchar(MAX) = ''
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @colsUnpivot AS NVARCHAR(MAX),
@query AS NVARCHAR(MAX),
@queryPivot AS NVARCHAR(MAX),
@colsPivot as NVARCHAR(MAX),
@columnToPivot as NVARCHAR(MAX),
@tableToPivot as NVARCHAR(MAX),
@colsResult as xml
select @tableToPivot = @TableName;
select @columnToPivot = @FieldNameTranspose
select @colsUnpivot = stuff((select ','+quotename(C.name)
from sys.columns as C
where C.object_id = object_id(@tableToPivot) and
C.name <> @columnToPivot
for xml path('')), 1, 1, '')
set @queryPivot = 'SELECT @colsResult = (SELECT '',''
+ quotename('+@columnToPivot+')
from '+@tableToPivot+' t
where '+@columnToPivot+' <> ''''
FOR XML PATH(''''), TYPE)'
exec sp_executesql @queryPivot, N'@colsResult xml out', @colsResult out
select @colsPivot = STUFF(@colsResult.value('.', 'NVARCHAR(MAX)'),1,1,'')
set @query
= 'select name, rowid, '+@colsPivot+'
from
(
select '+@columnToPivot+' , name, value, ROW_NUMBER() over (partition by '+@columnToPivot+' order by '+@columnToPivot+') as rowid
from '+@tableToPivot+'
unpivot
(
value for name in ('+@colsUnpivot+')
) unpiv
) src
pivot
(
sum(value)
for '+@columnToPivot+' in ('+@colsPivot+')
) piv
order by rowid'
exec(@query)
END
Code which disable chrome extensions for ones, who uses DesiredCapabilities to set browser flags :
desired_capabilities['chromeOptions'] = {
"args": ["--disable-extensions"],
"extensions": []
}
webdriver.Chrome(desired_capabilities=desired_capabilities)
Expanding from Sinan Ünür solution:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test</title>
<style type="text/css">
table { page-break-inside:auto }
div { page-break-inside:avoid; } /* This is the key */
thead { display:table-header-group }
tfoot { display:table-footer-group }
</style>
</head>
<body>
<table>
<thead>
<tr><th>heading</th></tr>
</thead>
<tfoot>
<tr><td>notes</td></tr>
</tfoot>
<tr>
<td><div>Long<br />cell<br />should'nt<br />be<br />cut</div></td>
</tr>
<tr>
<td><div>Long<br />cell<br />should'nt<br />be<br />cut</div></td>
</tr>
<!-- 500 more rows -->
<tr>
<td>x</td>
</tr>
</tbody>
</table>
</body>
</html>
It seems that page-break-inside:avoid
in some browsers is only taken in consideration for block elements, not for cell, table, row neither inline-block.
If you try to display:block
the TR
tag, and use there page-break-inside:avoid
, it works, but messes around with your table layout.
You probably are looking for AddReference dialog accessible from Project Context Menu (right click..)
From there you can reference dll's, after which you can reference namespaces that you need in your code.
For those that are not familiar:
sudo chown -R YOUR_COMPUTER_USER_NAME PATH_OF_FILE
You can use CSS grid to achieve this, this is the long-hand version for the purposes of illustration:
div.container {_x000D_
display: grid;_x000D_
grid-template-columns: 220px 20px auto;_x000D_
grid-template-rows: auto;_x000D_
}_x000D_
_x000D_
div.left {_x000D_
grid-column-start: 1;_x000D_
grid-column-end: 2;_x000D_
grid-row-start: row1-start_x000D_
grid-row-end: 3;_x000D_
background-color: Aqua;_x000D_
}_x000D_
_x000D_
div.right {_x000D_
grid-column-start: 3;_x000D_
grid-column-end: 4;_x000D_
grid-row-start: 1;_x000D_
grid-row-end; 1;_x000D_
background-color: Silver;_x000D_
}_x000D_
_x000D_
div.below {_x000D_
grid-column-start: 1;_x000D_
grid-column-end: 4;_x000D_
grid-row-start: 2;_x000D_
grid-row-end; 2;_x000D_
}
_x000D_
<div class="container">_x000D_
<div class="left">Left</div>_x000D_
<div class="right">Right</div>_x000D_
<div class="below">Below</div>_x000D_
</div>
_x000D_
Or the more traditional method using float and margin.
I have included a background colour in this example to help show where things are - and also what to do with content below the floated-area.
Don't put your styles inline in real life, extract them into a style sheet.
div.left {_x000D_
width: 200px;_x000D_
float: left;_x000D_
background-color: Aqua;_x000D_
}_x000D_
_x000D_
div.right {_x000D_
margin-left: 220px;_x000D_
background-color: Silver;_x000D_
}_x000D_
_x000D_
div.clear {_x000D_
clear: both;_x000D_
}
_x000D_
<div class="left"> Left </div>_x000D_
<div class="right"> Right </div>_x000D_
<div class="clear">Below</div>
_x000D_
<div style="width: 200px; float: left; background-color: Aqua;"> Left </div>
<div style="margin-left: 220px; background-color: Silver;"> Right </div>
<div style="clear: both;">Below</div>
This will find the second occurrence of substring in string.
def find_2nd(string, substring):
return string.find(substring, string.find(substring) + 1)
Edit: I haven't thought much about the performance, but a quick recursion can help with finding the nth occurrence:
def find_nth(string, substring, n):
if (n == 1):
return string.find(substring)
else:
return string.find(substring, find_nth(string, substring, n - 1) + 1)
Short date patterns:
const shortDatePatterns = {
'aa-DJ': "dd/MM/yyyy",
'aa-ER': "dd/MM/yyyy",
'aa-ET': "dd/MM/yyyy",
'af': "yyyy-MM-dd",
'af-NA': "yyyy-MM-dd",
'af-ZA': "yyyy-MM-dd",
'agq-CM': "d/M/yyyy",
'ak-GH': "yyyy/MM/dd",
'am': "dd/MM/yyyy",
'am-ET': "dd/MM/yyyy",
'ar': "dd/MM/yy",
'ar-001': "d/M/yyyy",
'ar-AE': "dd/MM/yyyy",
'ar-BH': "dd/MM/yyyy",
'ar-DJ': "d/M/yyyy",
'ar-DZ': "dd-MM-yyyy",
'ar-EG': "dd/MM/yyyy",
'ar-ER': "d/M/yyyy",
'ar-IL': "d/M/yyyy",
'ar-IQ': "dd/MM/yyyy",
'ar-JO': "dd/MM/yyyy",
'ar-KM': "d/M/yyyy",
'ar-KW': "dd/MM/yyyy",
'ar-LB': "dd/MM/yyyy",
'ar-LY': "dd/MM/yyyy",
'ar-MA': "dd-MM-yyyy",
'ar-MR': "d/M/yyyy",
'ar-OM': "dd/MM/yyyy",
'ar-PS': "d/M/yyyy",
'ar-QA': "dd/MM/yyyy",
'ar-SA': "dd/MM/yy",
'ar-SD': "d/M/yyyy",
'ar-SO': "d/M/yyyy",
'ar-SS': "d/M/yyyy",
'ar-SY': "dd/MM/yyyy",
'ar-TD': "d/M/yyyy",
'ar-TN': "dd-MM-yyyy",
'ar-YE': "dd/MM/yyyy",
'arn-CL': "dd-MM-yyyy",
'as': "dd-MM-yyyy",
'as-IN': "dd-MM-yyyy",
'asa-TZ': "dd/MM/yyyy",
'ast-ES': "d/M/yyyy",
'az': "dd.MM.yyyy",
'az-Cyrl-AZ': "dd.MM.yyyy",
'az-Latn-AZ': "dd.MM.yyyy",
'ba': "dd.MM.yy",
'ba-RU': "dd.MM.yy",
'bas-CM': "d/M/yyyy",
'be': "dd.MM.yy",
'be-BY': "dd.MM.yy",
'bem-ZM': "dd/MM/yyyy",
'bez-TZ': "dd/MM/yyyy",
'bg': "d.M.yyyy '?.'",
'bg-BG': "d.M.yyyy '?.'",
'bin-NG': "d/M/yyyy",
'bm': "d/M/yyyy",
'bm-Latn-ML': "d/M/yyyy",
'bn': "d/M/yyyy",
'bn-BD': "d/M/yyyy",
'bn-IN': "dd-MM-yy",
'bo': "yyyy/M/d",
'bo-CN': "yyyy/M/d",
'bo-IN': "yyyy-MM-dd",
'br': "dd/MM/yyyy",
'br-FR': "dd/MM/yyyy",
'brx-IN': "M/d/yyyy",
'bs': "d.M.yyyy.",
'bs-Cyrl-BA': "d.M.yyyy",
'bs-Latn-BA': "d.M.yyyy.",
'byn-ER': "dd/MM/yyyy",
'ca': "d/M/yyyy",
'ca-AD': "d/M/yyyy",
'ca-ES': "d/M/yyyy",
'ca-ES-valencia': "d/M/yyyy",
'ca-FR': "d/M/yyyy",
'ca-IT': "d/M/yyyy",
'ce-RU': "yyyy-MM-dd",
'cgg-UG': "dd/MM/yyyy",
'chr-Cher-US': "M/d/yyyy",
'co': "dd/MM/yyyy",
'co-FR': "dd/MM/yyyy",
'cs-CZ': "dd.MM.yyyy",
'cu': "yyyy.MM.dd",
'cu-RU': "yyyy.MM.dd",
'cy': "dd/MM/yyyy",
'cy-GB': "dd/MM/yyyy",
'da-DK': "dd-MM-yyyy",
'da-GL': "dd/MM/yyyy",
'dav-KE': "dd/MM/yyyy",
'de': "dd.MM.yyyy",
'de-AT': "dd.MM.yyyy",
'de-BE': "dd.MM.yyyy",
'de-CH': "dd.MM.yyyy",
'de-DE': "dd.MM.yyyy",
'de-IT': "dd.MM.yyyy",
'de-LI': "dd.MM.yyyy",
'de-LU': "dd.MM.yyyy",
'dje-NE': "d/M/yyyy",
'dsb-DE': "d. M. yyyy",
'dua-CM': "d/M/yyyy",
'dv-MV': "dd/MM/yy",
'dyo-SN': "d/M/yyyy",
'dz': "yyyy-MM-dd",
'dz-BT': "yyyy-MM-dd",
'ebu-KE': "dd/MM/yyyy",
'ee': "M/d/yyyy",
'ee-GH': "M/d/yyyy",
'ee-TG': "M/d/yyyy",
'el-CY': "d/M/yyyy",
'el-GR': "d/M/yyyy",
'en-001': "dd/MM/yyyy",
'en-029': "dd/MM/yyyy",
'en-150': "dd/MM/yyyy",
'en-AG': "dd/MM/yyyy",
'en-AI': "dd/MM/yyyy",
'en-AS': "M/d/yyyy",
'en-AT': "dd/MM/yyyy",
'en-AU': "d/MM/yyyy",
'en-BB': "dd/MM/yyyy",
'en-BE': "dd/MM/yyyy",
'en-BI': "M/d/yyyy",
'en-BM': "dd/MM/yyyy",
'en-BS': "dd/MM/yyyy",
'en-BW': "dd/MM/yyyy",
'en-BZ': "dd/MM/yyyy",
'en-CA': "yyyy-MM-dd",
'en-CC': "dd/MM/yyyy",
'en-CH': "dd/MM/yyyy",
'en-CK': "dd/MM/yyyy",
'en-CM': "dd/MM/yyyy",
'en-CX': "dd/MM/yyyy",
'en-CY': "dd/MM/yyyy",
'en-DE': "dd/MM/yyyy",
'en-DK': "dd/MM/yyyy",
'en-DM': "dd/MM/yyyy",
'en-ER': "dd/MM/yyyy",
'en-FI': "dd/MM/yyyy",
'en-FJ': "dd/MM/yyyy",
'en-FK': "dd/MM/yyyy",
'en-FM': "dd/MM/yyyy",
'en-GB': "dd/MM/yyyy",
'en-GD': "dd/MM/yyyy",
'en-GG': "dd/MM/yyyy",
'en-GH': "dd/MM/yyyy",
'en-GI': "dd/MM/yyyy",
'en-GM': "dd/MM/yyyy",
'en-GU': "M/d/yyyy",
'en-GY': "dd/MM/yyyy",
'en-HK': "d/M/yyyy",
'en-ID': "dd/MM/yyyy",
'en-IE': "dd/MM/yyyy",
'en-IL': "dd/MM/yyyy",
'en-IM': "dd/MM/yyyy",
'en-IN': "dd-MM-yyyy",
'en-IO': "dd/MM/yyyy",
'en-JE': "dd/MM/yyyy",
'en-JM': "d/M/yyyy",
'en-KE': "dd/MM/yyyy",
'en-KI': "dd/MM/yyyy",
'en-KN': "dd/MM/yyyy",
'en-KY': "dd/MM/yyyy",
'en-LC': "dd/MM/yyyy",
'en-LR': "dd/MM/yyyy",
'en-LS': "dd/MM/yyyy",
'en-MG': "dd/MM/yyyy",
'en-MH': "M/d/yyyy",
'en-MO': "dd/MM/yyyy",
'en-MP': "M/d/yyyy",
'en-MS': "dd/MM/yyyy",
'en-MT': "dd/MM/yyyy",
'en-MU': "dd/MM/yyyy",
'en-MW': "dd/MM/yyyy",
'en-MY': "d/M/yyyy",
'en-NA': "dd/MM/yyyy",
'en-NF': "dd/MM/yyyy",
'en-NG': "dd/MM/yyyy",
'en-NL': "dd/MM/yyyy",
'en-NR': "dd/MM/yyyy",
'en-NU': "dd/MM/yyyy",
'en-NZ': "d/MM/yyyy",
'en-PG': "dd/MM/yyyy",
'en-PH': "dd/MM/yyyy",
'en-PK': "dd/MM/yyyy",
'en-PN': "dd/MM/yyyy",
'en-PR': "M/d/yyyy",
'en-PW': "dd/MM/yyyy",
'en-RW': "dd/MM/yyyy",
'en-SB': "dd/MM/yyyy",
'en-SC': "dd/MM/yyyy",
'en-SD': "dd/MM/yyyy",
'en-SE': "yyyy-MM-dd",
'en-SG': "d/M/yyyy",
'en-SH': "dd/MM/yyyy",
'en-SI': "dd/MM/yyyy",
'en-SL': "dd/MM/yyyy",
'en-SS': "dd/MM/yyyy",
'en-SX': "dd/MM/yyyy",
'en-SZ': "dd/MM/yyyy",
'en-TC': "dd/MM/yyyy",
'en-TK': "dd/MM/yyyy",
'en-TO': "dd/MM/yyyy",
'en-TT': "dd/MM/yyyy",
'en-TV': "dd/MM/yyyy",
'en-TZ': "dd/MM/yyyy",
'en-UG': "dd/MM/yyyy",
'en-UM': "M/d/yyyy",
'en-US': "M/d/yyyy",
'en-VC': "dd/MM/yyyy",
'en-VG': "dd/MM/yyyy",
'en-VI': "M/d/yyyy",
'en-VU': "dd/MM/yyyy",
'en-WS': "dd/MM/yyyy",
'en-ZA': "yyyy/MM/dd",
'en-ZM': "dd/MM/yyyy",
'en-ZW': "d/M/yyyy",
'eo-001': "yyyy-MM-dd",
'es': "dd/MM/yyyy",
'es-419': "d/M/yyyy",
'es-AR': "d/M/yyyy",
'es-BO': "d/M/yyyy",
'es-BR': "d/M/yyyy",
'es-BZ': "d/M/yyyy",
'es-CL': "dd-MM-yyyy",
'es-CO': "d/MM/yyyy",
'es-CR': "d/M/yyyy",
'es-CU': "d/M/yyyy",
'es-DO': "d/M/yyyy",
'es-EC': "d/M/yyyy",
'es-ES': "dd/MM/yyyy",
'es-GQ': "d/M/yyyy",
'es-GT': "d/MM/yyyy",
'es-HN': "d/M/yyyy",
'es-MX': "dd/MM/yyyy",
'es-NI': "d/M/yyyy",
'es-PA': "MM/dd/yyyy",
'es-PE': "d/MM/yyyy",
'es-PH': "d/M/yyyy",
'es-PR': "MM/dd/yyyy",
'es-PY': "d/M/yyyy",
'es-SV': "d/M/yyyy",
'es-US': "M/d/yyyy",
'es-UY': "d/M/yyyy",
'es-VE': "d/M/yyyy",
'et': "dd.MM.yyyy",
'et-EE': "dd.MM.yyyy",
'eu-ES': "yyyy/M/d",
'ewo-CM': "d/M/yyyy",
'fa-IR': "dd/MM/yyyy",
'ff-CM': "d/M/yyyy",
'ff-GN': "d/M/yyyy",
'ff-Latn-SN': "dd/MM/yyyy",
'ff-MR': "d/M/yyyy",
'ff-NG': "d/M/yyyy",
'fi': "d.M.yyyy",
'fi-FI': "d.M.yyyy",
'fil-PH': "M/d/yyyy",
'fo': "dd.MM.yyyy",
'fo-DK': "dd.MM.yyyy",
'fo-FO': "dd.MM.yyyy",
'fr': "dd/MM/yyyy",
'fr-029': "dd/MM/yyyy",
'fr-BE': "dd-MM-yy",
'fr-BF': "dd/MM/yyyy",
'fr-BI': "dd/MM/yyyy",
'fr-BJ': "dd/MM/yyyy",
'fr-BL': "dd/MM/yyyy",
'fr-CA': "yyyy-MM-dd",
'fr-CD': "dd/MM/yyyy",
'fr-CF': "dd/MM/yyyy",
'fr-CG': "dd/MM/yyyy",
'fr-CH': "dd.MM.yyyy",
'fr-CI': "dd/MM/yyyy",
'fr-CM': "dd/MM/yyyy",
'fr-DJ': "dd/MM/yyyy",
'fr-DZ': "dd/MM/yyyy",
'fr-FR': "dd/MM/yyyy",
'fr-GA': "dd/MM/yyyy",
'fr-GF': "dd/MM/yyyy",
'fr-GN': "dd/MM/yyyy",
'fr-GP': "dd/MM/yyyy",
'fr-GQ': "dd/MM/yyyy",
'fr-HT': "dd/MM/yyyy",
'fr-KM': "dd/MM/yyyy",
'fr-LU': "dd/MM/yyyy",
'fr-MA': "dd/MM/yyyy",
'fr-MC': "dd/MM/yyyy",
'fr-MF': "dd/MM/yyyy",
'fr-MG': "dd/MM/yyyy",
'fr-ML': "dd/MM/yyyy",
'fr-MQ': "dd/MM/yyyy",
'fr-MR': "dd/MM/yyyy",
'fr-MU': "dd/MM/yyyy",
'fr-NC': "dd/MM/yyyy",
'fr-NE': "dd/MM/yyyy",
'fr-PF': "dd/MM/yyyy",
'fr-PM': "dd/MM/yyyy",
'fr-RE': "dd/MM/yyyy",
'fr-RW': "dd/MM/yyyy",
'fr-SC': "dd/MM/yyyy",
'fr-SN': "dd/MM/yyyy",
'fr-SY': "dd/MM/yyyy",
'fr-TD': "dd/MM/yyyy",
'fr-TG': "dd/MM/yyyy",
'fr-TN': "dd/MM/yyyy",
'fr-VU': "dd/MM/yyyy",
'fr-WF': "dd/MM/yyyy",
'fr-YT': "dd/MM/yyyy",
'fur-IT': "dd/MM/yyyy",
'fy-NL': "dd-MM-yyyy",
'ga': "dd/MM/yyyy",
'ga-IE': "dd/MM/yyyy",
'gd': "dd/MM/yyyy",
'gd-GB': "dd/MM/yyyy",
'gl': "dd/MM/yyyy",
'gl-ES': "dd/MM/yyyy",
'gn': "dd/MM/yyyy",
'gn-PY': "dd/MM/yyyy",
'gsw-CH': "dd.MM.yyyy",
'gsw-FR': "dd/MM/yyyy",
'gsw-LI': "dd.MM.yyyy",
'gu': "dd-MM-yy",
'gu-IN': "dd-MM-yy",
'guz-KE': "dd/MM/yyyy",
'gv-IM': "dd/MM/yyyy",
'ha-Latn-GH': "d/M/yyyy",
'ha-Latn-NE': "d/M/yyyy",
'ha-Latn-NG': "d/M/yyyy",
'haw-US': "d/M/yyyy",
'he-IL': "dd/MM/yyyy",
'hi-IN': "dd-MM-yyyy",
'hr': "d.M.yyyy.",
'hr-BA': "d. M. yyyy.",
'hr-HR': "d.M.yyyy.",
'hsb-DE': "d.M.yyyy",
'hu': "yyyy. MM. dd.",
'hu-HU': "yyyy. MM. dd.",
'hy-AM': "dd.MM.yyyy",
'ia-001': "yyyy/MM/dd",
'ia-FR': "yyyy/MM/dd",
'ibb-NG': "d/M/yyyy",
'id': "dd/MM/yyyy",
'id-ID': "dd/MM/yyyy",
'ig-NG': "dd/MM/yyyy",
'ii-CN': "yyyy/M/d",
'is': "d.M.yyyy",
'is-IS': "d.M.yyyy",
'it': "dd/MM/yyyy",
'it-CH': "dd.MM.yyyy",
'it-IT': "dd/MM/yyyy",
'it-SM': "dd/MM/yyyy",
'it-VA': "dd/MM/yyyy",
'iu-Cans-CA': "d/M/yyyy",
'iu-Latn-CA': "d/MM/yyyy",
'ja-JP': "yyyy/MM/dd",
'jgo-CM': "yyyy-MM-dd",
'jmc-TZ': "dd/MM/yyyy",
'jv-Java-ID': "dd/MM/yyyy",
'jv-Latn-ID': "dd/MM/yyyy",
'ka-GE': "dd.MM.yyyy",
'kab-DZ': "d/M/yyyy",
'kam-KE': "dd/MM/yyyy",
'kde-TZ': "dd/MM/yyyy",
'kea-CV': "d/M/yyyy",
'khq-ML': "d/M/yyyy",
'ki': "dd/MM/yyyy",
'ki-KE': "dd/MM/yyyy",
'kk-KZ': "dd.MM.yyyy",
'kkj-CM': "dd/MM yyyy",
'kl-GL': "dd-MM-yyyy",
'kln-KE': "dd/MM/yyyy",
'km': "dd/MM/yy",
'km-KH': "dd/MM/yy",
'kn': "dd-MM-yy",
'kn-IN': "dd-MM-yy",
'ko-KP': "yyyy. M. d.",
'ko-KR': "yyyy-MM-dd",
'kok-IN': "dd-MM-yyyy",
'kr': "d/M/yyyy",
'kr-NG': "d/M/yyyy",
'ks-Arab-IN': "M/d/yyyy",
'ks-Deva-IN': "dd-MM-yyyy",
'ksb-TZ': "dd/MM/yyyy",
'ksf-CM': "d/M/yyyy",
'ksh-DE': "d. M. yyyy",
'ku-Arab-IQ': "yyyy/MM/dd",
'ku-Arab-IR': "dd/MM/yyyy",
'kw': "dd/MM/yyyy",
'kw-GB': "dd/MM/yyyy",
'ky': "d-MMM yy",
'ky-KG': "d-MMM yy",
'la': "dd/MM/yyyy",
'la-001': "dd/MM/yyyy",
'lag-TZ': "dd/MM/yyyy",
'lb': "dd.MM.yy",
'lb-LU': "dd.MM.yy",
'lg-UG': "dd/MM/yyyy",
'lkt-US': "M/d/yyyy",
'ln-AO': "d/M/yyyy",
'ln-CD': "d/M/yyyy",
'ln-CF': "d/M/yyyy",
'ln-CG': "d/M/yyyy",
'lo-LA': "d/M/yyyy",
'lrc-IQ': "yyyy-MM-dd",
'lrc-IR': "dd/MM/yyyy",
'lt': "yyyy-MM-dd",
'lt-LT': "yyyy-MM-dd",
'lu': "d/M/yyyy",
'lu-CD': "d/M/yyyy",
'luo-KE': "dd/MM/yyyy",
'luy-KE': "dd/MM/yyyy",
'lv': "dd.MM.yyyy",
'lv-LV': "dd.MM.yyyy",
'mas-KE': "dd/MM/yyyy",
'mas-TZ': "dd/MM/yyyy",
'mer-KE': "dd/MM/yyyy",
'mfe-MU': "d/M/yyyy",
'mg': "yyyy-MM-dd",
'mg-MG': "yyyy-MM-dd",
'mgh-MZ': "dd/MM/yyyy",
'mgo-CM': "yyyy-MM-dd",
'mi-NZ': "dd/MM/yyyy",
'mk': "dd.M.yyyy",
'mk-MK': "dd.M.yyyy",
'ml': "d/M/yyyy",
'ml-IN': "d/M/yyyy",
'mn': "yyyy.MM.dd",
'mn-MN': "yyyy.MM.dd",
'mn-Mong-CN': "yyyy/M/d",
'mn-Mong-MN': "yyyy/M/d",
'mni-IN': "dd/MM/yyyy",
'moh-CA': "M/d/yyyy",
'mr': "dd-MM-yyyy",
'mr-IN': "dd-MM-yyyy",
'ms': "d/MM/yyyy",
'ms-BN': "d/MM/yyyy",
'ms-MY': "d/MM/yyyy",
'ms-SG': "d/MM/yyyy",
'mt': "dd/MM/yyyy",
'mt-MT': "dd/MM/yyyy",
'mua-CM': "d/M/yyyy",
'my': "dd-MM-yyyy",
'my-MM': "dd-MM-yyyy",
'mzn-IR': "dd/MM/yyyy",
'naq-NA': "dd/MM/yyyy",
'nb-NO': "dd.MM.yyyy",
'nb-SJ': "dd.MM.yyyy",
'nd-ZW': "dd/MM/yyyy",
'nds-DE': "d.MM.yyyy",
'nds-NL': "d.MM.yyyy",
'ne': "M/d/yyyy",
'ne-IN': "yyyy/M/d",
'ne-NP': "M/d/yyyy",
'nl': "d-M-yyyy",
'nl-AW': "dd-MM-yyyy",
'nl-BE': "d/MM/yyyy",
'nl-BQ': "dd-MM-yyyy",
'nl-CW': "dd-MM-yyyy",
'nl-NL': "d-M-yyyy",
'nl-SR': "dd-MM-yyyy",
'nl-SX': "dd-MM-yyyy",
'nmg-CM': "d/M/yyyy",
'nn-NO': "dd.MM.yyyy",
'nnh-CM': "dd/MM/yyyy",
'no': "dd.MM.yyyy",
'nqo-GN': "dd/MM/yyyy",
'nr': "yyyy-MM-dd",
'nr-ZA': "yyyy-MM-dd",
'nso-ZA': "yyyy-MM-dd",
'nus-SS': "d/MM/yyyy",
'nyn-UG': "dd/MM/yyyy",
'oc-FR': "dd/MM/yyyy",
'om': "dd/MM/yyyy",
'om-ET': "dd/MM/yyyy",
'om-KE': "dd/MM/yyyy",
'or-IN': "dd-MM-yy",
'os-GE': "dd.MM.yyyy",
'os-RU': "dd.MM.yyyy",
'pa': "dd-MM-yy",
'pa-Arab-PK': "dd-MM-yy",
'pa-IN': "dd-MM-yy",
'pap-029': "d-M-yyyy",
'pl': "dd.MM.yyyy",
'pl-PL': "dd.MM.yyyy",
'prg-001': "dd.MM.yyyy",
'prs-AF': "yyyy/M/d",
'ps': "yyyy/M/d",
'ps-AF': "yyyy/M/d",
'pt': "dd/MM/yyyy",
'pt-AO': "dd/MM/yyyy",
'pt-BR': "dd/MM/yyyy",
'pt-CH': "dd/MM/yyyy",
'pt-CV': "dd/MM/yyyy",
'pt-GQ': "dd/MM/yyyy",
'pt-GW': "dd/MM/yyyy",
'pt-LU': "dd/MM/yyyy",
'pt-MO': "dd/MM/yyyy",
'pt-MZ': "dd/MM/yyyy",
'pt-PT': "dd/MM/yyyy",
'pt-ST': "dd/MM/yyyy",
'pt-TL': "dd/MM/yyyy",
'quc-Latn-GT': "dd/MM/yyyy",
'quz-BO': "dd/MM/yyyy",
'quz-EC': "dd/MM/yyyy",
'quz-PE': "dd/MM/yyyy",
'rm-CH': "dd-MM-yyyy",
'rn-BI': "d/M/yyyy",
'ro': "dd.MM.yyyy",
'ro-MD': "dd.MM.yyyy",
'ro-RO': "dd.MM.yyyy",
'rof-TZ': "dd/MM/yyyy",
'ru': "dd.MM.yyyy",
'ru-BY': "dd.MM.yyyy",
'ru-KG': "dd.MM.yyyy",
'ru-KZ': "dd.MM.yyyy",
'ru-MD': "dd.MM.yyyy",
'ru-RU': "dd.MM.yyyy",
'ru-UA': "dd.MM.yyyy",
'rw': "yyyy-MM-dd",
'rw-RW': "yyyy-MM-dd",
'rwk-TZ': "dd/MM/yyyy",
'sa': "dd-MM-yyyy",
'sa-IN': "dd-MM-yyyy",
'sah-RU': "dd.MM.yyyy",
'saq-KE': "dd/MM/yyyy",
'sbp-TZ': "dd/MM/yyyy",
'sd': "dd/MM/yyyy",
'sd-Arab-PK': "dd/MM/yyyy",
'sd-Deva-IN': "dd/MM/yyyy",
'se': "yyyy-MM-dd",
'se-FI': "d.M.yyyy",
'se-NO': "yyyy-MM-dd",
'se-SE': "yyyy-MM-dd",
'seh-MZ': "d/M/yyyy",
'ses-ML': "d/M/yyyy",
'sg': "d/M/yyyy",
'sg-CF': "d/M/yyyy",
'shi-Latn-MA': "d/M/yyyy",
'shi-Tfng-MA': "d/M/yyyy",
'si': "yyyy-MM-dd",
'si-LK': "yyyy-MM-dd",
'sk': "d. M. yyyy",
'sk-SK': "d. M. yyyy",
'sl': "d. MM. yyyy",
'sl-SI': "d. MM. yyyy",
'sma-NO': "dd.MM.yyyy",
'sma-SE': "yyyy-MM-dd",
'smj-NO': "dd.MM.yyyy",
'smj-SE': "yyyy-MM-dd",
'smn-FI': "d.M.yyyy",
'sms-FI': "d.M.yyyy",
'sn': "yyyy-MM-dd",
'sn-Latn-ZW': "yyyy-MM-dd",
'so': "dd/MM/yyyy",
'so-DJ': "dd/MM/yyyy",
'so-ET': "dd/MM/yyyy",
'so-KE': "dd/MM/yyyy",
'so-SO': "dd/MM/yyyy",
'sq-AL': "d.M.yyyy",
'sq-MK': "d.M.yyyy",
'sq-XK': "d.M.yyyy",
'sr': "d.M.yyyy.",
'sr-Cyrl-BA': "d.M.yyyy.",
'sr-Cyrl-ME': "d.M.yyyy.",
'sr-Cyrl-RS': "dd.MM.yyyy.",
'sr-Cyrl-XK': "d.M.yyyy.",
'sr-Latn-BA': "d.M.yyyy.",
'sr-Latn-ME': "d.M.yyyy.",
'sr-Latn-RS': "d.M.yyyy.",
'sr-Latn-XK': "d.M.yyyy.",
'ss': "yyyy-MM-dd",
'ss-SZ': "yyyy-MM-dd",
'ss-ZA': "yyyy-MM-dd",
'ssy-ER': "dd/MM/yyyy",
'st': "yyyy-MM-dd",
'st-LS': "yyyy-MM-dd",
'st-ZA': "yyyy-MM-dd",
'sv': "yyyy-MM-dd",
'sv-AX': "yyyy-MM-dd",
'sv-FI': "dd-MM-yyyy",
'sv-SE': "yyyy-MM-dd",
'sw-CD': "dd/MM/yyyy",
'sw-KE': "dd/MM/yyyy",
'sw-TZ': "dd/MM/yyyy",
'sw-UG': "dd/MM/yyyy",
'syr-SY': "dd/MM/yyyy",
'ta-IN': "dd-MM-yyyy",
'ta-LK': "d/M/yyyy",
'ta-MY': "d/M/yyyy",
'ta-SG': "d/M/yyyy",
'te-IN': "dd-MM-yy",
'teo-KE': "dd/MM/yyyy",
'teo-UG': "dd/MM/yyyy",
'tg': "dd.MM.yyyy",
'tg-Cyrl-TJ': "dd.MM.yyyy",
'th': "d/M/yyyy",
'th-TH': "d/M/yyyy",
'ti-ER': "dd/MM/yyyy",
'ti-ET': "dd/MM/yyyy",
'tig-ER': "dd/MM/yyyy",
'tk': "dd.MM.yy 'ý.'",
'tk-TM': "dd.MM.yy 'ý.'",
'tn': "yyyy-MM-dd",
'tn-BW': "yyyy-MM-dd",
'tn-ZA': "yyyy-MM-dd",
'to': "d/M/yyyy",
'to-TO': "d/M/yyyy",
'tr': "d.MM.yyyy",
'tr-CY': "d.MM.yyyy",
'tr-TR': "d.MM.yyyy",
'ts-ZA': "yyyy-MM-dd",
'tt': "dd.MM.yyyy",
'tt-RU': "dd.MM.yyyy",
'twq-NE': "d/M/yyyy",
'tzm-Arab-MA': "d/M/yyyy",
'tzm-Latn-DZ': "dd-MM-yyyy",
'tzm-Latn-MA': "dd/MM/yyyy",
'tzm-Tfng-MA': "dd-MM-yyyy",
'ug': "yyyy-M-d",
'ug-CN': "yyyy-M-d",
'uk-UA': "dd.MM.yyyy",
'ur-IN': "d/M/yy",
'ur-PK': "dd/MM/yyyy",
'uz': "dd/MM/yyyy",
'uz-Arab-AF': "dd/MM yyyy",
'uz-Cyrl-UZ': "dd/MM/yyyy",
'uz-Latn-UZ': "dd/MM/yyyy",
'vai-Latn-LR': "dd/MM/yyyy",
'vai-Vaii-LR': "dd/MM/yyyy",
've': "yyyy-MM-dd",
've-ZA': "yyyy-MM-dd",
'vi': "dd/MM/yyyy",
'vi-VN': "dd/MM/yyyy",
'vo-001': "yyyy-MM-dd",
'vun-TZ': "dd/MM/yyyy",
'wae-CH': "yyyy-MM-dd",
'wal-ET': "dd/MM/yyyy",
'wo-SN': "dd/MM/yyyy",
'xh-ZA': "yyyy-MM-dd",
'xog-UG': "dd/MM/yyyy",
'yav-CM': "d/M/yyyy",
'yi-001': "dd/MM/yyyy",
'yo-BJ': "dd/MM/yyyy",
'yo-NG': "dd/MM/yyyy",
'zgh-Tfng-MA': "d/M/yyyy",
'zh-CN': "yyyy/M/d",
'zh-Hans-HK': "d/M/yyyy",
'zh-Hans-MO': "d/M/yyyy",
'zh-HK': "d/M/yyyy",
'zh-MO': "d/M/yyyy",
'zh-SG': "d/M/yyyy",
'zh-TW': "yyyy/M/d",
'zu-ZA': "M/d/yyyy",
};
You've tried alot. And I feel for you. Here is an idea. I kinda followed everything you tried. The mental note I have in my head goes like this: "When Sql Server won't connect when you've tried everything, wire up your firewall rules by the program, not the port"
I know you said you disabled the firewall. But something is telling me to give this a try anyways.
I think you have to open the firewall "by program", and not by port.
http://technet.microsoft.com/en-us/library/cc646023.aspx
To add a program exception to the firewall using the Windows Firewall item in Control Panel.
On the Exceptions tab of the Windows Firewall item in Control Panel, click Add a program.
Browse to the location of the instance of SQL Server that you want to allow through the firewall, for example C:\Program Files\Microsoft SQL Server\MSSQL11.<instance_name>\MSSQL\Binn, select sqlservr.exe, and then click Open.
Click OK.
EDIT..........
http://msdn.microsoft.com/en-us/library/ms190479.aspx
I'm a little cloudy on which "program" you're trying to use on SQLB?
Is it SSMS on SQLB? Or a client program on SQLB ?
EDIT...........
No idea if this will help. But I use this to ping "ports" ... and something that is outside of the SSMS world.
http://www.microsoft.com/en-us/download/details.aspx?id=24009
Yes, you can input multiple items from cin
, using exactly the syntax you describe. The result is essentially identical to:
cin >> a;
cin >> b;
cin >> c;
This is due to a technique called "operator chaining".
Each call to operator>>(istream&, T)
(where T
is some arbitrary type) returns a reference to its first argument. So cin >> a
returns cin
, which can be used as (cin>>a)>>b
and so forth.
Note that each call to operator>>(istream&, T)
first consumes all whitespace characters, then as many characters as is required to satisfy the input operation, up to (but not including) the first next whitespace character, invalid character, or EOF.
For anyone coming across this question who uses Jaspersoft Studio (which, I think, is replacing iReports; it's quite similar, still freeware, just based on eclipse), look for the "Compile Report" icon on top of the editor area of your .jrxml file. Its icon, first in that line of icons, is a file with binary numbers on it (at least in version 5.6.2):
Clicking this icon will generate the .jasper file in the same directory as the .jrxml file.
If you have created multiple images dynamically than try this one:
// initialize your images array
private ImageView myImages[] = new ImageView[your_array_length];
// create programatically and add to parent view
for (int i = 0; i < your_array_length; i++) {
myImages[i] = new ImageView(this);
myImages[i].setId(i + 1);
myImages[i].setBackgroundResource(your_array[i]);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
frontWidth[i], frontHeight[i]);
((MarginLayoutParams) params).setMargins(frontX_axis[i],
frontY_axis[i], 0, 0);
myImages[i].setAdjustViewBounds(true);
myImages[i].setLayoutParams(params);
if (getIntent() != null && i != your_array,length) {
final int j = i;
myImages[j].getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() {
myImages[j].getViewTreeObserver().removeOnPreDrawListener(this);
finalHeight = myImages[j].getMeasuredHeight();
finalWidth = myImages[j].getMeasuredWidth();
your_textview.setText("Height: " + finalHeight + " Width: " + finalWidth);
return true;
}
});
}
your_parent_layout.addView(myImages[i], params);
}
// That's it. Happy Coding.
Here's an efficient option that doesn't use the clipboard.
Sub transposeAndPasteRow(rowToCopy As Range, pasteTarget As Range)
pasteTarget.Resize(rowToCopy.Columns.Count) = Application.WorksheetFunction.Transpose(rowToCopy.Value)
End Sub
Use it like this.
Sub test()
Call transposeAndPasteRow(Worksheets("Sheet1").Range("A1:A5"), Worksheets("Sheet2").Range("A1"))
End Sub
include
folder where you have installed
Codeblocks. int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX,
in that line.I simply closed all pages of visual studio and reopened ..it worked.
For other language use day of week to recognize day name
For example for Persian use below code
$dayName = getDayName(date('w', strtotime('2019-11-14')));
function getDayName($dayOfWeek) {
switch ($dayOfWeek){
case 6:
return '????';
case 0:
return '?? ????';
case 1:
return '?? ????';
case 2:
return '?? ????';
case 3:
return '???? ????';
case 4:
return '??? ????';
case 5:
return '????';
default:
return '';
}
}
More info : https://www.php.net/manual/en/function.date.php
Minimum crossdomain set I've used for embedding fitted single iframe on a page.
On embedding page (containing iframe):
<iframe frameborder="0" id="sizetracker" src="http://www.hurtta.com/Services/SizeTracker/DE" width="100%"></iframe>
<script type="text/javascript">
// Create browser compatible event handler.
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
// Listen for a message from the iframe.
eventer(messageEvent, function(e) {
if (isNaN(e.data)) return;
// replace #sizetracker with what ever what ever iframe id you need
document.getElementById('sizetracker').style.height = e.data + 'px';
}, false);
</script>
On embedded page (iframe):
<script type="text/javascript">
function sendHeight()
{
if(parent.postMessage)
{
// replace #wrapper with element that contains
// actual page content
var height= document.getElementById('wrapper').offsetHeight;
parent.postMessage(height, '*');
}
}
// Create browser compatible event handler.
var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
var eventer = window[eventMethod];
var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
// Listen for a message from the iframe.
eventer(messageEvent, function(e) {
if (isNaN(e.data)) return;
sendHeight();
},
false);
</script>
The task can be completed by running the two line python script from the same folder as the sequence of picture files. For png formatted files the script is -
from scitools.std import movie
movie('*.png',fps=1,output_file='thisismygif.gif')
Well previously, I used the approach that you can find inside the WebElement
:
WebElement baseTable = driver.findElement(By.tagName("table"));
WebElement tableRow = baseTable.findElement(By.xpath("//tr[2]")); //should be the third row
webElement cellIneed = tableRow.findElement(By.xpath("//td[2]"));
String valueIneed = cellIneed.getText();
Please note that I find inside the found WebElement
instance.
The above is Java code, assuming that driver
variable is healthy instance of WebDriver
I have used the following tool from priming with success. I have no skin in the game with primeNg, just passing on my suggestion.
If you need to edit files of same type with more encodings in different folders and projects (e.g. one project is in UTF-8 and other in Windows-12xx), go to Window > Preferences > General > Content Types > Text > and select each type with multiple encodings.
For each type delete content of the Default encoding and click Update.
This way Eclipse will not "autodetect" encoding and will use encoding set for project or folder.
I was executing the whole command in one line, as it was mentioned as such
$ docker run --name testproject-agent \
-e TP_API_KEY="REPLACE_WITH_YOUR_KEY" \
-e TP_AGENT_ALIAS="My First Agent" \
testproject/agent:latest
But its supposed to be a multiline command, and I copied the command line by line and pressed enter
after every line and bam! it worked.
Sometimes when you copy off of the web, the new-line
character gets omitted, hence my suggestion to try manually introducing the new line.
You can substitute in HTML entitiy:
$FileName = preg_replace("/'/", "\'", $UserInput);
In my case, I got this when trying to run Django tests through PyCharm. I think it is because PyCharm does not load the initial Django project settings, i.e. those that manage.py shell
runs initially. One can add them to the start of the testing script or just run the tests using manage.py test
.
Versions:
It's just like you did. And I'll give you a small tip for these kind of silly things: just use the browser url box to try js syntax. for example, write this: javascript:alert("test"+5)
and you have your answer.
The problem in your code is probably that this element does not exist in your document... maybe it's inside a form or something. You can test this too by writing in the url: javascript:alert(document.horseThumb_5)
to check where your mistake is.
This problem happens as a result of calling a method without brackets. Take a look at the example below:
class SomeClass(object):
def __init__(self):
print 'I am starting'
def some_meth(self):
print 'I am a method()'
x = SomeClass()
''' Not adding the bracket after the method call would result in method bound error '''
print x.some_meth
''' However this is how it should be called and it does solve it '''
x.some_meth()
Interesting problem. The solution I would try is the following.
Apply a low pass filter, such as convolution with a 2D gaussian mask. This will give you a bunch of (probably, but not necessarily floating point) values.
Perform a 2D non-maximal suppression using the known approximate radius of each paw pad (or toe).
This should give you the maximal positions without having multiple candidates which are close together. Just to clarify, the radius of the mask in step 1 should also be similar to the radius used in step 2. This radius could be selectable, or the vet could explicitly measure it beforehand (it will vary with age/breed/etc).
Some of the solutions suggested (mean shift, neural nets, and so on) probably will work to some degree, but are overly complicated and probably not ideal.
Your curl gets timed out. Probably the url you are trying that requires more that 30 seconds.
If you are running the script through browser, then set the set_time_limit
to zero for infinite seconds.
set_time_limit(0);
Increase the curl's operation time limit using this option CURLOPT_TIMEOUT
curl_setopt($ch, CURLOPT_TIMEOUT,500); // 500 seconds
It can also happen for infinite redirection from the server. To halt this try to run the script with follow location disabled.
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
Apple recommends for stylistic purposes.If you write this code:
@property (nonatomic,assign) BOOL working;
Then you can not use [object isWorking].
It will show an error. But if you use below code means
@property (assign,getter=isWorking) BOOL working;
So you can use [object isWorking] .
I was searching for this exact problem. I was following all the advice above but req.body was still returning an empty object {}. In my case, it was something just as simple as the html being incorrect.
In your form's html, make sure you use the 'name'
attribute in your input tags, not just 'id'
. Otherwise, nothing is parsed.
<input id='foo' type='text' value='1'/> // req = {}
<input id='foo' type='text' name='foo' value='1' /> // req = {foo:1}
My idiot mistake is your benefit.
You should use sb.delete(0, sb.length())
or sb.setLength(0)
and NOT create a new StringBuilder().
See this related post for performance: Is it better to reuse a StringBuilder in a loop?
compile 'com.android.support:appcompat-v7:25.2.0'
public class MainActivity extends AppCompatActivity
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.AppCompatButton
android:id="@+id/buttonAwesome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Awesome Button"
android:textColor="@color/whatever_text_color_you_want"
app:backgroundTint="@color/whatever_background_color_you_want"/>
A void*
pointer is used when you want to indicate a pointer to a hunk of memory without specifying the type. C's malloc
returns such a pointer, expecting you to cast it to a particular type immediately. It really isn't useful until you cast it to another pointer type. You're expected to know which type to cast it to, the compiler has no reflection capability to know what the underlying type should be.
The call to InitializeComponent()
(which is usually called in the default constructor of at least Window
and UserControl
) is actually a method call to the partial class of the control (rather than a call up the object hierarchy as I first expected).
This method locates a URI to the XAML for the Window
/UserControl
that is loading, and passes it to the System.Windows.Application.LoadComponent()
static method. LoadComponent()
loads the XAML file that is located at the passed in URI, and converts it to an instance of the object that is specified by the root element of the XAML file.
In more detail, LoadComponent
creates an instance of the XamlParser
, and builds a tree of the XAML. Each node is parsed by the XamlParser.ProcessXamlNode()
. This gets passed to the BamlRecordWriter
class. Some time after this I get a bit lost in how the BAML is converted to objects, but this may be enough to help you on the path to enlightenment.
Note: Interestingly, the InitializeComponent
is a method on the System.Windows.Markup.IComponentConnector
interface, of which Window
/UserControl
implement in the partial generated class.
Hope this helps!
It is hard to give a sensible solution since you are keen to avoid all sane approaches. Refactoring one line of code is the senible solution.
Note: Using -Xss sets the stack size of every thread and is a very bad idea.
Another approach is byte code manipulation to change the code as follows;
public static long fact(int n) {
return n < 2 ? n : n > 127 ? 0 : n * fact(n - 1);
}
given every answer for n > 127 is 0. This avoid changing the source code.
The length of an array in Java is immutable. So, you need to copy the desired part as a new array.
Use copyOfRange
method from java.util.Arrays class:
int[] newArray = Arrays.copyOfRange(oldArray, startIndex, endIndex);
startIndex is the initial index of the range to be copied, inclusive.
endIndex is the final index of the range to be copied, exclusive. (This index may lie outside the array)
E.g.:
//index 0 1 2 3 4
int[] arr = {10, 20, 30, 40, 50};
Arrays.copyOfRange(arr, 0, 2); // returns {10, 20}
Arrays.copyOfRange(arr, 1, 4); // returns {20, 30, 40}
Arrays.copyOfRange(arr, 2, arr.length); // returns {30, 40, 50} (length = 5)
Create the user with a password :
http://www.postgresql.org/docs/current/static/sql-createuser.html
CREATE USER name [ [ WITH ] option [ ... ] ]
where option can be:
SUPERUSER | NOSUPERUSER
| CREATEDB | NOCREATEDB
| CREATEROLE | NOCREATEROLE
| CREATEUSER | NOCREATEUSER
| INHERIT | NOINHERIT
| LOGIN | NOLOGIN
| REPLICATION | NOREPLICATION
| CONNECTION LIMIT connlimit
| [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
| VALID UNTIL 'timestamp'
| IN ROLE role_name [, ...]
| IN GROUP role_name [, ...]
| ROLE role_name [, ...]
| ADMIN role_name [, ...]
| USER role_name [, ...]
| SYSID uid
Then grant the user rights on a specific database :
http://www.postgresql.org/docs/current/static/sql-grant.html
Example :
grant all privileges on database db_name to someuser;
There is a tutorial on how to use Ajax here: https://www.w3schools.com/xml/ajax_intro.asp
This is an example code taken from that tutorial:
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
// Code for Internet Explorer 7+, Firefox, Chrome, Opera, and Safari
xmlhttp = new XMLHttpRequest();
}
else
{
// Code for Internet Explorer 6 and Internet Explorer 5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET", "ajax_info.txt", true);
xmlhttp.send();
}
</script>
</head>
<body>
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</body>
</html>
The localStorage
can only store string content and you are trying to store a jQuery object since html(htmlString)
returns a jQuery object.
You need to set the string content instead of an object. And use the setItem
method to add data and getItem
to get data.
window.localStorage.setItem('content', 'Test');
$('#test').html(window.localStorage.getItem('content'));
Query:
SELECT
m.maskid
, m.maskname
, m.schoolid
, s.schoolname
, maskdetail = STUFF((
SELECT ',' + md.maskdetail
FROM dbo.maskdetails md
WHERE m.maskid = md.maskid
FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '')
FROM dbo.tblmask m
JOIN dbo.school s ON s.ID = m.schoolid
ORDER BY m.maskname
Additional information:
If the data is a static or global variable, it is zero-filled by default, so just declare it myStruct _m;
If the data is a local variable or a heap-allocated zone, clear it with memset
like:
memset(&m, 0, sizeof(myStruct));
Current compilers (e.g. recent versions of gcc
) optimize that quite well in practice. This works only if all zero values (include null pointers and floating point zero) are represented as all zero bits, which is true on all platforms I know about (but the C standard permits implementations where this is false; I know no such implementation).
You could perhaps code myStruct m = {};
or myStruct m = {0};
(even if the first member of myStruct
is not a scalar).
My feeling is that using memset
for local structures is the best, and it conveys better the fact that at runtime, something has to be done (while usually, global and static data can be understood as initialized at compile time, without any cost at runtime).
First Declare a variable to store filenames (to use them later):
var myfiles = [];
Open File Dialog
$('#browseBtn').click(function() {
$('<input type="file" multiple>').on('change', function () {
myfiles = this.files; //save selected files to the array
console.log(myfiles); //show them on console
}).click();
});
i'm posting it, so it may help someone because there are no clear instructions on the internet to how to store filenames into an array!
You can check out this post on SuperUser.
Word starts page numbering over for each new section by default.
I do it slightly differently than the post above that goes through the ribbon menus, but in both methods you have to go through the document to each section's beginning.
My method:
Format Page Numbers
Continue from Previous Section
radio button under Page numbering
I find this right-click method to be a little faster. Also, usually if I insert the page numbers first before I start making any new sections, this problem doesn't happen in the first place.
This should should work: =IF(A1=1, B1)
The 3rd argument stating the value of the cell if the condition is not met is optional.
Try this,
EditText x = (EditText) findViewById(R.id.editText1);
int n = Integer.parseInt(x.getText().toString());
In GitHub markdown <ins>
text</ins>
works just fine.
connect constraint between uiview and labels as IBOutlet and set priority member to a less value when set hidden = YES
Did you mean the executable fails to run , if invoked from any other directory? This is rather a bug on the executable. One potential reason could be the executable requires some shared libraires from the installed folder. You may check environment variable LD_LIBRARY_PATH
One other easy way of doing it would be as follows (if you have a simple NetBeans project and not using maven for example).
UPDATE table1 SET (col1, col2) = (col2, col3) FROM othertable WHERE othertable.col1 = 123;
You should also check for readyState 0. Because when you use xhr.abort() this function set readyState to 0 in this object, and your if check will be always true - readyState !=4
$(document).ready(
var xhr;
var fn = function(){
if(xhr && xhr.readyState != 4 && xhr.readyState != 0){
xhr.abort();
}
xhr = $.ajax({
url: 'ajax/progress.ftl',
success: function(data) {
//do something
}
});
};
var interval = setInterval(fn, 500);
);
I think you want a pipelined table function.
Something like this:
CREATE OR REPLACE PACKAGE test AS
TYPE measure_record IS RECORD(
l4_id VARCHAR2(50),
l6_id VARCHAR2(50),
l8_id VARCHAR2(50),
year NUMBER,
period NUMBER,
VALUE NUMBER);
TYPE measure_table IS TABLE OF measure_record;
FUNCTION get_ups(foo NUMBER)
RETURN measure_table
PIPELINED;
END;
CREATE OR REPLACE PACKAGE BODY test AS
FUNCTION get_ups(foo number)
RETURN measure_table
PIPELINED IS
rec measure_record;
BEGIN
SELECT 'foo', 'bar', 'baz', 2010, 5, 13
INTO rec
FROM DUAL;
-- you would usually have a cursor and a loop here
PIPE ROW (rec);
RETURN;
END get_ups;
END;
For simplicity I removed your parameters and didn't implement a loop in the function, but you can see the principle.
Usage:
SELECT *
FROM table(test.get_ups(0));
L4_ID L6_ID L8_ID YEAR PERIOD VALUE
----- ----- ----- ---------- ---------- ----------
foo bar baz 2010 5 13
1 row selected.
This method works in Chrome and IE:
<a href="blablabla" onclick="setTimeout(function(){var ww = window.open(window.location, '_self'); ww.close(); }, 1000);">
If you click on this the window will be closed after 1000ms
</a>
A much easier way is to go to Data and select Group or Subtotal. Instant collapsible rows without messing with pivot tables or VBA.
In my case append only this line worked
SetOutputFilter DEFLATE
I like this one, that hasn't been mentioned above.
require 'pathname'
Pathname.new('/my/dir').children.each do |path|
puts path
end
The benefit is that you get a Pathname object instead of a string, that you can do useful stuff with and traverse further.
A TVF (table-valued function) is supposed to be SELECTed FROM. Try this:
select * from FN('myFunc')
I just had the same problem and tried every solution that I could find, but none worked. Eventually, I tried quitting Git Bash and re-opening it, and everything worked perfectly.
So, try quitting Git Bash and re-opening it.
You can use this function to disable the form:
function disableForm(formID){
$('#' + formID).children(':input').attr('disabled', 'disabled');
}
Note that it uses jQuery.
Select multiple lines by clicking first line then holding shift and clicking last line. Then press:
CTRL+SHIFT+L
or on MAC: CMD+SHIFT+L (as per comments)
Alternatively you can select lines and go to SELECTION MENU >> SPLIT INTO LINES.
Now you can edit multiple lines, move cursors etc. for all selected lines.
I had a hard time figuring out what constraints were causing this error. Here is a simpler way to do it.
I'm using Xcode 6.1.1
You can also do the following,to import datetime
from datetime import datetime as dt
dt.strptime(date, '%Y-%m-%d')
******************* Don't use KEYCODE !!!! ******************
The problem with keyCode is to avoid the combined keys with the numbers on top of keyboard, we must add a check on the key "Shift" and "Alt" to avoid special characters such as e @ & " { } ...
A simplest solution is to convert e.key to a number and check if the conversion gives NaN!
let key = Number(e.key)
if (isNaN(key) || e.key === null || e.key === ' ') {
console.log("is not numeric")
}
else {
console.log("is numeric")
}
Be careful if e.key is null or a space, it gives 0 !
Number(5) // => 5
Number('5') // => 5
Number(null) // => 0
Number(' ') // => 0
Number('chars') // => NaN
Number(undefined) // => NaN
I want to complete the answer from tchester.
(1) Enable the xp_cmdshell procedure:
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
-- Enable the xp_cmdshell procedure
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE
GO
(2) Create a login 'Domain\TestUser' (windows user) for the non-sysadmin user that has public access to the master database
(3) Grant EXEC permission on the xp_cmdshell stored procedure:
GRANT EXECUTE ON xp_cmdshell TO [Domain\TestUser]
(4) Create a proxy account that xp_cmdshell will be run under using sp_xp_cmdshell_proxy_account
EXEC sp_xp_cmdshell_proxy_account 'Domain\TestUser', 'pwd'
-- Note: pwd means windows password for [Domain\TestUser] account id on the box.
-- Don't include square brackets around Domain\TestUser.
(5) Grant control server permission to user
USE master;
GRANT CONTROL SERVER TO [Domain\TestUser]
GO
Unlike Virtualization, containerization uses the same host os. So the container built on linux can not be run on windows and vice versa.
In windows, you have to take help of virtuallization (using Hyper-v) to have same os as your containers's os and then you should be able to run the same.
Docker for windows is similar app which is built on Hyper-v and helps in running linux docker container on windows. But as far as I know, there is nothing as such which helps run windows containers on linux.
imageView.setImageDrawable(getResources().getDrawable(R.drawable.my_drawable));
You could try setInterval() instead:
var i = setInterval(function(){
//Call ajax here
},10000)
You can catch it like any other exception:
try {
foo();
}
catch (const std::bad_alloc&) {
return -1;
}
Quite what you can usefully do from this point is up to you, but it's definitely feasible technically.
In general you cannot, and should not try, to respond to this error. bad_alloc
indicates that a resource cannot be allocated because not enough memory is available. In most scenarios your program cannot hope to cope with that, and terminating soon is the only meaningful behaviour.
Worse, modern operating systems often over-allocate: on such systems, malloc
and new
can return a valid pointer even if there is not enough free memory left – std::bad_alloc
will never be thrown, or is at least not a reliable sign of memory exhaustion. Instead, attempts to access the allocated memory will then result in a segmentation fault, which is not catchable (you can handle the segmentation fault signal, but you cannot resume the program afterwards).
The only thing you could do when catching std::bad_alloc
is to perhaps log the error, and try to ensure a safe program termination by freeing outstanding resources (but this is done automatically in the normal course of stack unwinding after the error gets thrown if the program uses RAII appropriately).
In certain cases, the program may attempt to free some memory and try again, or use secondary memory (= disk) instead of RAM but these opportunities only exist in very specific scenarios with strict conditions:
It’s exceedingly rare that applications have control over point 1 — userspace applications never do, it’s a system-wide setting that requires root permissions to change.1
OK, so let’s assume you’ve fixed point 1. What you can now do is for instance use a LRU cache for some of your data (probably some particularly large business objects that can be regenerated or reloaded on demand). Next, you need to put the actual logic that may fail into a function that supports retry — in other words, if it gets aborted, you can just relaunch it:
lru_cache<widget> widget_cache;
double perform_operation(int widget_id) {
std::optional<widget> maybe_widget = widget_cache.find_by_id(widget_id);
if (not maybe_widget) {
maybe_widget = widget_cache.store(widget_id, load_widget_from_disk(widget_id));
}
return maybe_widget->frobnicate();
}
…
for (int num_attempts = 0; num_attempts < MAX_NUM_ATTEMPTS; ++num_attempts) {
try {
return perform_operation(widget_id);
} catch (std::bad_alloc const&) {
if (widget_cache.empty()) throw; // memory error elsewhere.
widget_cache.remove_oldest();
}
}
// Handle too many failed attempts here.
But even here, using std::set_new_handler
instead of handling std::bad_alloc
provides the same benefit and would be much simpler.
1 If you’re creating an application that does control point 1, and you’re reading this answer, please shoot me an email, I’m genuinely curious about your circumstances.
new
in c++?The usual notion is that if new
operator cannot allocate dynamic memory of the requested size, then it should throw an exception of type std::bad_alloc
.
However, something more happens even before a bad_alloc
exception is thrown:
C++03 Section 3.7.4.1.3: says
An allocation function that fails to allocate storage can invoke the currently installed new_handler(18.4.2.2), if any. [Note: A program-supplied allocation function can obtain the address of the currently installed new_handler using the set_new_handler function (18.4.2.3).] If an allocation function declared with an empty exception-specification (15.4), throw(), fails to allocate storage, it shall return a null pointer. Any other allocation function that fails to allocate storage shall only indicate failure by throw-ing an exception of class std::bad_alloc (18.4.2.1) or a class derived from std::bad_alloc.
Consider the following code sample:
#include <iostream>
#include <cstdlib>
// function to call if operator new can't allocate enough memory or error arises
void outOfMemHandler()
{
std::cerr << "Unable to satisfy request for memory\n";
std::abort();
}
int main()
{
//set the new_handler
std::set_new_handler(outOfMemHandler);
//Request huge memory size, that will cause ::operator new to fail
int *pBigDataArray = new int[100000000L];
return 0;
}
In the above example, operator new
(most likely) will be unable to allocate space for 100,000,000 integers, and the function outOfMemHandler()
will be called, and the program will abort after issuing an error message.
As seen here the default behavior of new
operator when unable to fulfill a memory request, is to call the new-handler
function repeatedly until it can find enough memory or there is no more new handlers. In the above example, unless we call std::abort()
, outOfMemHandler()
would be called repeatedly. Therefore, the handler should either ensure that the next allocation succeeds, or register another handler, or register no handler, or not return (i.e. terminate the program). If there is no new handler and the allocation fails, the operator will throw an exception.
new_handler
and set_new_handler
?new_handler
is a typedef for a pointer to a function that takes and returns nothing, and set_new_handler
is a function that takes and returns a new_handler
.
Something like:
typedef void (*new_handler)();
new_handler set_new_handler(new_handler p) throw();
set_new_handler's parameter is a pointer to the function operator new
should call if it can't allocate the requested memory. Its return value is a pointer to the previously registered handler function, or null if there was no previous handler.
Given the behavior of new
a well designed user program should handle out of memory conditions by providing a proper new_handler
which does one of the following:
Make more memory available: This may allow the next memory allocation attempt inside operator new's loop to succeed. One way to implement this is to allocate a large block of memory at program start-up, then release it for use in the program the first time the new-handler is invoked.
Install a different new-handler: If the current new-handler can't make any more memory available, and of there is another new-handler that can, then the current new-handler can install the other new-handler in its place (by calling set_new_handler
). The next time operator new calls the new-handler function, it will get the one most recently installed.
(A variation on this theme is for a new-handler to modify its own behavior, so the next time it's invoked, it does something different. One way to achieve this is to have the new-handler modify static, namespace-specific, or global data that affects the new-handler's behavior.)
Uninstall the new-handler: This is done by passing a null pointer to set_new_handler
. With no new-handler installed, operator new
will throw an exception ((convertible to) std::bad_alloc
) when memory allocation is unsuccessful.
Throw an exception convertible to std::bad_alloc
. Such exceptions are not be caught by operator new
, but will propagate to the site originating the request for memory.
Not return: By calling abort
or exit
.
So, similar to other solutions here is mine:
// For example you have this relation defined with "user()" method
public function user()
{
return $this->belongsTo('User');
}
// Just make another one defined with "user_frontend()" method
public function user_frontend()
{
return $this->belongsTo('User')->select(array('id', 'username'));
}
// Then use it later like this
$thing = new Thing();
$thing->with('user_frontend');
// This way, you get only id and username,
// and if you want all fields you can do this
$thing = new Thing();
$thing->with('user');
If you write a function then once you leave it all names inside disappear.
The concept is called namespace and it's so good, it made it into the Zen of Python:
Namespaces are one honking great idea -- let's do more of those!
The namespace of IPython can likewise be reset with the magic command %reset -f
. (The -f
means "force"; in other words, "don't ask me if I really want to delete all the variables, just do it.")
Yes, use the jQuery contains
selector.
ROWS UNBOUNDED PRECEDING
is no Teradata-specific syntax, it's Standard SQL. Together with the ORDER BY
it defines the window on which the result is calculated.
Logically a Windowed Aggregate Function is newly calculated for each row within the PARTITION based on all ROWS between a starting row and an ending row.
Starting and ending rows might be fixed or relative to the current row based on the following keywords:
Possible kinds of calculation include:
So SUM(x) OVER (ORDER BY col ROWS UNBOUNDED PRECEDING)
results in a Cumulative Sum or Running Total
11 -> 11
2 -> 11 + 2 = 13
3 -> 13 + 3 (or 11+2+3) = 16
44 -> 16 + 44 (or 11+2+3+44) = 60
I had this error, I looked into a log file C:\...\mysql\data\VM-IIS-Server.err and found this
2016-06-07 17:56:07 160c InnoDB: Error: unable to create temporary file; errno: 2
2016-06-07 17:56:07 3392 [ERROR] Plugin 'InnoDB' init function returned error.
2016-06-07 17:56:07 3392 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-06-07 17:56:07 3392 [ERROR] Unknown/unsupported storage engine: InnoDB
2016-06-07 17:56:07 3392 [ERROR] Aborting
The first line says "unable to create temporary file", it sounds like "insufficient privileges", first I tried to give access to mysql folder for my current user - no effect, then after some wandering around I came up to control panel->Administration->Services->Right Clicked MysqlService->Properties->Log On, switched to "This account", entered my username/password, clicked OK, and it woked!
My issue was not that I was referencing the server by the IP address instead of the URL. I had purchased a signed certificate from a CA for use inside a private network. The URL specified on the certificate does matter when referencing the server. Once I referenced the server by the URL in the certificate everything started to work.
VBA has a CurDir keyword that will return the "current directory" as stored in Excel. I'm not sure all the things that affect the current directory, but definitely opening or saving a workbook will change it.
MyWorkbook.SaveAs CurDir & Application.PathSeparator & "MySavedWorkbook.xls"
This assumes that the sheet you want to save has never been saved and you want to define the file name in code.
I created an AngularJS module to handle this issue regarding phonenumbers for myself with a custom directive and accompanying filter.
jsfiddle example: http://jsfiddle.net/aberke/s0xpkgmq/
Filter use example:
<p>{{ phonenumberValue | phonenumber }}</p>
Filter code:
.filter('phonenumber', function() {
/*
Format phonenumber as: c (xxx) xxx-xxxx
or as close as possible if phonenumber length is not 10
if c is not '1' (country code not USA), does not use country code
*/
return function (number) {
/*
@param {Number | String} number - Number that will be formatted as telephone number
Returns formatted number: (###) ###-####
if number.length < 4: ###
else if number.length < 7: (###) ###
Does not handle country codes that are not '1' (USA)
*/
if (!number) { return ''; }
number = String(number);
// Will return formattedNumber.
// If phonenumber isn't longer than an area code, just show number
var formattedNumber = number;
// if the first character is '1', strip it out and add it back
var c = (number[0] == '1') ? '1 ' : '';
number = number[0] == '1' ? number.slice(1) : number;
// # (###) ###-#### as c (area) front-end
var area = number.substring(0,3);
var front = number.substring(3, 6);
var end = number.substring(6, 10);
if (front) {
formattedNumber = (c + "(" + area + ") " + front);
}
if (end) {
formattedNumber += ("-" + end);
}
return formattedNumber;
};
});
Directive use example:
<phonenumber-directive placeholder="'Input phonenumber here'" model='myModel.phonenumber'></phonenumber-directive>
Directive code:
.directive('phonenumberDirective', ['$filter', function($filter) {
/*
Intended use:
<phonenumber-directive placeholder='prompt' model='someModel.phonenumber'></phonenumber-directive>
Where:
someModel.phonenumber: {String} value which to bind only the numeric characters [0-9] entered
ie, if user enters 617-2223333, value of 6172223333 will be bound to model
prompt: {String} text to keep in placeholder when no numeric input entered
*/
function link(scope, element, attributes) {
// scope.inputValue is the value of input element used in template
scope.inputValue = scope.phonenumberModel;
scope.$watch('inputValue', function(value, oldValue) {
value = String(value);
var number = value.replace(/[^0-9]+/g, '');
scope.phonenumberModel = number;
scope.inputValue = $filter('phonenumber')(number);
});
}
return {
link: link,
restrict: 'E',
scope: {
phonenumberPlaceholder: '=placeholder',
phonenumberModel: '=model',
},
// templateUrl: '/static/phonenumberModule/template.html',
template: '<input ng-model="inputValue" type="tel" class="phonenumber" placeholder="{{phonenumberPlaceholder}}" title="Phonenumber (Format: (999) 9999-9999)">',
};
}])
Full code with module and how to use it: https://gist.github.com/aberke/042eef0f37dba1138f9e
Here is an example that works on Chrome 5.0.375.125.
The page B (iframe content):
<html>
<head></head>
<body>
<script>
top.postMessage('hello', 'A');
</script>
</body>
</html>
Note the use of top.postMessage
or parent.postMessage
not window.postMessage
here
The page A:
<html>
<head></head>
<body>
<iframe src="B"></iframe>
<script>
window.addEventListener( "message",
function (e) {
if(e.origin !== 'B'){ return; }
alert(e.data);
},
false);
</script>
</body>
</html>
A and B must be something like http://domain.com
EDIT:
From another question, it looks the domains(A and B here) must have a /
for the postMessage
to work properly.
Try:
<div ng-repeat="item in items">
<pre>{{item.description}}</pre>
</div>
The <pre>
wrapper will print text with \n
as text
also if you print the json, for better look use json
filter, like:
<div ng-repeat="item in items">
<pre>{{item.description|json}}</pre>
</div>
I agree with @Paul Weber
that white-space: pre-wrap;
is better approach, anyways using <pre>
- the quick way mostly for debug some stuff (if you don't want to waste time on styling)
Am I missing something? You can just convert offer_date in the comparison:
SELECT *
FROM offers
WHERE to_char(offer_date, 'YYYYMM') = (SELECT to_date(create_date, 'YYYYMM') FROM customers where id = '12345678') AND
offer_rate > 0
git reset c14809fafb08b9e96ff2879999ba8c807d10fb07
is what you're after...
I know this is somewhat older, but since the keywords "border inside" landed me directly here, I would like to share some findings that may be worth mentioning here. When I was adding a border on the hover state, i got the effects that OP is talking about. The border ads pixels to the dimension of the box which made it jumpy. There is two more ways one can deal with this that also work for IE7.
1) Have a border already attached to the element and simply change the color. This way the mathematics are already included.
div {
width:100px;
height:100px;
background-color: #aaa;
border: 2px solid #aaa; /* notice the solid */
}
div:hover {
border: 2px dashed #666;
}
2 ) Compensate your border with a negative margin. This will still add the extra pixels, but the positioning of the element will not be jumpy on
div {
width:100px;
height:100px;
background-color: #aaa;
}
div:hover {
margin: -2px;
border: 2px dashed #333;
}
Try this easy 2019 jquery solution, although its been around a while;
add this plugin to head:
src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"
add this to js:
$("*").on("touchend", function(e) { $(this).focus(); }); //applies to all elements
some suggested variations to this are:
$(":input, :checkbox,").on("touchend", function(e) {(this).focus);}); //specify elements
$("*").on("click, touchend", function(e) { $(this).focus(); }); //include click event
css: body { cursor: pointer; } //touch anywhere to end a focus
Notes
References:
https://api.jquery.com/category/selectors/jquery-selector-extensions/
What you are looking for is this:
SHOW VARIABLES;
You can modify it further like any query:
SHOW VARIABLES LIKE '%max%';
You can check your respone content, just console.log it and you will see whitch property have a status code. If you do not understand jsons, please refer to the video: https://www.youtube.com/watch?v=Bv_5Zv5c-Ts
It explains very basic knowledge that let you feel more comfortable with javascript.
You can do it with shorter version of ajax request, please see code above:
$.get("example.url.com", function(data) {
console.log(data);
}).done(function() {
// TO DO ON DONE
}).fail(function(data, textStatus, xhr) {
//This shows status code eg. 403
console.log("error", data.status);
//This shows status message eg. Forbidden
console.log("STATUS: "+xhr);
}).always(function() {
//TO-DO after fail/done request.
console.log("ended");
});
Example console output:
error 403
STATUS: Forbidden
ended
- have names, unlike constructors, which can clarify code.
- do not need to create a new object upon each invocation - objects can be cached and reused, if necessary.
- can return a subtype of their return type - in particular, can return an object whose implementation class is unknown to the caller. This is a very valuable and widely used feature in many frameworks which use interfaces as the return type of static factory methods.
Well I was searching for an easy way. And find out on medium.
First to copy the json text and validate it on jsonlint or something similar. Then to copy from jsonlint, already the json is formatted. And paste the code on Xcode with preserving the format, shortcut shift + option + command + v
Google wanted to give some more headache to the developers.
So, what you have to do now is edit your AVD and add "Keyboard Support" for it in the Hardware section and change the value to "Yes"
This one is working fine using V 4.0.3
var vv = $('.mySelect2');
var label = $(vv).children("option[value='"+$(vv).select2("val")+"']").first().html();
console.log(label);
You can use this awesome library to compress. Add dependency in app-level gradel:
dependencies {
implementation 'id.zelory:compressor:3.0.0'
}
And then just compress the actual image file like this:
val compressedImageFile = Compressor.compress(context, actualImageFile)
you could add the following:
public float getAngle(Point target) {
float angle = (float) Math.toDegrees(Math.atan2(target.y - y, target.x - x));
if(angle < 0){
angle += 360;
}
return angle;
}
by the way, why do you want to not use a double here?
I replaced the "localhost" with IP Address (Database server's public IP Address) in the jdbc Url then it worked.
jdbcUrl = "jdbc:oracle:thin:<user>@//localhost:1521/<Service Name>";
??
jdbcUrl = "jdbc:oracle:thin:<user>@//<Public IP Address>:1521/<Service Name>";
I think I am a bit late to the party but... In my opinion, what you need is the object oriented API of matplotlib. In matplotlib 1.4.2 and using IPython 2.4.1 with Qt4Agg backend, I can do the following:
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1) # Creates figure fig and add an axes, ax.
fig2, ax2 = plt.subplots(1) # Another figure
ax.plot(range(20)) #Add a straight line to the axes of the first figure.
ax2.plot(range(100)) #Add a straight line to the axes of the first figure.
fig.show() #Only shows figure 1 and removes it from the "current" stack.
fig2.show() #Only shows figure 2 and removes it from the "current" stack.
plt.show() #Does not show anything, because there is nothing in the "current" stack.
fig.show() # Shows figure 1 again. You can show it as many times as you want.
In this case plt.show() shows anything in the "current" stack. You can specify figure.show() ONLY if you are using a GUI backend (e.g. Qt4Agg). Otherwise, I think you will need to really dig down into the guts of matplotlib to monkeypatch a solution.
Remember that most (all?) plt.* functions are just shortcuts and aliases for figure and axes methods. They are very useful for sequential programing, but you will find blocking walls very soon if you plan to use them in a more complex way.
A While
/Wend
loop can only be exited prematurely with a GOTO
or by exiting from an outer block (Exit sub
/function
or another exitable loop)
Change to a Do
loop instead:
Do While True
count = count + 1
If count = 10 Then
Exit Do
End If
Loop
Or for looping a set number of times:
for count = 1 to 10
msgbox count
next
(Exit For
can be used above to exit prematurely)
The ...For
extension methods on the HtmlHelper (e.g., DisplayFor
, TextBoxFor
, ElementFor
, etc...) take a property and nothing else. If you don't have a property, use the non-For
method (e.g., Display
, TextBox
, Element
, etc...).
The ...For
extension methods provides a way of simplifying postback by naming the control after the property. This is why it takes an expression and not simply a value. If you are not interested in this postback facilitation then do not use the ...For
methods at all.
Note: You should not be doing things like calling ToString
inside the view. This should be done inside the view model. I realize that a lot of demo projects put domain objects straight into the view. In my experience, this rarely works because it assumes that you do not want any formatting on the data in the domain entity. Best practice is to create a view model that wraps the entity into something that can be directly consumed by the view. Most of the properties in this view model should be strings that are already formatted or data for which you have element or display templates created.
I wanted a pure html approach as I wanted to collapse and expand html that was added on the fly via a template! I came up with this...
https://jsfiddle.net/3mguht2y/1/
var noJavascript = ":)";
Which might be of use to someone :)
While your Sleep
method is async, Thread.Sleep
is not. The whole idea of async is to reuse a single thread, not to start multiple threads. Because you've blocked using a synchronous call to Thread.Sleep, it's not going to work.
I'm assuming that Thread.Sleep
is a simplification of what you actually want to do. Can your actual implementation be coded as async methods?
If you do need to run multiple synchronous blocking calls, look elsewhere I think!
mycollection.find_one_and_update({"_id": mongo_id},
{"$set": {"newfield": "abc"}})
should work splendidly for you. If there is no document of id mongo_id
, it will fail, unless you also use upsert=True
. This returns the old document by default. To get the new one, pass return_document=ReturnDocument.AFTER
. All parameters are described in the API.
The method was introduced for MongoDB 3.0. It was extended for 3.2, 3.4, and 3.6.
As others have said, simply restarting the terminal after you've made changes should reset and changes you've made to your ~/.zshrc file. For instance after adding function to open visual studio:
function code {
if [[ $# = 0 ]]
then
open -a "Visual Studio Code"
else
local argPath="$1"
[[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
open -a "Visual Studio Code" "$argPath"
fi
}
I was able to use the keyword code to open the program from the command line.
cd my_directory && tar -czvf ../my_directory.tar.gz $(ls -A) && cd ..
This one worked for me and it's include all hidden files without putting all files in a root directory named "." like in tomoe's answer :
Just some examples on usage of array_split
, split
, hsplit
and vsplit
:
n [9]: a = np.random.randint(0,10,[4,4])
In [10]: a
Out[10]:
array([[2, 2, 7, 1],
[5, 0, 3, 1],
[2, 9, 8, 8],
[5, 7, 7, 6]])
Some examples on using array_split
:
If you give an array or list as second argument you basically give the indices (before) which to 'cut'
# split rows into 0|1 2|3
In [4]: np.array_split(a, [1,3])
Out[4]:
[array([[2, 2, 7, 1]]),
array([[5, 0, 3, 1],
[2, 9, 8, 8]]),
array([[5, 7, 7, 6]])]
# split columns into 0| 1 2 3
In [5]: np.array_split(a, [1], axis=1)
Out[5]:
[array([[2],
[5],
[2],
[5]]),
array([[2, 7, 1],
[0, 3, 1],
[9, 8, 8],
[7, 7, 6]])]
An integer as second arg. specifies the number of equal chunks:
In [6]: np.array_split(a, 2, axis=1)
Out[6]:
[array([[2, 2],
[5, 0],
[2, 9],
[5, 7]]),
array([[7, 1],
[3, 1],
[8, 8],
[7, 6]])]
split
works the same but raises an exception if an equal split is not possible
In addition to array_split
you can use shortcuts vsplit
and hsplit
.
vsplit
and hsplit
are pretty much self-explanatry:
In [11]: np.vsplit(a, 2)
Out[11]:
[array([[2, 2, 7, 1],
[5, 0, 3, 1]]),
array([[2, 9, 8, 8],
[5, 7, 7, 6]])]
In [12]: np.hsplit(a, 2)
Out[12]:
[array([[2, 2],
[5, 0],
[2, 9],
[5, 7]]),
array([[7, 1],
[3, 1],
[8, 8],
[7, 6]])]
-- html file --
<select name='city[]'>
<option name='Kabul' value="Kabul" > Kabul </option>
<option name='Herat' value='Herat' selected="selected"> Herat </option>
<option name='Mazar' value='Mazar'>Mazar </option>
</select>
-- php file --
$city = (isset($_POST['city']) ? $_POST['city']: null);
print("city is: ".$city[0]);
$("video").prop('muted', true); //mute
AND
$("video").prop('muted', false); //unmute
See all events here
(side note: use attr
if in jQuery < 1.6)
Adding "relaxedQueryChars" attribute to the server.xml worked for me :
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="443" URIEncoding="UTF-8" relaxedQueryChars="[]|{}^\`"<>"/>
Solution is to make JAVA_HOME == dir above bin where javac lives as in
type javac
javac is /usr/bin/javac # now check if its just a symlink
ls -la /usr/bin/javac
/usr/bin/javac -> /etc/alternatives/javac # its a symlink so check again
ls -la /etc/alternatives/javac # now check if its just a symlink
/etc/alternatives/javac -> /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
OK so finally found the bin above actual javac so do this
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
above can be simplified and generalized to
which javac >/dev/null 2>&1 || die "ERROR: no 'javac' command could be found in your PATH"
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which javac) )))
First create assets
folder then create fonts
folder in it.
Then you can set font
from assets
or directory
like bellow :
public class FontSampler extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
TextView tv = (TextView) findViewById(R.id.custom);
Typeface face = Typeface.createFromAsset(getAssets(), "fonts/HandmadeTypewriter.ttf");
tv.setTypeface(face);
File font = new File(Environment.getExternalStorageDirectory(), "MgOpenCosmeticaBold.ttf");
if (font.exists()) {
tv = (TextView) findViewById(R.id.file);
face = Typeface.createFromFile(font);
tv.setTypeface(face);
} else {
findViewById(R.id.filerow).setVisibility(View.GONE);
}
}
}
Regular expressions are your friends:
R> ## also adds missing ')' and sets column name
R> group<-data.frame(group=c("12357e", "12575e", "197e18", "e18947")) )
R> group
group
1 12357e
2 12575e
3 197e18
4 e18947
Now use gsub()
with the simplest possible replacement pattern: empty string:
R> group$groupNoE <- gsub("e", "", group$group)
R> group
group groupNoE
1 12357e 12357
2 12575e 12575
3 197e18 19718
4 e18947 18947
R>
Try this, to set the focus to the first input field:
$(this).parent().siblings('div.bottom').find("input.post").focus();
widget['bg'] = '#000000'
or
widget['background'] = '#000000'
would also work as hex-valued colors are also accepted.
Here is pythonic way to do it. This function will allow you to loop through key-value pair in all the levels. It does not save the whole thing to the memory but rather walks through the dict as you loop through it
def recursive_items(dictionary):
for key, value in dictionary.items():
if type(value) is dict:
yield (key, value)
yield from recursive_items(value)
else:
yield (key, value)
a = {'a': {1: {1: 2, 3: 4}, 2: {5: 6}}}
for key, value in recursive_items(a):
print(key, value)
Prints
a {1: {1: 2, 3: 4}, 2: {5: 6}}
1 {1: 2, 3: 4}
1 2
3 4
2 {5: 6}
5 6
You can simply set xhr.responseType = 'json';
const xhr = new XMLHttpRequest();_x000D_
xhr.open('GET', 'https://jsonplaceholder.typicode.com/posts/1');_x000D_
xhr.responseType = 'json';_x000D_
xhr.onload = function(e) {_x000D_
if (this.status == 200) {_x000D_
console.log('response', this.response); // JSON response _x000D_
}_x000D_
};_x000D_
xhr.send();_x000D_
_x000D_
In c# following code insert data into datatable on specified position
DataTable dt = new DataTable();
dt.Columns.Add("SL");
dt.Columns.Add("Amount");
dt.rows.add(1, 1000)
dt.rows.add(2, 2000)
dt.Rows.InsertAt(dt.NewRow(), 3);
var rowPosition = 3;
dt.Rows[rowPosition][dt.Columns.IndexOf("SL")] = 3;
dt.Rows[rowPosition][dt.Columns.IndexOf("Amount")] = 3000;
git checkout
has the --ours
option to check out the version of the file that you had locally (as opposed to --theirs
, which is the version that you pulled in). You can pass .
to git checkout
to tell it to check out everything in the tree. Then you need to mark the conflicts as resolved, which you can do with git add
, and commit your work once done:
git checkout --ours . # checkout our local version of all files
git add -u # mark all conflicted files as merged
git commit # commit the merge
Note the .
in the git checkout
command. That's very important, and easy to miss. git checkout
has two modes; one in which it switches branches, and one in which it checks files out of the index into the working copy (sometimes pulling them into the index from another revision first). The way it distinguishes is by whether you've passed a filename in; if you haven't passed in a filename, it tries switching branches (though if you don't pass in a branch either, it will just try checking out the current branch again), but it refuses to do so if there are modified files that that would effect. So, if you want a behavior that will overwrite existing files, you need to pass in .
or a filename in order to get the second behavior from git checkout
.
It's also a good habit to have, when passing in a filename, to offset it with --
, such as git checkout --ours -- <filename>
. If you don't do this, and the filename happens to match the name of a branch or tag, Git will think that you want to check that revision out, instead of checking that filename out, and so use the first form of the checkout
command.
I'll expand a bit on how conflicts and merging work in Git. When you merge in someone else's code (which also happens during a pull; a pull is essentially a fetch followed by a merge), there are few possible situations.
The simplest is that you're on the same revision. In this case, you're "already up to date", and nothing happens.
Another possibility is that their revision is simply a descendent of yours, in which case you will by default have a "fast-forward merge", in which your HEAD
is just updated to their commit, with no merging happening (this can be disabled if you really want to record a merge, using --no-ff
).
Then you get into the situations in which you actually need to merge two revisions. In this case, there are two possible outcomes. One is that the merge happens cleanly; all of the changes are in different files, or are in the same files but far enough apart that both sets of changes can be applied without problems. By default, when a clean merge happens, it is automatically committed, though you can disable this with --no-commit
if you need to edit it beforehand (for instance, if you rename function foo
to bar
, and someone else adds new code that calls foo
, it will merge cleanly, but produce a broken tree, so you may want to clean that up as part of the merge commit in order to avoid having any broken commits).
The final possibility is that there's a real merge, and there are conflicts. In this case, Git will do as much of the merge as it can, and produce files with conflict markers (<<<<<<<
, =======
, and >>>>>>>
) in your working copy. In the index (also known as the "staging area"; the place where files are stored by git add
before committing them), you will have 3 versions of each file with conflicts; there is the original version of the file from the ancestor of the two branches you are merging, the version from HEAD
(your side of the merge), and the version from the remote branch.
In order to resolve the conflict, you can either edit the file that is in your working copy, removing the conflict markers and fixing the code up so that it works. Or, you can check out the version from one or the other sides of the merge, using git checkout --ours
or git checkout --theirs
. Once you have put the file into the state you want it, you indicate that you are done merging the file and it is ready to commit using git add
, and then you can commit the merge with git commit
.
I tested 2 set based randomization methods against RAND() by generating 100,000,000 rows with each. To level the field the output is a float between 0-1 to mimic RAND(). Most of the code is testing infrastructure so I summarize the algorithms here:
-- Try #1 used
(CAST(CRYPT_GEN_RANDOM(8) AS BIGINT)%500000000000000000+500000000000000000.0)/1000000000000000000 AS Val
-- Try #2 used
RAND(Checksum(NewId()))
-- and to have a baseline to compare output with I used
RAND() -- this required executing 100000000 separate insert statements
Using CRYPT_GEN_RANDOM was clearly the most random since there is only a .000000001% chance of seeing even 1 duplicate when plucking 10^8 numbers FROM a set of 10^18 numbers. IOW we should not have seen any duplicates and this had none! This set took 44 seconds to generate on my laptop.
Cnt Pct
----- ----
1 100.000000 --No duplicates
SQL Server Execution Times: CPU time = 134795 ms, elapsed time = 39274 ms.
IF OBJECT_ID('tempdb..#T0') IS NOT NULL DROP TABLE #T0;
GO
WITH L0 AS (SELECT c FROM (VALUES (1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1)) AS D(c)) -- 2^4
,L1 AS (SELECT 1 AS c FROM L0 AS A CROSS JOIN L0 AS B) -- 2^8
,L2 AS (SELECT 1 AS c FROM L1 AS A CROSS JOIN L1 AS B) -- 2^16
,L3 AS (SELECT 1 AS c FROM L2 AS A CROSS JOIN L2 AS B) -- 2^32
SELECT TOP 100000000 (CAST(CRYPT_GEN_RANDOM(8) AS BIGINT)%500000000000000000+500000000000000000.0)/1000000000000000000 AS Val
INTO #T0
FROM L3;
WITH x AS (
SELECT Val,COUNT(*) Cnt
FROM #T0
GROUP BY Val
)
SELECT x.Cnt,COUNT(*)/(SELECT COUNT(*)/100 FROM #T0) Pct
FROM X
GROUP BY x.Cnt;
At almost 15 orders of magnitude less random this method was not quite twice as fast, taking only 23 seconds to generate 100M numbers.
Cnt Pct
---- ----
1 95.450254 -- only 95% unique is absolutely horrible
2 02.222167 -- If this line were the only problem I'd say DON'T USE THIS!
3 00.034582
4 00.000409 -- 409 numbers appeared 4 times
5 00.000006 -- 6 numbers actually appeared 5 times
SQL Server Execution Times: CPU time = 77156 ms, elapsed time = 24613 ms.
IF OBJECT_ID('tempdb..#T1') IS NOT NULL DROP TABLE #T1;
GO
WITH L0 AS (SELECT c FROM (VALUES (1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1),(1)) AS D(c)) -- 2^4
,L1 AS (SELECT 1 AS c FROM L0 AS A CROSS JOIN L0 AS B) -- 2^8
,L2 AS (SELECT 1 AS c FROM L1 AS A CROSS JOIN L1 AS B) -- 2^16
,L3 AS (SELECT 1 AS c FROM L2 AS A CROSS JOIN L2 AS B) -- 2^32
SELECT TOP 100000000 RAND(Checksum(NewId())) AS Val
INTO #T1
FROM L3;
WITH x AS (
SELECT Val,COUNT(*) Cnt
FROM #T1
GROUP BY Val
)
SELECT x.Cnt,COUNT(*)*1.0/(SELECT COUNT(*)/100 FROM #T1) Pct
FROM X
GROUP BY x.Cnt;
RAND() alone is useless for set-based generation so generating the baseline for comparing randomness took over 6 hours and had to be restarted several times to finally get the right number of output rows. It also seems that the randomness leaves a lot to be desired although it's better than using checksum(newid()) to reseed each row.
Cnt Pct
---- ----
1 99.768020
2 00.115840
3 00.000100 -- at least there were comparitively few values returned 3 times
Because of the restarts, execution time could not be captured.
IF OBJECT_ID('tempdb..#T2') IS NOT NULL DROP TABLE #T2;
GO
CREATE TABLE #T2 (Val FLOAT);
GO
SET NOCOUNT ON;
GO
INSERT INTO #T2(Val) VALUES(RAND());
GO 100000000
WITH x AS (
SELECT Val,COUNT(*) Cnt
FROM #T2
GROUP BY Val
)
SELECT x.Cnt,COUNT(*)*1.0/(SELECT COUNT(*)/100 FROM #T2) Pct
FROM X
GROUP BY x.Cnt;
Here are the steps to edit the commit message of a previous commit (which is not the most recent commit) using SourceTree for Windows version 1.5.2.0:
Select the commit immediately before the commit that you want to edit. For example, if I want to edit the commit with message "FOOBAR!" then I need to select the commit that comes right before it:
Right-click on the selected commit and click Rebase children...interactively
:
Select the commit that you want to edit, then click Edit Message
at the
bottom. In this case, I'm selecting the commit with the message "FOOBAR!":
Edit the commit message, and then click OK
. In my example, I've added
"SHAZBOT! SKADOOSH!"
When you return to interactive rebase window, click on OK
to finish the
rebase:
At this point, you'll need to force-push your new changes since you've rebased commits that you've already pushed. However, the current 1.5.2.0 version of SourceTree for Windows does not allow you to force-push through the GUI, so you'll need to use Git from the command line anyways in order to do that.
Click Terminal
from the GUI to open up a terminal.
From the terminal force-push with the following command,
git push origin <branch> -f
where <branch>
is the name of the branch that you want to push, and -f
means
to force the push. The force push will overwrite your commits on your
remote repo, but that's OK in your case since you said that you're not sharing
your repo with other people.
That's it! You're done!
Latest Versions of mysql don't support DATEADD instead use the syntax
DATE_ADD(date,INTERVAL expr type)
To get the last 3 months data use,
DATE_ADD(NOW(),INTERVAL -90 DAY)
DATE_ADD(NOW(), INTERVAL -3 MONTH)
The parent div (I assume the outermost div) is display: block
and will fill up all available area of its container (in this case, the body) that it can. Use a different display type -- inline-block
is probably what you are going for:
Invariant's answer is a good resource for how everything was started and what was the state of JavaFX on embedded and mobile in beginning of 2014. But, a lot has changed since then and the users who stumble on this thread do not get the updated information.
Most of my points are related to Invariant's answer, so I would suggest to go through it first.
UPDATE
JavaFXPorts has been deprecated. Gluon Mobile now uses GraalVM underneath. There are multiple advantages of using GraalVM. Please check this blogpost from Gluon. The IDE plugins have been updated to use Gluon Client plugins which leverages GraalVM to AOT compile applications for Android/iOS.
Old answer with JavaFXPorts
Some bad news first:
Now, some good news:
If you are not the DIY kind, I would suggest to install the IDE plugin on your favourite IDE and get started.
Most of the documentation on how to get started can be found here and some of the samples can be found here.
If you've already started the process, and don't want to kill it and restart under nohup, you can send it to the background, then disown it.
Ctrl+Z
(suspend the process)
bg
(restart the process in the background
disown %1
(assuming this is job #1, use jobs
to determine)
They are two different metrics to evaluate your model's performance usually being used in different phases.
Loss is often used in the training process to find the "best" parameter values for your model (e.g. weights in neural network). It is what you try to optimize in the training by updating weights.
Accuracy is more from an applied perspective. Once you find the optimized parameters above, you use this metrics to evaluate how accurate your model's prediction is compared to the true data.
Let us use a toy classification example. You want to predict gender from one's weight and height. You have 3 data, they are as follows:(0 stands for male, 1 stands for female)
y1 = 0, x1_w = 50kg, x2_h = 160cm;
y2 = 0, x2_w = 60kg, x2_h = 170cm;
y3 = 1, x3_w = 55kg, x3_h = 175cm;
You use a simple logistic regression model that is y = 1/(1+exp-(b1*x_w+b2*x_h))
How do you find b1 and b2? you define a loss first and use optimization method to minimize the loss in an iterative way by updating b1 and b2.
In our example, a typical loss for this binary classification problem can be: (a minus sign should be added in front of the summation sign)
We don't know what b1 and b2 should be. Let us make a random guess say b1 = 0.1 and b2 = -0.03. Then what is our loss now?
so the loss is
Then you learning algorithm (e.g. gradient descent) will find a way to update b1 and b2 to decrease the loss.
What if b1=0.1 and b2=-0.03 is the final b1 and b2 (output from gradient descent), what is the accuracy now?
Let's assume if y_hat >= 0.5, we decide our prediction is female(1). otherwise it would be 0. Therefore, our algorithm predict y1 = 1, y2 = 1 and y3 = 1. What is our accuracy? We make wrong prediction on y1 and y2 and make correct one on y3. So now our accuracy is 1/3 = 33.33%
PS: In Amir's answer, back-propagation is said to be an optimization method in NN. I think it would be treated as a way to find gradient for weights in NN. Common optimization method in NN are GradientDescent and Adam.
SELECT name, GROUP_CONCAT( section )
FROM `tmp`
GROUP BY name
Use the ssh2
functions. Anything you'd do via an exec() call can be done directly using these functions, saving you a lot of connections and shell invocations.
The given answers are perfectly fine, just an academic point:
Regular Expressions in the meaning of theoretical computer sciences ARE NOT ABLE do it like this. For them it had to look something like this:
^([^h].*$)|(h([^e].*$|$))|(he([^h].*$|$))|(heh([^e].*$|$))|(hehe.+$)
This only does a FULL match. Doing it for sub-matches would even be more awkward.
When your class implements Comparable, the compareTo
method of the class is defining the "natural" ordering of that object. That method is contractually obligated (though not demanded) to be in line with other methods on that object, such as a 0 should always be returned for objects when the .equals()
comparisons return true.
A Comparator is its own definition of how to compare two objects, and can be used to compare objects in a way that might not align with the natural ordering.
For example, Strings are generally compared alphabetically. Thus the "a".compareTo("b")
would use alphabetical comparisons. If you wanted to compare Strings on length, you would need to write a custom comparator.
In short, there isn't much difference. They are both ends to similar means. In general implement comparable for natural order, (natural order definition is obviously open to interpretation), and write a comparator for other sorting or comparison needs.
You can add timeout function in jQuery (Show alert after 3 seconds):
$(document).ready(function($) {
setTimeout(function() {
alert("Hello");
}, 3000);
});
You can think of a MySQL "database" as a schema/user in Oracle. If you have the privileges, you can query the DBA_USERS
view to see the list of schemas:
SELECT * FROM DBA_USERS;
You can't pass a parameter in a @selector().
It looks like you're trying to implement a callback. The best way to do that would be something like this:
[object setCallbackObject:self withSelector:@selector(myMethod:)];
Then in your object's setCallbackObject:withSelector: method: you can call your callback method.
-(void)setCallbackObject:(id)anObject withSelector:(SEL)selector {
[anObject performSelector:selector];
}
1:list name of all employee who earn more than RS.100000 in a year.
2:give the name of employee who earn heads the department where employee with employee I.D
In Python:
self
argument.self
) or the class (cls
) argument.__init__
is a special function and without overriding __new__
it will always be given the instance of the class as its first argument.
An example using the builtin classmethod and staticmethod decorators:
import sys
class Num:
max = sys.maxint
def __init__(self,num):
self.n = num
def getn(self):
return self.n
@staticmethod
def getone():
return 1
@classmethod
def getmax(cls):
return cls.max
myObj = Num(3)
# with the appropriate decorator these should work fine
myObj.getone()
myObj.getmax()
myObj.getn()
That said, I would try to use @classmethod
/@staticmethod
sparingly. If you find yourself creating objects that consist of nothing but staticmethod
s the more pythonic thing to do would be to create a new module of related functions.
LDF holds the transaction log. If you set your backups correctly - it will be small. It it grows - you have a very common problem of setting database recovery mode to FULL and then forgetting to backup the transaction log (LDF file). Let me explain how to fix it.
Some would suggest to use SHRINKFILE to trim you log. Note that this is OK only as an exception. If you do it regularly, it defeats the purpose of FULL recovery model: first you go into trouble of saving every single change in the log, then you just dump it. Set recovery mode to SIMPLE instead.
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = true
Set objWorkbook = objExcel.Workbooks.Add()
Set objWorksheet = objWorkbook.Worksheets(1)
intRow = 2
dim ch
objWorksheet.Cells(1,1) = "Name"
objWorksheet.Cells(1,2) = "Subject1"
objWorksheet.Cells(1,3) = "Subject2"
objWorksheet.Cells(1,4) = "Total"
for intRow = 2 to 10000
name= InputBox("Enter your name")
sb1 = cint(InputBox("Enter your Marks in Subject 1"))
sb2 = cint(InputBox("Enter your Marks in Subject 2"))
total= sb1+sb2+sb3+sb4
objExcel.Cells(intRow, 1).Value = name
objExcel.Cells(intRow, 2).Value = sb1
objExcel.Cells(intRow, 3).Value = sb2
objExcel.Cells(intRow, 4).Value = total
ch = InputBox("Do you want continue..? if no then type no or y to continue")
If ch = "no" Then Exit For
Next
objExcel.Cells.EntireColumn.AutoFit
MsgBox "Done"
enter code here
My recommendation is to use top location 33% or 25% from remaining space,
and not 50% as other examples posted here,
mainly because of the window header,
which look better and more comfort to the user,
complete code:
<script language="javascript" type="text/javascript">
function OpenPopupCenter(pageURL, title, w, h) {
var left = (screen.width - w) / 2;
var top = (screen.height - h) / 4; // for 25% - devide by 4 | for 33% - devide by 3
var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
}
</script>
</head>
<body>
<button onclick="OpenPopupCenter('http://www.google.com', 'TEST!?', 800, 600);">click on me</button>
</body>
</html>
check out this line:
var top = (screen.height - h) / 4; // for 25% - devide by 4 | for 33% - devide by 3
Using Javascript
var side = document.querySelector("#side");_x000D_
var main = document.querySelector("#main");_x000D_
var togg = document.querySelector("#toogle");_x000D_
var width = window.innerWidth;_x000D_
_x000D_
window.document.addEventListener("click", function() {_x000D_
_x000D_
if (side.clientWidth == 0) {_x000D_
// alert(side.clientWidth);_x000D_
side.style.width = "200px";_x000D_
main.style.marginLeft = "200px";_x000D_
main.style.width = (width - 200) + "px";_x000D_
togg.innerHTML = "Min";_x000D_
} else {_x000D_
// alert(side.clientWidth);_x000D_
side.style.width = "0";_x000D_
main.style.marginLeft = "0";_x000D_
main.style.width = width + "px"; _x000D_
togg.innerHTML = "Max";_x000D_
}_x000D_
_x000D_
}, false);
_x000D_
button {_x000D_
width: 100px;_x000D_
position: relative; _x000D_
display: block; _x000D_
}_x000D_
_x000D_
div {_x000D_
position: absolute;_x000D_
left: 0;_x000D_
border: 3px solid #73AD21;_x000D_
display: inline-block;_x000D_
transition: 0.5s; _x000D_
}_x000D_
_x000D_
#side {_x000D_
left: 0;_x000D_
width: 0px;_x000D_
background-color: red;_x000D_
}_x000D_
_x000D_
#main {_x000D_
width: 100%;_x000D_
background-color: white; _x000D_
}
_x000D_
<button id="toogle">Max</button>_x000D_
<div id="side">Sidebar</div>_x000D_
<div id="main">Main</div>
_x000D_
default_scope
This works for Rails 4+:
class Book < ActiveRecord::Base
default_scope { order(created_at: :desc) }
end
For Rails 2.3, 3, you need this instead:
default_scope order('created_at DESC')
For Rails 2.x:
default_scope :order => 'created_at DESC'
Where created_at
is the field you want the default sorting to be done on.
Note: ASC is the code to use for Ascending and DESC is for descending (desc
, NOT dsc
!).
scope
Once you're used to that you can also use scope
:
class Book < ActiveRecord::Base
scope :confirmed, :conditions => { :confirmed => true }
scope :published, :conditions => { :published => true }
end
For Rails 2 you need named_scope
.
:published
scope gives you Book.published
instead of
Book.find(:published => true)
.
Since Rails 3 you can 'chain' those methods together by concatenating them with periods between them, so with the above scopes you can now use Book.published.confirmed
.
With this method, the query is not actually executed until actual results are needed (lazy evaluation), so 7 scopes could be chained together but only resulting in 1 actual database query, to avoid performance problems from executing 7 separate queries.
You can use a passed in parameter such as a date or a user_id (something that will change at run-time and so will need that 'lazy evaluation', with a lambda, like this:
scope :recent_books, lambda
{ |since_when| where("created_at >= ?", since_when) }
# Note the `where` is making use of AREL syntax added in Rails 3.
Finally you can disable default scope with:
Book.with_exclusive_scope { find(:all) }
or even better:
Book.unscoped.all
which will disable any filter (conditions) or sort (order by).
Note that the first version works in Rails2+ whereas the second (unscoped) is only for Rails3+
So
... if you're thinking, hmm, so these are just like methods then..., yup, that's exactly what these scopes are!
They are like having def self.method_name ...code... end
but as always with ruby they are nice little syntactical shortcuts (or 'sugar') to make things easier for you!
In fact they are Class level methods as they operate on the 1 set of 'all' records.
Their format is changing however, with rails 4 there are deprecation warning when using #scope without passing a callable object. For example scope :red, where(color: 'red') should be changed to scope :red, -> { where(color: 'red') }
.
As a side note, when used incorrectly, default_scope can be misused/abused.
This is mainly about when it gets used for actions like where
's limiting (filtering) the default selection (a bad idea for a default) rather than just being used for ordering results.
For where
selections, just use the regular named scopes. and add that scope on in the query, e.g. Book.all.published
where published
is a named scope.
In conclusion, scopes are really great and help you to push things up into the model for a 'fat model thin controller' DRYer approach.
ObStupidAnswer (but I think there's a lesson in here somewhere):
enum Values {
AB, BC, CD, AE
}
try {
Values.valueOf(s);
return true;
} catch (IllegalArgumentException exc) {
return false;
}
Most simple way:
<script type="text/plain" src="http://raw.githubusercontent.com/user/repo/branch/file.js"></script>
Served by GitHub,
and
text/plain
text/plain
In my and possibly @BIOHAZARD case it was nginx proxy timeout
. In default it's 60
sec without activity in socket
I changed it to 24h in nginx
and it resolved problem
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
I changed a few things to work with Option Explicit
, and the code ran fine against a cell containing "abc.123"
, which returned "abc.12,"
. There were no compile errors.
Option Explicit ' This is new
Public Function ProcessString(input_string As String) As String
' The temp string used throughout the function
Dim temp_string As String
Dim i As Integer ' This is new
Dim return_string As String ' This is new
For i = 1 To Len(input_string)
temp_string = Mid(input_string, i, 1)
If temp_string Like "[A-Z, a-z, 0-9, :, -]" Then
return_string = return_string & temp_string
End If
Next i
return_string = Mid(return_string, 1, (Len(return_string) - 1))
ProcessString = return_string & ", "
End Function
I'll suggest you post more of your relevant code (that calls this function). You've stated that last_name is a String, but it appears that may not be the case. Step through your code line by line and ensure that this is actually the case.
Removing Punctuations, Numbers, and Special Characters
Example :-
Code
combi['tidy_tweet'] = combi['tidy_tweet'].str.replace("[^a-zA-Z#]", " ")
Thanks :)
Perhaps:
> data.frame(aname=NA, bname=NA)[numeric(0), ]
[1] aname bname
<0 rows> (or 0-length row.names)
Every system call that fails update the errno
value.
Thus, you can have more information about what happens when a ifstream
open fails by using something like :
cerr << "Error: " << strerror(errno);
However, since every system call updates the global errno
value, you may have issues in a multithreaded application, if another system call triggers an error between the execution of the f.open
and use of errno
.
On system with POSIX standard:
errno is thread-local; setting it in one thread does not affect its value in any other thread.
Edit (thanks to Arne Mertz and other people in the comments):
e.what()
seemed at first to be a more C++-idiomatically correct way of implementing this, however the string returned by this function is implementation-dependant and (at least in G++'s libstdc++) this string has no useful information about the reason behind the error...
Wherever there is errors or exceptions in static blocks, this exception will be thrown. To get the cause of this exception simply use Throwable.getCause()
to know what is wrong.