Remove ng.ps1
from the directory C:\Users\%username%\AppData\Roaming\npm\
then try clearing the npm cache at C:\Users\%username%\AppData\Roaming\npm-cache\
Many answer above are correct but same time convoluted with other aspects of authN/authZ. What actually resolves the exception in question is this line:
services.AddScheme<YourAuthenticationOptions, YourAuthenticationHandler>(YourAuthenticationSchemeName, options =>
{
options.YourProperty = yourValue;
})
Here is the little hack to overcome all the struggles you have for video autoplay in a website:
Note: Some browsers don't let videos to autoplay unless the user interacts with the device.
So scripts to check whether video is playing is:
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
get: function () {
return !!(this.currentTime > 0 && !this.paused && !this.ended && this.readyState > 2);
}});
And then you can simply autoplay the video by attaching event listeners to the body:
$('body').on('click touchstart', function () {
const videoElement = document.getElementById('home_video');
if (videoElement.playing) {
// video is already playing so do nothing
}
else {
// video is not playing
// so play video now
videoElement.play();
}
});
Note: autoplay
attribute is very basic which needs to be added to the video tag already other than these scripts.
You can see the working example with code here at this link:
How to autoplay video when the device is in low power mode / data saving mode / safari browser issue
You can now link to an external site using React Link by providing an object to to
with the pathname
key:
<Link to={ { pathname: '//example.zendesk.com/hc/en-us/articles/123456789-Privacy-Policies' } } >
If you find that you need to use JS to generate the link in a callback, you can use window.location.replace()
or window.location.assign()
.
Over using window.location.replace()
, as other good answers suggest, try using window.location.assign()
.
window.location.replace()
will replace the location history without preserving the current page.
window.location.assign()
will transition to the url specified, but will save the previous page in the browser history, allowing proper back-button functionality.
https://developer.mozilla.org/en-US/docs/Web/API/Location/replace https://developer.mozilla.org/en-US/docs/Web/API/Location/assign
Also, if you are using a window.location = url
method as mentioned in other answers, I highly suggest switching to window.location.href = url
.
There is a heavy argument about it, where many users seem to adamantly want to revert the newer object
type window.location
to its original implementation as string
merely because they can (and they egregiously attack anyone who says otherwise), but you could theoretically interrupt other library functionality accessing the window.location
object.
Check out this convo. It's terrible. Javascript: Setting location.href versus location
I think you can use the powershell in administrative mode or command prompt.
I had a similar issue uploading to an S3 bucket protected with KWS encryption. I have a minimal policy that allows the addition of objects under a specific s3 key.
I needed to add the following KMS permissions to my policy to allow the role to put objects in the bucket. (Might be slightly more than are strictly required)
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"kms:ListKeys",
"kms:GenerateRandom",
"kms:ListAliases",
"s3:PutAccountPublicAccessBlock",
"s3:GetAccountPublicAccessBlock",
"s3:ListAllMyBuckets",
"s3:HeadBucket"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"kms:ImportKeyMaterial",
"kms:ListKeyPolicies",
"kms:ListRetirableGrants",
"kms:GetKeyPolicy",
"kms:GenerateDataKeyWithoutPlaintext",
"kms:ListResourceTags",
"kms:ReEncryptFrom",
"kms:ListGrants",
"kms:GetParametersForImport",
"kms:TagResource",
"kms:Encrypt",
"kms:GetKeyRotationStatus",
"kms:GenerateDataKey",
"kms:ReEncryptTo",
"kms:DescribeKey"
],
"Resource": "arn:aws:kms:<MY-REGION>:<MY-ACCOUNT>:key/<MY-KEY-GUID>"
},
{
"Sid": "VisualEditor2",
"Effect": "Allow",
"Action": [
<The S3 actions>
],
"Resource": [
"arn:aws:s3:::<MY-BUCKET-NAME>",
"arn:aws:s3:::<MY-BUCKET-NAME>/<MY-BUCKET-KEY>/*"
]
}
]
}
in VS 2017 I cleaned the solution and rebuilt it and that fixed it
It's only possible when the server sends this header: Access-Control-Allow-Origin: *
If this is your code then you can setup it like this (PHP):
header('Access-Control-Allow-Origin: *');
Okay, redis is pretty user friendly but there are some gotchas.
Here are just some easy commands for working with redis on Ubuntu:
install:
sudo apt-get install redis-server
start with conf:
sudo redis-server <path to conf>
sudo redis-server config/redis.conf
stop with conf:
redis-ctl shutdown
(not sure how this shuts down the pid specified in the conf. Redis must save the path to the pid somewhere on boot)
log:
tail -f /var/log/redis/redis-server.log
Also, various example confs floating around online and on this site were beyond useless. The best, sure fire way to get a compatible conf is to copy-paste the one your installation is already using. You should be able to find it here:
/etc/redis/redis.conf
Then paste it at <path to conf>
, tweak as needed and you're good to go.
In my case I had to delete the services in my installshield project and start from square one. My original service components were added manually and I couldn't get them working, the only error I was getting was the same "Error 1920 service failed to start. Verify that you have sufficient privileges to start system services." that you were getting. After deleting my components, I re-added them using the component wizard.
I actually had to create two new components. One was of type "Install Service".
The other component I had to add was of "Control Service" type.
I had to choose the service that I had setup when I added the Install Service component.
After that it worked, even though nothing looked differently from the components I had added manually. Installshield must do something behind the scenes when it wires up the service components with the component wizard.
All of this was with Install Shield 2016.
many unstable solutions I prefer to edit the host file
/etc/hosts
127.0.0.1 dl.google.com
127.0.0.1 tools.google.com
You are getting that error because when the param1
if statements are evaluated, param is always null due to being scoped variables without delayed expansion.
When parentheses are used, all the commands and variables within those parentheses are expanded. And at that time, param1 has no value making the if statements invalid. When using delayed expansion, the variables are only expanded when the command is actually called.
Also I recommend using if not defined
command to determine if a variable is set.
@echo off
setlocal EnableExtensions EnableDelayedExpansion
cls
title ~USB Wizard~
echo What do you want to do?
echo 1.Enable/Disable USB Storage Devices.
echo 2.Enable/Disable Writing Data onto USB Storage.
echo 3.~Yet to come~.
set "a=%globalparam1%"
goto :aCheck
:aPrompt
set /p "a=Enter Choice: "
:aCheck
if not defined a goto :aPrompt
echo %a%
IF "%a%"=="2" (
title USB WRITE LOCK
echo What do you want to do?
echo 1.Apply USB Write Protection
echo 2.Remove USB Write Protection
::param1
set "param1=%globalparam2%"
goto :param1Check
:param1Prompt
set /p "param1=Enter Choice: "
:param1Check
if not defined param1 goto :param1Prompt
echo !param1!
if "!param1!"=="1" (
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies\ /v WriteProtect /t REG_DWORD /d 00000001
echo USB Write is Locked!
)
if "!param1!"=="2" (
REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies\ /v WriteProtect /t REG_DWORD /d 00000000
echo USB Write is Unlocked!
)
)
pause
endlocal
TRY
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Internet Settings
EnableAutoProxyResultCache = dword: 0
In command line it's better to use REG tool rather than REGEDIT:
REG IMPORT yourfile.reg
REG is designed for console mode, while REGEDIT is for graphical mode. This is why running regedit.exe /S yourfile.reg is a bad idea, since you will not be notified if the there's an error, whereas REG Tool will prompt:
> REG IMPORT missing_file.reg
ERROR: Error opening the file. There may be a disk or file system error.
> %windir%\System32\reg.exe /?
REG Operation [Parameter List]
Operation [ QUERY | ADD | DELETE | COPY |
SAVE | LOAD | UNLOAD | RESTORE |
COMPARE | EXPORT | IMPORT | FLAGS ]
Return Code: (Except for REG COMPARE)
0 - Successful
1 - Failed
For help on a specific operation type:
REG Operation /?
Examples:
REG QUERY /?
REG ADD /?
REG DELETE /?
REG COPY /?
REG SAVE /?
REG RESTORE /?
REG LOAD /?
REG UNLOAD /?
REG COMPARE /?
REG EXPORT /?
REG IMPORT /?
REG FLAGS /?
I have found out when running a PS1 file for a Mapped drive to Dropbox that I'm always getting this error. When opening up properties for the PS1 there is no "Unblock".
The only thing that work for me is
powershell.exe -executionpolicy bypass -file .\Script.ps1
I can generate this error by setting system property trustStore to a missing jks file. For example
System.setProperty("javax.net.ssl.keyStore", "C:/keystoreFile.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "mypassword");
System.setProperty("javax.net.ssl.trustStore", "C:/missing-keystore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "mypassword");
This code does not generate a FileNotFound exception for some reason, but exactly the InvalidAlgorithmParameter exception listed above.
Kind of a dumb answer, but I can reproduce.
PHP exec("php script.php")
can do it.
From the Manual:
If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.
So if you redirect the output to a log file (what is a good idea anyways), your calling script will not hang and your email script will run in bg.
strace supported By Git,as Michael Fox Mention Maybe not useful for complex/windows software.
Well, I used curl in PHP to circumvent this. I have a webservice running in port 82.
<?php
$curl = curl_init();
$timeout = 30;
$ret = "";
$url="http://localhost:82/put_val?val=".$_GET["val"];
curl_setopt ($curl, CURLOPT_URL, $url);
curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($curl, CURLOPT_MAXREDIRS, 20);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5");
curl_setopt ($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
$text = curl_exec($curl);
echo $text;
?>
Here is the javascript that makes the call to the PHP file
function getdata(obj1, obj2) {
var xmlhttp;
if (window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest();
else
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","phpURLFile.php?eqp="+obj1+"&val="+obj2,true);
xmlhttp.send();
}
My HTML runs on WAMP in port 80. So there we go, same origin policy has been circumvented :-)
I've used the TripAdvisor API before and its suited me well. It returns, per destination, a list of top-rated hotels, along with options to retrieve reviews, photos, nearby restaurants and a couple other useful things.
http://www.tripadvisor.com/help/what_type_of_tripadvisor_content_is_available
From the API page (available API content) :
* Hotel, attraction and restaurant ratings and reviews
* Top 10 lists of hotels, attractions and restaurants in a destination
* Traveler photos of a destination
* Travelers' Choice award badges for hotels and destinations
To expand upon @nstehr's answer, you could also use Yahoo Pipes to facilitate a more granular local search. Go to pipes.yahoo.com and do a search for existing hotel pipes and you'll get the idea..
In modern browsers and HTML5, there is a method called pushState
on window history
. That will change the URL and push it to the history without loading the page.
You can use it like this, it will take 3 parameters, 1) state object 2) title and a URL):
window.history.pushState({page: "another"}, "another page", "example.html");
This will change the URL, but not reload the page. Also, it doesn't check if the page exist, so if you do some JavaScript code which be reacting to the URL, you can work with them like this.
Also there is history.replaceState()
which does exactly the same thing, except it will modify the current history instead of creating a new one!
Also you can create a function to check if history.pushState
exist, then carry on with the rest like this:
function goTo(page, title, url) {
if ("undefined" !== typeof history.pushState) {
history.pushState({page: page}, title, url);
} else {
window.location.assign(url);
}
}
goTo("another page", "example", 'example.html');
Also you can change the #
for <HTML5 browsers
, which won't reload the page. That's the way Angular uses to do SPA according to hashtag...
Changing #
is quite easy, doing like:
window.location.hash = "example";
And you can detect it like this:
window.onhashchange = function () {
console.log("#changed", window.location.hash);
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security;
using System.DirectoryServices.AccountManagement;
public struct Credentials
{
public string Username;
public string Password;
}
public class Domain_Authentication
{
public Credentials Credentials;
public string Domain;
public Domain_Authentication(string Username, string Password, string SDomain)
{
Credentials.Username = Username;
Credentials.Password = Password;
Domain = SDomain;
}
public bool IsValid()
{
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, Domain))
{
// validate the credentials
return pc.ValidateCredentials(Credentials.Username, Credentials.Password);
}
}
}
I have found when I am using a manifest that the listing of jars for the classpath need to have a space after the listing of each jar e.g. "required_lib/sun/pop3.jar required_lib/sun/smtp.jar ". Even if it is the last in the list.
I do know that the account needs to have "Log on as a Service" privileges. Other than that, I'm not sure. A quick reference to Log on as a Service can be found here, and there is a lot of information of specific privileges here.
Here is Simple way to alter in view. add below in view just before passing it into template.
form = MyForm(instance = instance.obj)
form.fields['email'].widget.attrs = {'class':'here_class_name'}
Assuming there are a few ignore directories, why not use "git status node/logs/" which will tell you what files are to be added? In the directory I have a text file that is not part of status output, e.g.:
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add ..." to include in what will be committed)
node/logs/.gitignore
.gitignore is:
*
!.gitignore
Expanding on @Harmon above, looks like you can combine the display
and print
statements together ... if you need. Or, maybe it's easier to just format your entire HTML as one string and then use display. Either way, nice feature.
display(HTML('<h1>Hello, world!</h1>'))
print("Here's a link:")
display(HTML("<a href='http://www.google.com' target='_blank'>www.google.com</a>"))
print("some more printed text ...")
display(HTML('<p>Paragraph text here ...</p>'))
Outputs something like this:
Here's a link:
some more printed text ...
Paragraph text here ...
Fortran has better I/O routines, e.g. the implied do facility gives flexibility that C's standard library can't match.
The Fortran compiler directly handles the more complex syntax involved, and as such syntax can't be easily reduced to argument passing form, C can't implement it efficiently.
I have use @Mirko N. answser using made the new Custom EditText
public class EditViewCustom extends EditText {
Button cancelBtn;
RelativeLayout titleReleLayout;
public EditViewCustom(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public EditViewCustom(Context context, AttributeSet attrs) {
super(context, attrs);
}
public EditViewCustom(Context context) {
super(context);
}
public void setViews(Button cancelBtn,RelativeLayout titleReleLayout){
this.cancelBtn = cancelBtn;
this.titleReleLayout = titleReleLayout;
}
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
Log.d("KEYCODE_BACK","KEYCODE_BACK");
cancelBtn.setVisibility(View.GONE);
this.setFocusableInTouchMode(false);
this.setFocusable(false);
titleReleLayout.setVisibility(View.VISIBLE);
return super.onKeyPreIme(keyCode, event);
}
return super.onKeyPreIme(keyCode, event);
}
}
Then set data from your activity
searchEditView.setViews(cancelBtn, titleRelativeLayout);
Thank you.
Hey an easy way is to simply set the src of the video to nothing, so that the video will desapear while it's hidden an then set the src back to the video you want when you click on the link that opens the video.. to do that simply set an id to the youtube iframe and call the src function using that id like this:
<script type="text/javascript">
function deleteVideo()
{
document.getElementById('VideoPlayer').src='';
}
function LoadVideo()
{
document.getElementById('VideoPlayer').src='http://www.youtube.com/embed/WHAT,EVER,YOUTUBE,VIDEO,YOU,WHANT';
}
</script>
<body>
<p onclick="LoadVideo()">LOAD VIDEO</P>
<p onclick="deleteVideo()">CLOSE</P>
<iframe id="VideoPlayer" width="853" height="480" src="http://www.youtube.com/WHAT,EVER,YOUTUBE,VIDEO,YOU,HAVE" frameborder="0" allowfullscreen></iframe>
</boby>
Good question- and there is wealth of information in the question itself.
The article Refresh Tokens: When to Use Them and How They Interact with JWTs gives a good idea for this scenario. Some points are:-
Also take a look at auth0/angular-jwt angularjs
For Web API. read Enable OAuth Refresh Tokens in AngularJS App using ASP .NET Web API 2, and Owin
You can find your app package name by below command:
adb shell pm list packages
Above command returns package list of all apps, Example:
org.linphone.debug
.
.
com.android.email
Now I want to start app linphone by using below command and this worked for me:
adb shell am start org.belphone.debug
For Angular 5
app.module.ts
import {DatePipe} from '@angular/common';
.
.
.
providers: [DatePipe]
demo.component.ts
import { DatePipe } from '@angular/common';
.
.
constructor(private datePipe: DatePipe) {}
ngOnInit() {
var date = new Date();
console.log(this.datePipe.transform(date,"yyyy-MM-dd")); //output : 2018-02-13
}
more information angular/datePipe
$('html, body').animate({scrollTop: $("#page").offset().top}, 2000);
In my case (Hibernate 3.5.2, Postgresql, Ubuntu), setting hibernate.hbm2ddl.auto=update
only created new tables and created new columns in already existing tables.
It did neither drop tables, nor drop columns, nor alter columns. It can be called a safe option, but something like hibernate.hbm2ddl.auto=create_tables add_columns
would be more clear.
use the below code please :
Properties p = new Properties();
StringBuffer path = new StringBuffer("com/al/common/email/templates/");
path.append("foo.properties");
InputStream fs = getClass().getClassLoader()
.getResourceAsStream(path.toString());
if(fs == null){
System.err.println("Unable to load the properties file");
}
else{
try{
p.load(fs);
}
catch (IOException e) {
e.printStackTrace();
}
}
A really simple way to do this...
// create the option
var opt = $("<option>").val("myvalue").text("my text");
//append option to the select element
$(#my-select).append(opt);
This could be done in lots of ways, even in a single line if really you want to.
CSS transitions only animate from one set of styles to another; what you're looking for is CSS animations.
You need to define the animation keyframes and apply it to the element:
@keyframes changewidth {
from {
width: 100px;
}
to {
width: 300px;
}
}
div {
animation-duration: 0.1s;
animation-name: changewidth;
animation-iteration-count: infinite;
animation-direction: alternate;
}
Check out the link above to figure out how to customize it to your liking, and you'll have to add browser prefixes.
uint32_t
is standard, uint32
is not. That is, if you include <inttypes.h>
or <stdint.h>
, you will get a definition of uint32_t
. uint32
is a typedef in some local code base, but you should not expect it to exist unless you define it yourself. And defining it yourself is a bad idea.
In angular 4, this worked for me
template.html
<select (change)="filterChanged($event.target.value)">
<option *ngFor="let type of filterTypes" [value]="type.value">{{type.display}}
</option>
</select>
component.ts
export class FilterComponent implements OnInit {
selectedFilter:string;
public filterTypes = [
{ value: 'percentage', display: 'percentage' },
{ value: 'amount', display: 'amount' }
];
constructor() {
this.selectedFilter = 'percentage';
}
filterChanged(selectedValue:string){
console.log('value is ', selectedValue);
}
ngOnInit() {
}
}
<form action="display.html" method="post">_x000D_
<input type="text" name="serialNumber" />_x000D_
<input type="submit" value="Submit" />_x000D_
</form>
_x000D_
In display.html you should add the following code.
<script>
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
var sn = getParameterByName('serialNumber');
document.getElementById("write").innerHTML = sn;
</script>
I have found a great work-around for this. It really only works practically if you want to be able to select up to 4 or so options from your drop down list but here it is:
For each "item" create as many rows as drop-down items you'd like to be able to select. So if you want to be able to select up to 3 characteristics from a given drop down list for each person on your list, create a total of 3 rows for each person. Then merge A:1-A:3, B:1-B:3, C:1-C:3 etc until you reach the column that you'd like your drop-down list to be. Don't merge those cells, instead place the your Data Validation drop-down in each of those cells.
Hope this is clear!!
sort
method has been deprecated and replaced with sort_values
. After converting to datetime object using df['Date']=pd.to_datetime(df['Date'])
df.sort_values(by=['Date'])
Note: to sort in-place and/or in a descending order (the most recent first):
df.sort_values(by=['Date'], inplace=True, ascending=False)
Not sure if it is a best practice...
Suggestion: do not implement this or anything when unsure. Reevaluate when facts are known, then perform before/after performance tests to verify.
NSDictionary -> NSData:
NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
[archiver encodeObject:yourDictionary forKey:@"Some Key Value"];
[archiver finishEncoding];
[archiver release];
// Here, data holds the serialized version of your dictionary
// do what you need to do with it before you:
[data release];
NSData -> NSDictionary
NSData *data = [[NSMutableData alloc] initWithContentsOfFile:[self dataFilePath]];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
NSDictionary *myDictionary = [[unarchiver decodeObjectForKey:@"Some Key Value"] retain];
[unarchiver finishDecoding];
[unarchiver release];
[data release];
You can do that with any class that conforms to NSCoding.
I just developed a considerably easier solution. (Yes, I know this is an old question but someone researching this same issue may find this useful.)
I was using an SVG called hamburger.svg. I looked at it with a text editor and couldn't find anything that was setting a colour for the three lines - I'm guessing it defaults to black because that's certainly the behaviour I get - so I simply added a "stroke" parameter to the definition of the SVG. That didn't QUITE work - the borders of the three lines were my chosen colour (white) but the rest of the line was still black so I added a "fill" parameter as well. And that did the trick!
Here is the code for the original hamburger.svg in its entirety:
<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg height="32px" id="Layer_1" style="enable-background:new 0 0 32 32;" version="1.1" viewBox="0 0 32 32" width="32px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M4,10h24c1.104,0,2-0.896,2-2s-0.896-2-2-2H4C2.896,6,2,6.896,2,8S2.896,10,4,10z M28,14H4c-1.104,0-2,0.896-2,2 s0.896,2,2,2h24c1.104,0,2-0.896,2-2S29.104,14,28,14z M28,22H4c-1.104,0-2,0.896-2,2s0.896,2,2,2h24c1.104,0,2-0.896,2-2 S29.104,22,28,22z"/></svg>
And here is the code for the new SVG after I edited it and saved it as hamburger_white.svg:
<?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg height="32px" id="Layer_1" style="enable-background:new 0 0 32 32;" version="1.1" viewBox="0 0 32 32" width="32px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M4,10h24c1.104,0,2-0.896,2-2s-0.896-2-2-2H4C2.896,6,2,6.896,2,8S2.896,10,4,10z M28,14H4c-1.104,0-2,0.896-2,2 s0.896,2,2,2h24c1.104,0,2-0.896,2-2S29.104,14,28,14z M28,22H4c-1.104,0-2,0.896-2,2s0.896,2,2,2h24c1.104,0,2-0.896,2-2 S29.104,22,28,22z" stroke="white" fill="white"/></svg>
As you can see if you scroll way over to the right, all I did was add:
stroke="white" fill="white"
to the very end of the path. The other thing I had to do was change the file name of the hamburger in the HTML. No messing with the CSS at all and no need to track down another icon.
Easy-peasey! You can imitate this to make your hamburger any colour you like.
After looking at the code you're having typos, here is the updated code
var clicks = 0; // should be var not int
function clickME() {
clicks += 1;
document.getElementById("clicks").innerHTML = clicks; //getElementById() not getElementByID() Which you corrected in edit
}
Note: Don't use in-built handlers, as .click()
is javascript function try giving different name like clickME()
Yes, you can group by multiple columns. For example,
SELECT * FROM table
GROUP BY col1, col2
The results will first be grouped by col1, then by col2. In MySQL, column preference goes from left to right.
For everyone stumbling upon this post because pandas gets mentioned,
you now have the very elegant and straighforward option of directly accessing the
secondary_y axis in pandas with ax.right_ax
So paraphrasing the example initially posted, you would write:
table = sql.read_frame(query,connection)
ax = table[[0, 1]].plot(ylim=(0,100), secondary_y=table[1])
ax.set_ylabel('$')
ax.right_ax.set_ylabel('Your second Y-Axis Label goes here!')
I am a bit extending provided answers (since so far they concentrate on their "own"/artificial terminology focusing on programming a particular language instead of taking care of the bigger picture behind the scene of creating the programming languages, in general, i.e. when things like type-safety vs. memory considerations make the difference):
int is not boolean
Consider
boolean bar = true;
System.out.printf("Bar is %b\n", bar);
System.out.printf("Bar is %d\n", (bar)?1:0);
int baz = 1;
System.out.printf("Baz is %d\n", baz);
System.out.printf("Baz is %b\n", baz);
with output
Bar is true
Bar is 1
Baz is 1
Baz is true
Java code on 3rd line (bar)?1:0
illustrates that bar (boolean) cannot be implicitly converted (casted) into an int. I am bringing this up not to illustrate the details of implementation behind JVM, but to point out that in terms of low level considerations (as memory size) one does have to prefer values over type safety. Especially if that type safety is not truly/fully used as in boolean types where checks are done in form of
if value \in {0,1} then cast to boolean type, otherwise throw an exception.
All just to state that {0,1} < {-2^31, .. , 2^31 -1}. Seems like an overkill, right? Type safety is truly important in user defined types, not in implicit casting of primitives (although last are included in the first).
Bytes are not types or bits
Note that in memory your variable from range of {0,1} will still occupy at least a byte or a word (xbits depending on the size of the register) unless specially taken care of (e.g. packed nicely in memory - 8 "boolean" bits into 1 byte - back and forth).
By preferring type safety (as in putting/wrapping value into a box of a particular type) over extra value packing (e.g. using bit shifts or arithmetic), one does effectively chooses writing less code over gaining more memory. (On the other hand one can always define a custom user type which will facilitate all the conversion not worth than Boolean).
keyword vs. type
Finally, your question is about comparing keyword vs. type. I believe it is important to explain why or how exactly you will get performance by using/preferring keywords ("marked" as primitive) over types (normal composite user-definable classes using another keyword class) or in other words
boolean foo = true;
vs.
Boolean foo = true;
The first "thing" (type) can not be extended (subclassed) and not without a reason. Effectively Java terminology of primitive and wrapping classes can be simply translated into inline value (a LITERAL or a constant that gets directly substituted by compiler whenever it is possible to infer the substitution or if not - still fallback into wrapping the value).
Optimization is achieved due to trivial:
"Less runtime casting operations => more speed."
That is why when the actual type inference is done it may (still) end up in instantiating of wrapping class with all the type information if necessary (or converting/casting into such).
So, the difference between boolean and Boolean is exactly in Compilation and Runtime (a bit far going but almost as instanceof vs. getClass()).
Finally, autoboxing is slower than primitives
Note the fact that Java can do autoboxing is just a "syntactic sugar". It does not speed up anything, just allows you to write less code. That's it. Casting and wrapping into type information container is still performed. For performance reasons choose arithmetics which will always skip extra housekeeping of creating class instances with type information to implement type safety. Lack of type safety is the price you pay to gain performance. For code with boolean-valued expressions type safety (when you write less and hence implicit code) would be critical e.g. for if-then-else flow controls.
From within gdb press Ctrl
x
2
and the screen will split into 3 parts.
First part will show you the normal code in high level language.
Second will show you the assembly equivalent and corresponding instruction Pointer
.
Third will present you the normal gdb
prompt to enter commands.
there are many causes such as
To examine the problem in detail, you can use Wireshark.
or you can just re-request or re-connect again.
If you create a cookie and do not specify an expiration date, it will create a session cookie which will expire at the end of the session.
See https://stackoverflow.com/a/532660/1901857 for more information.
As @filoxo said, you can use document.querySelectorAll
.
If you know that there is only one element with the class you are looking for, or you are interested only in the first one, you can use:
document.querySelector('.class1.class2');
BTW, while .class1.class2
indicates an element with both classes, .class1 .class2
(notice the whitespace) indicates an hierarchy - and element with class class2
which is inside en element with class class1
:
<div class='class1'>
<div>
<div class='class2'>
:
:
And if you want to force retrieving a direct child, use >
sign (.class1 > .class2
):
<div class='class1'>
<div class='class2'>
:
:
For entire information about selectors:
https://www.w3schools.com/jquery/jquery_ref_selectors.asp
An old thread, sure, but a popular one apparently. It's 2020 now and none of these answers have addressed the issue of unreadable code. @pimvdb's answer takes up less lines, but it's also pretty complicated to follow. For easier debugging and better readability, I should suggest refactoring the OP's code to something like this, and adopting an early return pattern, as this is likely the main reason you were unsure of why the were getting undefined:
function validatePassword() {
const password = document.getElementById("password");
const confirm_password = document.getElementById("password_confirm");
if (password.value.length === 0) {
return false;
}
if (password.value !== confirm_password.value) {
return false;
}
return true;
}
for monochrome background you could use a svg with a mask, where the background color should be displayed
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" preserveAspectRatio="xMidYMid meet" focusable="false" style="pointer-events: none; display: block; width: 100%; height: 100%;" >
<defs>
<mask id="Mask">
<rect width="100%" height="100%" fill="#fff" />
<polyline stroke-width="2.5" stroke="black" stroke-linecap="square" fill="none" transform="translate(10.373882, 8.762969) rotate(-315.000000) translate(-10.373882, -8.762969) " points="7.99893906 13.9878427 12.7488243 13.9878427 12.7488243 3.53809523"></polyline>
</mask>
</defs>
<rect x="0" y="0" width="20" height="20" fill="white" mask="url(#Mask)" />
</svg>
and than use this css
background-repeat: no-repeat;
background-position: center center;
background-size: contain;
background-image: url(your/path/to.svg);
background-color: var(--color);
In which scenarios does one out-perform the other?
For smaller tables (less than 1000 rows) use a temp variable, otherwise use a temp table.
DateTime.UtcNow.ToString("s")
Returns something like 2008-04-10T06:30:00
UtcNow
obviously returns a UTC time so there is no harm in:
string.Concat(DateTime.UtcNow.ToString("s"), "Z")
If you're willing to transmit some data and that you don't need to be secured (any public infos) you can use a CORS proxy, it's very easy, you'll not have to change anything in your code or in server side (especially of it's not your server like the Yahoo API or OpenWeather). I've used it to fetch JSON files with an XMLHttpRequest and it worked fine.
What version of Excel?
In general, you cannot change the column letters. They are part of the Excel system.
You can use a row in the sheet to enter headers for a table that you are using. The table headers can be descriptive column names.
In Excel 2007 and later, you can convert a range of data into an Excel Table (Insert Ribbon > Table). An Excel Table can use structured table references instead of cell addresses, so the labels in the first row of the table now serve as a name reference for the data in the column.
If you have an Excel Table in your sheet (Excel 2007 and later) and scroll down, the column letters will be replaced with the column headers for the table column.
If this does not answer your question, please consider editing your question to include the detail you want to learn about.
What we found was that there was just a slight delay between the call to our server code and the return to the success call back. If we wrapped the call to the server in the $("#myModal").on('hidden.bs.modal', function (e)
handler and then called the $("#myModal").modal("hide");
method, the browser would hide the modal and then invoke the server side code.
Again, not elegant but functional.
function myFunc(){
$("#myModal").on('hidden.bs.modal', function (e) {
// Invoke your server side code here.
});
$("#myModal").modal("hide");
};
As you can see, when myFunc
is invoked, it will hide the modal and then invoke the server side code.
Go strings are not null terminated, and to remove the last char of a string you can simply do:
s = s[:len(s)-1]
To list untracked files try:
git ls-files --others --exclude-standard
If you need to pipe the output to xargs
, it is wise to mind white spaces using git ls-files -z
and xargs -0
:
git ls-files -z -o --exclude-standard | xargs -0 git add
Nice alias for adding untracked files:
au = !git add $(git ls-files -o --exclude-standard)
Edit: For reference: git-ls-files
Using Spark Sql 2.4.0 you can do that:
spark.sql("SELECT STRING(NULLIF(column,'')) as column_string")
If you don't care about data:
Best way would be to drop the database and run syncdb
again. Or you can run:
For Django >= 1.5
python manage.py flush
For Django < 1.5
python manage.py reset appname
(you can add --no-input
to the end of the command for it to skip the interactive prompt.)
If you do care about data:
From the docs:
syncdb will only create tables for models which have not yet been installed. It will never issue ALTER TABLE statements to match changes made to a model class after installation. Changes to model classes and database schemas often involve some form of ambiguity and, in those cases, Django would have to guess at the correct changes to make. There is a risk that critical data would be lost in the process.
If you have made changes to a model and wish to alter the database tables to match, use the sql command to display the new SQL structure and compare that to your existing table schema to work out the changes.
https://docs.djangoproject.com/en/dev/ref/django-admin/
Reference: FAQ - https://docs.djangoproject.com/en/dev/faq/models/#if-i-make-changes-to-a-model-how-do-i-update-the-database
People also recommend South ( http://south.aeracode.org/docs/about.html#key-features ), but I haven't tried it.
Actually, I think this is the best way.
from django.core.validators import URLValidator
from django.core.exceptions import ValidationError
val = URLValidator(verify_exists=False)
try:
val('http://www.google.com')
except ValidationError, e:
print e
If you set verify_exists
to True
, it will actually verify that the URL exists, otherwise it will just check if it's formed correctly.
edit: ah yeah, this question is a duplicate of this: How can I check if a URL exists with Django’s validators?
Using ES6
notation, you can do something like this:
For appending you can use the spread operator like this:
var arr1 = [1,2,3]_x000D_
var obj = 4_x000D_
var newData = [...arr1, obj] // [1,2,3,4]_x000D_
console.log(newData);
_x000D_
If you have copied the seeders files from any other project then you need to run the artisan command php artisan db:seed
otherwise it is fine.
I found the solution after a few tries, I hope this can help you. Add the following to your <ReactTable>
component:
getTrProps={(state, rowInfo) => {
if (rowInfo && rowInfo.row) {
return {
onClick: (e) => {
this.setState({
selected: rowInfo.index
})
},
style: {
background: rowInfo.index === this.state.selected ? '#00afec' : 'white',
color: rowInfo.index === this.state.selected ? 'white' : 'black'
}
}
}else{
return {}
}
}
In your state
don't forget to add a null selected
value, like:
state = { selected: null }
For simple things, I just use the XmlDocument/XmlNode/XmlAttribute classes and XmlDocument DOM found in System.XML.
It generates the XML for me, I just need to link a few items together.
However, on larger things, I use XML serialization.
When I got a similar status code 128
error from Jenkins:
status code 128:
stdout:
stderr: fatal: Couldn't find remote ref refs/heads/jenkins
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2172)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1864)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:78)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:545)
at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:358)
at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:113)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:67)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:299)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE
It was because I hadn't pushed my new branch "jenkins"
that had my Jenkinsfile
. So the solution was to just push my changes
As an exercise, I would suggest doing the following:
public void save(String fileName) throws FileNotFoundException {
PrintWriter pw = new PrintWriter(new FileOutputStream(fileName));
for (Club club : clubs)
pw.println(club.getName());
pw.close();
}
This will write the name of each club on a new line in your file.
Soccer Chess Football Volleyball ...
I'll leave the loading to you. Hint: You wrote one line at a time, you can then read one line at a time.
Every class in Java extends the Object
class. As such you can override its methods. In this case, you should be interested by the toString()
method. In your Club
class, you can override it to print some message about the class in any format you'd like.
public String toString() {
return "Club:" + name;
}
You could then change the above code to:
public void save(String fileName) throws FileNotFoundException {
PrintWriter pw = new PrintWriter(new FileOutputStream(fileName));
for (Club club : clubs)
pw.println(club); // call toString() on club, like club.toString()
pw.close();
}
It's a warning, not an error. It occurs because fsevents
is an optional dependency, used only when project is run on macOS environment (the package provides 'Native Access to Mac OS-X FSEvents').
And since you're running your project on Windows, fsevents
is skipped as irrelevant.
There is a PR to fix this behaviour here: https://github.com/npm/cli/pull/169
There's an easier way to think about this. Start with 1 bit. This can obviously represent 2 values (0 or 1). What happens when we add a bit? We can now represent twice as many values: the values we could represent before with a 0 appended and the values we could represent before with a 1 appended.
So the the number of values we can represent with n bits is just 2^n (2 to the power n)
I think you can find your answer here : Is an anchor tag without the href attribute safe?
Also if you want to no link operation with href , you can use it like :
<a href="javascript:void(0);">something</a>
you can simple use some div
to make a container and the display: flex;
to make the content appear side-by-side like this:
CSS
.splitscreen {
display:flex;
}
.splitscreen .left {
flex: 1;
}
.splitscreen .right {
flex: 1;
}
HTML
<div class="splitscreen">
<div class="left">
<!-- content -->
</div>
<div class="right">
<!-- content -->
</div>
</div>
using flex
you say who will use more space on the screen.
The <font>
tag has been deprecated, at least in XHTML. That means that it's use is officially "frowned upon," and there is no guarantee that future browsers will continue to display the text as you intended.
You have to use CSS. Go with the <span>
tag, or a separate style sheet. According to its specification, the <span>
tag has no semantic meaning and just allows you to change the style of a particular region.
You can install the Microsoft Report Viewer 2012 Runtime and change your references so they point to the ones installed by the runtime.
http://www.microsoft.com/en-gb/download/details.aspx?id=35747
I have installed the runtime without it asking for SQL Server 2012. Before installing try uninstalling any previous versions of report viewer.
You can try add this function in file RCTHTTPRequestHandler.m
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
{
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
}
I totally agree with the above answer. The only thing is that for me the solution was set the code in viewDidAppear
viewDidAppear
{
[self.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:YES];
}
When I used the viewWillAppear the scrolling didn't work.
The “depth” (or equivalently the “level number”) of a node is the number of edges on the “path” from the root node
The “height” of a node is the number of edges on the longest path from the node to a leaf node.
Here is the simple solution with StreamEx
EntryStream.of(countByType).sortedBy(e -> e.getValue()).keys().toList();
You can't remove from list if you're browsing it with "for each" loop. You can use Iterator
. Replace:
for (DrugStrength aDrugStrength : aDrugStrengthList) {
if (!aDrugStrength.isValidDrugDescription()) {
aDrugStrengthList.remove(aDrugStrength);
}
}
With:
for (Iterator<DrugStrength> it = aDrugStrengthList.iterator(); it.hasNext(); ) {
DrugStrength aDrugStrength = it.next();
if (!aDrugStrength.isValidDrugDescription()) {
it.remove();
}
}
db.collection_name.find({"filed_name":{$exists:true}});
fetch documents that contain this filed_name even it is null.
Warning
db.collection_name.find({"filed_name":{$ne:null}});
fetch documents that its field_name has a value $ne to null but this value could be an empty string also.
My proposition:
db.collection_name.find({ "field_name":{$ne:null},$where:"this.field_name.length >0"})
C++11 has some portable timer stuff. Check out sleep_for.
Mongoose 4.5 support this
Project.find(query)
.populate({
path: 'pages',
populate: {
path: 'components',
model: 'Component'
}
})
.exec(function(err, docs) {});
And you can join more than one deep level
Alternate syntax,
git fetch origin remote_branch_name:local_branch_name
It depends on the tablix structure you are using. In a table, for example, you do not have column groups, so Reporting Services does not recognize which textboxes are the column headers and setting RepeatColumnHeaders property to True doesn't work.
Instead, you need to:
RepeatOnNewPage
property to True.
KeepWithGroup
property is set to After
.The KeepWithGroup
property specifies which group to which the static member needs to stick. If set to After
then the static member sticks with the group after it, or below it, acting as a group header. If set to Before
, then the static member sticks with the group before, or above it, acting as a group footer. If set to None
, Reporting Services decides where to put the static member.
Now when you view the report, the column headers repeat on each page of the tablix.
This video shows how to set it exactly as the answer described.
.sr-only
is a class name specifically used for screen readers. You can use any class name, but .sr-only
is pretty commonly used. If you don't care about developing with compliance in mind, then it can be removed. It will not affect UI in any way if removed because the CSS for this class is not visible to desktop and mobile device browsers.
There seems to be some information missing here about the use of .sr-only
to explain its purpose and being for screen readers. First and foremost, it is very important to always keep impaired users in mind. Impairment is the purpose of 508 compliance: https://www.section508.gov/, and it is great that bootstrap takes this into consideration. However, the use of .sr-only
is not all that needs to be taken into consideration for 508 compliance. You have the use of color, size of fonts, accessibility via navigation, descriptors, use of aria and so much more.
But as for .sr-only
- what does the CSS actually do? There are several slightly different variants of the CSS used for .sr-only
. One of the few I use is below:
.sr-only {
position: absolute;
margin: -1px 0 0 -1px;
padding: 0;
display: block;
width: 1px;
height: 1px;
font-size: 1px;
line-height: 1px;
overflow: hidden;
clip: rect(0,0,0,0);
border: 0;
outline: 0;
}
The above CSS hides content in desktop and mobile browsers wrapped with this class, but is seen by a screen reader like JAWS: http://www.freedomscientific.com/Products/Blindness/JAWS. Example markup is as follows:
<a href="#" target="_blank">
Click to Open Site
<span class="sr-only">This is an external link</span>
</a>
Additionally, if a DOM element has a width and height of 0, the element is not seen by the DOM. This is why the above CSS uses width: 1px; height: 1px;
. By using display: none
and setting your CSS to height: 0
and width: 0
, the element is not seen by the DOM and is thus problematic. The above CSS using width: 1px; height: 1px;
is not all you do to make the content invisible to desktop and mobile browsers (without overflow: hidden
, your content would still show on the screen), and visible to screen readers. Hiding the content from desktop and mobile browsers is done by adding an offset from width: 1px
and height: 1px
previously mentioned by using:
position: absolute;
margin: -1px 0 0 -1px;
overflow: hidden;
Lastly, to have a very good idea of what a screen reader sees and relays to its impaired user, turn off page styling for your browser. For Firefox, you can do this by going to:
View > Page Style > No Style
I hope the information I provided here is of further use to someone in addition to the other responses.
Just pass it as an array:
$data = [
'name' => 'Raphael',
'age' => 22,
'email' => '[email protected]'
];
return View::make('user')->with($data);
Or chain them, like @Antonio mentioned.
There is a PPA with up-to-date versions of Ruby 2.x for Ubuntu 12.04+:
$ sudo apt-add-repository ppa:brightbox/ruby-ng
$ sudo apt-get update
$ sudo apt-get install ruby2.4
$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux-gnu]
Vector
synchronizes on each individual operation. That's almost never what you want to do.
Generally you want to synchronize a whole sequence of operations. Synchronizing individual operations is both less safe (if you iterate over a Vector
, for instance, you still need to take out a lock to avoid anyone else changing the collection at the same time, which would cause a ConcurrentModificationException
in the iterating thread) but also slower (why take out a lock repeatedly when once will be enough)?
Of course, it also has the overhead of locking even when you don't need to.
Basically, it's a very flawed approach to synchronization in most situations. As Mr Brian Henk pointed out, you can decorate a collection using the calls such as Collections.synchronizedList
- the fact that Vector
combines both the "resized array" collection implementation with the "synchronize every operation" bit is another example of poor design; the decoration approach gives cleaner separation of concerns.
As for a Stack
equivalent - I'd look at Deque
/ArrayDeque
to start with.
It is actually possible:
foo( 'blah', (new ReflectionFunction('foo'))->getParameters()[1]->getDefaultValue(), 'test');
Whether you would want to do so is another story :)
The reasons to avoid this solution are:
But it can actually be useful in situations where:
you don't want/can't change the original function.
you could change the function but:
null
(or equivalent) is not an option (see DiegoDD's comment)func_num_args()
About the performance, a very simple test shows that using the Reflection API to get the default parameters makes the function call 25 times slower, while it still takes less than one microsecond. You should know if you can to live with that.
Of course, if you mean to use it in a loop, you should get the default value beforehand.
Those two queries are performing OUTER JOIN
. See below
Oracle recommends that you use the FROM clause OUTER JOIN syntax rather than the Oracle join operator. Outer join queries that use the Oracle join operator (+) are subject to the following rules and restrictions, which do not apply to the FROM clause OUTER JOIN syntax:
You cannot specify the (+) operator in a query block that also contains FROM clause join syntax.
The (+) operator can appear only in the WHERE clause or, in the context of left- correlation (when specifying the TABLE clause) in the FROM clause, and can be applied only to a column of a table or view.
If A and B are joined by multiple join conditions, then you must use the (+) operator in all of these conditions. If you do not, then Oracle Database will return only the rows resulting from a simple join, but without a warning or error to advise you that you do not have the results of an outer join.
The (+) operator does not produce an outer join if you specify one table in the outer query and the other table in an inner query.
You cannot use the (+) operator to outer-join a table to itself, although self joins are valid. For example, the following statement is not valid:
-- The following statement is not valid: SELECT employee_id, manager_id FROM employees WHERE employees.manager_id(+) = employees.employee_id;
However, the following self join is valid:
SELECT e1.employee_id, e1.manager_id, e2.employee_id FROM employees e1, employees e2 WHERE e1.manager_id(+) = e2.employee_id ORDER BY e1.employee_id, e1.manager_id, e2.employee_id;
The (+) operator can be applied only to a column, not to an arbitrary expression. However, an arbitrary expression can contain one or more columns marked with the (+) operator.
A WHERE condition containing the (+) operator cannot be combined with another condition using the OR logical operator.
A WHERE condition cannot use the IN comparison condition to compare a column marked with the (+) operator with an expression.
If the WHERE clause contains a condition that compares a column from table B with a constant, then the (+) operator must be applied to the column so that Oracle returns the rows from table A for which it has generated nulls for this column. Otherwise Oracle returns only the results of a simple join.
In a query that performs outer joins of more than two pairs of tables, a single table can be the null-generated table for only one other table. For this reason, you cannot apply the (+) operator to columns of B in the join condition for A and B and the join condition for B and C. Refer to SELECT for the syntax for an outer join.
Taken from http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/queries006.htm
Your question almost spells the SQL for this:
DELETE FROM table WHERE id IN (1, 4, 6, 7)
The gcc compiler is not in your $PATH
.
It means either you dont have gcc installed or it's not in your $PATH variable.
To install gcc use this: (run as root)
Redhat base:
yum groupinstall "Development Tools"
Debian base:
apt-get install build-essential
Regular expressions are used for Pattern Matching.
To use in Excel follow these steps:
Step 1: Add VBA reference to "Microsoft VBScript Regular Expressions 5.5"
Step 2: Define your pattern
Basic definitions:
-
Range.
a-z
matches an lower case letters from a to z0-5
matches any number from 0 to 5[]
Match exactly one of the objects inside these brackets.
[a]
matches the letter a[abc]
matches a single letter which can be a, b or c[a-z]
matches any single lower case letter of the alphabet.()
Groups different matches for return purposes. See examples below.
{}
Multiplier for repeated copies of pattern defined before it.
[a]{2}
matches two consecutive lower case letter a: aa
[a]{1,3}
matches at least one and up to three lower case letter a
, aa
, aaa
+
Match at least one, or more, of the pattern defined before it.
a+
will match consecutive a's a
, aa
, aaa
, and so on?
Match zero or one of the pattern defined before it.
[a-z]?
matches empty string or any single lower case letter.*
Match zero or more of the pattern defined before it.
[a-z]*
matches empty string or string of lower case letters..
Matches any character except newline \n
a.
Matches a two character string starting with a and ending with anything except \n
|
OR operator
a|b
means either a
or b
can be matched.red|white|orange
matches exactly one of the colors.^
NOT operator
[^0-9]
character can not contain a number[^aA]
character can not be lower case a
or upper case A
\
Escapes special character that follows (overrides above behavior)
\.
, \\
, \(
, \?
, \$
, \^
Anchoring Patterns:
^
Match must occur at start of string
^a
First character must be lower case letter a
^[0-9]
First character must be a number.$
Match must occur at end of string
a$
Last character must be lower case letter a
Precedence table:
Order Name Representation
1 Parentheses ( )
2 Multipliers ? + * {m,n} {m, n}?
3 Sequence & Anchors abc ^ $
4 Alternation |
Predefined Character Abbreviations:
abr same as meaning
\d [0-9] Any single digit
\D [^0-9] Any single character that's not a digit
\w [a-zA-Z0-9_] Any word character
\W [^a-zA-Z0-9_] Any non-word character
\s [ \r\t\n\f] Any space character
\S [^ \r\t\n\f] Any non-space character
\n [\n] New line
Example 1: Run as macro
The following example macro looks at the value in cell A1
to see if the first 1 or 2 characters are digits. If so, they are removed and the rest of the string is displayed. If not, then a box appears telling you that no match is found. Cell A1
values of 12abc
will return abc
, value of 1abc
will return abc
, value of abc123
will return "Not Matched" because the digits were not at the start of the string.
Private Sub simpleRegex()
Dim strPattern As String: strPattern = "^[0-9]{1,2}"
Dim strReplace As String: strReplace = ""
Dim regEx As New RegExp
Dim strInput As String
Dim Myrange As Range
Set Myrange = ActiveSheet.Range("A1")
If strPattern <> "" Then
strInput = Myrange.Value
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = strPattern
End With
If regEx.Test(strInput) Then
MsgBox (regEx.Replace(strInput, strReplace))
Else
MsgBox ("Not matched")
End If
End If
End Sub
Example 2: Run as an in-cell function
This example is the same as example 1 but is setup to run as an in-cell function. To use, change the code to this:
Function simpleCellRegex(Myrange As Range) As String
Dim regEx As New RegExp
Dim strPattern As String
Dim strInput As String
Dim strReplace As String
Dim strOutput As String
strPattern = "^[0-9]{1,3}"
If strPattern <> "" Then
strInput = Myrange.Value
strReplace = ""
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = strPattern
End With
If regEx.test(strInput) Then
simpleCellRegex = regEx.Replace(strInput, strReplace)
Else
simpleCellRegex = "Not matched"
End If
End If
End Function
Place your strings ("12abc") in cell A1
. Enter this formula =simpleCellRegex(A1)
in cell B1
and the result will be "abc".
Example 3: Loop Through Range
This example is the same as example 1 but loops through a range of cells.
Private Sub simpleRegex()
Dim strPattern As String: strPattern = "^[0-9]{1,2}"
Dim strReplace As String: strReplace = ""
Dim regEx As New RegExp
Dim strInput As String
Dim Myrange As Range
Set Myrange = ActiveSheet.Range("A1:A5")
For Each cell In Myrange
If strPattern <> "" Then
strInput = cell.Value
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = strPattern
End With
If regEx.Test(strInput) Then
MsgBox (regEx.Replace(strInput, strReplace))
Else
MsgBox ("Not matched")
End If
End If
Next
End Sub
Example 4: Splitting apart different patterns
This example loops through a range (A1
, A2
& A3
) and looks for a string starting with three digits followed by a single alpha character and then 4 numeric digits. The output splits apart the pattern matches into adjacent cells by using the ()
. $1
represents the first pattern matched within the first set of ()
.
Private Sub splitUpRegexPattern()
Dim regEx As New RegExp
Dim strPattern As String
Dim strInput As String
Dim Myrange As Range
Set Myrange = ActiveSheet.Range("A1:A3")
For Each C In Myrange
strPattern = "(^[0-9]{3})([a-zA-Z])([0-9]{4})"
If strPattern <> "" Then
strInput = C.Value
With regEx
.Global = True
.MultiLine = True
.IgnoreCase = False
.Pattern = strPattern
End With
If regEx.test(strInput) Then
C.Offset(0, 1) = regEx.Replace(strInput, "$1")
C.Offset(0, 2) = regEx.Replace(strInput, "$2")
C.Offset(0, 3) = regEx.Replace(strInput, "$3")
Else
C.Offset(0, 1) = "(Not matched)"
End If
End If
Next
End Sub
Results:
Additional Pattern Examples
String Regex Pattern Explanation
a1aaa [a-zA-Z][0-9][a-zA-Z]{3} Single alpha, single digit, three alpha characters
a1aaa [a-zA-Z]?[0-9][a-zA-Z]{3} May or may not have preceding alpha character
a1aaa [a-zA-Z][0-9][a-zA-Z]{0,3} Single alpha, single digit, 0 to 3 alpha characters
a1aaa [a-zA-Z][0-9][a-zA-Z]* Single alpha, single digit, followed by any number of alpha characters
</i8> \<\/[a-zA-Z][0-9]\> Exact non-word character except any single alpha followed by any single digit
Here you'll find your answer:
Using Git how do I find changes between local and remote
For the lazy:
- Use "git log origin..HEAD"
- Use "git fetch" followed by "git log HEAD..origin". You can cherry-pick individual commits using the listed commit ids.
The above assumes, of course, that "origin" is the name of your remote tracking branch (which it is if you've used clone with default options).
I know this is old, but I was having trouble too. For Spring 3 using Maven and Eclipse, I needed to put the log4j.xml in src/test/resources for the Unit test to log properly. Placing in in the root of the test did not work for me. Hopefully this helps others.
A Simple Explanation:
Are you serializing data?
Serialization is basically writing class data to a file/stream/etc. De-serialization is reading that data back to a class.
Do you intend to go into production?
If you are just testing something with unimportant/fake data, then don't worry about it (unless you are testing serialization directly).
Is this the first version?
If so, set serialVersionUID=1L
.
Is this the second, third, etc. prod version?
Now you need to worry about serialVersionUID
, and should look into it in depth.
Basically, if you don't update the version correctly when you update a class you need to write/read, you will get an error when you try to read old data.
Try the below code-
mSQLiteDatabase = getWritableDatabase();//To delete , database should be writable.
int rowDeleted = mSQLiteDatabase.delete(TABLE_NAME,id + " =?",
new String[] {String.valueOf(id)});
mSQLiteDatabase.close();//This is very important once database operation is done.
if(rowDeleted != 0){
//delete success.
} else {
//delete failed.
}
insert
methods/* Syntax:
array.insert(index, value1, value2, ..., valueN) */
Array.prototype.insert = function(index) {
this.splice.apply(this, [index, 0].concat(
Array.prototype.slice.call(arguments, 1)));
return this;
};
It can insert multiple elements (as native splice
does) and supports chaining:
["a", "b", "c", "d"].insert(2, "X", "Y", "Z").slice(1, 6);
// ["b", "X", "Y", "Z", "c"]
/* Syntax:
array.insert(index, value1, value2, ..., valueN) */
Array.prototype.insert = function(index) {
index = Math.min(index, this.length);
arguments.length > 1
&& this.splice.apply(this, [index, 0].concat([].pop.call(arguments)))
&& this.insert.apply(this, arguments);
return this;
};
It can merge arrays from the arguments with the given array and also supports chaining:
["a", "b", "c", "d"].insert(2, "V", ["W", "X", "Y"], "Z").join("-");
// "a-b-V-W-X-Y-Z-c-d"
for centos, just zlib didn't solve the problem.I did
sudo yum install zlib-devel.i686
This should help -
var json = "{'@STARTDATE': '2016-02-17 00:00:00.000', '@ENDDATE': '2016-02-18 23:59:00.000' }";
var fdate = JObject.Parse(json)["@STARTDATE"];
Here's a shell script I made for myself:
#! /bin/sh
for device in `adb devices | awk '{print $1}'`; do
if [ ! "$device" = "" ] && [ ! "$device" = "List" ]
then
echo " "
echo "adb -s $device $@"
echo "------------------------------------------------------"
adb -s $device $@
fi
done
I am afraid there isn't any easy solution with regards to font resizing. You can change the font size using a media query, but technically it will not resize smoothly. For an example, if you use:
@media only screen and (max-width: 320px){font-size: 3em;}
your font-size
will be 3em both for a 300 pixels and 200 pixels width. But you need lower font-size
for 200px width to make perfect responsive.
So, what is the real solution? There is only one way. You have to create a PNG image (with a transparent background) containing your text. After that you can easily make your image responsive (for example: width:35%; height:28px). By this way your text will be fully responsive with all devices.
I had a very similar problem and want to share my solution
Given this table (all MySQL 5.6):
create table DailySchedule
(
id int auto_increment primary key,
start_time time not null,
stop_time time not null
);
Select all rows where a given time x (hh:mm:ss)
is between start and stop time. Including the next day.
Note: replace NOW()
with the any time x
you like
SELECT id
FROM DailySchedule
WHERE
(start_time < stop_time AND NOW() BETWEEN start_time AND stop_time)
OR
(stop_time < start_time AND NOW() < start_time AND NOW() < stop_time)
OR
(stop_time < start_time AND NOW() > start_time)
Results
Given
id: 1, start_time: 10:00:00, stop_time: 15:00:00
id: 2, start_time: 22:00:00, stop_time: 12:00:00
NOW = 09:00:00
: 2
NOW = 14:00:00
: 1
NOW = 11:00:00
: 1,2
NOW = 20:00:00
: nothingYou are still in the context of your CategoryController
even though you're loading a PartialView
from your Views/News
folder.
Fix:
I chose the "ISAPI & CGI Restrictions" after clicking the server name (not the site name) in IIS Manager, and right clicked the "ASP.NET v4.0.30319" lines and chose "Allow".
After turning on ASP.NET from "Programs and Features > Turn Windows features on or off", you must install ASP.NET from the Windows command prompt. The MIME types don't ever show up, but after doing this command, I noticed these extensions showed up under the IIS web site "Handler Mappings" section of IIS Manager.
C:\>cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>dir aspnet_reg*
Volume in drive C is Windows
Volume Serial Number is 8EE6-5DD0
Directory of C:\Windows\Microsoft.NET\Framework64\v4.0.30319
03/18/2010 08:23 PM 19,296 aspnet_regbrowsers.exe
03/18/2010 08:23 PM 36,696 aspnet_regiis.exe
03/18/2010 08:23 PM 102,232 aspnet_regsql.exe
3 File(s) 158,224 bytes
0 Dir(s) 34,836,508,672 bytes free
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis.exe -i
Start installing ASP.NET (4.0.30319).
.....
Finished installing ASP.NET (4.0.30319).
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>
However, I still got this error. But if you do what I mentioned for the "Fix", this will go away.
HTTP Error 404.2 - Not Found
The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server.
The current answer can be simplified to...
@Component({
...
template: '<child [myCallback]="theCallback"></child>',
directives: [ChildComponent]
})
export class ParentComponent{
public theCallback(){
...
}
}
@Component({...})
export class ChildComponent{
//This will be bound to the ParentComponent.theCallback
@Input()
public myCallback: Function;
...
}
I solved this with a static class:
@SuppressWarnings("serial")
public class MimeTypes {
private static final HashMap<String, String> mimeTypes;
static {
mimeTypes = new HashMap<String, String>() {
{
put(".323", "text/h323");
put(".3g2", "video/3gpp2");
put(".3gp", "video/3gpp");
put(".3gp2", "video/3gpp2");
put(".3gpp", "video/3gpp");
put(".7z", "application/x-7z-compressed");
put(".aa", "audio/audible");
put(".AAC", "audio/aac");
put(".aaf", "application/octet-stream");
put(".aax", "audio/vnd.audible.aax");
put(".ac3", "audio/ac3");
put(".aca", "application/octet-stream");
put(".accda", "application/msaccess.addin");
put(".accdb", "application/msaccess");
put(".accdc", "application/msaccess.cab");
put(".accde", "application/msaccess");
put(".accdr", "application/msaccess.runtime");
put(".accdt", "application/msaccess");
put(".accdw", "application/msaccess.webapplication");
put(".accft", "application/msaccess.ftemplate");
put(".acx", "application/internet-property-stream");
put(".AddIn", "text/xml");
put(".ade", "application/msaccess");
put(".adobebridge", "application/x-bridge-url");
put(".adp", "application/msaccess");
put(".ADT", "audio/vnd.dlna.adts");
put(".ADTS", "audio/aac");
put(".afm", "application/octet-stream");
put(".ai", "application/postscript");
put(".aif", "audio/x-aiff");
put(".aifc", "audio/aiff");
put(".aiff", "audio/aiff");
put(".air", "application/vnd.adobe.air-application-installer-package+zip");
put(".amc", "application/x-mpeg");
put(".application", "application/x-ms-application");
put(".art", "image/x-jg");
put(".asa", "application/xml");
put(".asax", "application/xml");
put(".ascx", "application/xml");
put(".asd", "application/octet-stream");
put(".asf", "video/x-ms-asf");
put(".ashx", "application/xml");
put(".asi", "application/octet-stream");
put(".asm", "text/plain");
put(".asmx", "application/xml");
put(".aspx", "application/xml");
put(".asr", "video/x-ms-asf");
put(".asx", "video/x-ms-asf");
put(".atom", "application/atom+xml");
put(".au", "audio/basic");
put(".avi", "video/x-msvideo");
put(".axs", "application/olescript");
put(".bas", "text/plain");
put(".bcpio", "application/x-bcpio");
put(".bin", "application/octet-stream");
put(".bmp", "image/bmp");
put(".c", "text/plain");
put(".cab", "application/octet-stream");
put(".caf", "audio/x-caf");
put(".calx", "application/vnd.ms-office.calx");
put(".cat", "application/vnd.ms-pki.seccat");
put(".cc", "text/plain");
put(".cd", "text/plain");
put(".cdda", "audio/aiff");
put(".cdf", "application/x-cdf");
put(".cer", "application/x-x509-ca-cert");
put(".chm", "application/octet-stream");
put(".class", "application/x-java-applet");
put(".clp", "application/x-msclip");
put(".cmx", "image/x-cmx");
put(".cnf", "text/plain");
put(".cod", "image/cis-cod");
put(".config", "application/xml");
put(".contact", "text/x-ms-contact");
put(".coverage", "application/xml");
put(".cpio", "application/x-cpio");
put(".cpp", "text/plain");
put(".crd", "application/x-mscardfile");
put(".crl", "application/pkix-crl");
put(".crt", "application/x-x509-ca-cert");
put(".cs", "text/plain");
put(".csdproj", "text/plain");
put(".csh", "application/x-csh");
put(".csproj", "text/plain");
put(".css", "text/css");
put(".csv", "text/csv");
put(".cur", "application/octet-stream");
put(".cxx", "text/plain");
put(".dat", "application/octet-stream");
put(".datasource", "application/xml");
put(".dbproj", "text/plain");
put(".dcr", "application/x-director");
put(".def", "text/plain");
put(".deploy", "application/octet-stream");
put(".der", "application/x-x509-ca-cert");
put(".dgml", "application/xml");
put(".dib", "image/bmp");
put(".dif", "video/x-dv");
put(".dir", "application/x-director");
put(".disco", "text/xml");
put(".dll", "application/x-msdownload");
put(".dll.config", "text/xml");
put(".dlm", "text/dlm");
put(".doc", "application/msword");
put(".docm", "application/vnd.ms-word.document.macroEnabled.12");
put(".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
put(".dot", "application/msword");
put(".dotm", "application/vnd.ms-word.template.macroEnabled.12");
put(".dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template");
put(".dsp", "application/octet-stream");
put(".dsw", "text/plain");
put(".dtd", "text/xml");
put(".dtsConfig", "text/xml");
put(".dv", "video/x-dv");
put(".dvi", "application/x-dvi");
put(".dwf", "drawing/x-dwf");
put(".dwp", "application/octet-stream");
put(".dxr", "application/x-director");
put(".eml", "message/rfc822");
put(".emz", "application/octet-stream");
put(".eot", "application/octet-stream");
put(".eps", "application/postscript");
put(".etl", "application/etl");
put(".etx", "text/x-setext");
put(".evy", "application/envoy");
put(".exe", "application/octet-stream");
put(".exe.config", "text/xml");
put(".fdf", "application/vnd.fdf");
put(".fif", "application/fractals");
put(".filters", "Application/xml");
put(".fla", "application/octet-stream");
put(".flr", "x-world/x-vrml");
put(".flv", "video/x-flv");
put(".fsscript", "application/fsharp-script");
put(".fsx", "application/fsharp-script");
put(".generictest", "application/xml");
put(".gif", "image/gif");
put(".group", "text/x-ms-group");
put(".gsm", "audio/x-gsm");
put(".gtar", "application/x-gtar");
put(".gz", "application/x-gzip");
put(".h", "text/plain");
put(".hdf", "application/x-hdf");
put(".hdml", "text/x-hdml");
put(".hhc", "application/x-oleobject");
put(".hhk", "application/octet-stream");
put(".hhp", "application/octet-stream");
put(".hlp", "application/winhlp");
put(".hpp", "text/plain");
put(".hqx", "application/mac-binhex40");
put(".hta", "application/hta");
put(".htc", "text/x-component");
put(".htm", "text/html");
put(".html", "text/html");
put(".htt", "text/webviewhtml");
put(".hxa", "application/xml");
put(".hxc", "application/xml");
put(".hxd", "application/octet-stream");
put(".hxe", "application/xml");
put(".hxf", "application/xml");
put(".hxh", "application/octet-stream");
put(".hxi", "application/octet-stream");
put(".hxk", "application/xml");
put(".hxq", "application/octet-stream");
put(".hxr", "application/octet-stream");
put(".hxs", "application/octet-stream");
put(".hxt", "text/html");
put(".hxv", "application/xml");
put(".hxw", "application/octet-stream");
put(".hxx", "text/plain");
put(".i", "text/plain");
put(".ico", "image/x-icon");
put(".ics", "application/octet-stream");
put(".idl", "text/plain");
put(".ief", "image/ief");
put(".iii", "application/x-iphone");
put(".inc", "text/plain");
put(".inf", "application/octet-stream");
put(".inl", "text/plain");
put(".ins", "application/x-internet-signup");
put(".ipa", "application/x-itunes-ipa");
put(".ipg", "application/x-itunes-ipg");
put(".ipproj", "text/plain");
put(".ipsw", "application/x-itunes-ipsw");
put(".iqy", "text/x-ms-iqy");
put(".isp", "application/x-internet-signup");
put(".ite", "application/x-itunes-ite");
put(".itlp", "application/x-itunes-itlp");
put(".itms", "application/x-itunes-itms");
put(".itpc", "application/x-itunes-itpc");
put(".IVF", "video/x-ivf");
put(".jar", "application/java-archive");
put(".java", "application/octet-stream");
put(".jck", "application/liquidmotion");
put(".jcz", "application/liquidmotion");
put(".jfif", "image/pjpeg");
put(".jnlp", "application/x-java-jnlp-file");
put(".jpb", "application/octet-stream");
put(".jpe", "image/jpeg");
put(".jpeg", "image/jpeg");
put(".jpg", "image/jpeg");
put(".js", "application/x-javascript");
put(".json", "application/json");
put(".jsx", "text/jscript");
put(".jsxbin", "text/plain");
put(".latex", "application/x-latex");
put(".library-ms", "application/windows-library+xml");
put(".lit", "application/x-ms-reader");
put(".loadtest", "application/xml");
put(".lpk", "application/octet-stream");
put(".lsf", "video/x-la-asf");
put(".lst", "text/plain");
put(".lsx", "video/x-la-asf");
put(".lzh", "application/octet-stream");
put(".m13", "application/x-msmediaview");
put(".m14", "application/x-msmediaview");
put(".m1v", "video/mpeg");
put(".m2t", "video/vnd.dlna.mpeg-tts");
put(".m2ts", "video/vnd.dlna.mpeg-tts");
put(".m2v", "video/mpeg");
put(".m3u", "audio/x-mpegurl");
put(".m3u8", "audio/x-mpegurl");
put(".m4a", "audio/m4a");
put(".m4b", "audio/m4b");
put(".m4p", "audio/m4p");
put(".m4r", "audio/x-m4r");
put(".m4v", "video/x-m4v");
put(".mac", "image/x-macpaint");
put(".mak", "text/plain");
put(".man", "application/x-troff-man");
put(".manifest", "application/x-ms-manifest");
put(".map", "text/plain");
put(".master", "application/xml");
put(".mda", "application/msaccess");
put(".mdb", "application/x-msaccess");
put(".mde", "application/msaccess");
put(".mdp", "application/octet-stream");
put(".me", "application/x-troff-me");
put(".mfp", "application/x-shockwave-flash");
put(".mht", "message/rfc822");
put(".mhtml", "message/rfc822");
put(".mid", "audio/mid");
put(".midi", "audio/mid");
put(".mix", "application/octet-stream");
put(".mk", "text/plain");
put(".mmf", "application/x-smaf");
put(".mno", "text/xml");
put(".mny", "application/x-msmoney");
put(".mod", "video/mpeg");
put(".mov", "video/quicktime");
put(".movie", "video/x-sgi-movie");
put(".mp2", "video/mpeg");
put(".mp2v", "video/mpeg");
put(".mp3", "audio/mpeg");
put(".mp4", "video/mp4");
put(".mp4v", "video/mp4");
put(".mpa", "video/mpeg");
put(".mpe", "video/mpeg");
put(".mpeg", "video/mpeg");
put(".mpf", "application/vnd.ms-mediapackage");
put(".mpg", "video/mpeg");
put(".mpp", "application/vnd.ms-project");
put(".mpv2", "video/mpeg");
put(".mqv", "video/quicktime");
put(".ms", "application/x-troff-ms");
put(".msi", "application/octet-stream");
put(".mso", "application/octet-stream");
put(".mts", "video/vnd.dlna.mpeg-tts");
put(".mtx", "application/xml");
put(".mvb", "application/x-msmediaview");
put(".mvc", "application/x-miva-compiled");
put(".mxp", "application/x-mmxp");
put(".nc", "application/x-netcdf");
put(".nsc", "video/x-ms-asf");
put(".nws", "message/rfc822");
put(".ocx", "application/octet-stream");
put(".oda", "application/oda");
put(".odc", "text/x-ms-odc");
put(".odh", "text/plain");
put(".odl", "text/plain");
put(".odp", "application/vnd.oasis.opendocument.presentation");
put(".ods", "application/oleobject");
put(".odt", "application/vnd.oasis.opendocument.text");
put(".one", "application/onenote");
put(".onea", "application/onenote");
put(".onepkg", "application/onenote");
put(".onetmp", "application/onenote");
put(".onetoc", "application/onenote");
put(".onetoc2", "application/onenote");
put(".orderedtest", "application/xml");
put(".osdx", "application/opensearchdescription+xml");
put(".p10", "application/pkcs10");
put(".p12", "application/x-pkcs12");
put(".p7b", "application/x-pkcs7-certificates");
put(".p7c", "application/pkcs7-mime");
put(".p7m", "application/pkcs7-mime");
put(".p7r", "application/x-pkcs7-certreqresp");
put(".p7s", "application/pkcs7-signature");
put(".pbm", "image/x-portable-bitmap");
put(".pcast", "application/x-podcast");
put(".pct", "image/pict");
put(".pcx", "application/octet-stream");
put(".pcz", "application/octet-stream");
put(".pdf", "application/pdf");
put(".pfb", "application/octet-stream");
put(".pfm", "application/octet-stream");
put(".pfx", "application/x-pkcs12");
put(".pgm", "image/x-portable-graymap");
put(".pic", "image/pict");
put(".pict", "image/pict");
put(".pkgdef", "text/plain");
put(".pkgundef", "text/plain");
put(".pko", "application/vnd.ms-pki.pko");
put(".pls", "audio/scpls");
put(".pma", "application/x-perfmon");
put(".pmc", "application/x-perfmon");
put(".pml", "application/x-perfmon");
put(".pmr", "application/x-perfmon");
put(".pmw", "application/x-perfmon");
put(".png", "image/png");
put(".pnm", "image/x-portable-anymap");
put(".pnt", "image/x-macpaint");
put(".pntg", "image/x-macpaint");
put(".pnz", "image/png");
put(".pot", "application/vnd.ms-powerpoint");
put(".potm", "application/vnd.ms-powerpoint.template.macroEnabled.12");
put(".potx", "application/vnd.openxmlformats-officedocument.presentationml.template");
put(".ppa", "application/vnd.ms-powerpoint");
put(".ppam", "application/vnd.ms-powerpoint.addin.macroEnabled.12");
put(".ppm", "image/x-portable-pixmap");
put(".pps", "application/vnd.ms-powerpoint");
put(".ppsm", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12");
put(".ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow");
put(".ppt", "application/vnd.ms-powerpoint");
put(".pptm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12");
put(".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation");
put(".prf", "application/pics-rules");
put(".prm", "application/octet-stream");
put(".prx", "application/octet-stream");
put(".ps", "application/postscript");
put(".psc1", "application/PowerShell");
put(".psd", "application/octet-stream");
put(".psess", "application/xml");
put(".psm", "application/octet-stream");
put(".psp", "application/octet-stream");
put(".pub", "application/x-mspublisher");
put(".pwz", "application/vnd.ms-powerpoint");
put(".qht", "text/x-html-insertion");
put(".qhtm", "text/x-html-insertion");
put(".qt", "video/quicktime");
put(".qti", "image/x-quicktime");
put(".qtif", "image/x-quicktime");
put(".qtl", "application/x-quicktimeplayer");
put(".qxd", "application/octet-stream");
put(".ra", "audio/x-pn-realaudio");
put(".ram", "audio/x-pn-realaudio");
put(".rar", "application/octet-stream");
put(".ras", "image/x-cmu-raster");
put(".rat", "application/rat-file");
put(".rc", "text/plain");
put(".rc2", "text/plain");
put(".rct", "text/plain");
put(".rdlc", "application/xml");
put(".resx", "application/xml");
put(".rf", "image/vnd.rn-realflash");
put(".rgb", "image/x-rgb");
put(".rgs", "text/plain");
put(".rm", "application/vnd.rn-realmedia");
put(".rmi", "audio/mid");
put(".rmp", "application/vnd.rn-rn_music_package");
put(".roff", "application/x-troff");
put(".rpm", "audio/x-pn-realaudio-plugin");
put(".rqy", "text/x-ms-rqy");
put(".rtf", "application/rtf");
put(".rtx", "text/richtext");
put(".ruleset", "application/xml");
put(".s", "text/plain");
put(".safariextz", "application/x-safari-safariextz");
put(".scd", "application/x-msschedule");
put(".sct", "text/scriptlet");
put(".sd2", "audio/x-sd2");
put(".sdp", "application/sdp");
put(".sea", "application/octet-stream");
put(".searchConnector-ms", "application/windows-search-connector+xml");
put(".setpay", "application/set-payment-initiation");
put(".setreg", "application/set-registration-initiation");
put(".settings", "application/xml");
put(".sgimb", "application/x-sgimb");
put(".sgml", "text/sgml");
put(".sh", "application/x-sh");
put(".shar", "application/x-shar");
put(".shtml", "text/html");
put(".sit", "application/x-stuffit");
put(".sitemap", "application/xml");
put(".skin", "application/xml");
put(".sldm", "application/vnd.ms-powerpoint.slide.macroEnabled.12");
put(".sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide");
put(".slk", "application/vnd.ms-excel");
put(".sln", "text/plain");
put(".slupkg-ms", "application/x-ms-license");
put(".smd", "audio/x-smd");
put(".smi", "application/octet-stream");
put(".smx", "audio/x-smd");
put(".smz", "audio/x-smd");
put(".snd", "audio/basic");
put(".snippet", "application/xml");
put(".snp", "application/octet-stream");
put(".sol", "text/plain");
put(".sor", "text/plain");
put(".spc", "application/x-pkcs7-certificates");
put(".spl", "application/futuresplash");
put(".src", "application/x-wais-source");
put(".srf", "text/plain");
put(".SSISDeploymentManifest", "text/xml");
put(".ssm", "application/streamingmedia");
put(".sst", "application/vnd.ms-pki.certstore");
put(".stl", "application/vnd.ms-pki.stl");
put(".sv4cpio", "application/x-sv4cpio");
put(".sv4crc", "application/x-sv4crc");
put(".svc", "application/xml");
put(".swf", "application/x-shockwave-flash");
put(".t", "application/x-troff");
put(".tar", "application/x-tar");
put(".tcl", "application/x-tcl");
put(".testrunconfig", "application/xml");
put(".testsettings", "application/xml");
put(".tex", "application/x-tex");
put(".texi", "application/x-texinfo");
put(".texinfo", "application/x-texinfo");
put(".tgz", "application/x-compressed");
put(".thmx", "application/vnd.ms-officetheme");
put(".thn", "application/octet-stream");
put(".tif", "image/tiff");
put(".tiff", "image/tiff");
put(".tlh", "text/plain");
put(".tli", "text/plain");
put(".toc", "application/octet-stream");
put(".tr", "application/x-troff");
put(".trm", "application/x-msterminal");
put(".trx", "application/xml");
put(".ts", "video/vnd.dlna.mpeg-tts");
put(".tsv", "text/tab-separated-values");
put(".ttf", "application/octet-stream");
put(".tts", "video/vnd.dlna.mpeg-tts");
put(".txt", "text/plain");
put(".u32", "application/octet-stream");
put(".uls", "text/iuls");
put(".user", "text/plain");
put(".ustar", "application/x-ustar");
put(".vb", "text/plain");
put(".vbdproj", "text/plain");
put(".vbk", "video/mpeg");
put(".vbproj", "text/plain");
put(".vbs", "text/vbscript");
put(".vcf", "text/x-vcard");
put(".vcproj", "Application/xml");
put(".vcs", "text/plain");
put(".vcxproj", "Application/xml");
put(".vddproj", "text/plain");
put(".vdp", "text/plain");
put(".vdproj", "text/plain");
put(".vdx", "application/vnd.ms-visio.viewer");
put(".vml", "text/xml");
put(".vscontent", "application/xml");
put(".vsct", "text/xml");
put(".vsd", "application/vnd.visio");
put(".vsi", "application/ms-vsi");
put(".vsix", "application/vsix");
put(".vsixlangpack", "text/xml");
put(".vsixmanifest", "text/xml");
put(".vsmdi", "application/xml");
put(".vspscc", "text/plain");
put(".vss", "application/vnd.visio");
put(".vsscc", "text/plain");
put(".vssettings", "text/xml");
put(".vssscc", "text/plain");
put(".vst", "application/vnd.visio");
put(".vstemplate", "text/xml");
put(".vsto", "application/x-ms-vsto");
put(".vsw", "application/vnd.visio");
put(".vsx", "application/vnd.visio");
put(".vtx", "application/vnd.visio");
put(".wav", "audio/wav");
put(".wave", "audio/wav");
put(".wax", "audio/x-ms-wax");
put(".wbk", "application/msword");
put(".wbmp", "image/vnd.wap.wbmp");
put(".wcm", "application/vnd.ms-works");
put(".wdb", "application/vnd.ms-works");
put(".wdp", "image/vnd.ms-photo");
put(".webarchive", "application/x-safari-webarchive");
put(".webtest", "application/xml");
put(".wiq", "application/xml");
put(".wiz", "application/msword");
put(".wks", "application/vnd.ms-works");
put(".WLMP", "application/wlmoviemaker");
put(".wlpginstall", "application/x-wlpg-detect");
put(".wlpginstall3", "application/x-wlpg3-detect");
put(".wm", "video/x-ms-wm");
put(".wma", "audio/x-ms-wma");
put(".wmd", "application/x-ms-wmd");
put(".wmf", "application/x-msmetafile");
put(".wml", "text/vnd.wap.wml");
put(".wmlc", "application/vnd.wap.wmlc");
put(".wmls", "text/vnd.wap.wmlscript");
put(".wmlsc", "application/vnd.wap.wmlscriptc");
put(".wmp", "video/x-ms-wmp");
put(".wmv", "video/x-ms-wmv");
put(".wmx", "video/x-ms-wmx");
put(".wmz", "application/x-ms-wmz");
put(".wpl", "application/vnd.ms-wpl");
put(".wps", "application/vnd.ms-works");
put(".wri", "application/x-mswrite");
put(".wrl", "x-world/x-vrml");
put(".wrz", "x-world/x-vrml");
put(".wsc", "text/scriptlet");
put(".wsdl", "text/xml");
put(".wvx", "video/x-ms-wvx");
put(".x", "application/directx");
put(".xaf", "x-world/x-vrml");
put(".xaml", "application/xaml+xml");
put(".xap", "application/x-silverlight-app");
put(".xbap", "application/x-ms-xbap");
put(".xbm", "image/x-xbitmap");
put(".xdr", "text/plain");
put(".xht", "application/xhtml+xml");
put(".xhtml", "application/xhtml+xml");
put(".xla", "application/vnd.ms-excel");
put(".xlam", "application/vnd.ms-excel.addin.macroEnabled.12");
put(".xlc", "application/vnd.ms-excel");
put(".xld", "application/vnd.ms-excel");
put(".xlk", "application/vnd.ms-excel");
put(".xll", "application/vnd.ms-excel");
put(".xlm", "application/vnd.ms-excel");
put(".xls", "application/vnd.ms-excel");
put(".xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12");
put(".xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12");
put(".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
put(".xlt", "application/vnd.ms-excel");
put(".xltm", "application/vnd.ms-excel.template.macroEnabled.12");
put(".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template");
put(".xlw", "application/vnd.ms-excel");
put(".xml", "text/xml");
put(".xmta", "application/xml");
put(".xof", "x-world/x-vrml");
put(".XOML", "text/plain");
put(".xpm", "image/x-xpixmap");
put(".xps", "application/vnd.ms-xpsdocument");
put(".xrm-ms", "text/xml");
put(".xsc", "application/xml");
put(".xsd", "text/xml");
put(".xsf", "text/xml");
put(".xsl", "text/xml");
put(".xslt", "text/xml");
put(".xsn", "application/octet-stream");
put(".xss", "application/xml");
put(".xtp", "application/octet-stream");
put(".xwd", "image/x-xwindowdump");
put(".z", "application/x-compress");
put(".zip", "application/x-zip-compressed");
}
};
}
public static String getMimeType(String extension) {
if (extension == null) {
return null;
}
if (!extension.startsWith(".")) {
extension = "." + extension.toLowerCase(Locale.getDefault());
}
String mime = mimeTypes.get(extension);
return mime != null ? mime : "application/octet-stream";
}
}
Add a DoEvents function inside the loop, see below.
You may also want to ensure that the Status bar is visible to the user and reset it when your code completes.
Sub ProgressMeter()
Dim booStatusBarState As Boolean
Dim iMax As Integer
Dim i As Integer
iMax = 10000
Application.ScreenUpdating = False
''//Turn off screen updating
booStatusBarState = Application.DisplayStatusBar
''//Get the statusbar display setting
Application.DisplayStatusBar = True
''//Make sure that the statusbar is visible
For i = 1 To iMax ''// imax is usually 30 or so
fractionDone = CDbl(i) / CDbl(iMax)
Application.StatusBar = Format(fractionDone, "0%") & " done..."
''// or, alternatively:
''// statusRange.value = Format(fractionDone, "0%") & " done..."
''// Some code.......
DoEvents
''//Yield Control
Next i
Application.DisplayStatusBar = booStatusBarState
''//Reset Status bar display setting
Application.StatusBar = False
''//Return control of the Status bar to Excel
Application.ScreenUpdating = True
''//Turn on screen updating
End Sub
The problem was that the ID column wasn't getting any value. I saw on @Martin Smith SQL Fiddle that he declared the ID column with DEFAULT newid
and I didn't..
I improved with one check iteration the good code of Hors Sujet to avoid including folders in the result array:
function getDirContents($dir, &$results = array()){ $files = scandir($dir); foreach($files as $key => $value){ $path = realpath($dir.DIRECTORY_SEPARATOR.$value); if(is_dir($path) == false) { $results[] = $path; } else if($value != "." && $value != "..") { getDirContents($path, $results); if(is_dir($path) == false) { $results[] = $path; } } } return $results; }
1 - Your malloc() is wrong.
2 - You are overstepping the bounds of the allocated memory
3 - You should initialize your allocated memory
Here is the program with all the changes needed. I compiled and ran... no errors or warnings.
#include <stdio.h>
#include <stdlib.h> //malloc
#include <math.h> //sine
#include <string.h>
#define TIME 255
#define HARM 32
int main (void) {
double sineRads;
double sine;
int tcount = 0;
int hcount = 0;
/* allocate some heap memory for the large array of waveform data */
double *ptr = malloc(sizeof(double) * TIME);
//memset( ptr, 0x00, sizeof(double) * TIME); may not always set double to 0
for( tcount = 0; tcount < TIME; tcount++ )
{
ptr[tcount] = 0;
}
tcount = 0;
if (NULL == ptr) {
printf("ERROR: couldn't allocate waveform memory!\n");
} else {
/*evaluate and add harmonic amplitudes for each time step */
for(tcount = 0; tcount < TIME; tcount++){
for(hcount = 0; hcount <= HARM; hcount++){
sineRads = ((double)tcount / (double)TIME) * (2*M_PI); //angular frequency
sineRads *= (hcount + 1); //scale frequency by harmonic number
sine = sin(sineRads);
ptr[tcount] += sine; //add to other results for this time step
}
}
free(ptr);
ptr = NULL;
}
return 0;
}
edit your .env and add this line after mail config lines
MAIL_ENCRYPTION=""
Save and try to send email
I have done EXACTLY what you want to do and it works great. Unit tests "*Tests" always run, and "*IntegrationTests" only run when you do a mvn verify or mvn install. Here it the snippet from my POM. serg10 almost had it right....but not quite.
<plugin>
<!-- Separates the unit tests from the integration tests. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Skip the default running of this plug-in (or everything is run twice...see below) -->
<skip>true</skip>
<!-- Show 100% of the lines from the stack trace (doesn't work) -->
<trimStackTrace>false</trimStackTrace>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<!-- Never skip running the tests when the test phase is invoked -->
<skip>false</skip>
<includes>
<!-- Include unit tests within integration-test phase. -->
<include>**/*Tests.java</include>
</includes>
<excludes>
<!-- Exclude integration tests within (unit) test phase. -->
<exclude>**/*IntegrationTests.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<!-- Never skip running the tests when the integration-test phase is invoked -->
<skip>false</skip>
<includes>
<!-- Include integration tests within integration-test phase. -->
<include>**/*IntegrationTests.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
Good luck!
You can use date
filter:
{{ game.gameDate|date("m/d/Y") }}
In my case, this line solved the problem:
"translate_tabs_to_spaces": false
First I executed:
sudo chown -R $(whoami):admin /usr/local
Then:
cd $(brew --prefix) && git fetch origin && git reset --hard origin/master
Let me just put this here for my own reference. I know that it is not good Python code, but I needed a script for a project I was working on and I wanted to put the script in a scripts
directory.
import os.path
import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
In Access, you will probably find a Join is quicker unless your tables are very small:
SELECT DISTINCT Table1.Column1
FROM Table1
LEFT JOIN Table2
ON Table1.Column1 = Table2.Column1
WHERE Table2.Column1 Is Null
This will exclude from the list all records with a match in Table2.
tmp = df.groupby(['A'])['c'].transform('mean')
is like
tmp1 = df.groupby(['A']).agg({'c':'mean'})
tmp = df['A'].map(tmp1['c'])
or
tmp1 = df.groupby(['A'])['c'].mean()
tmp = df['A'].map(tmp1)
official Link of DB 2 JDBC Driver from IBM
Swift 5
In my case I needed access to the UILabel that was clicked, so you could do this inside the gesture recognizer.
let label:UILabel = gesture.view as! UILabel
The gesture.view property contains the view of what was clicked, you can simply downcast it to what you know it is.
@IBAction func tapLabel(gesture: UITapGestureRecognizer) {
let label:UILabel = gesture.view as! UILabel
guard let text = label.attributedText?.string else {
return
}
print(text)
}
So you could do something like above for the tapLabel function and in viewDidLoad put...
<Label>.addGestureRecognizer(UITapGestureRecognizer(target:self, action: #selector(tapLabel(gesture:))))
Just replace <Label>
with your actual label name
/* START --- scroll till anchor */
(function($) {
$.fn.goTo = function() {
var top_menu_height=$('#div_menu_header').height() + 5 ;
//alert ( 'top_menu_height is:' + top_menu_height );
$('html, body').animate({
scrollTop: (-1)*top_menu_height + $(this).offset().top + 'px'
}, 500);
return this; // for chaining...
}
})(jQuery);
$(document).ready(function(){
var url = document.URL, idx = url.indexOf("#") ;
var hash = idx != -1 ? url.substring(idx+1) : "";
$(window).load(function(){
// Remove the # from the hash, as different browsers may or may not include it
var anchor_to_scroll_to = location.hash.replace('#','');
if ( anchor_to_scroll_to != '' ) {
anchor_to_scroll_to = '#' + anchor_to_scroll_to ;
$(anchor_to_scroll_to).goTo();
}
});
});
/* STOP --- scroll till anchror */
It may help to think of an image as a "snapshot" of a container.
You can make images from a container (new "snapshots"), and you can also start new containers from an image (instantiate the "snapshot"). For example, you can instantiate a new container from a base image, run some commands in the container, and then "snapshot" that as a new image. Then you can instantiate 100 containers from that new image.
Other things to consider:
docker images
.Use it by this Method:
str.encode().decode()
I am using Oracle SQL Developer,
In this tool, I had to enable DBMS output to view the results printed by dbms_output.put_line
You can find this option in the result pane where other query results are displayed. so, in the result pane, I have 7 tabs. 1st tab named as Results, next one is Script Output and so on. Out of this you can find a tab named as "DBMS Output" select this tab, then the 1st icon (looks like a dialogue icon) is Enable DBMS Output. Click this icon. Then you execute the PL/SQL, then select "DBMS Output tab, you should be able to see the results there.
Split on your separator at most once, and take the first piece:
sep = '...'
stripped = text.split(sep, 1)[0]
You didn't say what should happen if the separator isn't present. Both this and Alex's solution will return the entire string in that case.
CPMSifDlg::EncodeAndSend()
method is declared as non-static
and thus it must be called using an object of CPMSifDlg
. e.g.
CPMSifDlg obj;
return obj.EncodeAndSend(firstName, lastName, roomNumber, userId, userFirstName, userLastName);
If EncodeAndSend
doesn't use/relate any specifics of an object (i.e. this
) but general for the class CPMSifDlg
then declare it as static
:
class CPMSifDlg {
...
static int EncodeAndSend(...);
^^^^^^
};
-Xmx
sets the Maximum Heap size
Just add quotes around the size in your code. Using this you can use percentage in width, height
input: {
width: '80%'
}
It depends on how the class is constructed
Answering this question comes understanding a huge switch case statement in the C++ language standard, and one which is hard for mere mortals to get intuition about.
As a simple example of how difficult thing are:
main.cpp
#include <cassert>
int main() {
struct C { int i; };
// This syntax is called "default initialization"
C a;
// i undefined
// This syntax is called "value initialization"
C b{};
assert(b.i == 0);
}
In default initialization you would start from: https://en.cppreference.com/w/cpp/language/default_initialization we go to the part "The effects of default initialization are" and start the case statement:
Then, if someone decides to value initialize we go to https://en.cppreference.com/w/cpp/language/value_initialization "The effects of value initialization are" and start the case statement:
= delete
)This is why I strongly recommend that you just never rely on "implicit" zero initialization. Unless there are strong performance reasons, explicitly initialize everything, either on the constructor if you defined one, or using aggregate initialization. Otherwise you make things very very risky for future developers.
Since I can not comment because of not having enough reward points I have to answer to correct answer given by @Burhan Khalid.
In very layman language Enter key press is combination of carriage return and line feed.
Carriage return points the cursor to the beginning of the line horizontly and Line feed shifts the cursor to the next line vertically.Combination of both gives you new line(\n) effect.
Reference - https://en.wikipedia.org/wiki/Carriage_return#Computers
For Angular 9/8
Source Link with Examples
export class AppComponent {
isDone = true;
}
1) *ngIf
<div *ngIf="isDone">
It's Done!
</div>
<!-- Negation operator-->
<div *ngIf="!isDone">
It's Not Done!
</div>
2) *ngIf and Else
<ng-container *ngIf="isDone; else elseNotDone">
It's Done!
</ng-container>
<ng-template #elseNotDone>
It's Not Done!
</ng-template>
3) *ngIf, Then and Else
<ng-container *ngIf="isDone; then iAmDone; else iAmNotDone">
</ng-container>
<ng-template #iAmDone>
It's Done!
</ng-template>
<ng-template #iAmNotDone>
It's Not Done!
</ng-template>
Use bind
function instead.
Make it more friendly.
Example:
var clickHandler = "click";
if('ontouchstart' in document.documentElement){
clickHandler = "touchstart";
}
$(".button").bind(clickHandler,function(){
alert('Visible on touch and non-touch enabled devices');
});
Custom algorithm:
public static int toInt(String value) {
int output = 0;
boolean isFirstCharacter = true;
boolean isNegativeNumber = false;
byte bytes[] = value.getBytes();
for (int i = 0; i < bytes.length; i++) {
char c = (char) bytes[i];
if (!Character.isDigit(c)) {
isNegativeNumber = (c == '-');
if (!(isFirstCharacter && (isNegativeNumber || c == '+'))) {
throw new NumberFormatException("For input string \"" + value + "\"");
}
} else {
int number = Character.getNumericValue(c);
output = output * 10 + number;
}
isFirstCharacter = false;
}
if (isNegativeNumber)
output *= -1;
return output;
}
Another solution:
(Use the string charAt method instead of convert string to byte array)
public static int toInt(String value) {
int output = 0;
boolean isFirstCharacter = true;
boolean isNegativeNumber = false;
for (int i = 0; i < value.length(); i++) {
char c = value.charAt(i);
if (!Character.isDigit(c)) {
isNegativeNumber = (c == '-');
if (!(isFirstCharacter && (isNegativeNumber || c == '+'))) {
throw new NumberFormatException("For input string \"" + value + "\"");
}
} else {
int number = Character.getNumericValue(c);
output = output * 10 + number;
}
isFirstCharacter = false;
}
if (isNegativeNumber)
output *= -1;
return output;
}
Examples:
int number1 = toInt("20");
int number2 = toInt("-20");
int number3 = toInt("+20");
System.out.println("Numbers = " + number1 + ", " + number2 + ", " + number3);
try {
toInt("20 Hadi");
} catch (NumberFormatException e) {
System.out.println("Error: " + e.getMessage());
}
I think you don't have your permissions set up correctly for /var/www Change the ownership of the folder.
sudo chown -R **yourusername** /var/www
You can use
document.querySelector('your-element').scrollIntoView({behavior: 'smooth'});
If you want to scroll top the top of the page, you can just place an empty element in the top, and smooth scroll to that one.
This is how I would do it, you don't need get-content:
ls -r | Select-String dummy | select line,path
or
ls -r | Select-String dummy | fl *
To see what the different properties are...
This is faster. The second argument is -filter:
ls -r . *.bat | select-string netsh
ls -r . -filter *.bat | select-string netsh
I had to INSERT more than 14000 rows into a table and found that line for line with Mysqli prepared statements took more than ten minutes, while argument unpacking with string parameters for the same Mysqli prepared statements did it in less than 10 seconds. My data was very repetitive as it was multiples of id's and one constant integer.
10 minutes code:
$num = 1000;
$ent = 4;
$value = ['id' => 1,
'id' => 2,
'id' => 3,
'id' => 4,
'id' => 5,
'id' => 6,
'id' => 7,
'id' => 8,
'id' => 9,
'id' => 10,
'id' => 11,
'id' => 12,
'id' => 13,
'id' => 14];
$cnt = 0;
$query = "INSERT INTO table (col1, col2) VALUES (?,?)";
$stmt = $this->db->prepare($query);
$stmt->bind_param('ii', $arg_one,$arg_two);
foreach ($value as $k => $val) {
for ($i=0; $i < $num; $i++) {
$arg_one = $k;
$arg_two = $ent;
if($stmt->execute()) {
$cnt++;
}
}
}
10 second code:
$ent = 4;
$num = 1000;
$value = ['id' => 1,
'id' => 2,
'id' => 3,
'id' => 4,
'id' => 5,
'id' => 6,
'id' => 7,
'id' => 8,
'id' => 9,
'id' => 10,
'id' => 11,
'id' => 12,
'id' => 13,
'id' => 14];
$newdat = [];
foreach ($value as $k => $val) {
for ($i=0; $i < $num; $i++) {
$newdat[] = $val;
$newdat[] = $ent;
}
}
// create string of data types
$cnt = count($newdat);
$param = str_repeat('i',$cnt);
// create string of question marks
$rec = (count($newdat) == 0) ? 0 : $cnt / 2 - 1;
$id_q = str_repeat('(?,?),', $rec) . '(?,?)';
// insert
$query = "INSERT INTO table (col1, col2) VALUES $id_q";
$stmt = $db->prepare($query);
$stmt->bind_param($param, ...$newdat);
$stmt->execute();
There isn't a built-in "PowerShell" way of running a SQL query. If you have the SQL Server tools installed, you'll get an Invoke-SqlCmd cmdlet.
Because PowerShell is built on .NET, you can use the ADO.NET API to run your queries.
A CodeIgniter helper is a PHP file with multiple functions. It is not a class
Create a file and put the following code into it.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('test_method'))
{
function test_method($var = '')
{
return $var;
}
}
Save this to application/helpers/ . We shall call it "new_helper.php"
The first line exists to make sure the file cannot be included and ran from outside the CodeIgniter scope. Everything after this is self explanatory.
This can be in your controller, model or view (not preferable)
$this->load->helper('new_helper');
echo test_method('Hello World');
If you use this helper in a lot of locations you can have it load automatically by adding it to the autoload configuration file i.e. <your-web-app>\application\config\autoload.php
.
$autoload['helper'] = array('new_helper');
-Mathew
there is a function called isNaN
it return true if it's (Not-a-number) , so u can check for a number this way
if(!isNaN(miscCharge))
{
//do some thing if it's a number
}else{
//do some thing if it's NOT a number
}
hope it works
The Bootstrap version will be stated at the top of the CSS file. Simply open it and look at the top of the file.
e.g.
/*!
* Bootstrap v2.3.0
*
* Copyright 2012 Twitter, Inc
* Licensed under the Apache License v2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Designed and built with all the love in the world @twitter by @mdo and @fat.
*/
You need to use the event.target
which is the element which originally triggered the event. The this
in your example code refers to document
.
In jQuery, that's...
$(document).click(function(event) {
var text = $(event.target).text();
});
Without jQuery...
document.addEventListener('click', function(e) {
e = e || window.event;
var target = e.target || e.srcElement,
text = target.textContent || target.innerText;
}, false);
Also, ensure if you need to support < IE9 that you use attachEvent()
instead of addEventListener()
.
To allow receiving & sending cookies by a CORS request successfully, do the following.
Back-end (server):
Set the HTTP header Access-Control-Allow-Credentials
value to true
.
Also, make sure the HTTP headers Access-Control-Allow-Origin
and Access-Control-Allow-Headers
are set and not with a wildcard *
.
Recommended Cookie settings per Chrome and Firefox update in 2021: SameSite=None
and Secure
. See MDN documentation
For more info on setting CORS in express js read the docs here
Front-end (client): Set the XMLHttpRequest.withCredentials
flag to true
, this can be achieved in different ways depending on the request-response library used:
jQuery 1.5.1 xhrFields: {withCredentials: true}
ES6 fetch() credentials: 'include'
axios: withCredentials: true
Avoid having to use CORS in combination with cookies. You can achieve this with a proxy.
If you for whatever reason don't avoid it. The solution is above.
It turned out that Chrome won't set the cookie if the domain contains a port. Setting it for localhost
(without port) is not a problem. Many thanks to Erwin for this tip!
In command line it's better to use REG tool rather than REGEDIT:
REG IMPORT yourfile.reg
REG is designed for console mode, while REGEDIT is for graphical mode. This is why running regedit.exe /S yourfile.reg is a bad idea, since you will not be notified if the there's an error, whereas REG Tool will prompt:
> REG IMPORT missing_file.reg
ERROR: Error opening the file. There may be a disk or file system error.
> %windir%\System32\reg.exe /?
REG Operation [Parameter List]
Operation [ QUERY | ADD | DELETE | COPY |
SAVE | LOAD | UNLOAD | RESTORE |
COMPARE | EXPORT | IMPORT | FLAGS ]
Return Code: (Except for REG COMPARE)
0 - Successful
1 - Failed
For help on a specific operation type:
REG Operation /?
Examples:
REG QUERY /?
REG ADD /?
REG DELETE /?
REG COPY /?
REG SAVE /?
REG RESTORE /?
REG LOAD /?
REG UNLOAD /?
REG COMPARE /?
REG EXPORT /?
REG IMPORT /?
REG FLAGS /?
Your error on the snippet of data you posted is a little cryptic, in that because there are no common values, the join operation fails because the values don't overlap it requires you to supply a suffix for the left and right hand side:
In [173]:
df_a.join(df_b, on='mukey', how='left', lsuffix='_left', rsuffix='_right')
Out[173]:
mukey_left DI PI mukey_right niccdcd
index
0 100000 35 14 NaN NaN
1 1000005 44 14 NaN NaN
2 1000006 44 14 NaN NaN
3 1000007 43 13 NaN NaN
4 1000008 43 13 NaN NaN
merge
works because it doesn't have this restriction:
In [176]:
df_a.merge(df_b, on='mukey', how='left')
Out[176]:
mukey DI PI niccdcd
0 100000 35 14 NaN
1 1000005 44 14 NaN
2 1000006 44 14 NaN
3 1000007 43 13 NaN
4 1000008 43 13 NaN
Adding this for completeness. If you (like me) use a script in your package.json
file, just add the --timeout
option to mocha:
"scripts": {
"test": "mocha 'test/**/*.js' --timeout 10000",
"test-debug": "mocha --debug 'test/**/*.js' --timeout 10000"
},
Then you can run npm run test
to run your test suite with the timeout set to 10,000 milliseconds.
Yes, you can use the File API for this.
Here's a complete example (see comments):
document.getElementById("btnLoad").addEventListener("click", function showFileSize() {
// (Can't use `typeof FileReader === "function"` because apparently it
// comes back as "object" on some browsers. So just see if it's there
// at all.)
if (!window.FileReader) { // This is VERY unlikely, browser support is near-universal
console.log("The file API isn't supported on this browser yet.");
return;
}
var input = document.getElementById('fileinput');
if (!input.files) { // This is VERY unlikely, browser support is near-universal
console.error("This browser doesn't seem to support the `files` property of file inputs.");
} else if (!input.files[0]) {
addPara("Please select a file before clicking 'Load'");
} else {
var file = input.files[0];
addPara("File " + file.name + " is " + file.size + " bytes in size");
}
});
function addPara(text) {
var p = document.createElement("p");
p.textContent = text;
document.body.appendChild(p);
}
_x000D_
body {
font-family: sans-serif;
}
_x000D_
<form action='#' onsubmit="return false;">
<input type='file' id='fileinput'>
<input type='button' id='btnLoad' value='Load'>
</form>
_x000D_
Slightly off-topic, but: Note that client-side validation is no substitute for server-side validation. Client-side validation is purely to make it possible to provide a nicer user experience. For instance, if you don't allow uploading a file more than 5MB, you could use client-side validation to check that the file the user has chosen isn't more than 5MB in size and give them a nice friendly message if it is (so they don't spend all that time uploading only to get the result thrown away at the server), but you must also enforce that limit at the server, as all client-side limits (and other validations) can be circumvented.
I believe it is because cell.getCellStyle
initially returns the default cell style which you then change.
Create styles like this and apply them to cells:
cellStyle = (XSSFCellStyle) cell.getSheet().getWorkbook().createCellStyle();
Although as the previous poster noted try and create styles and reuse them.
There is also some utility class in the XSSF library that will avoid the code I have provided and automatically try and reuse styles. Can't remember the class 0ff hand.
It will convert Enum Constant
into Camel Case. It would be helpful for anyone who is looking for such funtionality.
public enum TRANSLATE_LANGUAGES {
ARABIC("ar"), BULGARIAN("bg"), CATALAN("ca"), CHINESE_SIMPLIFIED("zh-CN"), CHINESE_TRADITIONAL("zh-TW"), CZECH("cs"), DANISH("da"), DUTCH("nl"), ENGLISH("en"), ESTONIAN("et"), FINNISH("fi"), FRENCH(
"fr"), GERMAN("de"), GREEK("el"), HAITIAN_CREOLE("ht"), HEBREW("he"), HINDI("hi"), HMONG_DAW("mww"), HUNGARIAN("hu"), INDONESIAN("id"), ITALIAN("it"), JAPANESE("ja"), KOREAN("ko"), LATVIAN(
"lv"), LITHUANIAN("lt"), MALAY("ms"), NORWEGIAN("no"), PERSIAN("fa"), POLISH("pl"), PORTUGUESE("pt"), ROMANIAN("ro"), RUSSIAN("ru"), SLOVAK("sk"), SLOVENIAN("sl"), SPANISH("es"), SWEDISH(
"sv"), THAI("th"), TURKISH("tr"), UKRAINIAN("uk"), URDU("ur"), VIETNAMESE("vi");
private String code;
TRANSLATE_LANGUAGES(String language) {
this.code = language;
}
public String langCode() {
return this.code;
}
public String toCamelCase(TRANSLATE_LANGUAGES lang) {
String toString = lang.toString();
if (toString.contains("_")) {
String st = toUpperLowerCase(toString.split("_"));
}
return "";
}
private String toUpperLowerCase(String[] tempString) {
StringBuilder builder = new StringBuilder();
for (String temp : tempString) {
String char1 = temp.substring(0, 1);
String restString = temp.substring(1, temp.length()).toLowerCase();
builder.append(char1).append(restString).append(" ");
}
return builder.toString();
}
}
Since Java 7 this is very easy and intuitive to do.
List<String> fileContent = new ArrayList<>(Files.readAllLines(FILE_PATH, StandardCharsets.UTF_8));
for (int i = 0; i < fileContent.size(); i++) {
if (fileContent.get(i).equals("old line")) {
fileContent.set(i, "new line");
break;
}
}
Files.write(FILE_PATH, fileContent, StandardCharsets.UTF_8);
Basically you read the whole file to a List
, edit the list and finally write the list back to file.
FILE_PATH
represents the Path
of the file.
Object does not have forEach
, it belongs to Array
prototype. If you want to iterate through each key-value pair in the object and take the values. You can do this:
Object.keys(a).forEach(function (key){
console.log(a[key]);
});
Usage note: For an object v = {"cat":"large", "dog": "small", "bird": "tiny"};
, Object.keys(v)
gives you an array of the keys so you get ["cat","dog","bird"]
Well, It's a bit late for this but I've just started learning Qt and maybe this could help somebody out there:
If you're using Qt Creator then when you've started creating the project you were asked to choose a kit to be used with your project, Let's say you chose Desktop Qt <version-here> MinGW 64-bit
. For Qt 5, If you opened the Qt folder of your installation, you'll find a folder with the version of Qt installed as its name inside it, here you can find the kits you can choose from.
You can go to /PATH/FOR/Qt/mingw<version>_64/include
and here you'll find all the includes you can use in your program, just search for QApplication
and you'll find it inside the folder QtWidgets
, So you can use #include <QtWidgets/QApplication>
since the path starts from the include
folder.
The same goes for other headers if you're stuck with any and for other kits.
Note: "all the includes you can use" doesn't mean these are the only ones you can use, If you include iostream
for example then the compiler will include it from /PATH/FOR/Qt/Tools/mingw<version>_64/lib/gcc/x86_64-w64-mingw32/7.3.0/include/c++/iostream
If you have a table with this exact record layout, use its name as a type, otherwise you will have to declare the type explicitly:
CREATE OR REPLACE FUNCTION get_object_fields
(
name text
)
RETURNS mytable
AS
$$
DECLARE f1 INT;
DECLARE f2 INT;
…
DECLARE f8 INT;
DECLARE retval mytable;
BEGIN
-- fetch fields f1, f2 and f3 from table t1
-- fetch fields f4, f5 from table t2
-- fetch fields f6, f7 and f8 from table t3
retval := (f1, f2, …, f8);
RETURN retval;
END
$$ language plpgsql;
You can try this:
use database
go
declare @temp as int
select @temp = count(1) from sys.schemas where name = 'newSchema'
if @temp = 0
begin
exec ('create SCHEMA temporal')
print 'The schema newSchema was created in database'
end
else
print 'The schema newSchema already exists in database'
go
So i just found a solution for that: In the hover animation do this:
animation: hover 1s infinite alternate ease-in-out,splash 1;
You can use it as follows,
<td>
<input type="submit" name="save" class="noborder" id="save" value="Save" alt="Save"
tabindex="4" />
</td>
<td>
<input type="submit" name="publish" class="noborder" id="publish" value="Publish"
alt="Publish" tabindex="5" />
</td>
And in PHP,
<?php
if($_POST['save'])
{
//Save Code
}
else if($_POST['publish'])
{
//Publish Code
}
?>
rand.nextInt((max+1) - min) + min;
This is working fine.
Use the binascii
module:
>>> import binascii
>>> binascii.hexlify('foo'.encode('utf8'))
b'666f6f'
>>> binascii.unhexlify(_).decode('utf8')
'foo'
See this answer: Python 3.1.1 string to hex
marker = new google.maps.Marker({
map:map,
// draggable:true,
// animation: google.maps.Animation.DROP,
position: new google.maps.LatLng(59.32522, 18.07002),
icon: 'http://cdn.com/my-custom-icon.png' // null = default icon
});
You have to do this with 2 passes:
str.ljust()
and str.rjust()
Install from marketplace
It's the behavior of marketplace whether to keep the apk after installation. Google play doesn't keep the apk after the installation. Other third-party marketplaces might have the different behaviors.
Install from development/debug tool (adb, eclipse, android studio)
When we install the apk from debug tool, directly invoke adb install
or from eclipse/android studio, the apk will be transferred (adb push
) to a public read and writable directory, usually /data/local/tmp/
. After that, the tool will use the pm
command to install, it will delete the temporary apk in /data/local/tmp/
after the successful installation.
We could get these information from debug output like following.
$ adb install bin/TestApplication.apk
3155 KB/s (843375 bytes in 0.260s)
pkg: /data/local/tmp/TestApplication.apk
Success
How system keeps the apk
Of course the system have to store all apks somewhere. There are three places for the system to keep the apks based on the different types of apks:
for stock app
Those are usually shipped in device by manufacture, including core app for system running and google service, you can find them under directory /system/app
and /system/priv-app
.
user installed app
Most of the apks fall into this category. These apks are usually installed from marketplace by users or by adb install
without -s
option. You can find them under the directory /data/app
for a rooted device.
app on sdcard
If the apk enable its install location in sdcard with android:installLocation="auto"
in its manifest, the app can be moved to sdcard from system's app manager menu. These apks are usually located in secure folder of sdcard /mnt/sdcard/asec
.
Anther way to force the install location to sdcard is using the command adb install -s apk-to-install.apk
.
As a note, the files for pre-installed app are not in a single .apk
file anymore. There is a folder containing files for every pre-installed app in the directory /system/app
or /system/priv-app
for the newest android release.
For some 'Eclipse Marketplace' plugins Uninstall may not work. (Ex: SonarLint v5)
So Try,
Help -> About Eclipse -> Installation details
search the plugin name in 'Installed Software'
Select plugin name and Uninstall it
Additional Detail
To fix plugin errors, after the uninstall revert back older version of plugin,
Help -> install new software..
Get plugin url from Google search and Add it (Example: https://eclipse-uc.sonarlint.org)
Select and install older versions of the Plugin. This will fix most of the plugin problems.
If you're using the OSÂ X Terminal app (as stated by the OP), a better approach (thanks to Chris Page's answer to How do I reset the scrollback in the terminal via a shell command?) is just this:
clear && printf '\e[3J'
or more concisely (hat tip to user qiuyi):
printf '\33c\e[3J'
which clears the scrollback buffer as well as the screen. There are other options as well. See Chris Page's answer to How do I reset the scrollback in the terminal via a shell command? for more information.
The AppleScript answer given in this thread works, but it has the nasty side effect of clearing any terminal window that happens to be active. This is surprising if you're running the script in one window and trying to get work done in another!
You avoid this by refining the AppleScript to only clear the screen if it is frontmost by doing this (taken from MattiSG's answer to How do I reset the scrollback in the terminal via a shell command?):
osascript -e 'if application "Terminal" is frontmost then tell application "System Events" to keystroke "k" using command down'
... but as when it's not the current window, the output will stack up until it becomes current again, which probably isn't what you want.
Try the code below. It works for me.
for (int iTaksa = 1; iTaksa <=8; iTaksa++) { // 'Count 8 Loop is 8 Taksa
strTaksaStringStar[iCountTaksa] = strTaksaStringCount[iTaksa];
LabelEndTaksa_Exit : {
if (iCountTaksa == 1) { //If count is 6 then next it's 2
iCountTaksa = 2;
break LabelEndTaksa_Exit;
}
if (iCountTaksa == 2) { //If count is 2 then next it's 3
iCountTaksa = 3;
break LabelEndTaksa_Exit;
}
if (iCountTaksa == 3) { //If count is 3 then next it's 4
iCountTaksa = 4;
break LabelEndTaksa_Exit;
}
if (iCountTaksa == 4) { //If count is 4 then next it's 7
iCountTaksa = 7;
break LabelEndTaksa_Exit;
}
if (iCountTaksa == 7) { //If count is 7 then next it's 5
iCountTaksa = 5;
break LabelEndTaksa_Exit;
}
if (iCountTaksa == 5) { //If count is 5 then next it's 8
iCountTaksa = 8;
break LabelEndTaksa_Exit;
}
if (iCountTaksa == 8) { //If count is 8 then next it's 6
iCountTaksa = 6;
break LabelEndTaksa_Exit;
}
if (iCountTaksa == 6) { //If count is 6 then loop 1 as 1 2 3 4 7 5 8 6 --> 1
iCountTaksa = 1;
break LabelEndTaksa_Exit;
}
} //LabelEndTaksa_Exit : {
} // "for (int iTaksa = 1; iTaksa <=8; iTaksa++) {"
abc "$@" is generally the correct answer.
But I was trying to pass a parameter through to an su command, and no amount of quoting could stop the error su: unrecognized option '--myoption'
. What actually worked for me was passing all the arguments as a single string :
abc "$*"
My exact case (I'm sure someone else needs this) was in my .bashrc
# run all aws commands as Jenkins user
aws ()
{
sudo su jenkins -c "aws $*"
}
This code works for me with IE8 and Firefox
<td>
<textarea style="width:100%" rows=3 name="abc">Modify width:% accordingly</textarea>
</td>
html, body{
width:100%;
}
This tells the html to be 100% wide. But 100% refers to the whole browser window width, so no more than that.
You may want to set a min width instead.
html, body{
min-width:100%;
}
So it will be 100% as a minimum, bot more if needed.
You can specify custom width for .modal-lg class specifically for your popup for wider viewport resolution. Here is how to do it:
CSS:
@media (min-width: 1400px){
.my-modal-popup .modal-lg {
width: 1308px;
}
}
JS:
var modal = $modal.open({
animation: true,
templateUrl: 'modalTemplate.html',
controller: 'modalController',
size: 'lg',
windowClass: 'my-modal-popup'
});
The question on itself is very much invalid. Forcing (by doing enable_seqscan=off for example) is very bad idea. It might be useful to check if it will be faster, but production code should never use such tricks.
Instead - do explain analyze of your query, read it, and find out why PostgreSQL chooses bad (in your opinion) plan.
There are tools on the web that help with reading explain analyze output - one of them is explain.depesz.com - written by me.
Another option is to join #postgresql channel on freenode irc network, and talking to guys there to help you out - as optimizing query is not a matter of "ask a question, get answer be happy". it's more like a conversation, with many things to check, many things to be learned.
EmEditor works quite well for me. It's shareware IIRC but doesn't stop working after the license expires..
Here's a solution with nested list comprehensions, os.walk
and simple suffix matching instead of glob
:
import os
cfiles = [os.path.join(root, filename)
for root, dirnames, filenames in os.walk('src')
for filename in filenames if filename.endswith('.c')]
It can be compressed to a one-liner:
import os;cfiles=[os.path.join(r,f) for r,d,fs in os.walk('src') for f in fs if f.endswith('.c')]
or generalized as a function:
import os
def recursive_glob(rootdir='.', suffix=''):
return [os.path.join(looproot, filename)
for looproot, _, filenames in os.walk(rootdir)
for filename in filenames if filename.endswith(suffix)]
cfiles = recursive_glob('src', '.c')
If you do need full glob
style patterns, you can follow Alex's and
Bruno's example and use fnmatch
:
import fnmatch
import os
def recursive_glob(rootdir='.', pattern='*'):
return [os.path.join(looproot, filename)
for looproot, _, filenames in os.walk(rootdir)
for filename in filenames
if fnmatch.fnmatch(filename, pattern)]
cfiles = recursive_glob('src', '*.c')
Send Mail using phpMailer library through Gmail Please donwload library files from Github
<?php
/**
* This example shows settings to use when sending via Google's Gmail servers.
*/
//SMTP needs accurate times, and the PHP time zone MUST be set
//This should be done in your php.ini, but this is how to do it if you don't have access to that
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "[email protected]";
//Password to use for SMTP authentication
$mail->Password = "yourpassword";
//Set who the message is to be sent from
$mail->setFrom('[email protected]', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('[email protected]', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('[email protected]', 'John Doe');
//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
If you already have your public key added to the GITHUB server there are other solutions that you can try.
In my case the GIT PUSH was failing from inside RUBYMINE but doing it from the Terminal window solved the problem.
For more solutions visit this page https://github.com/gitlabhq/gitlabhq/issues/4730
A very simple approach independent of python version was missing in already given answers which you can use most of the time (at least I do):
new_list = my_list * 1 #Solution 1 when you are not using nested lists
However, If my_list contains other containers (for eg. nested lists) you must use deepcopy as others suggested in the answers above from the copy library. For example:
import copy
new_list = copy.deepcopy(my_list) #Solution 2 when you are using nested lists
.Bonus: If you don't want to copy elements use (aka shallow copy):
new_list = my_list[:]
Let's understand difference between Solution#1 and Solution #2
>>> a = range(5)
>>> b = a*1
>>> a,b
([0, 1, 2, 3, 4], [0, 1, 2, 3, 4])
>>> a[2] = 55
>>> a,b
([0, 1, 55, 3, 4], [0, 1, 2, 3, 4])
As you can see Solution #1 worked perfectly when we were not using the nested lists. Let's check what will happen when we apply solution #1 to nested lists.
>>> from copy import deepcopy
>>> a = [range(i,i+4) for i in range(3)]
>>> a
[[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]]
>>> b = a*1
>>> c = deepcopy(a)
>>> for i in (a, b, c): print i
[[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]]
[[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]]
[[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]]
>>> a[2].append('99')
>>> for i in (a, b, c): print i
[[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5, 99]]
[[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5, 99]] #Solution#1 didn't work in nested list
[[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5]] #Solution #2 - DeepCopy worked in nested list
You could do this:
verts = list(xrange(1000))
That would give you a list of 1000 elements in size and which happens to be initialised with values from 0-999. As list
does a __len__
first to size the new list it should be fairly efficient.
Late as usual. If anyone is still interested in this there are a number of related SO questions and answers. My version of recursive extension method for resolving this:
public static IEnumerable<T> FindControlsOfType<T>(this Control parent)
where T : Control
{
foreach (Control child in parent.Controls)
{
if (child is T)
{
yield return (T)child;
}
else if (child.Controls.Count > 0)
{
foreach (T grandChild in child.FindControlsOfType<T>())
{
yield return grandChild;
}
}
}
}
Here are some more exotic Python 3 ways to get "hello" TAB "alex" (tested with Python 3.6.10):
"hello\N{TAB}alex"
"hello\N{tab}alex"
"hello\N{TaB}alex"
"hello\N{HT}alex"
"hello\N{CHARACTER TABULATION}alex"
"hello\N{HORIZONTAL TABULATION}alex"
"hello\x09alex"
"hello\u0009alex"
"hello\U00000009alex"
Actually, instead of using an escape sequence, it is possible to insert tab symbol directly into the string literal. Here is the code with a tabulation character to copy and try:
"hello alex"
If the tab in the string above won't be lost anywhere during copying the string then "print(repr(< string from above >)" should print 'hello\talex'.
See respective Python documentation for reference.
1) To remove white space everywhere:
df.columns = df.columns.str.replace(' ', '')
2) To remove white space at the beginning of string:
df.columns = df.columns.str.lstrip()
3) To remove white space at the end of string:
df.columns = df.columns.str.rstrip()
4) To remove white space at both ends:
df.columns = df.columns.str.strip()
5) To replace white space everywhere
df.columns = df.columns.str.replace(' ', '_')
6) To replace white space at the beginning:
df.columns = df.columns.str.replace('^ +', '_')
7) To replace white space at the end:
df.columns = df.columns.str.replace(' +$', '_')
8) To replace white space at both ends:
df.columns = df.columns.str.replace('^ +| +$', '_')
All above applies to a specific column as well, assume you have a column named col
, then just do:
df[col] = df[col].str.strip() # or .replace as above
here is my soln to define the remote and local port and then write out to a file the received data, put this all in a class of your choice with the correct imports
static UdpClient sendClient = new UdpClient();
static int localPort = 49999;
static int remotePort = 49000;
static IPEndPoint localEP = new IPEndPoint(IPAddress.Any, localPort);
static IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse("127.0.0.1"), remotePort);
static string logPath = System.AppDomain.CurrentDomain.BaseDirectory + "/recvd.txt";
static System.IO.StreamWriter fw = new System.IO.StreamWriter(logPath, true);
private static void initStuff()
{
fw.AutoFlush = true;
sendClient.ExclusiveAddressUse = false;
sendClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
sendClient.Client.Bind(localEP);
sendClient.BeginReceive(DataReceived, sendClient);
}
private static void DataReceived(IAsyncResult ar)
{
UdpClient c = (UdpClient)ar.AsyncState;
IPEndPoint receivedIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
Byte[] receivedBytes = c.EndReceive(ar, ref receivedIpEndPoint);
fw.WriteLine(DateTime.Now.ToString("HH:mm:ss.ff tt") + " (" + receivedBytes.Length + " bytes)");
c.BeginReceive(DataReceived, ar.AsyncState);
}
static void Main(string[] args)
{
initStuff();
byte[] emptyByte = {};
sendClient.Send(emptyByte, emptyByte.Length, remoteEP);
}
Best approach to add a brand logo inside a navbar-inner
class and a container. About the <h3>
issue <h3>
has a certain padding given to it in bootstrap as @creimers told. And if you are using a bigger image, increase the height of navbar too or the logo will float outside.
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="navbar-inner"> <!--changes made here-->
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img src="http://placehold.it/150x50&text=Logo" alt="">
</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</div>
</div>
</nav>
One way to do that is to use a counter:
ArrayList<Integer> list = new ArrayList<Integer>();
...
int size = list.size();
for (Integer i : list) {
...
if (--size == 0) {
// Last item.
...
}
}
Edit
Anyway, as Tom Hawtin said, it is sometimes better to use the "old" syntax when you need to get the current index information, by using a for
loop or the iterator
, as everything you win when using the Java5 syntax will be lost in the loop itself...
for (int i = 0; i < list.size(); i++) {
...
if (i == (list.size() - 1)) {
// Last item...
}
}
or
for (Iterator it = list.iterator(); it.hasNext(); ) {
...
if (!it.hasNext()) {
// Last item...
}
}
You should define source code encoding, add this to the top of your script:
# -*- coding: utf-8 -*-
The reason why it works differently in console and in the IDE is, likely, because of different default encodings set. You can check it by running:
import sys
print sys.getdefaultencoding()
Also see:
For Eclipse
A good way to add external JARs to your Android project or any Java project is:
libs
in your project's root folderlibs
folderNow right click on the Jar file and then select Build Path > Add to Build Path, which will create a folder called 'Referenced Libraries' within your project
By doing this, you will not lose your libraries that are being referenced on your hard drive whenever you transfer your project to another computer.
For Android Studio
Please Note : If you are using 3rd party libraries then it is better to use transitive dependencies where Gradle script automatically downloads the JAR and the dependency JAR when gradle script run.
Ex : compile 'com.google.android.gms:play-services-ads:9.4.0'
Read more about Gradle Dependency Mangement
If you save the state of the application in a bundle (typically non-persistent, dynamic data in onSaveInstanceState
), it can be passed back to onCreate
if the activity needs to be recreated (e.g., orientation change) so that you don't lose this prior information. If no data was supplied, savedInstanceState
is null.
... you should use the onPause() method to write any persistent data (such as user edits) to storage. In addition, the method onSaveInstanceState(Bundle) is called before placing the activity in such a background state, allowing you to save away any dynamic instance state in your activity into the given Bundle, to be later received in onCreate(Bundle) if the activity needs to be re-created. See the Process Lifecycle section for more information on how the lifecycle of a process is tied to the activities it is hosting. Note that it is important to save persistent data in onPause() instead of onSaveInstanceState(Bundle) because the latter is not part of the lifecycle callbacks, so will not be called in every situation as described in its documentation.
int randomWithRange(int min, int max)
{
int range = (max - min) + 1;
return (int)(Math.random() * range) + min;
}
Output of randomWithRange(2, 5)
10 times:
5
2
3
3
2
4
4
4
5
4
The bounds are inclusive, ie [2,5], and min
must be less than max
in the above example.
EDIT: If someone was going to try and be stupid and reverse min
and max
, you could change the code to:
int randomWithRange(int min, int max)
{
int range = Math.abs(max - min) + 1;
return (int)(Math.random() * range) + (min <= max ? min : max);
}
EDIT2: For your question about double
s, it's just:
double randomWithRange(double min, double max)
{
double range = (max - min);
return (Math.random() * range) + min;
}
And again if you want to idiot-proof it it's just:
double randomWithRange(double min, double max)
{
double range = Math.abs(max - min);
return (Math.random() * range) + (min <= max ? min : max);
}
PROPAGATION_REQUIRED = 0; If DataSourceTransactionObject T1 is already started for Method M1. If for another Method M2 Transaction object is required, no new Transaction object is created. Same object T1 is used for M2.
PROPAGATION_MANDATORY = 2; method must run within a transaction. If no existing transaction is in progress, an exception will be thrown.
PROPAGATION_REQUIRES_NEW = 3; If DataSourceTransactionObject T1 is already started for Method M1 and it is in progress (executing method M1). If another method M2 start executing then T1 is suspended for the duration of method M2 with new DataSourceTransactionObject T2 for M2. M2 run within its own transaction context.
PROPAGATION_NOT_SUPPORTED = 4; If DataSourceTransactionObject T1 is already started for Method M1. If another method M2 is run concurrently. Then M2 should not run within transaction context. T1 is suspended till M2 is finished.
PROPAGATION_NEVER = 5; None of the methods run in transaction context.
An isolation level: It is about how much a transaction may be impacted by the activities of other concurrent transactions. It a supports consistency leaving the data across many tables in a consistent state. It involves locking rows and/or tables in a database.
The problem with multiple transaction
Scenario 1. If T1 transaction reads data from table A1 that was written by another concurrent transaction T2. If on the way T2 is rollback, the data obtained by T1 is invalid one. E.g. a=2 is original data. If T1 read a=1 that was written by T2. If T2 rollback then a=1 will be rollback to a=2 in DB. But, now, T1 has a=1 but in DB table it is changed to a=2.
Scenario2. If T1 transaction reads data from table A1. If another concurrent transaction (T2) update data on table A1. Then the data that T1 has read is different from table A1. Because T2 has updated the data on table A1. E.g. if T1 read a=1 and T2 updated a=2. Then a!=b.
Scenario 3. If T1 transaction reads data from table A1 with certain number of rows. If another concurrent transaction (T2) inserts more rows on table A1. The number of rows read by T1 is different from rows on table A1.
Scenario 1 is called Dirty reads.
Scenario 2 is called Non-repeatable reads.
Scenario 3 is called Phantom reads.
So, isolation level is the extend to which Scenario 1, Scenario 2, Scenario 3 can be prevented. You can obtain complete isolation level by implementing locking. That is preventing concurrent reads and writes to the same data from occurring. But it affects performance. The level of isolation depends upon application to application how much isolation is required.
ISOLATION_READ_UNCOMMITTED: Allows to read changes that haven’t yet been committed. It suffer from Scenario 1, Scenario 2, Scenario 3.
ISOLATION_READ_COMMITTED: Allows reads from concurrent transactions that have been committed. It may suffer from Scenario 2 and Scenario 3. Because other transactions may be updating the data.
ISOLATION_REPEATABLE_READ: Multiple reads of the same field will yield the same results untill it is changed by itself. It may suffer from Scenario 3. Because other transactions may be inserting the data.
ISOLATION_SERIALIZABLE: Scenario 1, Scenario 2, Scenario 3 never happen. It is complete isolation. It involves full locking. It affects performace because of locking.
You can test using:
public class TransactionBehaviour {
// set is either using xml Or annotation
DataSourceTransactionManager manager=new DataSourceTransactionManager();
SimpleTransactionStatus status=new SimpleTransactionStatus();
;
public void beginTransaction()
{
DefaultTransactionDefinition Def = new DefaultTransactionDefinition();
// overwrite default PROPAGATION_REQUIRED and ISOLATION_DEFAULT
// set is either using xml Or annotation
manager.setPropagationBehavior(XX);
manager.setIsolationLevelName(XX);
status = manager.getTransaction(Def);
}
public void commitTransaction()
{
if(status.isCompleted()){
manager.commit(status);
}
}
public void rollbackTransaction()
{
if(!status.isCompleted()){
manager.rollback(status);
}
}
Main method{
beginTransaction()
M1();
If error(){
rollbackTransaction()
}
commitTransaction();
}
}
You can debug and see the result with different values for isolation and propagation.
Your chunk of code does not create a new one, it only checks if its already there and nothing else.
File file = new File(filePath);
if(file.exists())
//Do something
else
// Do something else.
For Android Studio below 4.1:
From the Top menu Click File and then click Export to Zip File
For Android Studio 4.1 and above:
From the Top menu click File > Manage IDE Settings > Export to Zip File ()
Suddenly, without any major change in my project, I too got this error.
All the above did not work for me, since I needed both the support libs V4 and V7.
At the end, because 2 hours ago the project compiled with no problems, I simply told Android Studio to REBUILD the project, and the error was gone.
An improvement on Theodor Zoulias's nice multi-core Parallel.ForEach implementation:
public static ulong SumToUlongPar(this uint[] arrayToSum, int startIndex, int length, int degreeOfParallelism = 0)
{
var concurrentSums = new ConcurrentBag<ulong>();
int maxDegreeOfPar = degreeOfParallelism <= 0 ? Environment.ProcessorCount : degreeOfParallelism;
var options = new ParallelOptions() { MaxDegreeOfParallelism = maxDegreeOfPar };
Parallel.ForEach(Partitioner.Create(startIndex, startIndex + length), options, range =>
{
ulong localSum = 0;
for (int i = range.Item1; i < range.Item2; i++)
localSum += arrayToSum[i];
concurrentSums.Add(localSum);
});
ulong sum = 0;
var sumsArray = concurrentSums.ToArray();
for (int i = 0; i < sumsArray.Length; i++)
sum += sumsArray[i];
return sum;
}
which works for unsigned integer data types, since C# only support Interlocked.Add() for int and long. The above implementation can also be easily modified to support other integer and floating-point data types to do summation in parallel using multiple cores of the CPU. It is used in the HPCsharp nuget package.
Going off of what Derloopkat said, which still can fail on conversion (no offense Derloopkat) because Excel is terrible at this:
It will open, check it to make sure it's accurate and then save as an excel file.
I saw this question while I was looking for a way to count multiple files lines, so if you want to count multiple file lines of a .txt file you can do this,
cat *.txt | wc -l
it will also run on one .txt file ;)
Remove the quotes here:
is:
ORDER BY = 'post_datetime DESC' AND LIMIT = '3'
Should be:
ORDER BY post_datetime DESC LIMIT 3
You can use setInterval
:
var timer = setInterval( myFunction, 1000);
Just declare your function as myFunction or some other name, and then don't bind it to $('.more')
's live event.
The CSS3 specification allowing different origins for background-position is now supported in Firefox 14 but still not in Chrome 21 (apparently IE9 partly supports them, but I've not tested it myself)
In addition to the Chrome issue that @MattyF referenced there's a more succinct summary here: http://code.google.com/p/chromium/issues/detail?id=95085
change it to 32-bit (true) it works
if you get this Length cannot be less than zero. Parameter name: length issue in iis server configuation do the simple thing change the connection string in web.config file like your sql server name and server name and restart iis then try to load the page it works
a = ['1', '2', '3', '4']
print len(a) - 1
3
Pass the object from controller to view, convert it to markup without encoding, and parse it to json.
@model IEnumerable<CollegeInformationDTO>
@section Scripts{
<script>
var jsArray = JSON.parse('@Html.Raw(Json.Encode(@Model))');
</script>
}
==
shouldn't be used to compare objects in your if
. For NSString
use isEqualToString:
to compare them.
Rather than kludging it so you can continue, why not back up and wonder why you're running into a NaN in the first place?
If any of the numeric inputs to an operation is NaN, the output will also be NaN. That's the way the current IEEE Floating Point standard works (it's not just Javascript). That behavior is for a good reason: the underlying intention is to keep you from using a bogus result without realizing it's bogus.
The way NaN works is if something goes wrong way down in some sub-sub-sub-operation (producing a NaN at that lower level), the final result will also be NaN, which you'll immediately recognize as an error even if your error handling logic (throw/catch maybe?) isn't yet complete.
NaN as the result of an arithmetic calculation always indicates something has gone awry in the details of the arithmetic. It's a way for the computer to say "debugging needed here". Rather than finding some way to continue anyway with some number that's hardly ever right (is 0 really what you want?), why not find the problem and fix it.
A common problem in Javascript is that both parseInt(...)
and parseFloat(...)
will return NaN if given a nonsensical argument (null
, ''
, etc). Fix the issue at the lowest level possible rather than at a higher level. Then the result of the overall calculation has a good chance of making sense, and you're not substituting some magic number (0 or 1 or whatever) for the result of the entire calculation. (The trick of (parseInt(foo.value) || 0) works only for sums, not products - for products you want the default value to be 1 rather than 0, but not if the specified value really is 0.)
Perhaps for ease of coding you want a function to retrieve a value from the user, clean it up, and provide a default value if necessary, like this:
function getFoobarFromUser(elementid) {
var foobar = parseFloat(document.getElementById(elementid).innerHTML)
if (isNaN(foobar)) foobar = 3.21; // default value
return(foobar.toFixed(2));
}
length = 4
string = "abcdefgh"
str_dict = [ o for o in string ]
parts = [ ''.join( str_dict[ (j * length) : ( ( j + 1 ) * length ) ] ) for j in xrange(len(string)/length )]
It means you haven't assigned a provisioning profile to the configuration.
Usually it's because "Any iOS SDK" must have a profile and cannot be set to "Don't sign".
All this and more is answered in the TN2250 Tech Note about Code Signing and Troubleshooting.
After misunderstanding, I finally got what you are trying to do. You should check your server configuration files; are you using apache2 or some other server software?
Look for lines that start with LoadModule php
...
There probably are configuration files/directories named mods
or something like that, start from there.
You could also check output from php -r 'phpinfo();' | grep php
and compare lines to phpinfo();
from web server.
php
interactively:(so you can paste/write code in the console)
php -a
php -f file.php
php -f file.php > results.html
To run only small part, one line or like, you can use:
php -r '$x = "Hello World"; echo "$x\n";'
If you are running linux then do man php
at console.
if you need/want to run php through fpm, use cli fcgi
SCRIPT_NAME="file.php" SCRIP_FILENAME="file.php" REQUEST_METHOD="GET" cgi-fcgi -bind -connect "/var/run/php-fpm/php-fpm.sock"
where /var/run/php-fpm/php-fpm.sock is your php-fpm socket file.
The where
statement gets executed before the order by
. So, your desired query is saying "take the first row and then order it by t_stamp
desc". And that is not what you intend.
The subquery method is the proper method for doing this in Oracle.
If you want a version that works in both servers, you can use:
select ril.*
from (select ril.*, row_number() over (order by t_stamp desc) as seqnum
from raceway_input_labo ril
) ril
where seqnum = 1
The outer *
will return "1" in the last column. You would need to list the columns individually to avoid this.
you need nested foreach loops
foreach($samplearr as $key => $item){
echo $key;
foreach($item as $detail){
echo $detail['value1'] . " " . $detail['value2']
}
}
Here is a simple way of running MySQL queries in the bash shell
mysql -u [database_username] -p [database_password] -D [database_name] -e "SELECT * FROM [table_name]"
Do not use a KeyListener for this as you'll miss much including pasting of text. Also a KeyListener is a very low-level construct and as such, should be avoided in Swing applications.
The solution has been described many times on SO: Use a DocumentFilter. There are several examples of this on this site, some written by me.
For example: using-documentfilter-filterbypass
Also for tutorial help, please look at: Implementing a DocumentFilter.
Edit
For instance:
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.DocumentFilter;
import javax.swing.text.PlainDocument;
public class DocFilter {
public static void main(String[] args) {
JTextField textField = new JTextField(10);
JPanel panel = new JPanel();
panel.add(textField);
PlainDocument doc = (PlainDocument) textField.getDocument();
doc.setDocumentFilter(new MyIntFilter());
JOptionPane.showMessageDialog(null, panel);
}
}
class MyIntFilter extends DocumentFilter {
@Override
public void insertString(FilterBypass fb, int offset, String string,
AttributeSet attr) throws BadLocationException {
Document doc = fb.getDocument();
StringBuilder sb = new StringBuilder();
sb.append(doc.getText(0, doc.getLength()));
sb.insert(offset, string);
if (test(sb.toString())) {
super.insertString(fb, offset, string, attr);
} else {
// warn the user and don't allow the insert
}
}
private boolean test(String text) {
try {
Integer.parseInt(text);
return true;
} catch (NumberFormatException e) {
return false;
}
}
@Override
public void replace(FilterBypass fb, int offset, int length, String text,
AttributeSet attrs) throws BadLocationException {
Document doc = fb.getDocument();
StringBuilder sb = new StringBuilder();
sb.append(doc.getText(0, doc.getLength()));
sb.replace(offset, offset + length, text);
if (test(sb.toString())) {
super.replace(fb, offset, length, text, attrs);
} else {
// warn the user and don't allow the insert
}
}
@Override
public void remove(FilterBypass fb, int offset, int length)
throws BadLocationException {
Document doc = fb.getDocument();
StringBuilder sb = new StringBuilder();
sb.append(doc.getText(0, doc.getLength()));
sb.delete(offset, offset + length);
if (test(sb.toString())) {
super.remove(fb, offset, length);
} else {
// warn the user and don't allow the insert
}
}
}
Why is this important?
Riya,
Making the assumption that you want to split on the full stop (.), then here's an approach that would capture all occurences:
// add @ to the string to allow split over multiple lines
// (display purposes to save scroll bar appearing on SO question :))
string strBig = @"Retrieves a substring from this instance.
The substring starts at a specified character position. great";
// split the string on the fullstop, if it has a length>0
// then, trim that string to remove any undesired spaces
IEnumerable<string> subwords = strBig.Split('.')
.Where(x => x.Length > 0).Select(x => x.Trim());
// iterate around the new 'collection' to sanity check it
foreach (var subword in subwords)
{
Console.WriteLine(subword);
}
enjoy...
This might also be helpful: http://rush.heroku.com/
I haven't used it much, but looks pretty cool
From the site:
rush is a replacement for the unix shell (bash, zsh, etc) which uses pure Ruby syntax. Grep through files, find and kill processes, copy files - everything you do in the shell, now in Ruby
The msg['To']
needs to be a string:
msg['To'] = "[email protected], [email protected], [email protected]"
While the recipients
in sendmail(sender, recipients, message)
needs to be a list:
sendmail("[email protected]", ["[email protected]", "[email protected]", "[email protected]"], "Howdy")
There's a small Java program which generates docs (adoc or md) from a yaml file.
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withMarkupLanguage(MarkupLanguage.ASCIIDOC)
.withSwaggerMarkupLanguage(MarkupLanguage.ASCIIDOC)
.withOutputLanguage(Language.DE)
.build();
Swagger2MarkupConverter builder = Swagger2MarkupConverter.from(yamlFileAsString).withConfig(config).build();
return builder.toFileWithoutExtension(outFile);
Unfortunately it only supports OpenAPI 2.0 but not OpenAPI 3.0.
#include <string>
#include <cmath>
double _string_to_double(std::string s,unsigned short radix){
double n = 0;
for (unsigned short x = s.size(), y = 0;x>0;)
if(!(s[--x] ^ '.')) // if is equal
n/=pow(10,s.size()-1-x), y+= s.size()-x;
else
n+=( (s[x]-48) * pow(10,s.size()-1-x - y) );
return n;
}
or
//In case you want to convert from different bases.
#include <string>
#include <iostream>
#include <cmath>
double _string_to_double(std::string s,unsigned short radix){
double n = 0;
for (unsigned short x = s.size(), y = 0;x>0;)
if(!(s[--x] ^ '.'))
n/=pow(radix,s.size()-1-x), y+= s.size()-x;
else
n+=( (s[x]- (s[x]<='9' ? '0':'0'+7) ) * pow(radix,s.size()-1-x - y) );
return n;
}
int main(){
std::cout<<_string_to_double("10.A",16)<<std::endl;//Prints 16.625
std::cout<<_string_to_double("1001.1",2)<<std::endl;//Prints 9.5
std::cout<<_string_to_double("123.4",10)<<std::endl;//Prints 123.4
return 0;
}
I'm using Visual Studio Professional licensed over the MAPS Action Pack subscription. Since the new version of the Microsoft Partner Center one have to add the subscribed user to the partner benefit software.
Partner Center->Benefits->Visual Studio Subscriptions->Add user
After that one have to sign out and reenter the credentials in the account settings of VS.
Not really solve your question but it's an important alternative.
If you want to add custom html to the beginning of the page (inside <body>
element), you may use Page.ClientScript.RegisterClientScriptBlock()
.
Although the method is called "script", but you can add arbitary string, including html.
I had this issue and was able to fix it by adding constraints to determine the max with for a label.
When dropping a multiline label in there is not constraint set to enforce the width inside the parent view. This is where the new PreferredMaxWidth comes into play. On iOS 7 and earlier you have to define the max width yourself. I simply added a 10px constraint to the left and right hand side of the label.
You can also add a <= width constraint which also fixes the issue.
So this is not actually a bug, you simply have to define the max width yourself. The explicit option mention in other answer will also work as you are setting this width value however you will have to modify this value if you want the max width to change based on the parent width (as you have explicitly set the width).
My above solution ensures the width is always maintained no matter how big the parent view is.
The easiest way is:
var oldstr="Angular isn't easy";
var newstr=oldstr.toString().replace("isn't","is");
Over a year later... if what you need is get the auto generated id of a table, you can just
SELECT @ReportOptionId = SCOPE_IDENTITY()
Otherwise, it seems like you are stuck with using a table.
You are able to move a part of your code into another thread to offload the main thread
and avoid getting ANR, NetworkOnMainThreadException, IllegalStateException(e.g. Cannot access database on the main thread since it may potentially lock the UI for a long period of time).
There are some approaches that you should choose depends on the situation
Java Thread or Android HandlerThread
Java threads are one-time use only and die after executing its run method.
HandlerThread is a handy class for starting a new thread that has a looper.
AsyncTask (deprecated in API level 30)
AsyncTask is designed to be a helper class around Thread and Handler and does not constitute a generic threading framework. AsyncTasks should ideally be used for short operations (a few seconds at the most.) If you need to keep threads running for long periods of time, it is highly recommended you use the various APIs provided by the java.util.concurrent package such as Executor, ThreadPoolExecutor and FutureTask.
Since Main thread monopolizes UI components it is not possible to access to some View, that is why Handler is on the rescue
Thread pool implementation ThreadPoolExecutor, ScheduledThreadPoolExecutor...
ThreadPoolExecutor class that implements ExecutorService which gives fine control on the thread pool (Eg, core pool size, max pool size, keep alive time, etc.)
ScheduledThreadPoolExecutor - a class that extends ThreadPoolExecutor. It can schedule tasks after a given delay or periodically.
FutureTask performs asynchronous processing, however, if the result is not ready yet or processing has not complete, calling get() will be block the thread
AsyncTaskLoaders as they solve a lot of problems that are inherent to AsyncTask
This is the defacto choice for long running processing on Android, a good example would be to upload or download large files. The upload and download may continue even if the user exits the app and you certainly do not want to block the user from being able to use the app while these tasks are going on.
Effectively, you have to create a Service and create a job using JobInfo.Builder that specifies your criteria for when to run the service.
Library for composing asynchronous and event-based programs by using observable sequences.
Coroutines (Kotlin)
The main gist of it is, it makes asynchronous code looks so much like synchronous