The best way is to simply reset the password by connecting with a domain/local admin (so you may need help from your system administrators), but this only works if SQL Server was set up to allow local admins (these are now left off the default admin group during setup).
If you can't use this or other existing methods to recover / reset the SA password, some of which are explained here:
Then you could always backup your important databases, uninstall SQL Server, and install a fresh instance.
You can also search for less scrupulous ways to do it (e.g. there are password crackers that I am not enthusiastic about sharing).
As an aside, the login properties for sa
would never say Windows Authentication. This is by design as this is a SQL Authentication account. This does not mean that Windows Authentication is disabled at the instance level (in fact it is not possible to do so), it just doesn't apply for a SQL auth account.
I wrote a tip on using PSExec to connect to an instance using the NT AUTHORITY\SYSTEM
account (which works < SQL Server 2012), and a follow-up that shows how to hack the SqlWriter service (which can work on more modern versions):
And some other resources:
Make sure to deliberate about whether the win of the quicker binary search is worth the cost of keeping the list sorted (to be able to use the binary search). I.e. if you have lots of insert/remove operations and only an occasional search the binary search could in total be slower than the linear search.
UILabel
has a property lineBreakMode
that you can set as per your requirement.
In my case the issue was due to how I build my Nav bar. I was doing it through a jQuery plugin so I can quickly build Bootstrap components through javascript.
To cut a long story short binding the data elements of the button through jQuery .data() resulted in a collapse button that didn't work, doing it via .attr() fixed the issue.
This doesn't work:
$this.addClass("navbar navbar-default")
.append($("<div />").addClass("container-fluid")
.append($("<div />").addClass("navbar-header")
.append($("<button />").addClass("navbar-toggle collapsed")
.attr("type","button")
.attr("aria-expanded", "false")
.data("target","#" + id)
.data("toggle","collapse")
.html("<span class='sr-only'>Toggle navigation</span>"
+ "<span class='icon-bar'></span>"
+ "<span class='icon-bar'></span>"
+ "<span class='icon-bar'></span>"))
.append($("<a href='#' />").addClass("navbar-brand")
.append(document.createTextNode(settings.label))))
.append($("<div />").addClass("collapse navbar-collapse").attr("id",id)));
But this does (with the changes left in comments):
$this.addClass("navbar navbar-default")
.append($("<div />").addClass("container-fluid")
.append($("<div />").addClass("navbar-header")
.append($("<button />").addClass("navbar-toggle collapsed")
.attr("type","button")
.attr("aria-expanded", "false")
.attr("data-target", "#" + id) //.data("target","#" + id)
.attr("data-toggle", "collapse") // .data("toggle","collapse")
.html("<span class='sr-only'>Toggle navigation</span>"
+ "<span class='icon-bar'></span>"
+ "<span class='icon-bar'></span>"
+ "<span class='icon-bar'></span>"))
.append($("<a href='#' />").addClass("navbar-brand")
.append(document.createTextNode(settings.label))))
.append($("<div />").addClass("collapse navbar-collapse").attr("id",id)));
I can only assume that this is related to the way jQuery binds .data(), it doesn't write the attributes out to the elements, but just attaches them to the jQuery object. Using the .data() version resulted in HTML:
<button class="navbar-toggle collapsed" aria-expanded="false" type="button" >
Where as the .attr() version gives:
<button class="navbar-toggle collapsed" aria-expanded="false" type="button" data-toggle="collapse" data-target="#6a2034fe-8922-4edd-920e-6bd0ea0b2caf">
It seems that Bootstrap needs the data-nnn attribute in the HTML.
To extract joebloggs
from this string in bash using parameter expansion without any extra processes...
MYVAR="/var/cpanel/users/joebloggs:DNS9=domain.com"
NAME=${MYVAR%:*} # retain the part before the colon
NAME=${NAME##*/} # retain the part after the last slash
echo $NAME
Doesn't depend on joebloggs
being at a particular depth in the path.
Summary
An overview of a few parameter expansion modes, for reference...
${MYVAR#pattern} # delete shortest match of pattern from the beginning
${MYVAR##pattern} # delete longest match of pattern from the beginning
${MYVAR%pattern} # delete shortest match of pattern from the end
${MYVAR%%pattern} # delete longest match of pattern from the end
So #
means match from the beginning (think of a comment line) and %
means from the end. One instance means shortest and two instances means longest.
You can get substrings based on position using numbers:
${MYVAR:3} # Remove the first three chars (leaving 4..end)
${MYVAR::3} # Return the first three characters
${MYVAR:3:5} # The next five characters after removing the first 3 (chars 4-9)
You can also replace particular strings or patterns using:
${MYVAR/search/replace}
The pattern
is in the same format as file-name matching, so *
(any characters) is common, often followed by a particular symbol like /
or .
Examples:
Given a variable like
MYVAR="users/joebloggs/domain.com"
Remove the path leaving file name (all characters up to a slash):
echo ${MYVAR##*/}
domain.com
Remove the file name, leaving the path (delete shortest match after last /
):
echo ${MYVAR%/*}
users/joebloggs
Get just the file extension (remove all before last period):
echo ${MYVAR##*.}
com
NOTE: To do two operations, you can't combine them, but have to assign to an intermediate variable. So to get the file name without path or extension:
NAME=${MYVAR##*/} # remove part before last slash
echo ${NAME%.*} # from the new var remove the part after the last period
domain
In my case, I just needed to close my pop-up and redirect the user to his profile page when he clicks "ok" after reading some message I tried with a few hacks, including setTimeout + self.close(), but with IE, this was closing the whole tab...
Solution :
I replaced my link with a simple submit button.
<button type="submit" onclick="window.location.href='profile.html';">buttonText</button>
.
Nothing more.
This may sound stupid, but I didn't think to such a simple solution, since my pop-up did not have any form.
I hope it will help some front-end noobs like me !
To answer your first question: yes it is feasible to develop an android application in pure python, in order to achieve this I suggest you use BeeWare, which is just a suite of python tools, that work together very well and they enable you to develop platform native applications in python.
checkout this video by the creator of BeeWare that perfectly explains and demonstrates it's application
Android's preferred language of implementation is Java - so if you want to write an Android application in Python, you need to have a way to run your Python code on a Java Virtual Machine. This is what VOC does. VOC is a transpiler - it takes Python source code, compiles it to CPython Bytecode, and then transpiles that bytecode into Java-compatible bytecode. The end result is that your Python source code files are compiled directly to a Java .class file, which can be packaged into an Android application.
VOC also allows you to access native Java objects as if they were Python objects, implement Java interfaces with Python classes, and subclass Java classes with Python classes. Using this, you can write an Android application directly against the native Android APIs.
Once you've written your native Android application, you can use Briefcase to package your Python code as an Android application.
Briefcase is a tool for converting a Python project into a standalone native application. You can package projects for:
You can check This native Android Tic Tac Toe app written in Python, using the BeeWare suite. on GitHub
in addition to the BeeWare tools, you'll need to have a JDK and Android SDK installed to test run your application.
and to answer your second question: a good environment can be anything you are comfortable with be it a text editor and a command line, or an IDE, if you're looking for a good python IDE I would suggest you try Pycharm, it has a community edition which is free, and it has a similar environment as android studio, due to to the fact that were made by the same company.
I hope this has been helpful
install certificate in java linux
/opt/jdk(version)/bin/keytool -import -alias aliasname -file certificate.cer -keystore cacerts -storepass password
Stack Smashing here is actually caused due to a protection mechanism used by gcc to detect buffer overflow errors. For example in the following snippet:
#include <stdio.h>
void func()
{
char array[10];
gets(array);
}
int main(int argc, char **argv)
{
func();
}
The compiler, (in this case gcc) adds protection variables (called canaries) which have known values. An input string of size greater than 10 causes corruption of this variable resulting in SIGABRT to terminate the program.
To get some insight, you can try disabling this protection of gcc using option -fno-stack-protector
while compiling. In that case you will get a different error, most likely a segmentation fault as you are trying to access an illegal memory location. Note that -fstack-protector
should always be turned on for release builds as it is a security feature.
You can get some information about the point of overflow by running the program with a debugger. Valgrind doesn't work well with stack-related errors, but like a debugger, it may help you pin-point the location and reason for the crash.
Here is simple overlay div without using any gif, This can be applied over another div.
<style>
.loader {
position: relative;
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 70px;
height: 70px;
left:50%;
top:50%;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
}
#overlay{
position: absolute;
top:0px;
left:0px;
width: 100%;
height: 100%;
background: black;
opacity: .5;
}
.container{
position:relative;
height: 300px;
width: 200px;
border:1px solid
}
/* Safari */
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
<h2>How To Create A Loader</h2>
<div class="container">
<h3>Overlay over this div</h3>
<div id="overlay">
<div class="loader"></div>
</div>
<div>
Instead of doing all these, one can simply use ".Result" to get the result from a particular task.
eg: List list = GetListAsync().Result;
Which as per the definition => Gets the result value of this Task < TResult >
if put 'http_errors' => false
in guzzle request options, then it would stop throw exception while get 4xx or 5xx error, like this: $client->get(url, ['http_errors' => false])
. then you parse the response, not matter it's ok or error, it would be in the response
for more info
To avoid exceptions killing your app you should catch those exceptions and treat them the way you wish, defining the behavior for you app on those situations where the id is not found.
begin
current_user.comments.find(ids)
rescue
#do something in case of exception found
end
Here's more info on exceptions in ruby.
Multiple SQL statements must be executed with the mysqli_multi_query()
function.
Example (MySQLi Object-oriented):
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO names (firstname, lastname)
VALUES ('inpute value here', 'inpute value here');";
$sql .= "INSERT INTO phones (landphone, mobile)
VALUES ('inpute value here', 'inpute value here');";
if ($conn->multi_query($sql) === TRUE) {
echo "New records created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
Seemed to be a no brainer; the WCF service should be enabled using Programs and Features -> Turn Windows features on or off
in the Control Panel. Go to .NET Framework Advanced Services -> WCF Services
and enable HTTP Activation
as described in this blog post on mdsn.
From the command prompt (as admin), you can run:
C:\> DISM /Online /Enable-Feature /FeatureName:WCF-HTTP-Activation
C:\> DISM /Online /Enable-Feature /FeatureName:WCF-HTTP-Activation45
If you get an error then use the below
C:\> DISM /Online /Enable-Feature /all /FeatureName:WCF-HTTP-Activation
C:\> DISM /Online /Enable-Feature /all /FeatureName:WCF-HTTP-Activation45
Do like this, it is the easiest way.
qry
will be your own query, whatever you want in the select list.
set @qry = ' select * into TempData from (' + @qry + ')Tmp '
exec (@qry)
select * from TempData
drop table TempData
In my side, it is because POSTMAN setting issue, but I don't know why, maybe I copy a query from other. I simply create a new request in POSTMAN and run it, it works.
This works fine for me
Excel.Application oXL = null;
Excel._Workbook oWB = null;
Excel._Worksheet oSheet = null;
try
{
oXL = new Excel.Application();
string path = @"C:\Templates\NCRepTemplate.xlt";
oWB = oXL.Workbooks.Open(path, 0, false, 5, "", "",
false, Excel.XlPlatform.xlWindows, "", true, false,
0, true, false, false);
oSheet = (Excel._Worksheet)oWB.ActiveSheet;
oSheet.Cells[2, 2] = "Text";
Best practice: one form per product is definitely the way to go.
Benefits:
In your specific situation
If you only ever intend to have one form element, in this case a submit
button, one form for all should work just fine.
My recommendation Do one form per product, and change your markup to something like:
<form method="post" action="">
<input type="hidden" name="product_id" value="123">
<button type="submit" name="action" value="add_to_cart">Add to Cart</button>
</form>
This will give you a much cleaner and usable POST
. No parsing. And it will allow you to add more parameters in the future (size, color, quantity, etc).
Note: There's no technical benefit to using
<button>
vs.<input>
, but as a programmer I find it cooler to work withaction=='add_to_cart'
thanaction=='Add to Cart'
. Besides, I hate mixing presentation with logic. If one day you decide that it makes more sense for the button to say "Add" or if you want to use different languages, you could do so freely without having to worry about your back-end code.
In C the char type has a numeric value so the > operator will work just fine for example
#include <stdio.h>
main() {
char a='z';
char b='h';
if ( a > b ) {
printf("%c greater than %c\n",a,b);
}
}
To copy remote-to-remote files you can use the synchronize module with 'delegate_to: source-server
' keyword:
- hosts: serverB
tasks:
- name: Copy Remote-To-Remote (from serverA to serverB)
synchronize: src=/copy/from_serverA dest=/copy/to_serverB
delegate_to: serverA
This playbook can run from your machineC.
You don't need to necessarily use Objects, you can do it with normal multi-dimensional Arrays.
This is my solution without Objects:
// Javascript
const matrix = [];
matrix.key1 = [
'value1',
'value2',
];
matrix.key2 = [
'value3',
];
which in PHP is equivalent to:
// PHP
$matrix = [
"key1" => [
'value1',
'value2',
],
"key2" => [
'value3',
]
];
When you create an App, a file called styles.xml will be created in your res/values folder. If you change the styles, you can change the background, text color, etc for all your layouts. That way you don’t have to go into each individual layout and change the it manually.
styles.xml:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.AppBaseTheme" parent="@android:style/Theme.Light">
<item name="android:editTextColor">#295055</item>
<item name="android:textColorPrimary">#295055</item>
<item name="android:textColorSecondary">#295055</item>
<item name="android:textColorTertiary">#295055</item>
<item name="android:textColorPrimaryInverse">#295055</item>
<item name="android:textColorSecondaryInverse">#295055</item>
<item name="android:textColorTertiaryInverse">#295055</item>
<item name="android:windowBackground">@drawable/custom_background</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
parent="@android:style/Theme.Light"
is Google’s native colors. Here is a reference of what the native styles are:
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml
name="Theme.AppBaseTheme"
means that you are creating a style that inherits all the styles from parent="@android:style/Theme.Light"
.
This part you can ignore unless you want to inherit from AppBaseTheme again. = <style name="AppTheme" parent="AppBaseTheme">
@drawable/custom_background is a custom image I put in the drawable’s folder. It is a 300x300 png image.
#295055 is a dark blue color.
My code changes the background and text color. For Button text, please look through Google’s native stlyes (the link I gave u above).
Then in Android Manifest, remember to include the code:
<application
android:theme="@style/Theme.AppBaseTheme">
If you look at the output you receive from print()
and also in your Traceback, you'll see the value you get back is not a string, it's a bytes object (prefixed by b
):
b'{\n "note":"This file .....
If you fetch the URL using a tool such as curl -v
, you will see that the content type is
Content-Type: application/json; charset=utf-8
So it's JSON, encoded as UTF-8, and Python is considering it a byte stream, not a simple string. In order to parse this, you need to convert it into a string first.
Change the last line of code to this:
info = json.loads(js.decode("utf-8"))
(Cross-posting my answer from here: https://stackoverflow.com/a/25775147/798533)
For anybody looking for the resolution of the image to upload (if you want to create some fancy photoshop screenshots), they are:
Good reference guide here: http://www.paintcodeapp.com/news/iphone-6-screens-demystified (talks about resolutions and downsampling of the iPhone 6+).
I'll throw this out there. Why?
You can't just change all your strings to secure strings and suddenly your application is "secure". Secure string is designed to keep the string encrypted for as long as possible, and only decrypted for a very short period of time, wiping the memory after an operation has been performed upon it.
I would hazard saying that you may have some design level issues to deal with before worrying about securing your application strings. Give us some more information on what your trying to do and we may be able to help better.
Making scrolling tables is always a challenge. This is a solution where the table is scrolled both horizontally and vertically with fixed height on tbody making theader and tbody "stick" (without display: sticky). I've added a "big" table just to show. I got inspiration from G-Cyrillus to make the tbody display:block; But when it comes to width of a cell (both in header and body), it's depending on the inside content. Therefore I added content with specific width inside each cell, both in thead and minimum first row in tbody (the other rows adapt accordingly)
.go-wrapper {_x000D_
overflow-x: auto;_x000D_
width: 100%;_x000D_
}_x000D_
.go-wrapper table {_x000D_
width: auto;_x000D_
}_x000D_
.go-wrapper table tbody {_x000D_
display: block;_x000D_
height: 220px;_x000D_
overflow: auto;_x000D_
}_x000D_
.go-wrapper table thead {_x000D_
display: table;_x000D_
}_x000D_
.go-wrapper table tfoot {_x000D_
display: table;_x000D_
}_x000D_
.go-wrapper table thead tr, _x000D_
.go-wrapper table tbody tr,_x000D_
.go-wrapper table tfoot tr {_x000D_
display: table-row;_x000D_
}_x000D_
_x000D_
.go-wrapper table th,_x000D_
.go-wrapper table td { _x000D_
white-space: nowrap; _x000D_
}_x000D_
_x000D_
.go-wrapper .aw-50 { min-height: 1px; width: 50px; }_x000D_
.go-wrapper .aw-100 { min-height: 1px; width: 100px; }_x000D_
.go-wrapper .aw-200 { min-height: 1px; width: 200px; }_x000D_
.go-wrapper .aw-400 { min-height: 1px; width: 400px; }_x000D_
_x000D_
/***** Colors *****/_x000D_
.go-wrapper table {_x000D_
border: 2px solid red_x000D_
}_x000D_
.go-wrapper table thead, _x000D_
.go-wrapper table tbody, _x000D_
.go-wrapper table tfoot {_x000D_
outline: 1px solid green_x000D_
}_x000D_
.go-wrapper td {_x000D_
outline: 1px solid blue_x000D_
}
_x000D_
<!DOCTYPE html>_x000D_
<html lang="en">_x000D_
_x000D_
<head>_x000D_
<meta charset="UTF-8">_x000D_
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">_x000D_
<title>Template</title>_x000D_
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">_x000D_
<link rel="stylesheet" href="css/main.css">_x000D_
</head>_x000D_
_x000D_
<body>_x000D_
<div class="container">_x000D_
<div class="row mt-5 justify-content-md-center">_x000D_
<div class="col-8">_x000D_
<div class="go-wrapper">_x000D_
<table class="table">_x000D_
<thead>_x000D_
<tr>_x000D_
<th><div class="aw-50" ><div class="checker"><span><input type="checkbox" class="styled"></span></div></div></th>_x000D_
<th><div class="aw-200">Name</div></th>_x000D_
<th><div class="aw-50" >Week</div></th>_x000D_
<th><div class="aw-100">Date</div></th>_x000D_
<th><div class="aw-100">Time</div></th>_x000D_
<th><div class="aw-200">Project</div></th>_x000D_
<th><div class="aw-400">Text</div></th>_x000D_
<th><div class="aw-200">Activity</div></th>_x000D_
<th><div class="aw-50" >Hours</th>_x000D_
<th><div class="aw-50" >Pause</div></th>_x000D_
<th><div class="aw-100">Status</div></th>_x000D_
</tr>_x000D_
</thead>_x000D_
<tbody>_x000D_
<tr>_x000D_
<td><div class="aw-50"><div class="checker"><span><input type="checkbox" class="styled"></span></div></div></td>_x000D_
<td><div class="aw-200">AAAAA</div></td>_x000D_
<td><div class="aw-50" >15</div></td>_x000D_
<td><div class="aw-100">07.04.2020</div></td>_x000D_
<td><div class="aw-100">10:00</div></td>_x000D_
<td><div class="aw-200">Project 1</div></td>_x000D_
<td><div class="aw-400">Blah blah blah</div></td>_x000D_
<td><div class="aw-200">Activity</div></td>_x000D_
<td><div class="aw-50" >2t</div></td>_x000D_
<td><div class="aw-50" >30min</div></td>_x000D_
<td><div class="aw-100">Waiting</div></td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>BBBBB</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>CCCCC</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah Blah blah blah</td>_x000D_
<td>Activity Activity Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>DDDDD</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>EEEEE</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>FFFFF</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity Activity Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>GGGGG</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>HHHHH</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>IIIII</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>JJJJJ</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>KKKKK</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>LLLLL</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>MMMMM</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>NNNNN</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>OOOOO</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>PPPPP</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>QQQQQ</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>RRRRR</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>SSSSS</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>TTTTT</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>UUUUU</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>VVVVV</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>XXXXX</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>YYYYY</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>ZZZZZ</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>ÆÆÆÆÆ</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>ØØØØØ</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
<tr>_x000D_
<td><div class="checker"><span><input type="checkbox" class="styled"></span></div></td>_x000D_
<td>ÅÅÅÅÅ</td>_x000D_
<td>15</td>_x000D_
<td>07.04.2020</td>_x000D_
<td>10:00</td>_x000D_
<td>Project 1</td>_x000D_
<td>Blah blah blah</td>_x000D_
<td>Activity</td>_x000D_
<td>2t</td>_x000D_
<td>30min</td>_x000D_
<td>Waiting</td>_x000D_
</tr>_x000D_
</tbody>_x000D_
<tfoot>_x000D_
<tr>_x000D_
<th><div class="aw-50" ><div class="checker"><span><input type="checkbox" class="styled"></span></div></div></th>_x000D_
<th><div class="aw-200">Name</div></th>_x000D_
<th><div class="aw-50" >Week</div></th>_x000D_
<th><div class="aw-100">Date</div></th>_x000D_
<th><div class="aw-100">Time</div></th>_x000D_
<th><div class="aw-200">Project</div></th>_x000D_
<th><div class="aw-400">Text</div></th>_x000D_
<th><div class="aw-200">Activity</div></th>_x000D_
<th><div class="aw-50" >Hours</th>_x000D_
<th><div class="aw-50" >Pause</div></th>_x000D_
<th><div class="aw-100">Status</div></th>_x000D_
</tr>_x000D_
</tfoot>_x000D_
</table>_x000D_
</div>_x000D_
</div>_
There are a few problems here.
1: onBlur expects a callback, and you are calling renderPasswordConfirmError
and using the return value, which is null.
2: you need a place to render the error.
3: you need a flag to track "and I validating", which you would set to true on blur. You can set this to false on focus if you want, depending on your desired behavior.
handleBlur: function () {
this.setState({validating: true});
},
render: function () {
return <div>
...
<input
type="password"
placeholder="Password (confirm)"
valueLink={this.linkState('password2')}
onBlur={this.handleBlur}
/>
...
{this.renderPasswordConfirmError()}
</div>
},
renderPasswordConfirmError: function() {
if (this.state.validating && this.state.password !== this.state.password2) {
return (
<div>
<label className="error">Please enter the same password again.</label>
</div>
);
}
return null;
},
Use int()
on a boolean test:
x = int(x == 'true')
int()
turns the boolean into 1
or 0
. Note that any value not equal to 'true'
will result in 0
being returned.
Tools
> Options
> Use System Git
, then select the git.exe
file
The credentials will be required again, and the problem will be solved.
In my case, this problem will happen when the wpf program's architechture is not exactly same with dependency. Suppose you have one dependency that is x64, and another one is AnyCPU. Then if you choose x64, the type in AnyCPU dll will "does not exist", otherwise the type in x64 dll will "does not exist". You just cannot emilate both of them.
Had similar problem in Xcode 6.4. The progress bar indicated that "Indexing" was "Paused". Tried deleting project.xcworkspace, then deleting Derived Data as described above. Did not appear to help. Noting that the posts above also suggest fixing warnings, and since I had inherited this huge project with 180 warnings, I said to myself, "What the hell this looks like a good day to fix warnings". As I was fixing warnings, a half hour later, I noticed that the "Indexing" progress bar had increased from 10% to about 20%. An hour later, it was at 50%, then another hour to 80%, then after another half hour it was done! Conclusion: Add "take a long lunch or a nap" to the above suggestions.
If you specify @GET("foobar?a=5")
, then any @Query("b")
must be appended using &
, producing something like foobar?a=5&b=7
.
If you specify @GET("foobar")
, then the first @Query
must be appended using ?
, producing something like foobar?b=7
.
That's how Retrofit works.
When you specify @GET("foobar?")
, Retrofit thinks you already gave some query parameter, and appends more query parameters using &
.
Remove the ?
, and you will get the desired result.
Summary
This example assumes you always know where the apache root folder is '/var/www/' and you are trying to find the next folder path (e.g. '/var/www/my_website_folder'). Also this works from a script or the web browser which is why there is additional code.
Code PHP7
function getHtmlRootFolder(string $root = '/var/www/') {
// -- try to use DOCUMENT_ROOT first --
$ret = str_replace(' ', '', $_SERVER['DOCUMENT_ROOT']);
$ret = rtrim($ret, '/') . '/';
// -- if doesn't contain root path, find using this file's loc. path --
if (!preg_match("#".$root."#", $ret)) {
$root = rtrim($root, '/') . '/';
$root_arr = explode("/", $root);
$pwd_arr = explode("/", getcwd());
$ret = $root . $pwd_arr[count($root_arr) - 1];
}
return (preg_match("#".$root."#", $ret)) ? rtrim($ret, '/') . '/' : null;
}
Example
echo getHtmlRootFolder();
Output:
/var/www/somedir/
Details:
Basically first tries to get DOCUMENT_ROOT if it contains '/var/www/' then use it, else get the current dir (which much exist inside the project) and gets the next path value based on count of the $root path. Note: added rtrim statements to ensure the path returns ending with a '/' in all cases . It doesn't check for it requiring to be larger than /var/www/ it can also return /var/www/ as a possible response.
str.isalpha()
Return true if all characters in the string are alphabetic and there is at least one character, false otherwise. Alphabetic characters are those characters defined in the Unicode character database as “Letter”, i.e., those with general category property being one of “Lm”, “Lt”, “Lu”, “Ll”, or “Lo”. Note that this is different from the “Alphabetic” property defined in the Unicode Standard.
In python2.x:
>>> s = u'a1??'
>>> for char in s: print char, char.isalpha()
...
a True
1 False
? True
? True
>>> s = 'a1??'
>>> for char in s: print char, char.isalpha()
...
a True
1 False
? False
? False
? False
? False
? False
? False
>>>
In python3.x:
>>> s = 'a1??'
>>> for char in s: print(char, char.isalpha())
...
a True
1 False
? True
? True
>>>
This code work:
>>> def is_alpha(word):
... try:
... return word.encode('ascii').isalpha()
... except:
... return False
...
>>> is_alpha('??')
False
>>> is_alpha(u'??')
False
>>>
>>> a = 'a'
>>> b = 'a'
>>> ord(a), ord(b)
(65345, 97)
>>> a.isalpha(), b.isalpha()
(True, True)
>>> is_alpha(a), is_alpha(b)
(False, True)
>>>
Add overflow: auto to the container div. http://www.quirksmode.org/css/clearing.html This website shows a few options when having this issue.
That can't be done with a for
-loop, unless you use the Reflection API. However, you can use Arrays.asList
instead to accomplish the same:
List<Answer> answers = Arrays.asList(answer1, answer2, answer3);
The proper way is to use Hibernate Transformers:
public class StudentDTO {
private String studentName;
private String courseDescription;
public StudentDTO() { }
...
}
.
List resultWithAliasedBean = s.createSQLQuery(
"SELECT st.name as studentName, co.description as courseDescription " +
"FROM Enrolment e " +
"INNER JOIN Student st on e.studentId=st.studentId " +
"INNER JOIN Course co on e.courseCode=co.courseCode")
.setResultTransformer( Transformers.aliasToBean(StudentDTO.class))
.list();
StudentDTO dto =(StudentDTO) resultWithAliasedBean.get(0);
Iterating througth Object[] is redundant and would have some performance penalty. Detailed information about transofrmers usage you will find here: Transformers for HQL and SQL
If you are looking for even more simple solution you can use out-of-the-box-map-transformer:
List iter = s.createQuery(
"select e.student.name as studentName," +
" e.course.description as courseDescription" +
"from Enrolment as e")
.setResultTransformer( Transformers.ALIAS_TO_ENTITY_MAP )
.iterate();
String name = (Map)(iter.next()).get("studentName");
s=input("Enter any character:")
if s.isalnum():
print("Alpha Numeric Character")
if s.isalpha():
print("Alphabet character")
if s.islower():
print("Lower case alphabet character")
else:
print("Upper case alphabet character")
else:
print("it is a digit")
elif s.isspace():
print("It is space character")
else:
print("Non Space Special Character")
ddlPageSize.Items.FindByValue("25").Selected = true;
I know this is an old question but this may help someone looking for a different method. This is what I use on windows to kill processes that I've called.
si = subprocess.STARTUPINFO()
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
subprocess.call(["taskkill", "/IM", "robocopy.exe", "/T", "/F"], startupinfo=si)
/IM is the image name, you can also do /PID if you want. /T kills the process as well as the child processes. /F force terminates it. si, as I have it set, is how you do this without showing a CMD window. This code is used in python 3.
I was able to fix it using the answer here: https://stackoverflow.com/a/32176571/1174024 But I have 150 modules. So I would have had to perform this step 150 times.
So I needed to do it a different way.
So first close the existing project, then Import it again, In the first step of the wizard choose "Gradle" project. Then the next step of the wizard has the Gradle project properties. Here it's going to ask you for, among other things, the Java SDK to use. The default will be "Project SDK". Do not use this default, instead hand pick your Java SDK from the list. Then finish the import.
Now the problem should go away.
Below is code how you can display an output of float data with 2 decimal places in Java:
float ratingValue = 52.98929821f;
DecimalFormat decimalFormat = new DecimalFormat("#.##");
float twoDigitsFR = Float.valueOf(decimalFormat.format(ratingValue)); // output is 52.98
I think I found another solution to this question.
Go to Project > Properties > Java Build Path > tab [Order and Export] > Tick Android Version Checkbox Then if your workspace does not build automatically…
Properties again > Build Project
The key is already the ... ehm ... key
echo $array[20120504];
If you are unsure, if the key exists, test for it
$key = 20120504;
$result = isset($array[$key]) ? $array[$key] : null;
Minor addition:
$result = @$array[$key] ?: null;
One may argue, that @
is bad, but keep it serious: This is more readable and straight forward, isn't?
Update: With PHP7 my previous example is possible without the error-silencer
$result = $array[$key] ?? null;
Original question was to parse a list of topics, however starting with the original example to have a function return a single value may also useful. To that end, here is an example of (one way) to do that:
<script type='text/javascript'>
function getSingleValueUsingJQuery() {
var value = "";
var url = "rest/endpointName/" + document.getElementById('someJSPFieldName').value;
jQuery.ajax({
type: 'GET',
url: url,
async: false,
contentType: "application/json",
dataType: 'json',
success: function(json) {
console.log(json.value); // needs to match the payload (i.e. json must have {value: "foo"}
value = json.value;
},
error: function(e) {
console.log("jQuery error message = "+e.message);
}
});
return value;
}
</script>
I solved it this way:
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.jpg</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.png</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.gif</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
This works on Tomcat and ofcourse Jboss. However in the end I decided to use the solution Spring provides (as mentioned by rozky) which is far more portable.
Tensorflow indeed supports Python 3.6.X version, but only for 64-bit architecture. Here is the link where you can download Python 3.6.X 64-bit version
This is quite likely the simplest way to achieve what you are looking for.
In order to use this map
function in this instance, we will have to pass a currentValue
(always-required) parameter, as well an index
(optional) parameter.
In the below example, station
is our currentValue
, and x
is our index
.
station
represents the current value of the object within the array as it is iterated over.
x
automatically increments; increasing by one each time a new object is mapped.
render () {
return (
<div>
{stations.map((station, x) => (
<div key={x}> {station} </div>
))}
</div>
);
}
What Thomas Valadez had answered, while it had provided the best/simplest method to render a component from an array of objects, it had failed to properly address the way in which you would assign a key during this process.
Just add classpath entry ( I mean your parent directory location) under System Variables and User Variables menu ... Follow : Right Click My Computer>Properties>Advanced>Environment Variables
Based on Tom Gullen´s answer.
var start = new Date("02/05/2013");
var end = new Date("02/10/2013");
var loop = new Date(start);
while(loop <= end){
alert(loop);
var newDate = loop.setDate(loop.getDate() + 1);
loop = new Date(newDate);
}
I just had this error too but it was masking another more relevant error message where the code was trying to store a 125 characters string in a 100 characters column:
DatabaseError: value too long for type character varying(100)
I had to debug through the code for the above message to show up, otherwise it displays
DatabaseError: current transaction is aborted
//Suppose function not taking any parameter means just add the GetAlterConfirmation(function(result) {});
GetAlterConfirmation('test','messageText',function(result) {
alert(result);
}); //Function into document load or any other click event.
function GetAlterConfirmation(titleText, messageText, _callback){
bootbox.confirm({
title: titleText,
message: messageText,
buttons: {
cancel: {
label: '<i class="fa fa-times"></i> Cancel'
},
confirm: {
label: '<i class="fa fa-check"></i> Confirm'
}
},
callback: function (result) {
return _callback(result);
}
});
Perhaps getting the Mac address is not the best approach for verifying a client's machine over the internet. Consider using a token instead which is stored in the client's browser by an administrator's login.
Therefore the client can only have this token if the administrator grants it to them through their browser. If the token is not present or valid then the client's machine is invalid.
I had the same problem. I managed to solve it by simply updating my version of jquery. I was using 1.6.1 and updated to 1.7.1 - no more crashes.
You have to set to element_blank()
in theme()
elements you need to remove
ggplot(data = diamonds, mapping = aes(x = clarity)) + geom_bar(aes(fill = cut))+
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank())
use the keyword break
instead of return
I realize this question is old, but I wanted to post an alternate solution in case anyone else (like myself) found this thread while having the same question. I was able to work around the lack of an OR operator by echoing the variable and using findstr to validate.
for /f %%v in ('echo %var% ^| findstr /x /c:"1" /c:"2"') do (
if %errorlevel% equ 0 echo true
)
Refreshing my memory on setting position, I'm coming to this so late I don't know if anyone else will see it, but --
I don't like setting position using css()
, though often it's fine. I think the best bet is to use jQuery UI's position()
setter as noted by xdazz. However if jQuery UI is, for some reason, not an option (yet jQuery is), I prefer this:
const leftOffset = 200;
const topOffset = 200;
let $div = $("#mydiv");
let baseOffset = $div.offsetParent().offset();
$div.offset({
left: baseOffset.left + leftOffset,
top: baseOffset.top + topOffset
});
This has the advantage of not arbitrarily setting $div
's parent to relative positioning (what if $div
's parent was, itself, absolute positioned inside something else?). I think the only major edge case is if $div
doesn't have any offsetParent
, not sure if it would return document
, null
, or something else entirely.
offsetParent
has been available since jQuery 1.2.6, sometime in 2008, so this technique works now and when the original question was asked.
The best and perfect solution for this issue:
I tried the jQuery with the Ajax success responses, but it doesn't work so I invented my own and finally it works!
Click here to see the full solution
var rs = '{"test" : "Got it perfect!","message" : "Got it!"}';
eval("var toObject = "+ rs + ";");
alert(toObject.message);
Swift 4+
protocol Singleton: class {
static var sharedInstance: Self { get }
}
final class Kraken: Singleton {
static let sharedInstance = Kraken()
private init() {}
}
Could you not just do this:
var codeToExecute = "My.Namespace.functionName()";
var tmpFunc = new Function(codeToExecute);
tmpFunc();
You can also execute any other JavaScript using this method.
if you aren't yet using .net 4.5:
/// <summary>
/// TODO: AFTER WE UPGRADE TO .NET 4.5 THIS WILL NO LONGER BE NECESSARY.
/// </summary>
public class EmailAnnotation : RegularExpressionAttribute
{
static EmailAnnotation()
{
DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(EmailAnnotation), typeof(RegularExpressionAttributeAdapter));
}
/// <summary>
/// from: http://stackoverflow.com/a/6893571/984463
/// </summary>
public EmailAnnotation()
: base(@"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*"
+ "@"
+ @"((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$") { }
public override string FormatErrorMessage(string name)
{
return "E-mail is not valid";
}
}
Then you can do this:
public class ContactEmailAddressDto
{
public int ContactId { get; set; }
[Required]
[Display(Name = "New Email Address")]
[EmailAnnotation] //**<----- Nifty.**
public string EmailAddressToAdd { get; set; }
}
With a \
before a Class declaration you are calling the root namespace:
$now = \Carbon\Carbon::now()->timestamp;
otherwise it looks for it at the current namespace declared at the beginning of the class. other solution is to use it:
use Carbon\Carbon
$now = Carbon::now()->timestamp;
you can even assign it an alias:
use Carbon\Carbon as Time;
$now = Time::now()->timestamp;
hope it helps.
To view database roles assigned to users, you can use sys.database_role_members
The following query returns the members of the database roles.
SELECT DP1.name AS DatabaseRoleName,
isnull (DP2.name, 'No members') AS DatabaseUserName
FROM sys.database_role_members AS DRM
RIGHT OUTER JOIN sys.database_principals AS DP1
ON DRM.role_principal_id = DP1.principal_id
LEFT OUTER JOIN sys.database_principals AS DP2
ON DRM.member_principal_id = DP2.principal_id
WHERE DP1.type = 'R'
ORDER BY DP1.name;
Just edit the file "c:\wamp\alias\phpmyadmin.conf"
like this
<Directory "C:/wamp64/apps/phpmyadmin4.5.5.1/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
If you are using bootstrap that will be the problem. If you want to use same bootstrap file in two locations use it below the header section .(example - inside body)
Note : "specially when you use html editors. "
Thank you.
If it's maintainable to use those 2 properties, you could:
bool alreadyExists = myList.Any(x=> x.Foo=="ooo" && x.Bar == "bat");
The import line should be:
import React, { Component } from 'react';
Note the uppercase R for React.
With webpack you can put env-specific config into the externals
field in webpack.config.js
externals: {
'Config': JSON.stringify(process.env.NODE_ENV === 'production' ? {
serverUrl: "https://myserver.com"
} : {
serverUrl: "http://localhost:8090"
})
}
If you want to store the configs in a separate JSON file, that's possible too, you can require that file and assign to Config
:
externals: {
'Config': JSON.stringify(process.env.NODE_ENV === 'production' ? require('./config.prod.json') : require('./config.dev.json'))
}
Then in your modules, you can use the config:
var Config = require('Config')
fetchData(Config.serverUrl + '/Enterprises/...')
For React:
import Config from 'Config';
axios.get(this.app_url, {
'headers': Config.headers
}).then(...);
Not sure if it covers your use case but it's been working pretty well for us.
A variation. Produces an error if line number is greater than number of lines.
string GetLine(string fileName, int lineNum)
{
using (StreamReader sr = new StreamReader(fileName))
{
string line;
int count = 1;
while ((line = sr.ReadLine()) != null)
{
if(count == lineNum)
{
return line;
}
count++;
}
}
return "line number is bigger than number of lines";
}
Try this, you will know the difference between change and modify,
ALTER TABLE table_name CHANGE curr_column_name new_column_name new_column_datatype [constraints]
ALTER TABLE table_name MODIFY column_name new_column_datatype [constraints]
CHANGE
.MODIFY
. You cannot change the name of the column using this statement.Hope, I explained well in detail.
Create a local variable in your class that extends Thread
or implements Runnable
.
public class Extractor extends Thread {
public String webpage = "";
public Extractor(String w){
webpage = w;
}
public void setWebpage(String l){
webpage = l;
}
@Override
public void run() {// l is link
System.out.println(webpage);
}
public String toString(){
return "Page: "+webpage;
}}
This way, you can pass a variable when you run it.
Extractor e = new Extractor("www.google.com");
e.start();
The output:
"www.google.com"
I am not sure if this helps but I had the same problem.
You are using springSecurityFilterChain with CSRF protection. That means you have to send a token when you send a form via POST request. Try to add the next input to your form:
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
Your code works as is for me. I'm verifying this by using netcat on Linux.
Using netcat, I can do nc -ul 127.0.0.1 5005
which will listen for packets at:
That being said, here's the output that I see when I run your script, while having netcat running.
[9:34am][wlynch@watermelon ~] nc -ul 127.0.0.1 5005
Hello, World!
If you are looking for a built-in Java two-element tuple, try AbstractMap.SimpleEntry
.
Based on the answer of @macetw I print the exception directly to stderr in a decorator.
Python 3
from functools import wraps
from sys import stderr
from traceback import format_exc
from typing import Callable, Collection, Any, Mapping
def force_error_output(func: Callable):
@wraps(func)
def forced_error_output(*args: Collection[Any], **kwargs: Mapping[str, Any]):
nonlocal func
try:
func(*args, **kwargs)
except Exception as exception:
stderr.write(format_exc())
stderr.write("\n")
stderr.flush()
raise exception
return forced_error_output
Python 2
from functools import wraps
from sys import stderr
from traceback import format_exc
def force_error_output(func):
@wraps(func)
def forced_error_output(*args, **kwargs):
try:
func(*args, **kwargs)
except Exception as exception:
stderr.write(format_exc())
stderr.write("\n")
stderr.flush()
raise exception
return forced_error_output
Then in your worker just use the decorator
@force_error_output
def da_worker(arg1: int, arg2: str):
pass
If you want to do it without cli, you can do it fully on Github website.
New pull request
.Create new pull request
.The warning is a reminder that virtual members are likely to be overridden on derived class. In that case whatever the parent class did to a virtual member will be undone or changed by overriding child class. Look at the small example blow for clarity
The parent class below attempts to set value to a virtual member on its constructor. And this will trigger Re-sharper warning, let see on code:
public class Parent
{
public virtual object Obj{get;set;}
public Parent()
{
// Re-sharper warning: this is open to change from
// inheriting class overriding virtual member
this.Obj = new Object();
}
}
The child class here overrides the parent property. If this property was not marked virtual the compiler would warn that the property hides property on the parent class and suggest that you add 'new' keyword if it is intentional.
public class Child: Parent
{
public Child():base()
{
this.Obj = "Something";
}
public override object Obj{get;set;}
}
Finally the impact on use, the output of the example below abandons the initial value set by parent class constructor. And this is what Re-sharper attempts to to warn you, values set on the Parent class constructor are open to be overwritten by the child class constructor which is called right after the parent class constructor.
public class Program
{
public static void Main()
{
var child = new Child();
// anything that is done on parent virtual member is destroyed
Console.WriteLine(child.Obj);
// Output: "Something"
}
}
Gmail requires port 465, and also it's the code from phpmailer :)
This one more version - this will help in generic
Public strSubTag As String
Public iStartCol As Integer
Public iEndCol As Integer
Public strSubTag2 As String
Public iStartCol2 As Integer
Public iEndCol2 As Integer
Sub Create()
Dim strFilePath As String
Dim strFileName As String
'ThisWorkbook.Sheets("Sheet1").Range("C3").Activate
'strTag = ActiveCell.Offset(0, 1).Value
strFilePath = ThisWorkbook.Sheets("Sheet1").Range("B4").Value
strFileName = ThisWorkbook.Sheets("Sheet1").Range("B5").Value
strSubTag = ThisWorkbook.Sheets("Sheet1").Range("F3").Value
iStartCol = ThisWorkbook.Sheets("Sheet1").Range("F4").Value
iEndCol = ThisWorkbook.Sheets("Sheet1").Range("F5").Value
strSubTag2 = ThisWorkbook.Sheets("Sheet1").Range("G3").Value
iStartCol2 = ThisWorkbook.Sheets("Sheet1").Range("G4").Value
iEndCol2 = ThisWorkbook.Sheets("Sheet1").Range("G5").Value
Dim iCaptionRow As Integer
iCaptionRow = ThisWorkbook.Sheets("Sheet1").Range("B3").Value
'strFileName = ThisWorkbook.Sheets("Sheet1").Range("B4").Value
MakeXML iCaptionRow, iCaptionRow + 1, strFilePath, strFileName
End Sub
Sub MakeXML(iCaptionRow As Integer, iDataStartRow As Integer, sOutputFilePath As String, sOutputFileName As String)
Dim Q As String
Dim sOutputFileNamewithPath As String
Q = Chr$(34)
Dim sXML As String
'sXML = sXML & "<rows>"
' ''--determine count of columns
Dim iColCount As Integer
iColCount = 1
While Trim$(Cells(iCaptionRow, iColCount)) > ""
iColCount = iColCount + 1
Wend
Dim iRow As Integer
Dim iCount As Integer
iRow = iDataStartRow
iCount = 1
While Cells(iRow, 1) > ""
'sXML = sXML & "<row id=" & Q & iRow & Q & ">"
sXML = "<?xml version=" & Q & "1.0" & Q & " encoding=" & Q & "UTF-8" & Q & "?>"
For iCOl = 1 To iColCount - 1
If (iStartCol = iCOl) Then
sXML = sXML & "<" & strSubTag & ">"
End If
If (iEndCol = iCOl) Then
sXML = sXML & "</" & strSubTag & ">"
End If
If (iStartCol2 = iCOl) Then
sXML = sXML & "<" & strSubTag2 & ">"
End If
If (iEndCol2 = iCOl) Then
sXML = sXML & "</" & strSubTag2 & ">"
End If
sXML = sXML & "<" & Trim$(Cells(iCaptionRow, iCOl)) & ">"
sXML = sXML & Trim$(Cells(iRow, iCOl))
sXML = sXML & "</" & Trim$(Cells(iCaptionRow, iCOl)) & ">"
Next
'sXML = sXML & "</row>"
Dim nDestFile As Integer, sText As String
''Close any open text files
Close
''Get the number of the next free text file
nDestFile = FreeFile
sOutputFileNamewithPath = sOutputFilePath & sOutputFileName & iCount & ".XML"
''Write the entire file to sText
Open sOutputFileNamewithPath For Output As #nDestFile
Print #nDestFile, sXML
iRow = iRow + 1
sXML = ""
iCount = iCount + 1
Wend
'sXML = sXML & "</rows>"
Close
End Sub
Set the PGPASSWORD environment variable inside the script before calling psql
PGPASSWORD=pass1234 psql -U MyUsername myDatabaseName
For reference, see http://www.postgresql.org/docs/current/static/libpq-envars.html
Edit
Since Postgres 9.2 there is also the option to specify a connection string or URI that can contain the username and password.
Using that is a security risk because the password is visible in plain text when looking at the command line of a running process e.g. using ps
(Linux), ProcessExplorer (Windows) or similar tools, by other users.
See also this question on Database Administrators
This is the way i calculated the slope: Source: http://classroom.synonym.com/calculate-trendline-2709.html
class Program
{
public double CalculateTrendlineSlope(List<Point> graph)
{
int n = graph.Count;
double a = 0;
double b = 0;
double bx = 0;
double by = 0;
double c = 0;
double d = 0;
double slope = 0;
foreach (Point point in graph)
{
a += point.x * point.y;
bx = point.x;
by = point.y;
c += Math.Pow(point.x, 2);
d += point.x;
}
a *= n;
b = bx * by;
c *= n;
d = Math.Pow(d, 2);
slope = (a - b) / (c - d);
return slope;
}
}
class Point
{
public double x;
public double y;
}
Do you want an 'int' that looks like 20110425171213? In which case you'd be better off ToString with the appropriate format (something like 'yyyyMMddHHmmss') and then casting the string to an integer (or a long, unsigned int as it will be way more than 32 bits).
If you want an actual numeric value (the number of seconds since the year 0) then that's a very different calculation, e.g.
result = second
result += minute * 60
result += hour * 60 * 60
result += day * 60 * 60 * 24
etc.
But you'd be better off using Ticks.
It's usually good enough - unless you're programming assembly - to envisage a pointer containing a numeric memory address, with 1 referring to the second byte in the process's memory, 2 the third, 3 the fourth and so on....
When you want to access the data/value in the memory that the pointer points to - the contents of the address with that numerical index - then you dereference the pointer.
Different computer languages have different notations to tell the compiler or interpreter that you're now interested in the pointed-to object's (current) value - I focus below on C and C++.
Consider in C, given a pointer such as p
below...
const char* p = "abc";
...four bytes with the numerical values used to encode the letters 'a', 'b', 'c', and a 0 byte to denote the end of the textual data, are stored somewhere in memory and the numerical address of that data is stored in p
. This way C encodes text in memory is known as ASCIIZ.
For example, if the string literal happened to be at address 0x1000 and p
a 32-bit pointer at 0x2000, the memory content would be:
Memory Address (hex) Variable name Contents
1000 'a' == 97 (ASCII)
1001 'b' == 98
1002 'c' == 99
1003 0
...
2000-2003 p 1000 hex
Note that there is no variable name/identifier for address 0x1000, but we can indirectly refer to the string literal using a pointer storing its address: p
.
To refer to the characters p
points to, we dereference p
using one of these notations (again, for C):
assert(*p == 'a'); // The first character at address p will be 'a'
assert(p[1] == 'b'); // p[1] actually dereferences a pointer created by adding
// p and 1 times the size of the things to which p points:
// In this case they're char which are 1 byte in C...
assert(*(p + 1) == 'b'); // Another notation for p[1]
You can also move pointers through the pointed-to data, dereferencing them as you go:
++p; // Increment p so it's now 0x1001
assert(*p == 'b'); // p == 0x1001 which is where the 'b' is...
If you have some data that can be written to, then you can do things like this:
int x = 2;
int* p_x = &x; // Put the address of the x variable into the pointer p_x
*p_x = 4; // Change the memory at the address in p_x to be 4
assert(x == 4); // Check x is now 4
Above, you must have known at compile time that you would need a variable called x
, and the code asks the compiler to arrange where it should be stored, ensuring the address will be available via &x
.
In C, if you have a variable that is a pointer to a structure with data members, you can access those members using the ->
dereferencing operator:
typedef struct X { int i_; double d_; } X;
X x;
X* p = &x;
p->d_ = 3.14159; // Dereference and access data member x.d_
(*p).d_ *= -1; // Another equivalent notation for accessing x.d_
To use a pointer, a computer program also needs some insight into the type of data that is being pointed at - if that data type needs more than one byte to represent, then the pointer normally points to the lowest-numbered byte in the data.
So, looking at a slightly more complex example:
double sizes[] = { 10.3, 13.4, 11.2, 19.4 };
double* p = sizes;
assert(p[0] == 10.3); // Knows to look at all the bytes in the first double value
assert(p[1] == 13.4); // Actually looks at bytes from address p + 1 * sizeof(double)
// (sizeof(double) is almost always eight bytes)
++p; // Advance p by sizeof(double)
assert(*p == 13.4); // The double at memory beginning at address p has value 13.4
*(p + 2) = 29.8; // Change sizes[3] from 19.4 to 29.8
// Note earlier ++p and + 2 here => sizes[3]
Sometimes you don't know how much memory you'll need until your program is running and sees what data is thrown at it... then you can dynamically allocate memory using malloc
. It is common practice to store the address in a pointer...
int* p = (int*)malloc(sizeof(int)); // Get some memory somewhere...
*p = 10; // Dereference the pointer to the memory, then write a value in
fn(*p); // Call a function, passing it the value at address p
(*p) += 3; // Change the value, adding 3 to it
free(p); // Release the memory back to the heap allocation library
In C++, memory allocation is normally done with the new
operator, and deallocation with delete
:
int* p = new int(10); // Memory for one int with initial value 10
delete p;
p = new int[10]; // Memory for ten ints with unspecified initial value
delete[] p;
p = new int[10](); // Memory for ten ints that are value initialised (to 0)
delete[] p;
See also C++ smart pointers below.
Often a pointer may be the only indication of where some data or buffer exists in memory. If ongoing use of that data/buffer is needed, or the ability to call free()
or delete
to avoid leaking the memory, then the programmer must operate on a copy of the pointer...
const char* p = asprintf("name: %s", name); // Common but non-Standard printf-on-heap
// Replace non-printable characters with underscores....
for (const char* q = p; *q; ++q)
if (!isprint(*q))
*q = '_';
printf("%s\n", p); // Only q was modified
free(p);
...or carefully orchestrate reversal of any changes...
const size_t n = ...;
p += n;
...
p -= n; // Restore earlier value...
free(p);
In C++, it's best practice to use smart pointer objects to store and manage the pointers, automatically deallocating them when the smart pointers' destructors run. Since C++11 the Standard Library provides two, unique_ptr
for when there's a single owner for an allocated object...
{
std::unique_ptr<T> p{new T(42, "meaning")};
call_a_function(p);
// The function above might throw, so delete here is unreliable, but...
} // p's destructor's guaranteed to run "here", calling delete
...and shared_ptr
for share ownership (using reference counting)...
{
auto p = std::make_shared<T>(3.14, "pi");
number_storage1.may_add(p); // Might copy p into its container
number_storage2.may_add(p); // Might copy p into its container } // p's destructor will only delete the T if neither may_add copied it
In C, NULL
and 0
- and additionally in C++ nullptr
- can be used to indicate that a pointer doesn't currently hold the memory address of a variable, and shouldn't be dereferenced or used in pointer arithmetic. For example:
const char* p_filename = NULL; // Or "= 0", or "= nullptr" in C++
int c;
while ((c = getopt(argc, argv, "f:")) != -1)
switch (c) {
case f: p_filename = optarg; break;
}
if (p_filename) // Only NULL converts to false
... // Only get here if -f flag specified
In C and C++, just as inbuilt numeric types don't necessarily default to 0
, nor bools
to false
, pointers are not always set to NULL
. All these are set to 0/false/NULL when they're static
variables or (C++ only) direct or indirect member variables of static objects or their bases, or undergo zero initialisation (e.g. new T();
and new T(x, y, z);
perform zero-initialisation on T's members including pointers, whereas new T;
does not).
Further, when you assign 0
, NULL
and nullptr
to a pointer the bits in the pointer are not necessarily all reset: the pointer may not contain "0" at the hardware level, or refer to address 0 in your virtual address space. The compiler is allowed to store something else there if it has reason to, but whatever it does - if you come along and compare the pointer to 0
, NULL
, nullptr
or another pointer that was assigned any of those, the comparison must work as expected. So, below the source code at the compiler level, "NULL" is potentially a bit "magical" in the C and C++ languages...
More strictly, initialised pointers store a bit-pattern identifying either NULL
or a (often virtual) memory address.
The simple case is where this is a numeric offset into the process's entire virtual address space; in more complex cases the pointer may be relative to some specific memory area, which the CPU may select based on CPU "segment" registers or some manner of segment id encoded in the bit-pattern, and/or looking in different places depending on the machine code instructions using the address.
For example, an int*
properly initialised to point to an int
variable might - after casting to a float*
- access memory in "GPU" memory quite distinct from the memory where the int
variable is, then once cast to and used as a function pointer it might point into further distinct memory holding machine opcodes for the program (with the numeric value of the int*
effectively a random, invalid pointer within these other memory regions).
3GL programming languages like C and C++ tend to hide this complexity, such that:
If the compiler gives you a pointer to a variable or function, you can dereference it freely (as long as the variable's not destructed/deallocated meanwhile) and it's the compiler's problem whether e.g. a particular CPU segment register needs to be restored beforehand, or a distinct machine code instruction used
If you get a pointer to an element in an array, you can use pointer arithmetic to move anywhere else in the array, or even to form an address one-past-the-end of the array that's legal to compare with other pointers to elements in the array (or that have similarly been moved by pointer arithmetic to the same one-past-the-end value); again in C and C++, it's up to the compiler to ensure this "just works"
Specific OS functions, e.g. shared memory mapping, may give you pointers, and they'll "just work" within the range of addresses that makes sense for them
Attempts to move legal pointers beyond these boundaries, or to cast arbitrary numbers to pointers, or use pointers cast to unrelated types, typically have undefined behaviour, so should be avoided in higher level libraries and applications, but code for OSes, device drivers, etc. may need to rely on behaviour left undefined by the C or C++ Standard, that is nevertheless well defined by their specific implementation or hardware.
int i = 65;
char c = Convert.ToChar(i);
"TypeScript Fundamentals" -- a Pluralsight video-course by Dan Wahlin and John Papa is a really good, presently (March 25, 2016) updated to reflect TypeScript 1.8, introduction to Typescript.
For me the really good features, beside the nice possibilities for intellisense, are the classes, interfaces, modules, the ease of implementing AMD, and the possibility to use the Visual Studio Typescript debugger when invoked with IE.
To summarize: If used as intended, Typescript can make JavaScript programming more reliable, and easier. It can increase the productivity of the JavaScript programmer significantly over the full SDLC.
Well, now I'm using ImageMagick. I save my frames as PNG files and then invoke ImageMagick's convert.exe from Python to create an animated GIF. The nice thing about this approach is I can specify a frame duration for each frame individually. Unfortunately this depends on ImageMagick being installed on the machine. They have a Python wrapper but it looks pretty crappy and unsupported. Still open to other suggestions.
I use this, it works with php...
<span><?php
if (file_exists("image/".$data['img_name'])) {
?>
<img src="image/<?php echo $data['img_name']; ?>" width="100" height="100">
<?php
}else{
echo "Image Not Found";
}>?
</span>
Essentially what the code is doing, is checking for the File. The $data
variable will be used with our array then actually make the desired change. If it isn't found, it will throw an Exception.
There is no built-in method for Node to change the CWD of the underlying shell running the Node process.
You can change the current working directory of the Node process through the command process.chdir()
.
var process = require('process');
process.chdir('../');
When the Node process exists, you will find yourself back in the CWD you started the process in.
The issue arises when the image is not present on the cluster and k8s engine is going to pull the respective registry. k8s Engine enables 3 types of ImagePullPolicy mentioned :
Best Practices : It is always recommended to tag the new image in both docker file as well as k8s deployment file. So That it can pull the new image in container.
Another important thing you need to note with ".addEventListener is not a function" error is that the error might be coming a result of assigning it a wrong object eg consider
let myImages = ['images/pic1.jpg','images/pic2.jpg','images/pic3.jpg','images/pic4.jpg','images/pic5.jpg'];
let i = 0;
while(i < myImages.length){
const newImage = document.createElement('img');
newImage.setAttribute('src',myImages[i]);
thumbBar.appendChild(newImage);
//Code just below will bring the said error
myImages[i].addEventListener('click',fullImage);
//Code just below execute properly
newImage.addEventListener('click',fullImage);
i++;
}
In the code Above I am basically assigning images to a div element in my html dynamically using javascript. I've done this by writing the images in an array and looping them through a while loop and adding all of them to the div element.
I've then added a click event listener for all images.
The code "myImages[i].addEventListener('click',fullImage);" will give you an error of "addEventListener is not a function" because I am chaining an addEventListener to an array object which does not have the addEventListener() function.
However for the code "newImage.addEventListener('click',fullImage);" it executes properly because the newImage object has access the function addEventListener() while the array object does not.
For more clarification follow the link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Not_a_function
Case 1 : Yes, this works fine.
Case 2 : This will fail with the error ORA-01441 : cannot decrease column length because some value is too big.
Share and enjoy.
You should be able to use the /quiet
or /qn
options with msiexec
to perform a silent install.
MSI packages export public properties, which you can set with the PROPERTY=value
syntax on the end of the msiexec
parameters.
For example, this command installs a package with no UI and no reboot, with a log and two properties:
msiexec /i c:\path\to\package.msi /quiet /qn /norestart /log c:\path\to\install.log PROPERTY1=value1 PROPERTY2=value2
You can read the options for msiexec
by just running it with no options from Start -> Run.
You could first build a list of keys to delete, and then iterate over that list deleting them.
dict = {'one' : 1, 'two' : 2, 'three' : 3, 'four' : 4}
delete = []
for k,v in dict.items():
if v%2 == 1:
delete.append(k)
for i in delete:
del dict[i]
The simple answer is that arrays are ALWAYS passed by reference and the int arg[] simply lets the compiler know to expect an array
The variable pCv is of type VARCHAR2 so when you concat the insert you aren't putting it inside single quotes:
EXECUTE IMMEDIATE 'INSERT INTO M'||pNum||'GR (CV, SUP, IDM'||pNum||') VALUES('''||pCv||''', '||pSup||', '||pIdM||')';
Additionally the error ORA-06512 raise when you are trying to insert a value too large in a column. Check the definiton of the table M_pNum_GR and the parameters that you are sending. Just for clarify if you try to insert the value 100 on a NUMERIC(2) field the error will raise.
//Delete all records of table
db.execSQL("DELETE FROM " + TABLE_NAME);
//Reset the auto_increment primary key if you needed
db.execSQL("UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME=" + TABLE_NAME);
//For go back free space by shrinking sqlite file
db.execSQL("VACUUM");
just add your script like this:
<script src="/js/intlTelInput.min.js" charset="utf-8"></script>
Ok I finally worked this out. This is using TortoiseHg on Windows. If you're not using that you can do it on the command line.
hggit
:Open a command line, enter an empty directory.
git init --bare .git
(If you don't use a bare repo you'll get an error like abort: git remote error: refs/heads/master failed to update
cd
to your Mercurial repository.
hg bookmarks hg
hg push c:/path/to/your/git/repo
In the Git directory: git config --bool core.bare false
(Don't ask me why. Something about "work trees". Git is seriously unfriendly. I swear writing the actual code is easier than using Git.)
Hopefully it will work and then you can push from that new git repo to a non-bare one.
As @Raheel Answered it will fine but if you are working with Laravel 7/6
Then Eloquent whereIn
Query.
Example1:
$users = User::wherein('id',[1,2,3])->get();
Example2:
$users = DB::table('users')->whereIn('id', [1, 2, 3])->get();
Example3:
$ids = [1,2,3];
$users = User::wherein('id',$ids)->get();
you can write the function in a separate file (say common-functions.php) and include it wherever needed.
function getEmployeeFullName($employeeId) {
// Write code to return full name based on $employeeId
}
You can include common-functions.php in another file as below.
include('common-functions.php');
echo 'Name of first employee is ' . getEmployeeFullName(1);
You can include any number of files to another file. But including comes with a little performance cost. Therefore include only the files which are really required.
It looks like you have a 64bit arch, fine -- but a 32bit version of the .NET runtime and/or a 32bit version of Windows.
And as such, the address space available to your process is still the same, it has not changed from your previous setup.
Upgrade to both a 64bit OS and a 64bit .NET version ;)
This would be the shortest way to sum up int
type array (for long
array LongStream
, for double
array DoubleStream
and so forth). Not all the primitive integer or floating point types have the Stream
implementation though.
IntStream.of(integers).sum();
Yes, you could make an indexer on your Record class that maps from the property name to the correct property. This would keep all the binding from property name to property in one place eg:
public class Record
{
public string ItemType { get; set; }
public string this[string propertyName]
{
set
{
switch (propertyName)
{
case "itemType":
ItemType = value;
break;
// etc
}
}
}
}
Alternatively, as others have mentioned, use reflection.
Apparently anonymous functions cannot be serialized.
Example
$function = function () {
return "ABC";
};
serialize($function); // would throw error
From your code you are using Closure:
$callback = function () // <---------------------- Issue
{
return 'ZendMail_' . microtime(true) . '.tmp';
};
Solution 1 : Replace with a normal function
Example
function emailCallback() {
return 'ZendMail_' . microtime(true) . '.tmp';
}
$callback = "emailCallback" ;
Solution 2 : Indirect method call by array variable
If you look at http://docs.mnkras.com/libraries_23rdparty_2_zend_2_mail_2_transport_2file_8php_source.html
public function __construct($options = null)
63 {
64 if ($options instanceof Zend_Config) {
65 $options = $options->toArray();
66 } elseif (!is_array($options)) {
67 $options = array();
68 }
69
70 // Making sure we have some defaults to work with
71 if (!isset($options['path'])) {
72 $options['path'] = sys_get_temp_dir();
73 }
74 if (!isset($options['callback'])) {
75 $options['callback'] = array($this, 'defaultCallback'); <- here
76 }
77
78 $this->setOptions($options);
79 }
You can use the same approach to send the callback
$callback = array($this,"aMethodInYourClass");
sumr
is implemented in terms of foldRight
:
final def sumr(implicit A: Monoid[A]): A = F.foldRight(self, A.zero)(A.append)
foldRight
is not always tail recursive, so you can overflow the stack if the collection is too long. See Why foldRight and reduceRight are NOT tail recursive? for some more discussion of when this is or isn't true.
The official answer from Facebook (http://developers.facebook.com/bugs/282710765082535):
Mikhail,
The facebook android sdk no longer supports android 1.5 and 1.6. Please upgrade to the next api version.
Good luck with your implementation.
You can see SNS as a traditional topic which you can have multiple Subscribers. You can have heterogeneous subscribers for one given SNS topic, including Lambda and SQS, for example. You can also send SMS messages or even e-mails out of the box using SNS. One thing to consider in SNS is only one message (notification) is received at once, so you cannot take advantage from batching.
SQS, on the other hand, is nothing but a queue, where you store messages and subscribe one consumer (yes, you can have N consumers to one SQS queue, but it would get messy very quickly and way harder to manage considering all consumers would need to read the message at least once, so one is better off with SNS combined with SQS for this use case, where SNS would push notifications to N SQS queues and every queue would have one subscriber, only) to process these messages. As of Jun 28, 2018, AWS Supports Lambda Triggers for SQS, meaning you don't have to poll for messages any more.
Furthermore, you can configure a DLQ on your source SQS queue to send messages to in case of failure. In case of success, messages are automatically deleted (this is another great improvement), so you don't have to worry about the already processed messages being read again in case you forgot to delete them manually. I suggest taking a look at Lambda Retry Behaviour to better understand how it works.
One great benefit of using SQS is that it enables batch processing. Each batch can contain up to 10 messages, so if 100 messages arrive at once in your SQS queue, then 10 Lambda functions will spin up (considering the default auto-scaling behaviour for Lambda) and they'll process these 100 messages (keep in mind this is the happy path as in practice, a few more Lambda functions could spin up reading less than the 10 messages in the batch, but you get the idea). If you posted these same 100 messages to SNS, however, 100 Lambda functions would spin up, unnecessarily increasing costs and using up your Lambda concurrency.
However, if you are still running traditional servers (like EC2 instances), you will still need to poll for messages and manage them manually.
You also have FIFO SQS queues, which guarantee the delivery order of the messages. SQS FIFO is also supported as an event source for Lambda as of November 2019
Even though there's some overlap in their use cases, both SQS and SNS have their own spotlight.
Use SNS if:
Use SQS if:
Use the DateTime.SpecifyKind
static method.
Creates a new DateTime object that has the same number of ticks as the specified DateTime, but is designated as either local time, Coordinated Universal Time (UTC), or neither, as indicated by the specified DateTimeKind value.
Example:
DateTime dateTime = DateTime.Now;
DateTime other = DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
Console.WriteLine(dateTime + " " + dateTime.Kind); // 6/1/2011 4:14:54 PM Local
Console.WriteLine(other + " " + other.Kind); // 6/1/2011 4:14:54 PM Utc
This version of non-blocking read doesn't require special modules and will work out-of-the-box on majority of Linux distros.
import os
import sys
import time
import fcntl
import subprocess
def async_read(fd):
# set non-blocking flag while preserving old flags
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
# read char until EOF hit
while True:
try:
ch = os.read(fd.fileno(), 1)
# EOF
if not ch: break
sys.stdout.write(ch)
except OSError:
# waiting for data be available on fd
pass
def shell(args, async=True):
# merge stderr and stdout
proc = subprocess.Popen(args, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if async: async_read(proc.stdout)
sout, serr = proc.communicate()
return (sout, serr)
if __name__ == '__main__':
cmd = 'ping 8.8.8.8'
sout, serr = shell(cmd.split())
The answer by retracile should be the closest one, yet it does not work for my case. One insert query just broke in the middle and the export just stopped. Not sure what is the reason. However It works fine during .dump
.
Finally I wrote a tool for the split up the SQL generated from .dump
:
Try this:
if cookie and not cookie.isspace():
# the string is non-empty
else:
# the string is empty
The above takes in consideration the cases where the string is None
or a sequence of white spaces.
I do recommend BarcodeLibrary
Here is a small piece of code of how to use it.
BarcodeLib.Barcode barcode = new BarcodeLib.Barcode()
{
IncludeLabel = true,
Alignment = AlignmentPositions.CENTER,
Width = 300,
Height = 100,
RotateFlipType = RotateFlipType.RotateNoneFlipNone,
BackColor = Color.White,
ForeColor = Color.Black,
};
Image img = barcode.Encode(TYPE.CODE128B, "123456789");
A very simple way if your code is in Python, where I didn't have to install a Python package, is the following:
\documentclass[11pt]{article}
\usepackage{pythonhighlight}
\begin{document}
The following is some Python code
\begin{python}
# A comment
x = [5, 7, 10]
y = 0
for num in x:
y += num
print(y)
\end{python}
\end{document}
Unfortunately, this only works for Python.
$(window).height();
To set anything in the middle you can use CSS.
<style>
#divCentre
{
position: absolute;
left: 50%;
top: 50%;
width: 300px;
height: 400px;
margin-left: -150px;
margin-top: -200px;
}
</style>
<div id="divCentre">I am at the centre</div>
Why not use flash & javascript upload control?
With multiple conditions
<div ng-class="{'class1' : con1 || can2, 'class2' : con3 && con4}">
Hello World!
</div>
To me, this is the most "natural" way to structure such data in JSON, provided that all of the keys are strings.
{
"keyvaluelist": {
"slide0001.html": "Looking Ahead",
"slide0008.html": "Forecast",
"slide0021.html": "Summary"
},
"otherdata": {
"one": "1",
"two": "2",
"three": "3"
},
"anotherthing": "thing1",
"onelastthing": "thing2"
}
I read this as
a JSON object with four elements
element 1 is a map of key/value pairs named "keyvaluelist",
element 2 is a map of key/value pairs named "otherdata",
element 3 is a string named "anotherthing",
element 4 is a string named "onelastthing"
The first element or second element could alternatively be described as objects themselves, of course, with three elements each.
To clarify how the shebang line works for windows, from the 3.7 Python doc:
Set Responsive and User friendly Background
<style>
body {
background: url(image.jpg);
background-size:100%;
background-repeat: no-repeat;
width: 100%;
}
</style>
Try trimming the string to make sure there is no extra white space:
Cursor c = db.rawQuery("SELECT * FROM tbl1 WHERE TRIM(name) = '"+name.trim()+"'", null);
Also use c.moveToFirst()
like @thinksteep mentioned.
This is a complete code for select statements.
SQLiteDatabase db = this.getReadableDatabase();
Cursor c = db.rawQuery("SELECT column1,column2,column3 FROM table ", null);
if (c.moveToFirst()){
do {
// Passing values
String column1 = c.getString(0);
String column2 = c.getString(1);
String column3 = c.getString(2);
// Do something Here with values
} while(c.moveToNext());
}
c.close();
db.close();
I am Using Oracle Database Express Edition 11g Release 2.
Follow the Steps:
Open run SQl Command Line
Step 1: Login as system user
SQL> connect system/tiger
Step 2 : SQL> CREATE USER UserName IDENTIFIED BY Password;
Step 3 : SQL> grant dba to UserName ;
Step 4 : SQL> GRANT UNLIMITED TABLESPACE TO UserName;
Step 5:
SQL> CREATE BIGFILE TABLESPACE TSD_UserName
DATAFILE 'tbs_perm_03.dat'
SIZE 8G
AUTOEXTEND ON;
Open Command Prompt in Windows or Terminal in Ubuntu. Then Type:
Note : if you Use Ubuntu then replace " \" to " /" in path.
Step 6: C:\> imp UserName/password@localhost file=D:\abc\xyz.dmp log=D:\abc\abc_1.log full=y;
Done....
I hope you Find Right solution here.
Thanks.
Why don't you simply use the size()
method on your Collection
to get the number of elements?
Iterator
is just meant to iterate,nothing else.
Basically, ajax request as well as synchronous request sends your document cookies automatically. So, you need to set your cookie to document, not to request. However, your request is cross-domain, and things became more complicated. Basing on this answer, additionally to set document cookie, you should allow its sending to cross-domain environment:
type: "GET",
url: "http://example.com",
cache: false,
// NO setCookies option available, set cookie to document
//setCookies: "lkfh89asdhjahska7al446dfg5kgfbfgdhfdbfgcvbcbc dfskljvdfhpl",
crossDomain: true,
dataType: 'json',
xhrFields: {
withCredentials: true
},
success: function (data) {
alert(data);
});
Use the following function
window.scrollTo(xpos, ypos)
Here xpos is Required. The coordinate to scroll to, along the x-axis (horizontal), in pixels
ypos is also Required. The coordinate to scroll to, along the y-axis (vertical), in pixels
clear:both
makes the element drop below any floated elements that precede it in the document.
You can also use clear:left
or clear:right
to make it drop below only those elements that have been floated left or right.
+------------+ +--------------------+
| | | |
| float:left | | without clear |
| | | |
| | +--------------------+
| | +--------------------+
| | | |
| | | with clear:right |
| | | (no effect here, |
| | | as there is no |
| | | float:right |
| | | element) |
| | | |
| | +--------------------+
| |
+------------+
+---------------------+
| |
| with clear:left |
| or clear:both |
| |
+---------------------+
Create a temporary element, then clone()
and append()
:
$('<div>').append($('#xxx').clone()).html();
100,000 should be fine.
I have (anecdotally) seen people having problems with many millions of files and I have had problems myself with Explorer just not having a clue how to count past 60-something thousand files, but NTFS should be good for the volumes you're talking.
In case you're wondering, the technical (and I hope theoretical) maximum number of files is: 4,294,967,295
You are experiencing this issue for two reasons.
When performing a join in JPQL you must ensure that an underlying association between the entities attempting to be joined exists. In your example, you are missing an association between the User and Area entities. In order to create this association we must add an Area field within the User class and establish the appropriate JPA Mapping. I have attached the source for User below. (Please note I moved the mappings to the fields)
User.java
@Entity
@Table(name="user")
public class User {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="iduser")
private Long idUser;
@Column(name="user_name")
private String userName;
@OneToOne()
@JoinColumn(name="idarea")
private Area area;
public Long getIdUser() {
return idUser;
}
public void setIdUser(Long idUser) {
this.idUser = idUser;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Area getArea() {
return area;
}
public void setArea(Area area) {
this.area = area;
}
}
Once this relationship is established you can reference the area object in your @Query declaration. The query specified in your @Query annotation must follow proper syntax, which means you should omit the on clause. See the following:
@Query("select u.userName from User u inner join u.area ar where ar.idArea = :idArea")
While looking over your question I also made the relationship between the User and Area entities bidirectional. Here is the source for the Area entity to establish the bidirectional relationship.
Area.java
@Entity
@Table(name = "area")
public class Area {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="idarea")
private Long idArea;
@Column(name="area_name")
private String areaName;
@OneToOne(fetch=FetchType.LAZY, mappedBy="area")
private User user;
public Long getIdArea() {
return idArea;
}
public void setIdArea(Long idArea) {
this.idArea = idArea;
}
public String getAreaName() {
return areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
May it's late for the answer. But will be helpful for anyone.
In My case want to call activity from Fragment and setResult back from the fragment.
I have used getContext of Fragment Like.
startActivityForResult(new Intent(getContext(), NextActivity.class), 111);
And Set Result from Fragment
getActivity().setResult(Activity.RESULT_OK);
getActivity().finish();
Now Getting Result to Fragment with
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK && requestCode == 111) {
}
}
Given
std::vector<Rule>& topPriorityRules;
The correct way to remove the first element of the referenced vector is
topPriorityRules.erase(topPriorityRules.begin());
which is exactly what you suggested.
Looks like i need to do iterator overloading.
There is no need to overload an iterator in order to erase first element of std::vector
.
P.S. Vector (dynamic array) is probably a wrong choice of data structure if you intend to erase from the front.
You can now use Modern ECMAScript syntax thanks to V8 Runtime.
You can use includes():
var grade = itemResponse.getResponse();
if(grade.includes("9th")){do something}
There is a library ng-device-detector which makes detecting entities like browser, os easy.
Here is tutorial that explains how to use this library. Detect OS, browser and device in AngularJS
You need to add re-tree.js and ng-device-detector.js scripts into your html
Inject "ng.deviceDetector" as dependency in your module.
Then inject "deviceDetector" service provided by the library into your controller or factory where ever you want the data.
"deviceDetector" contains all data regarding browser, os and device.
I had the same issue, but using Angular + DataTable with a fnDrawCallback
+ row grouping + $compiled nested directives. I placed the $timeout in my fnDrawCallback
function to fix pagination rendering.
Before example, based on row_grouping source:
var myDrawCallback = function myDrawCallbackFn(oSettings){
var nTrs = $('table#result>tbody>tr');
for(var i=0; i<nTrs.length; i++){
//1. group rows per row_grouping example
//2. $compile html templates to hook datatable into Angular lifecycle
}
}
After example:
var myDrawCallback = function myDrawCallbackFn(oSettings){
var nTrs = $('table#result>tbody>tr');
$timeout(function requiredRenderTimeoutDelay(){
for(var i=0; i<nTrs.length; i++){
//1. group rows per row_grouping example
//2. $compile html templates to hook datatable into Angular lifecycle
}
,50); //end $timeout
}
Even a short timeout delay was enough to allow Angular to render my compiled Angular directives.
SELECT *
FROM myTable
WHERE URL = LEFT('mysyte.com/?id=2®ion=0&page=1', LEN(URL))
Or use CHARINDEX http://msdn.microsoft.com/en-us/library/aa258228(v=SQL.80).aspx
For getting a list of int from an enum, use the following. It works!
List<int> listEnumValues = new List<int>();
YourEnumType[] myEnumMembers = (YourEnumType[])Enum.GetValues(typeof(YourEnumType));
foreach ( YourEnumType enumMember in myEnumMembers)
{
listEnumValues.Add(enumMember.GetHashCode());
}
I tried above solution, but the following code help me to close this issue.
if (18 < Build.VERSION.SDK_INT ){
//18 = JellyBean MR2, KITKAT=19
mWeb.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
}
Although @ruakh gave a good answer, I will add some alternatives for completeness:
You could in fact use even var Omega = 'Ω'
in JavaScript, but only if your JavaScript code is:
onclick="var Omega = 'Ω';
alert(Omega)"
or script
element inside an XHTML (or XHTML + XML) document
served with an XML content type.In these cases, the code will be first (before getting passed to the JavaScript interpreter) be parsed by an HTML parser so that character references like Ω
are recognized. The restrictions make this an impractical approach in most cases.
You can also enter the O character as such, as in var Omega = 'O'
, but then the character encoding must allow that, the encoding must be properly declared, and you need software that let you enter such characters. This is a clean solution and quite feasible if you use UTF-8 encoding for everything and are prepared to deal with the issues created by it. Source code will be readable, and reading it, you immediately see the character itself, instead of code notations. On the other hand, it may cause surprises if other people start working with your code.
Using the \u
notation, as in var Omega = '\u03A9'
, works independently of character encoding, and it is in practice almost universal. It can however be as such used only up to U+FFFF, i.e. up to \uffff
, but most characters that most people ever heard of fall into that area. (If you need “higher” characters, you need to use either surrogate pairs or one of the two approaches above.)
You can also construct a character using the String.fromCharCode()
method, passing as a parameter the Unicode number, in decimal as in var Omega = String.fromCharCode(937)
or in hexadecimal as in var Omega = String.fromCharCode(0x3A9)
. This works up to U+FFFF. This approach can be used even when you have the Unicode number in a variable.
use this..
$(".content_box a:not('.button')")
This is what worked for me, even with major DOWN grade:
<Wix ...>
<Product ...>
<Property Id="REINSTALLMODE" Value="amus" />
<MajorUpgrade AllowDowngrades="yes" />
Something like this??
Jsfiddle Demo
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
.searchinput{
display:inline-block;vertical-align: bottom;
width:30%;padding: 5px;padding-right:27px;border:1px solid #ccc;
outline: none;
}
.clearspace{width: 20px;display: inline-block;margin-left:-25px;
}
.clear {
width: 20px;
transition: max-width 0.3s;overflow: hidden;float: right;
display: block;max-width: 0px;
}
.show {
cursor: pointer;width: 20px;max-width:20px;
}
form{white-space: nowrap;}
</style>
</head>
<body>
<form>
<input type="text" class="searchinput">
</form>
<script src="jquery-1.11.3.min.js" type="text/javascript"></script> <script>
$(document).ready(function() {
$("input.searchinput").after('<span class="clearspace"><i class="clear" title="clear">✗</i></span>');
$("input.searchinput").on('keyup input',function(){
if ($(this).val()) {$(".clear").addClass("show");} else {$(".clear").removeClass("show");}
});
$('.clear').click(function(){
$('input.searchinput').val('').focus();
$(".clear").removeClass("show");
});
});
</script>
</body>
</html>
No need to use a macro. Supposing your first string is in A1.
=RIGHT(A1, 4)
Drag this down and you will get your four last characters.
Edit: To be sure, if you ever have sequences like 'ABC DEF' and want the last four LETTERS and not CHARACTERS you might want to use trimspaces()
=RIGHT(TRIMSPACES(A1), 4)
Edit: As per brettdj's suggestion, you may want to check that your string is actually 4-character long or more:
=IF(TRIMSPACES(A1)>=4, RIGHT(TRIMSPACES(A1), 4), TRIMSPACES(A1))
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["Jwt:Key"]));
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
var claims = new[]
{
new Claim(JwtRegisteredClaimNames.Email, model.UserName),
new Claim(JwtRegisteredClaimNames.NameId, model.Id.ToString()),
};
var token = new JwtSecurityToken(_config["Jwt:Issuer"],
_config["Jwt:Issuer"],
claims,
expires: DateTime.Now.AddMinutes(30),
signingCredentials: creds);
Then extract content
var handler = new JwtSecurityTokenHandler();
string authHeader = Request.Headers["Authorization"];
authHeader = authHeader.Replace("Bearer ", "");
var jsonToken = handler.ReadToken(authHeader);
var tokenS = handler.ReadToken(authHeader) as JwtSecurityToken;
var id = tokenS.Claims.First(claim => claim.Type == "nameid").Value;
List<T>.Add
adds a single element. Instead, use List<T>.AddRange
to add multiple values.
Additionally, List<T>.AddRange
takes an IEnumerable<T>
, so you don't need to convert tripDetails
into a List<TripDetails>
, you can pass it directly, e.g.:
tripDetailsCollection.AddRange(tripDetails);
I think the easiest way to match the characters like
\^$.?*|+()[
are using character classes from within R. Consider the following to clean column headers from a data file, which could contain spaces, and punctuation characters:
> library(stringr)
> colnames(order_table) <- str_replace_all(colnames(order_table),"[:punct:]|[:space:]","")
This approach allows us to string character classes to match punctation characters, in addition to whitespace characters, something you would normally have to escape with \\
to detect. You can learn more about the character classes at this cheatsheet below, and you can also type in ?regexp
to see more info about this.
https://www.rstudio.com/wp-content/uploads/2016/09/RegExCheatsheet.pdf
I created an example spreadsheet here of how to do this with simple Excel formulae, and without use of macros (you will need to make your own adjustments for getting rid of the first row, but this should be easy once you figure out how my example spreadsheet works):
If you're running Python 3.3 or better, you can use the clear()
method of list
, which is parallel to clear()
of dict
, set
, deque
and other mutable container types:
alist.clear() # removes all items from alist (equivalent to del alist[:])
As per the linked documentation page, the same can also be achieved with alist *= 0
.
To sum up, there are four equivalent ways to clear a list in-place (quite contrary to the Zen of Python!):
alist.clear() # Python 3.3+
del alist[:]
alist[:] = []
alist *= 0
you have to open a port of the service in you router then try you puplic ip out of your all network cause if you try it from your network , the puplic ip will always redirect you to your router but from the outside it will redirect to the server you have
Netstat tool simply parses some /proc files like /proc/net/tcp and combines it with other files contents. Yep, it's highly platform specific, but for Linux-only solution you can stick with it. Linux kernel documentation describes these files in details so you can find there how to read them.
Please also notice your question is too ambiguous because "port" could also mean serial port (/dev/ttyS* and analogs), parallel port, etc.; I've reused understanding from another answer this is network port but I'd ask you to formulate your questions more accurately.
if you have numbers in list, you can use map
to apply str
to each element:
print ', '.join(map(str, LIST))
^ map
is C code so it's faster than str(i) for i in LIST
You are using an inline table value function. Therefore you must use Select * From function. If you want to use select function() you must use a scalar function.
https://msdn.microsoft.com/fr-fr/library/ms186755%28v=sql.120%29.aspx
smaller-size version:
#register a:link {color: #fff}
another workaround:
var myarray = [];
$("#test").click(function() {
myarray[index]=$("#drop").val();
alert(myarray);
});
i wanted to add all checked checkbox to array. so example, if .each is used:
var vpp = [];
var incr=0;
$('.prsn').each(function(idx) {
if (this.checked) {
var p=$('.pp').eq(idx).val();
vpp[incr]=(p);
incr++;
}
});
//do what ever with vpp array;
You can use forget method on the widget
from tkinter import * root = Tk() b = Button(root, text="Delete me", command=b.forget) b.pack() b['command'] = b.forget root.mainloop()
Almost assuredly there is something wrong with the content that would be inserted into the genfile. Eclipse is not smart enough to show what the problems are or even indicate that there are problems!
Think about the last edit you made to any of the XML or image content - and try to 'rollback' your changes, manually if necessary.
I find that sometimes Eclipse does not like my file names for whatever reason, and I have to change them.
So add to the resources one by one assuring that it all 'works'. When something breaks, just try changing it a little bit until Eclipse accepts it.
You know it's working when the genfile appears - it will do so automatically if there are no problems.
I have been making use of
<script type="text/javascript" src="{{ URL::asset('js/jquery.js') }}"></script>
for javascript and
<link rel="stylesheet" href="{{ URL::asset('css/main.css') }}">
for css, this points to the public directory, so you need to keep your css and js files there.
Another option that should require less "work" for the browser than html()
or children()
:
function isEmpty( el ){
return !el.has('*').length;
}
echo date("l M j, Y",$res1['timep']);
This is really good for converting a unix timestamp to a readable date along with day. Example:
Thursday Jul 7, 2016
You usually should not catch all possible exceptions with try: ... except
as this is overly broad. Just catch those that are expected to happen for whatever reason. If you really must, for example if you want to find out more about some problem while debugging, you should do
try:
...
except Exception as ex:
print ex # do whatever you want for debugging.
raise # re-raise exception.
Looks like the usual suspects like pdfsharp and migradoc are not able to do that (pdfsharp only if you have Acrobat (Reader) installed).
I found here
code ready for copy/paste. It uses the default printer and from what I can see it doesn't even use any libraries, directly sending the pdf bytes to the printer. So I assume the printer also needs to support it, on one 10 year old printer I tested this it worked flawlessly.
Most other approaches - without commercial libraries or applications - require you to draw yourself in the printing device context. Doable but will take a while to figure it out and make it work across printers.
var quit = false;
function something() {
if(quit) {
return;
}
quit = true;
... other code....
}
If you need the result in a date format you can use:
Select Convert(DateTime, Convert(VarChar, GetDate(), 101))
Use FirebaseMessaging instead
FirebaseMessaging.getInstance().getToken()
.addOnCompleteListener(new OnCompleteListener<String>() {
@Override
public void onComplete(@NonNull Task<String> task) {
if (!task.isSuccessful()) {
Log.w(TAG, "Fetching FCM registration token failed", task.getException());
return;
}
// Get new FCM registration token
String token = task.getResult();
// Log and toast
String msg = getString(R.string.msg_token_fmt, token);
Log.d(TAG, msg);
Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
}
});
dir=/home/smith/Desktop/Test
parentdir="$(dirname "$dir")"
Works if there is a trailing slash, too.
Given your original dictionary orig
and the set of entries that you're interested in keys
:
filtered = dict(zip(keys, [orig[k] for k in keys]))
which isn't as nice as delnan's answer, but should work in every Python version of interest. It is, however, fragile to each element of keys
existing in your original dictionary.
Let's say you have one more commit at the bottom (oldest), then this becomes pretty easy:
commit dj374
made changes
commit y4746
made changes
commit k73ud
made changes
commit oldestCommit
made changes
Now, using below will easily server the purpose.
git diff k73ud oldestCommit
Windows Presentation Foundation (WPF)
Next-Generation User Experiences. The Windows Presentation Foundation, WPF, provides a unified framework for building applications and high-fidelity experiences in Windows Vista that blend application UI, documents, and media content. WPF offers developers 2D and 3D graphics support, hardware-accelerated effects, scalability to different form factors, interactive data visualization, and superior content readability.
Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF) is Microsoft’s unified programming model for building service-oriented applications. It enables developers to build secure, reliable, transacted solutions that integrate across platforms and interoperate with existing investments.
Question is a bit old, but easy way is to apply .center-block to button.
this is your first Activity1.
public class Activity1 extends Activity{
private int mRequestCode = 100;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, Activity2.class);
startActivityForResult(intent, mRequestCode);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == mRequestCode && resultCode == RESULT_OK){
String editTextString = data.getStringExtra("editText");
}
}
}
From here you are starting your Activity2.class by using startActivityForResult(mRequestCode, Activity2.class);
Now this is your second Activity, name is Activity2
public class Activity2 extends Activity {
private EditText mEditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//mEditText = (EditText)findViewById(R.id.edit_text);
Intent intent = new Intent();
intent.putExtra("editText", mEditText.getText().toString());
setResult(RESULT_OK, intent);
}
}
Now when you done with your second Activity then you call setResult() method, from onBackPress() or from any button click when your Activity2 will destroy then your Activity1's call back method onActivityResult() will call from there you can get your data from intent..
Hope it will help to you...:)
A little googling, gives me these results:
RewriteEngine On
RewriteBase /
RewriteRule ^index.(.*)?$ http://domain.com/subfolder/ [r=301]This will redirect any attempt to access a file named index.something to your subfolder, whether the file exists or not.
Or try this:
RewriteCond %{HTTP_HOST} !^www.sample.com$ [NC]
RewriteRule ^(.*)$ %{HTTP_HOST}/samlse/$1 [R=301,L]
I haven't done much redirect in the .htaccess file, so I'm not sure if this will work.
Although I'm sure this won't be accepted as the answer to this very old question, I came here looking for a way to do this and this is how I solved the problem.
I created a demonstration here at codepen.io.
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js" type="text/javascript"></script>
<script src="https://cdn.rawgit.com/mckamey/countdownjs/master/countdown.min.js" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.0.0.min.js" type="text/javascript"></script>
<div>
The time is now: <span class="now"></span>, a timer will go off <span class="duration"></span> at <span class="then"></span>
</div>
<div class="difference">The timer is set to go off <span></span></div>
<div class="countdown"></div>
var now = moment(); // new Date().getTime();
var then = moment().add(60, 'seconds'); // new Date(now + 60 * 1000);
$(".now").text(moment(now).format('h:mm:ss a'));
$(".then").text(moment(then).format('h:mm:ss a'));
$(".duration").text(moment(now).to(then));
(function timerLoop() {
$(".difference > span").text(moment().to(then));
$(".countdown").text(countdown(then).toString());
requestAnimationFrame(timerLoop);
})();
The time is now: 5:29:35 pm, a timer will go off in a minute at 5:30:35 pm
The timer is set to go off in a minute
1 minute
Note: 2nd line above updates as per momentjs and 3rd line above updates as per countdownjs and all of this is animated at about ~60FPS because of requestAnimationFrame()
Alternatively you can just look at this code snippet:
var now = moment(); // new Date().getTime();_x000D_
var then = moment().add(60, 'seconds'); // new Date(now + 60 * 1000);_x000D_
_x000D_
$(".now").text(moment(now).format('h:mm:ss a'));_x000D_
$(".then").text(moment(then).format('h:mm:ss a'));_x000D_
$(".duration").text(moment(now).to(then));_x000D_
(function timerLoop() {_x000D_
$(".difference > span").text(moment().to(then));_x000D_
$(".countdown").text(countdown(then).toString());_x000D_
requestAnimationFrame(timerLoop);_x000D_
})();_x000D_
_x000D_
// CountdownJS: http://countdownjs.org/_x000D_
// Rawgit: http://rawgit.com/_x000D_
// MomentJS: http://momentjs.com/_x000D_
// jQuery: https://jquery.com/_x000D_
// Light reading about the requestAnimationFrame pattern:_x000D_
// http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/_x000D_
// https://css-tricks.com/using-requestanimationframe/
_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js" type="text/javascript"></script>_x000D_
<script src="https://cdn.rawgit.com/mckamey/countdownjs/master/countdown.min.js" type="text/javascript"></script>_x000D_
<script src="https://code.jquery.com/jquery-3.0.0.min.js" type="text/javascript"></script>_x000D_
<div>_x000D_
The time is now: <span class="now"></span>,_x000D_
</div>_x000D_
<div>_x000D_
a timer will go off <span class="duration"></span> at <span class="then"></span>_x000D_
</div>_x000D_
<div class="difference">The timer is set to go off <span></span></div>_x000D_
<div class="countdown"></div>
_x000D_
requestAnimationFrame()
- use this for animation rather than setInterval()
.Additionally here is some light reading about the requestAnimationFrame()
pattern:
I found the requestAnimationFrame()
pattern to be much a more elegant solution than the setInterval()
pattern.
Try Foo.instance_methods.include? :bar
after encountering the same issue, I ended up on this thread. For future generation's sake: The current up-most voted answer, attempts to bind "this" to a variable in order to avoid changing the context when invoking the function which is defined in the setTimeout.
An alternate and more recommended approach(using Vue.JS 2.2 & ES6) is to use an arrow function in order to bind the context to the parent (Basically "addToBasket"'s "this" and the "setTimeout"'s "this" would still refer to the same object):
addToBasket: function(){
item = this.photo;
this.$http.post('/api/buy/addToBasket', item);
this.basketAddSuccess = true;
setTimeout(() => {
this.basketAddSuccess = false;
}, 2000);
}
This is a useful article which graphically shows the explanation of the reset command.
https://git-scm.com/docs/git-reset
Reset --hard can be quite dangerous as it overwrites your working copy without checking, so if you haven't commited the file at all, it is gone.
As for Source tree, there is no way I know of to undo commits. It would most likely use reset under the covers anyway
I played with customizing the colors. I went with the yellow text/blue background I've liked from Turbo Pascal. The problem I ran into was it let you set the colors of the editors but then the other views like Package Explorer or Navigator stayed with the default black-on-white colors. I'm sure you could do it programatically but there are waaaay to many settings for my patience.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>_x000D_
<script>_x000D_
$(document).ready(function(){_x000D_
var form=$("#myForm");_x000D_
$("#smt").click(function(){_x000D_
$.ajax({_x000D_
type:"POST",_x000D_
url:form.attr("action"),_x000D_
data:form.serialize(),_x000D_
success: function(response){_x000D_
console.log(response); _x000D_
}_x000D_
});_x000D_
});_x000D_
});_x000D_
</script>
_x000D_
This is perfect code , there is no problem.. You have to check that in php script.
The steps are as follows;
git fetch origin
or git fetch --all
, this will fetch all the remote branches to your local and then this the second option you can proced with.
git checkout --track origin/<The_remote_branch you want to switch over>
Then work on this branch and you can verify whether you are on that branch or not by typing
git branch
It displayes the branch you currently in.
On the 1st iteration of the outer loop (i = 1), the inner loop will iterate 1 times
On the 2nd iteration of the outer loop (i = 2), the inner loop will iterate 2 time
On the 3rd iteration of the outer loop (i = 3), the inner loop will iterate 3 times
.
.
On the FINAL iteration of the outer loop (i = n), the inner loop will
iterate n times
So, the total number of times the statements in the inner loop will be executed will be equal to the sum of the integers from 1 to n, which is:
((n)*n) / 2 = (n^2)/2 = O(n^2) times
if you have null value then in doing mathematical operation you will get this error to resolve it use df[~df['x'].isnull()]df[['x']].astype(int)
if you want your dataset to be unchangeable.
Use array.prototype.map and array.prototype.some:
var values = [
{ name: 'someName1' },
{ name: 'someName2' },
{ name: 'someName4' },
{ name: 'someName2' }
];
var valueArr = values.map(function(item){ return item.name });
var isDuplicate = valueArr.some(function(item, idx){
return valueArr.indexOf(item) != idx
});
console.log(isDuplicate);
One way to be 100% sure that you get a number with 2 decimals:
(Math.round(num*100)/100).toFixed(2)
If this causes rounding errors, you can use the following as James has explained in his comment:
(Math.round((num * 1000)/10)/100).toFixed(2)
You can simply write:
char c = (char) 2;
or
char c = Convert.ToChar(2);
or more complex option for ASCII encoding only
char[] characters = System.Text.Encoding.ASCII.GetChars(new byte[]{2});
char c = characters[0];
If any one want it in Java, Here is my Answer, For this you have to call Another Thread.
DEMO: http://jsfiddle.net/kF2uK/2/
function buttonState(){
$("input").each(function(){
$('#register').attr('disabled', 'disabled');
if($(this).val() == "" ) return false;
$('#register').attr('disabled', '');
})
}
$(function(){
$('#register').attr('disabled', 'disabled');
$('input').change(buttonState);
})
Although this does not help you right away, there is an alternative that can work with both Unix (fcntl) and Windows (win32 api calls), called: portalocker
It describes itself as a cross-platform (posix/nt) API for flock-style file locking for Python. It basically maps fcntl to win32 api calls.
The original code at http://code.activestate.com/recipes/65203/ can now be installed as a separate package - https://pypi.python.org/pypi/portalocker
take a look at shutil
. shutil.copyfile(src, dst)
will copy a file to another file.
Note that shutil.copyfile
will not create directories that do not already exist. for that, use os.makedirs
function random_numbers($digits) {
$min = pow(10, $digits - 1);
$max = pow(10, $digits) - 1;
return mt_rand($min, $max);
}
Tested here.
I had this issue on a newly created solution that used existing projects. For some reason, one project could not "see" one other project, even though it had the same reference as every other project, and the referenced project was also building. I suspect that it was failing to detect something having to do with multiple target frameworks, because it was building in one framework but not the other.
Cleaning and rebuilding didn't work, and restarting VS didn't work.
What ended up working was opening a "Developer Command Prompt for VS 2019" and then issuing a msbuild MySolution.sln
command. This completed successfully, and afterwards VS started building successfully also.
Create unique constraint that two numbers together CANNOT together be repeated:
ALTER TABLE someTable
ADD UNIQUE (col1, col2)
You can use:
string regExp = "\\W";
This is equivalent to Daniel's "[^a-zA-Z0-9]
"
\W matches any nonword character. Equivalent to the Unicode categories [^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}]
.
Yess, possible with conditions:
If you have your app installed in the user phone and a server app communicating with this app, and there at last one of location service providers activated in the user phone, and some horrible android permissions!
In most of android phones there 3 location providers that can give exact location (GPS_PROVIDER 1m) or estimated (NETWORK_PROVIDER around 2-20m) and PASSIVE_PROVIDER (more in LocationManager official documentation).
1* App sends SMS to user's phone
Yess, can be server app or you create an android app if you want something automated, so you can do it manually by sending SMS from your default SMS app! I use Kannel: Open Source WAP and SMS Gateway and here (lot of APIs to send SMS )
2* App receives SMS at user's phone from the SMS sender
Yess, you can get all received SMS, and you can filter them by sender phone number! and do some actions when your specified sms received, basic tuto here (i do some actions according to the content of my SMS)
3* App gets location coordinates of the user's phone
Yess, you can get actual user coordinates easily if one of location providers is activated, so you can get last known location when the user have activated one of location providers, if those disabled or the phone don't have GPS hardware you can use Open Cell Id api to get the nearest cell coordinates(10m-10Km) or Loc8 api but those not available in all around the world, and some apps use IP location apis to get the country, city and province, here the simplest way to get current user location.
4* App sends location coordinates to the SMS sender via SMS
Yess, you can get sender phone number and send user location, immediately when SMS received or at specified times in the day.
(Those 4 yesses for you :) )
Viber and other apps that access to users locations, identify there users by there phone numbers by obligating them to send SMS to the server app to create an account and activate the free service (Ex:VOIP) , and lunch a service that can:
And your application users must accept all of that when installing it, of corse i don't gonna install apps like this because i read permissions before installing :) and permissions maybe something like that:
<uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission>
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<-- and more if you wanna more -->
The final user will accept for something like that (those permissions of an android app u asked about):
This app has access to these permissions:
Your accounts -create accounts and set passwords -find accounts on the device -add or remove accounts -use accounts on the device -read Google service configuration
Your location -approximate location (network-based) -precise location (GPS and network-based)
Your messages -receive text messages (SMS) -send SMS messages -edit your text messages (SMS or MMS) -read your text messages (SMS or MMS)
Network communication -receive data from Internet -full network access -view Wi-Fi connections -view network connections -change network connectivity
Phone calls -read phone status and identity -directly call phone numbers
Storage -modify or delete the contents of your USB storage
Your applications information -retrieve running apps -close other apps -run at startup
Bluetooth -pair with Bluetooth devices -access Bluetooth settings
Camera -take pictures and videos
Other Application UI -draw over other apps
Microphone -record audio
Lock screen -disable your screen lock
Your social information -read your contacts -modify your contacts -read call log -write call log -read your social stream -write to your social stream
Development tools -read sensitive log data
System tools -modify system settings -send sticky broadcast -test access to protected storage
Affects battery -control vibration -prevent device from sleeping
Audio settings -change your audio settings
Sync Settings -read sync settings -toggle sync on and off -read sync statistics
Wallpaper -set wallpaper
There is a useful difference between call
and start /wait
when calling regsvr32.exe /s
for example, also referenced by Gary in
in his answer to how-do-i-get-the-application-exit-code-from-a-windows-command-line
call regsvr32.exe /s broken.dll
echo %errorlevel%
will always return 0 but
start /wait regsvr32.exe /s broken.dll
echo %errorlevel%
will return the error level from regsvr32.exe
I solve with this:
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient("HttpClientWithSSLUntrusted").ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
{
ClientCertificateOptions = ClientCertificateOption.Manual,
ServerCertificateCustomValidationCallback =
(httpRequestMessage, cert, cetChain, policyErrors) =>
{
return true;
}
});
YourService.cs
public UserService(IHttpClientFactory clientFactory, IOptions<AppSettings> appSettings)
{
_appSettings = appSettings.Value;
_clientFactory = clientFactory;
}
var request = new HttpRequestMessage(...
var client = _clientFactory.CreateClient("HttpClientWithSSLUntrusted");
HttpResponseMessage response = await client.SendAsync(request);
There is another one way, in which you can get indexPath of the cell where your button was pressed:
using usual action selector like:
UIButton *btn = ....;
[btn addTarget:self action:@selector(yourFunction:) forControlEvents:UIControlEventTouchUpInside];
and then in in yourFunction:
- (void) yourFunction:(id)sender {
UIButton *button = sender;
CGPoint center = button.center;
CGPoint rootViewPoint = [button.superview convertPoint:center toView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:rootViewPoint];
//the rest of your code goes here
..
}
since you get an indexPath it becames much simplier.
If you are using Toad for MySQL steps to import a file is as follows: