You can use the ATL text conversion macros to convert a narrow (char) string to a wide (wchar_t) one. For example, to convert a std::string:
#include <atlconv.h>
...
std::string str = "Hello, world!";
CA2W pszWide(str.c_str());
loadU(pszWide);
You can also specify a code page, so if your std::string contains UTF-8 chars you can use:
CA2W pszWide(str.c_str(), CP_UTF8);
Very useful but Windows only.
you should try the new Java Executor Services. http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html
With this you don't need to program the loop the time measuring by yourself.
public class Starter {
public static void main(final String[] args) {
final ExecutorService service = Executors.newSingleThreadExecutor();
try {
final Future<Object> f = service.submit(() -> {
// Do you long running calculation here
Thread.sleep(1337); // Simulate some delay
return "42";
});
System.out.println(f.get(1, TimeUnit.SECONDS));
} catch (final TimeoutException e) {
System.err.println("Calculation took to long");
} catch (final Exception e) {
throw new RuntimeException(e);
} finally {
service.shutdown();
}
}
}
You're almost there. Simply use:
//form[@id='myform']//input[@type='submit']
The //
shortcut can also be used inside an expression.
If you really have to iterate a Pandas dataframe, you will probably want to avoid using iterrows(). There are different methods and the usual iterrows()
is far from being the best. itertuples() can be 100 times faster.
In short:
df.itertuples(name=None)
. In particular, when you have a fixed number columns and less than 255 columns. See point (3)df.itertuples()
except if your columns have special characters such as spaces or '-'. See point (2)itertuples()
even if your dataframe has strange columns by using the last example. See point (4)iterrows()
if you cannot the previous solutions. See point (1)Generate a random dataframe with a million rows and 4 columns:
df = pd.DataFrame(np.random.randint(0, 100, size=(1000000, 4)), columns=list('ABCD'))
print(df)
1) The usual iterrows()
is convenient, but damn slow:
start_time = time.clock()
result = 0
for _, row in df.iterrows():
result += max(row['B'], row['C'])
total_elapsed_time = round(time.clock() - start_time, 2)
print("1. Iterrows done in {} seconds, result = {}".format(total_elapsed_time, result))
2) The default itertuples()
is already much faster, but it doesn't work with column names such as My Col-Name is very Strange
(you should avoid this method if your columns are repeated or if a column name cannot be simply converted to a Python variable name).:
start_time = time.clock()
result = 0
for row in df.itertuples(index=False):
result += max(row.B, row.C)
total_elapsed_time = round(time.clock() - start_time, 2)
print("2. Named Itertuples done in {} seconds, result = {}".format(total_elapsed_time, result))
3) The default itertuples()
using name=None is even faster but not really convenient as you have to define a variable per column.
start_time = time.clock()
result = 0
for(_, col1, col2, col3, col4) in df.itertuples(name=None):
result += max(col2, col3)
total_elapsed_time = round(time.clock() - start_time, 2)
print("3. Itertuples done in {} seconds, result = {}".format(total_elapsed_time, result))
4) Finally, the named itertuples()
is slower than the previous point, but you do not have to define a variable per column and it works with column names such as My Col-Name is very Strange
.
start_time = time.clock()
result = 0
for row in df.itertuples(index=False):
result += max(row[df.columns.get_loc('B')], row[df.columns.get_loc('C')])
total_elapsed_time = round(time.clock() - start_time, 2)
print("4. Polyvalent Itertuples working even with special characters in the column name done in {} seconds, result = {}".format(total_elapsed_time, result))
Output:
A B C D
0 41 63 42 23
1 54 9 24 65
2 15 34 10 9
3 39 94 82 97
4 4 88 79 54
... .. .. .. ..
999995 48 27 4 25
999996 16 51 34 28
999997 1 39 61 14
999998 66 51 27 70
999999 51 53 47 99
[1000000 rows x 4 columns]
1. Iterrows done in 104.96 seconds, result = 66151519
2. Named Itertuples done in 1.26 seconds, result = 66151519
3. Itertuples done in 0.94 seconds, result = 66151519
4. Polyvalent Itertuples working even with special characters in the column name done in 2.94 seconds, result = 66151519
This article is a very interesting comparison between iterrows and itertuples
On Form_Load
:
this.Icon = YourProjectNameSpace.Resources.YourResourceName.YouAppIconName;
Sticky session means to route the requests of particular session to the same physical machine who served the first request for that session.
Following on from brillout.com's answer, and also Roman Nurik's answer, and relaxing somewhat the the 'no SVG' requirement, you can desaturate images in Firefox using only a single SVG file and some CSS.
Your SVG file will look like this:
<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1"
baseProfile="full"
xmlns="http://www.w3.org/2000/svg">
<filter id="desaturate">
<feColorMatrix type="matrix" values="0.3333 0.3333 0.3333 0 0
0.3333 0.3333 0.3333 0 0
0.3333 0.3333 0.3333 0 0
0 0 0 1 0"/>
</filter>
</svg>
Save that as resources.svg, it can be reused from now on for any image you want to change to greyscale.
In your CSS you reference the filter using the Firefox specific filter
property:
.target {
filter: url(resources.svg#desaturate);
}
Add the MS proprietary ones too if you feel like it, apply that class to any image you want to convert to greyscale (works in Firefox >3.5, IE8).
edit: Here's a nice blog post which describes using the new CSS3 filter
property in SalmanPK's answer in concert with the SVG approach described here. Using that approach you'd end up with something like:
img.desaturate{
filter: gray; /* IE */
-webkit-filter: grayscale(1); /* Old WebKit */
-webkit-filter: grayscale(100%); /* New WebKit */
filter: url(resources.svg#desaturate); /* older Firefox */
filter: grayscale(100%); /* Current draft standard */
}
The C++ standard library has almost exactly that function call nth_element
, although it does modify your data. It has expected linear run-time, O(N), and it also does a partial sort.
const int N = ...;
double a[N];
// ...
const int m = ...; // m < N
nth_element (a, a + m, a + N);
// a[m] contains the mth element in a
=IF(COUNTIF(A1:D1,FALSE)>0,FALSE,TRUE)
(or you can specify any other range to look in)
After Playing around a bit I came up with this and it seems to work just splendidly
<select name="options[]" id="options" class="form-control" multiple>
@foreach($settings->includes->get('optionList') as $option)
<option value="{{ $option->id }}" {{ (collect(old('options'))->contains($option->id)) ? 'selected':'' }}>{{ $option->name }}</option>
@endforeach
</select>
I may be 100% wrong in leveraging the collect function but it works fine on many of my tests. After seeing a few other posts on the site I saw someone recommend leveraging the in_array($needle, $array) function but after noticing that if my old('options') was null it would error out because it requires in_array requires, bet you guessed an array. So after finding the solution to that albeit ugly solution I played with the collect method because after all we are using larval right! well anyway the ugly solution is as follows
@if (old("options")){{ (in_array($option->id, old("options")) ? "selected":"") }}@endif
inline but man that looks ugly to me so long story short I am using the following instead
{{ (collect(old('options'))->contains($option->id)) ? 'selected':'' }}
Hope this helps others!!
This does not seem to work for a non multiple select field ill get back with one that does work for that though.
List(Of String)
will handle that, mostly - though you need to either use AddRange
to add a collection of items, or Add
to add one at a time:
lstOfString.Add(String1)
lstOfString.Add(String2)
lstOfString.Add(String3)
lstOfString.Add(String4)
If you're adding known values, as you show, a good option is to use something like:
Dim inputs() As String = { "some value", _
"some value2", _
"some value3", _
"some value4" }
Dim lstOfString as List(Of String) = new List(Of String)(inputs)
' ...
Dim s3 = lstOfStrings(3)
This will still allow you to add items later as desired, but also get your initial values in quickly.
Edit:
In your code, you need to fix the declaration. Change:
Dim lstWriteBits() As List(Of String)
To:
Dim lstWriteBits As List(Of String)
Currently, you're declaring an Array of List(Of String) objects.
It's not that different in bash
.
workdone=0
while : ; do
...
if [ "$workdone" -ne 0 ]; then
break
fi
done
:
is the no-op command; its exit status is always 0, so the loop runs until workdone
is given a non-zero value.
There are many ways you could set and test the value of workdone
in order to exit the loop; the one I show above should work in any POSIX-compatible shell.
Here is the typical structure of new Codeigniter project:
- application/
- system/
- user_guide/
- index.php <- this is the file you need to change
I usually use this code in my CI index.php. Just change local_server_name to the name of your local webserver.
With this code you can deploy your site to your production server without changing index.php each time.
// Domain-based environment
if ($_SERVER['SERVER_NAME'] == 'local_server_name') {
define('ENVIRONMENT', 'development');
} else {
define('ENVIRONMENT', 'production');
}
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/
if (defined('ENVIRONMENT')) {
switch (ENVIRONMENT) {
case 'development':
error_reporting(E_ALL);
break;
case 'testing':
case 'production':
error_reporting(0);
ini_set('display_errors', 0);
break;
default:
exit('The application environment is not set correctly.');
}
}
As Brannon says, it's OrderByDescending
and ThenByDescending
:
var query = from person in people
orderby person.Name descending, person.Age descending
select person.Name;
is equivalent to:
var query = people.OrderByDescending(person => person.Name)
.ThenByDescending(person => person.Age)
.Select(person => person.Name);
pgrep -f aa.sh
To do something with the id, you pipe it. Here I kill all its child tasks.
pgrep aa.sh | xargs pgrep -P ${} | xargs kill
If you want to execute a command if the process is running do this
pgrep aa.sh && echo Running
typedef
defines a new data type. So you can have:
typedef char* my_string;
typedef struct{
int member1;
int member2;
} my_struct;
So now you can declare variables with these new data types
my_string s;
my_struct x;
s = "welcome";
x.member1 = 10;
For enum
, things are a bit different - consider the following examples:
enum Ranks {FIRST, SECOND};
int main()
{
int data = 20;
if (data == FIRST)
{
//do something
}
}
using typedef enum
creates an alias for a type:
typedef enum Ranks {FIRST, SECOND} Order;
int main()
{
Order data = (Order)20; // Must cast to defined type to prevent error
if (data == FIRST)
{
//do something
}
}
Using JNA its simple:
String username = Advapi32Util.getUserName();
System.out.println(username);
Advapi32Util.Account account = Advapi32Util.getAccountByName(username);
System.out.println(account.accountType);
System.out.println(account.domain);
System.out.println(account.fqn);
System.out.println(account.name);
System.out.println(account.sidString);
Well, there is no shortcut to do it as per my findings, but somehow you
an achieve it in few simple steps
First you have to declare a bean of type 'ProtobufJsonFormatHttpMessageConverter'
@Bean
@Primary
public ProtobufJsonFormatHttpMessageConverter protobufHttpMessageConverter() {
return new ProtobufJsonFormatHttpMessageConverter(JsonFormat.parser(), JsonFormat.printer());
}
Then you can just write an Utility class like ResponseBuilder, because it can parse the request by default but without these changes it can not produce Json response. and then you can write few methods to convert the response types to its related object type.
public static <T> T build(Message message, Class<T> type) {
Printer printer = JsonFormat.printer();
Gson gson = new Gson();
try {
return gson.fromJson(printer.print(message), type);
} catch (JsonSyntaxException | InvalidProtocolBufferException e) {
throw new ApiException(HttpStatus.INTERNAL_SERVER_ERROR, "Response conversion Error", e);
}
}
Then you can call this method from your controller class as last line like -
return ResponseBuilder.build(<returned_service_object>, <Type>);
Hope this will help you to implement protobuf in json format.
I would do something like this (generates all the selects you need). You can later on feed them to sqlplus:
echo "select table_name from user_tables;" | sqlplus -S user/pwd | grep -v "^--" | grep -v "TABLE_NAME" | grep "^[A-Z]" | while read sw;
do echo "desc $sw" | sqlplus -S user/pwd | grep -v "\-\-\-\-\-\-" | awk -F' ' '{print $1}' | while read nw;
do echo "select * from $sw where $nw='val'";
done;
done;
It yields:
select * from TBL1 where DESCRIPTION='val'
select * from TBL1 where ='val'
select * from TBL2 where Name='val'
select * from TBL2 where LNG_ID='val'
And what it does is - for each table_name
from user_tables
get each field (from desc) and create a select * from table where field equals 'val'.
I'm seen this problem with Chrome too, if I remember correctly if you minimize and then maximize your window it fixes it as well?
Haven't really used Chrome too much since it was released but this is definitely something I blame on Google as the code I was checking it on was air tight.
However, if you have indented code, it doesn't work out so well:
echo "continuation \ lines" >continuation lines
Try with single quotes and concatenating the strings:
echo 'continuation' \
'lines'
>continuation lines
Note: the concatenation includes a whitespace.
This post is old enough that this answer will probably be little use to the OP, but I spent forever trying to answer this same question, so I thought I would update it with my findings.
This answer assumes that you already have a working SQL query in place in your Excel document. There are plenty of tutorials to show you how to accomplish this on the web, and plenty that explain how to add a parameterized query to one, except that none seem to work for an existing, OLE DB query.
So, if you, like me, got handed a legacy Excel document with a working query, but the user wants to be able to filter the results based on one of the database fields, and if you, like me, are neither an Excel nor a SQL guru, this might be able to help you out.
Most web responses to this question seem to say that you should add a “?” in your query to get Excel to prompt you for a custom parameter, or place the prompt or the cell reference in [brackets] where the parameter should be. This may work for an ODBC query, but it does not seem to work for an OLE DB, returning “No value given for one or more required parameters” in the former instance, and “Invalid column name ‘xxxx’” or “Unknown object ‘xxxx’” in the latter two. Similarly, using the mythical “Parameters…” or “Edit Query…” buttons is also not an option as they seem to be permanently greyed out in this instance. (For reference, I am using Excel 2010, but with an Excel 97-2003 Workbook (*.xls))
What we can do, however, is add a parameter cell and a button with a simple routine to programmatically update our query text.
First, add a row above your external data table (or wherever) where you can put a parameter prompt next to an empty cell and a button (Developer->Insert->Button (Form Control) – You may need to enable the Developer tab, but you can find out how to do that elsewhere), like so:
Next, select a cell in the External Data (blue) area, then open Data->Refresh All (dropdown)->Connection Properties… to look at your query. The code in the next section assumes that you already have a parameter in your query (Connection Properties->Definition->Command Text) in the form “WHERE (DB_TABLE_NAME.Field_Name = ‘Default Query Parameter')” (including the parentheses). Clearly “DB_TABLE_NAME.Field_Name” and “Default Query Parameter” will need to be different in your code, based on the database table name, database value field (column) name, and some default value to search for when the document is opened (if you have auto-refresh set). Make note of the “DB_TABLE_NAME.Field_Name” value as you will need it in the next section, along with the “Connection name” of your query, which can be found at the top of the dialog.
Close the Connection Properties, and hit Alt+F11 to open the VBA editor. If you are not on it already, right click on the name of the sheet containing your button in the “Project” window, and select “View Code”. Paste the following code into the code window (copying is recommended, as the single/double quotes are dicey and necessary).
Sub RefreshQuery()
Dim queryPreText As String
Dim queryPostText As String
Dim valueToFilter As String
Dim paramPosition As Integer
valueToFilter = "DB_TABLE_NAME.Field_Name ="
With ActiveWorkbook.Connections("Connection name").OLEDBConnection
queryPreText = .CommandText
paramPosition = InStr(queryPreText, valueToFilter) + Len(valueToFilter) - 1
queryPreText = Left(queryPreText, paramPosition)
queryPostText = .CommandText
queryPostText = Right(queryPostText, Len(queryPostText) - paramPosition)
queryPostText = Right(queryPostText, Len(queryPostText) - InStr(queryPostText, ")") + 1)
.CommandText = queryPreText & " '" & Range("Cell reference").Value & "'" & queryPostText
End With
ActiveWorkbook.Connections("Connection name").Refresh
End Sub
Replace “DB_TABLE_NAME.Field_Name” and "Connection name" (in two locations) with your values (the double quotes and the space and equals sign need to be included).
Replace "Cell reference" with the cell where your parameter will go (the empty cell from the beginning) - mine was the second cell in the first row, so I put “B1” (again, the double quotes are necessary).
Save and close the VBA editor.
Enter your parameter in the appropriate cell.
Right click your button to assign the RefreshQuery sub as the macro, then click your button. The query should update and display the right data!
Notes: Using the entire filter parameter name ("DB_TABLE_NAME.Field_Name =") is only necessary if you have joins or other occurrences of equals signs in your query, otherwise just an equals sign would be sufficient, and the Len() calculation would be superfluous. If your parameter is contained in a field that is also being used to join tables, you will need to change the "paramPosition = InStr(queryPreText, valueToFilter) + Len(valueToFilter) - 1" line in the code to "paramPosition = InStr(Right(.CommandText, Len(.CommandText) - InStrRev(.CommandText, "WHERE")), valueToFilter) + Len(valueToFilter) - 1 + InStr(.CommandText, "WHERE")" so that it only looks for the valueToFilter after the "WHERE".
This answer was created with the aid of datapig’s “BaconBits” where I found the base code for the query update.
In case Translate works locally but not remotly e.i group.Translate(typeof(NTAccount)
If you want to have the application code executes using the LOGGED IN USER identity, then enable impersonation. Impersonation can be enabled thru IIS or by adding the following element in the web.config.
<system.web>
<identity impersonate="true"/>
If impersonation is enabled, the application executes using the permissions found in your user account. So if the logged in user has access, to a specific network resource, only then will he be able to access that resource thru the application.
Thank PRAGIM tech for this information from his diligent video
Windows authentication in asp.net Part 87:
https://www.youtube.com/watch?v=zftmaZ3ySMc
But impersonation creates a lot of overhead on the server
The best solution to allow users of certain network groups is to deny anonymous in the web config
<authorization><deny users="?"/><authentication mode="Windows"/>
and in your code behind, preferably in the global.asax, use the HttpContext.Current.User.IsInRole :
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
If HttpContext.Current.User.IsInRole("TheDomain\TheGroup") Then
//code to do when user is in group
End If
NOTE: The Group must be written with a backslash \ i.e. "TheDomain\TheGroup"
do this:
export | grep JAVA
THE RESULT: what java home is set to
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
i did this in my terminal:
open /Library
then i went to /Java/JavaVirturalMachines turns out I had the wrong "jdk1.8.0_202.jdk" folder, there was another number... 4. you can use this command to set java_home
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
A correct file upload would like this:
HTTP header:
Content-Type: multipart/form-data; boundary=ABCDEFGHIJKLMNOPQ
Http body:
--ABCDEFGHIJKLMNOPQ
Content-Disposition: form-data; name="file"; filename="my.txt"
Content-Type: application/octet-stream
Content-Length: ...
<...file data in base 64...>
--ABCDEFGHIJKLMNOPQ--
and code is like this:
public void uploadFile(File file) {
try {
RestTemplate restTemplate = new RestTemplate();
String url = "http://localhost:8080/file/user/upload";
HttpMethod requestMethod = HttpMethod.POST;
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
MultiValueMap<String, String> fileMap = new LinkedMultiValueMap<>();
ContentDisposition contentDisposition = ContentDisposition
.builder("form-data")
.name("file")
.filename(file.getName())
.build();
fileMap.add(HttpHeaders.CONTENT_DISPOSITION, contentDisposition.toString());
HttpEntity<byte[]> fileEntity = new HttpEntity<>(Files.readAllBytes(file.toPath()), fileMap);
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
body.add("file", fileEntity);
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers);
ResponseEntity<String> response = restTemplate.exchange(url, requestMethod, requestEntity, String.class);
System.out.println("file upload status code: " + response.getStatusCode());
} catch (IOException e) {
e.printStackTrace();
}
}
It seems that you can use regexp too
WHERE NOT REGEXP_LIKE(field, '^Done|^Finished')
I'm not sure how well this will perform though ... see here
For a standard shell (without bashisms) using only builtins:
uppers=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lowers=abcdefghijklmnopqrstuvwxyz
lc(){ #usage: lc "SOME STRING" -> "some string"
i=0
while ([ $i -lt ${#1} ]) do
CUR=${1:$i:1}
case $uppers in
*$CUR*)CUR=${uppers%$CUR*};OUTPUT="${OUTPUT}${lowers:${#CUR}:1}";;
*)OUTPUT="${OUTPUT}$CUR";;
esac
i=$((i+1))
done
echo "${OUTPUT}"
}
And for upper case:
uc(){ #usage: uc "some string" -> "SOME STRING"
i=0
while ([ $i -lt ${#1} ]) do
CUR=${1:$i:1}
case $lowers in
*$CUR*)CUR=${lowers%$CUR*};OUTPUT="${OUTPUT}${uppers:${#CUR}:1}";;
*)OUTPUT="${OUTPUT}$CUR";;
esac
i=$((i+1))
done
echo "${OUTPUT}"
}
convert into string and then you can count tatal no of digit by .length method. Like:
String numberString = "855865264".toString();
int NumLen = numberString .Length;
You should probably use:
if(myDictionary.ContainsKey(someInt))
{
// do something
}
The reason why you can't check for null is that the key here is a value type.
If you are interested in portability between different SQL servers you should use ANSI SQL queries. String escaping in ANSI SQL is done by using double quotes ("). Unfortunately, this escaping method is not portable to MySQL, unless it is set in ANSI compatibility mode.
Personally, I always start my MySQL server with the --sql-mode='ANSI' argument since this allows for both methods for escaping. If you are writing queries that are going to be executed in a MySQL server that was not setup / is controlled by you, here is what you can do:
Enclose them in the following MySQL specific queries:
SET @OLD_SQL_MODE=@@SQL_MODE;
SET SESSION SQL_MODE='ANSI';
-- ANSI SQL queries
SET SESSION SQL_MODE=@OLD_SQL_MODE;
This way the only MySQL specific queries are at the beginning and the end of your .sql script. If you what to ship them for a different server just remove these 3 queries and you're all set. Even more conveniently you could create a script named: script_mysql.sql that would contain the above mode setting queries, source a script_ansi.sql script and reset the mode.
Progress Bar without nested divs... for every element where the css linear-gradient works.
Here the JSFiddle http://jsfiddle.net/oj1L3y6t/2/
function show_progress(i) {_x000D_
var progress1 = i;_x000D_
var progress2 = progress1 + 1;_x000D_
var progress3 = progress1 + 2;_x000D_
_x000D_
var magic = "linear-gradient(to right, #FFC2CE " + progress1 + "% ,red " + progress2 + "% , #FFFFFF " + progress3 + "%)";_x000D_
document.getElementById("progress-0").style.background = magic;_x000D_
_x000D_
var magic = "linear-gradient(to right, lightblue " + progress1 + "% , lightgreen " + progress2 + "%)";_x000D_
document.getElementById("progress-1").style.background = magic;_x000D_
_x000D_
var magic = "linear-gradient(to right, lightblue " + progress1 + "% , #FFFFFF 100%)";_x000D_
document.getElementById("progress-2").style.background = magic;_x000D_
_x000D_
var magic = "linear-gradient(#FFC2CE " + progress1 + "% ,red " + progress2 + "% , #FFFFFF " + progress3 + "%)";_x000D_
document.getElementById("progress-3").style.background = magic;_x000D_
}_x000D_
_x000D_
function timeout() {_x000D_
t = setTimeout(function() {_x000D_
show_progress(t)_x000D_
timeout();_x000D_
}, 50);_x000D_
if (t == 78) {_x000D_
clearTimeout(t);_x000D_
}_x000D_
console.log(t);_x000D_
}_x000D_
_x000D_
timeout();
_x000D_
#progress-0 {_x000D_
border: 1px solid black;_x000D_
width: 500px;_x000D_
background: #999;_x000D_
text-align: center;_x000D_
}_x000D_
_x000D_
#progress-1 {_x000D_
border: 1px solid black;_x000D_
width: 500px;_x000D_
background: #999;_x000D_
text-align: center;_x000D_
margin-top: 10px;_x000D_
border-radius: 10px;_x000D_
}_x000D_
_x000D_
#progress-2 {_x000D_
border: 1px solid black;_x000D_
width: 500px;_x000D_
background: #999;_x000D_
text-align: center;_x000D_
margin-top: 10px;_x000D_
}_x000D_
_x000D_
#progress-3 {_x000D_
border: 1px solid black;_x000D_
width: 100px;_x000D_
height: 100px;_x000D_
background: #999;_x000D_
line-height: 100px;_x000D_
text-align: center;_x000D_
margin-top: 10px;_x000D_
border-radius: 200px;_x000D_
}
_x000D_
<div id="progress-0">Loading</div>_x000D_
<input id="progress-1" value="Loading"></input>_x000D_
<button id="progress-2">Loading</button>_x000D_
<p id="progress-3">Loading</p>
_x000D_
The following works for me on Snow Leopard:
Runtime rt = Runtime.getRuntime();
String[] testArgs = {"touch", "TEST"};
rt.exec(testArgs);
Thing is, if you want to read the output of that command, you need to read the input stream of the process. For instance,
Process pr = rt.exec(arguments);
BufferedReader r = new BufferedReader(new InputStreamReader(pr.getInputStream()));
Allows you to read the line-by-line output of the command pretty easily.
The problem might also be that MS-DOS does not interpret your order of arguments to mean "start a new command prompt". Your array should probably be:
{"start", "cmd.exe", "\c"}
To open commands in the new command prompt, you'd have to use the Process reference. But I'm not sure why you'd want to do that when you can just use exec, as the person before me commented.
You need some Administrator privilege to your account if your machine in local area network then you apply some administrator privilege to your User else you should start ide as Administrator...
In case the remote repository is not empty (this is the case if you are using IBM DevOps on hub.jazz.net) then you need to use the following sequence:
cd <localDir>
git init
git add -A .
git pull <url> master
git commit -m "message"
git remote add origin <url>
git push
EDIT 30th Jan 17: Please see comments below, make sure you are on the correct repo!
Before I respond to this question, I must explain to you the SERIALIZATION, because if you understand what it means serialization in science computer you can easily understand this keyword.
Serialization
When an object is transferred through the network / saved on physical media(file,...), the object must be "serialized". Serialization converts byte status object series. These bytes are sent on the network/saved and the object is re-created from these bytes.
Example
public class Foo implements Serializable
{
private String attr1;
private String attr2;
...
}
Now IF YOU WANT TO do NOT TRANSFERT/SAVED field of this object SO, you can use keyword transient
private transient attr2;
try one of them
<img src='images/icons/proceed_button.png' width='120' height='70' onmouseover="this.src='images/icons/proceed_button2.png';" onmouseout="this.src='images/icons/proceed_button.png';" />
or if you using image as a button in form
<input type="image" id="proceed" src="images/icons/proceed_button.png" alt"Go to Facebook page" onMouseOver="fnover();"onMouseOut="fnout();" onclick="fnclick()">
function fnover()
{
var myimg2 = document.getElementById("proceed");
myimg2.src = "images/icons/proceed_button2.png";
}
function fnout()
{
var myimg2 = document.getElementById("proceed");
myimg2.src = "images/icons/proceed_button.png";
}
Another approach would be to extended jquery like this:
$.fn.toggleCheckbox = function() {
this.attr('checked', !this.attr('checked'));
}
Then call:
$('.offer').find(':checkbox').toggleCheckbox();
You have to use the encoding as latin1 to read this file as there are some special character in this file, use the below code snippet to read the file.
The problem here is the encoding type. When Python can't convert the data to be read, it gives an error.
You can you latin1 or other encoding values.
I say try and test to find the right one for your dataset.
You may try this (using jQuery
)
$(function(){_x000D_
$('#MainPopupIframe').load(function(){_x000D_
$(this).show();_x000D_
console.log('iframe loaded successfully')_x000D_
});_x000D_
_x000D_
$('#click').on('click', function(){_x000D_
$('#MainPopupIframe').attr('src', 'https://heera.it'); _x000D_
});_x000D_
});
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>_x000D_
<button id='click'>click me</button>_x000D_
_x000D_
<iframe style="display:none" id='MainPopupIframe' src='' /></iframe>
_x000D_
Update: Using plain javascript
window.onload=function(){_x000D_
var ifr=document.getElementById('MainPopupIframe');_x000D_
ifr.onload=function(){_x000D_
this.style.display='block';_x000D_
console.log('laod the iframe')_x000D_
};_x000D_
var btn=document.getElementById('click'); _x000D_
btn.onclick=function(){_x000D_
ifr.src='https://heera.it'; _x000D_
};_x000D_
};
_x000D_
<button id='click'>click me</button>_x000D_
_x000D_
<iframe style="display:none" id='MainPopupIframe' src='' /></iframe>
_x000D_
Update: Also you can try this (dynamic iframe)
$(function(){_x000D_
$('#click').on('click', function(){_x000D_
var ifr=$('<iframe/>', {_x000D_
id:'MainPopupIframe',_x000D_
src:'https://heera.it',_x000D_
style:'display:none;width:320px;height:400px',_x000D_
load:function(){_x000D_
$(this).show();_x000D_
alert('iframe loaded !');_x000D_
}_x000D_
});_x000D_
$('body').append(ifr); _x000D_
});_x000D_
});
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>_x000D_
<button id='click'>click me</button><br />
_x000D_
You can use a simply bind on click and close, like this: (click)="drawer.close()
<a class="nav-link" [routerLink]="navItem.link" routerLinkActive="selected" (click)="drawer.close()">
As also noted in the docs here.
Go to Python X.X/Lib
and add these lines to the site.py
there,
import sys
sys.path.append("yourpathstring")
This changes your sys.path
so that on every load, it will have that value in it..
As stated here about site.py
,
This module is automatically imported during initialization. Importing this module will append site-specific paths to the module search path and add a few builtins.
For other possible methods of adding some path to sys.path
see these docs
1: The LayoutInflater
takes your layout XML-files and creates different View-objects from its contents.
2: The adapters are built to reuse Views, when a View is scrolled so that is no longer visible, it can be used for one of the new Views appearing. This reused View is the convertView
. If this is null it means that there is no recycled View and we have to create a new one, otherwise we should use it to avoid creating a new.
3: The parent
is provided so you can inflate your view into that for proper layout parameters.
All these together can be used to effectively create the view that will appear in your list (or other view that takes an adapter):
public View getView(int position, @Nullable View convertView, ViewGroup parent){
if (convertView == null) {
//We must create a View:
convertView = inflater.inflate(R.layout.my_list_item, parent, false);
}
//Here we can do changes to the convertView, such as set a text on a TextView
//or an image on an ImageView.
return convertView;
}
Notice the use of the LayoutInflater
, that parent
can be used as an argument for it, and how convertView
is reused.
I had the same problem, and found a nice solution here: http://blog.e-shell.org/134
This is caused by a mismatch in your database encodings, surely because the database from where you got the SQL dump was encoded as SQL_ASCII while the new one is encoded as UTF8. .. Recode is a small tool from the GNU project that let you change on-the-fly the encoding of a given file.
So I just recoded the dumpfile before playing it back:
postgres> gunzip -c /var/backups/pgall_b1.zip | recode iso-8859-1..u8 | psql test
In Debian or Ubuntu systems, recode can be installed via package.
If you want to sum the digit of a number, one way to do it is using sum()
+ a generator expression:
sum(int(i) for i in str(155))
I modified a little your code using sum()
, maybe you want to take a look at it:
birthday = raw_input("When is your birthday(mm/dd/yyyy)? ")
summ = sum(int(i) for i in birthday[0:2])
sumd = sum(int(i) for i in birthday[3:5])
sumy = sum(int(i) for i in birthday[6:10])
sumall = summ + sumd + sumy
print "The sum of your numbers is", sumall
sumln = sum(int(c) for c in str(sumall)))
print "Your lucky number is", sumln
You can also do it like this
public Map<Boolean, List<Student>> getpartitionMap(List<Student> studentsList) {
List<Predicate<Student>> allPredicates = getAllPredicates();
Predicate<Student> compositePredicate = allPredicates.stream()
.reduce(w -> true, Predicate::and)
Map<Boolean, List<Student>> studentsMap= studentsList
.stream()
.collect(Collectors.partitioningBy(compositePredicate));
return studentsMap;
}
public List<Student> getValidStudentsList(Map<Boolean, List<Student>> studentsMap) throws Exception {
List<Student> validStudentsList = studentsMap.entrySet()
.stream()
.filter(p -> p.getKey() == Boolean.TRUE)
.flatMap(p -> p.getValue().stream())
.collect(Collectors.toList());
return validStudentsList;
}
public List<Student> getInValidStudentsList(Map<Boolean, List<Student>> studentsMap) throws Exception {
List<Student> invalidStudentsList =
partionedByPredicate.entrySet()
.stream()
.filter(p -> p.getKey() == Boolean.FALSE)
.flatMap(p -> p.getValue().stream())
.collect(Collectors.toList());
return invalidStudentsList;
}
With flatMap
you will get just List<Student>
instead of List<List<Student>>
.
Thanks
As the new feature comes, SameSite=None
cookies must also be marked as Secure
or they will be rejected.
One can find more information about the change on chromium updates and on this blog post
Note: not quite related directly to the question, but might be useful for others who landed here as it was my concern at first during development of my website:
if you are seeing the warning from question that lists some 3rd party sites (in my case it was google.com, huh) - that means they need to fix it and it's nothing to do with your site. Of course unless the warning mentions your site, in which case adding Secure
should fix it.
If you right click on any result of "Edit Top 200 Rows" query in SSMS you will see the option "Pane -> SQL". It then shows the SQL Query that was run, which you can edit as you wish.
In SMSS 2012 and 2008, you can use Ctrl+3 to quickly get there.
Don't do nl2br
when you save it to the database. Do nl2br
when you're displaying the text in HTML. I can strongly recommend to not store any HTML formatting in the database (unless you're using a rich HTML editor as well, in which case it would be silly not to).
A newline \n
will just become a newline in the textarea.
In my case i have used .woff files from git repository, and i noticed git has changed my binary files. That with some null character at the file endings. I have rechanged to the orgnal .woff source files and it has corrected!
Also i have understood visual studio controller sending corrupted error like ERR_CONNECTION_RESET from the controller when it gots null character
I shared for all who live this problem
By using the value attribute:
var today = new Date();
document.getElementById('DATE').value += today;
You can always refer to resources in your application directly by their JNDI name as configured in the container, but if you do so, essentially you are wiring the container-specific name into your code. This has some disadvantages, for example, if you'll ever want to change the name later for some reason, you'll need to update all the references in all your applications, and then rebuild and redeploy them.
<resource-ref>
introduces another layer of indirection: you specify the name you want to use in the web.xml, and, depending on the container, provide a binding in a container-specific configuration file.
So here's what happens: let's say you want to lookup the java:comp/env/jdbc/primaryDB
name. The container finds that web.xml has a <resource-ref>
element for jdbc/primaryDB
, so it will look into the container-specific configuration, that contains something similar to the following:
<resource-ref>
<res-ref-name>jdbc/primaryDB</res-ref-name>
<jndi-name>jdbc/PrimaryDBInTheContainer</jndi-name>
</resource-ref>
Finally, it returns the object registered under the name of jdbc/PrimaryDBInTheContainer
.
The idea is that specifying resources in the web.xml has the advantage of separating the developer role from the deployer role. In other words, as a developer, you don't have to know what your required resources are actually called in production, and as the guy deploying the application, you will have a nice list of names to map to real resources.
Both do the same on all browsers, AFAIK. Checked on Chrome and Firefox, both append display:none
to the style
attribute of the element.
Assume I have a variable named file
that contains a file.
Then I could use file.write("hello\talex")
.
file.write("hello
means I'm starting to write to this file.\t
means a tabalex")
is the rest I'm writingUse ProcessBuilder to separate commands and arguments instead of spaces. This should work regardless of shell used:
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class Test {
public static void main(final String[] args) throws IOException, InterruptedException {
//Build command
List<String> commands = new ArrayList<String>();
commands.add("/bin/cat");
//Add arguments
commands.add("/home/narek/pk.txt");
System.out.println(commands);
//Run macro on target
ProcessBuilder pb = new ProcessBuilder(commands);
pb.directory(new File("/home/narek"));
pb.redirectErrorStream(true);
Process process = pb.start();
//Read output
StringBuilder out = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = null, previous = null;
while ((line = br.readLine()) != null)
if (!line.equals(previous)) {
previous = line;
out.append(line).append('\n');
System.out.println(line);
}
//Check result
if (process.waitFor() == 0) {
System.out.println("Success!");
System.exit(0);
}
//Abnormal termination: Log command parameters and output and throw ExecutionException
System.err.println(commands);
System.err.println(out.toString());
System.exit(1);
}
}
If it's been compiled for release this isn't possible. You might want to look into something like Log4J which will automatically give you enough information to determine pretty closely where the logged code occurred.
Ultimately no. You can query for listings with a search string from an RSS feed such as this:
http://YOURCITY.craigslist.org/search/sss?format=rss&query=SearchString
As far as posting, craiglist has not opened their API. However, this SO Question may shed some light and a possible solution - although not a very reliable one.
Craigslist Automated Posting API?
Write a note to craigslist asking them to open their API,
You get into a difficult situation when it is necessary to understand how scopes, ngRepeat and ngModel with NgModelController work. Also try to use 1.0.3 version. Your example will work a little differently.
You can simply use solution provided by jm-
But if you want to deal with the situation more deeply, you have to understand:
How your example "Binding to each element directly" works for AngularJS 1.0.3:
'f'
into input;ngModelController
changes model for item scope (names array is not changed) => name == 'Samf'
, names == ['Sam', 'Harry', 'Sally']
;$digest
loop is started;ngRepeat
replaces model value from item scope ('Samf'
) by value from unchanged names array ('Sam'
);ngModelController
rerenders input with actual model value ('Sam'
).How your example "Indexing into the array" works:
'f'
into input;ngModelController
changes item in names array
=> `names == ['Samf', 'Harry', 'Sally'];ngRepeat
can't find 'Samf'
in cache;ngRepeat
creates new scope, adds new div element with new input (that is why the input field loses focus - old div with old input is replaced by new div with new input);Also, you can try to use AngularJS Batarang and see how changes $id of the scope of div with input in which you enter.
If you need to do many append operations to build a large string, you can use StringIO or cStringIO. The interface is like a file. ie: you write
to append text to it.
If you're just appending two strings then just use +
.
As an alternative way to floating:
<style>
.wrapper{position:relative;}
.right,.left{width:50%; position:absolute;}
.right{right:0;}
.left{left:0;}
</style>
...
<div class="wrapper">
<div class="left"></div>
<div class="right"></div>
</div>
Considering that there's no necessity to position the .left div as absolute (depending on your direction, this could be the .right one) due to that would be in the desired position in natural flow of html code.
I have solved my problem this way.I have passed getApplicationContext from the previous class which has already access of getApplicationContext.I have passed Inputstream object to my new class Nutrients.
try{
InputStream is= getApplicationContext().getAssets().open("nutrient_list.json");
Nutrients nutrients=Nutrients.getNutrients(topRecognition,is);
} catch (IOException e) {
e.printStackTrace();
}
check this: https://github.com/luciotato/waitfor-ES6
your code with wait.for: (requires generators, --harmony flag)
function* (query) {
var r = yield wait.for( myApi.exec, 'SomeCommand');
return r;
}
You don't need AJAX for this, just some plain java script setting the background-color property of the body element, like this:
document.body.style.backgroundColor = "#AA0000";
If you want to do it as if it was initiated by the server, you would have to poll the server and then change the color accordingly.
Sometimes you still need to know if Cookie exists in Response. Then you can check if cookie key exists:
HttpContext.Current.Response.Cookies.AllKeys.Contains("myCookie")
More info can be found here.
In my case I had to modify Response Cookie in Application_EndRequest method in Global.asax. If Cookie doesn't exist I don't touch it:
string name = "myCookie";
HttpContext context = ((HttpApplication)sender).Context;
HttpCookie cookie = null;
if (context.Response.Cookies.AllKeys.Contains(name))
{
cookie = context.Response.Cookies[name];
}
if (cookie != null)
{
// update response cookie
}
This is a problem that can arise from writing down a "filename" instead of a path, while generating the .jks file. Generate a new one, put it on the Desktop (or any other real path) and re-generate APK.
By design adb root
command works in development builds only (i.e. eng
and userdebug
which have ro.debuggable=1
by default). So to enable the adb root
command on your otherwise rooted device just add the ro.debuggable=1
line to one of the following files:
/system/build.prop
/system/default.prop
/data/local.prop
If you want adb shell
to start as root
by default - then add ro.secure=0
as well.
Alternatively you could use modified adbd
binary (which does not check for ro.debuggable
)
From https://android.googlesource.com/platform/system/core/+/master/adb/daemon/main.cpp
#if defined(ALLOW_ADBD_ROOT)
// The properties that affect `adb root` and `adb unroot` are ro.secure and
// ro.debuggable. In this context the names don't make the expected behavior
// particularly obvious.
//
// ro.debuggable:
// Allowed to become root, but not necessarily the default. Set to 1 on
// eng and userdebug builds.
//
// ro.secure:
// Drop privileges by default. Set to 1 on userdebug and user builds.
Check for the existence by retrieving its object_id:
if object_id('tempdb..##clients_keyword') is not null
drop table ##clients_keyword
As other answers mentioned, (upper case) J
and search + replace for \n
can be used generally to strip newline characters and to concatenate lines.
But in order to get rid of the trailing newline character in the last line, you need to do this in Vim:
:set noendofline binary
:w
This question on StackOverflow deals with RadioButtonListFor and the answer addresses your question too. You can set the selected property in the RadioButtonListViewModel.
This is now supported (as of 2019). Please see sajad saderi's answer below for instructions.
No, this is not currently supported (in 2015).
My way to replicate Excel's MOD(a,b)
in VBA is to use XLMod(a,b)
in VBA where you include the function:
Function XLMod(a, b)
' This replicates the Excel MOD function
XLMod = a - b * Int(a / b)
End Function
in your VBA Module
You need something like this: https://github.com/axkibe/lsyncd It is a tool which combines rsync and inotify - the former is a tool that mirrors, with the correct options set, a directory to the last bit. The latter tells the kernel to notify a program of changes to a directory ot file. It says:
It aggregates and combines events for a few seconds and then spawns one (or more) process(es) to synchronize the changes.
But - according to Digital Ocean at https://www.digitalocean.com/community/tutorials/how-to-mirror-local-and-remote-directories-on-a-vps-with-lsyncd - it ought to be in the Ubuntu repository!
I have similar requirements, and this tool, which I have yet to try, seems suitable for the task.
Also you can use ng-repeat
with ng-if
:
<div ng-repeat="(key, value) in order" ng-if="value > 0">
simply change the text or value
property of controller.
if you do not edit selection property cursor goes to first of the new text.
onPress: () {
_controller.value=TextEditingValue(text: "sample text",selection: TextSelection.fromPosition(TextPosition(offset: sellPriceController.text.length)));
}
or in case you change the .text property:
onPress: () {
_controller.text="sample text";
_controller.selection = TextSelection.fromPosition(TextPosition(offset:_controller.text.length));
}
in cases that do not matter to you just don't change the selection property
I know I'm late to the party, but try this...
SELECT
`Train`,
`Dest`,
SUBSTRING_INDEX(GROUP_CONCAT(`Time` ORDER BY `Time` DESC), ",", 1) AS `Time`
FROM TrainTable
GROUP BY Train;
Src: Group Concat Documentation
Edit: fixed sql syntax
I don't know if this is the best way, but it has worked for me.
$root = $_SERVER['DOCUMENT_ROOT'];
include($root."/path/to/file.php");
This post already has a checked answer, but the answer doesn't filter for null values. The correct answer should prevent null values by using the Object::nonNull function as a predicate.
BigDecimal result = invoiceList.stream()
.map(Invoice::total)
.filter(Objects::nonNull)
.filter(i -> (i.getUnit_price() != null) && (i.getQuantity != null))
.reduce(BigDecimal.ZERO, BigDecimal::add);
This prevents null values from attempting to be summed as we reduce.
Without using inline CSS you could set the text size of all your buttons using:
input[type="submit"], input[type="button"] {
font-size: 14px;
}
You need the path of the plugins directory of your local GATE install. So if Gate is installed in "/home/user/GATE_Developer_8.1", the code looks like this:
System.setProperty("gate.home", "/home/user/GATE_Developer_8.1/plugins");
You don't have to set gate.home from the command line. You can set it in your application, as long as you set it BEFORE you call Gate.init().
According to the documentation, there needs to be a top level layout set.
A top level layout is necessary to ensure that your widgets will resize correctly when its window is resized. To check if you have set a top level layout, preview your widget and attempt to resize the window by dragging the size grip.
You can set one by clearing the selection and right clicking on the form itself and choosing one of the layouts available in the context menu.
Here is a very simple way to do what you want. In my case, it was getting Gradle to work (for Android Studio).
Run the following command:
sudo nano /etc/paths
or sudo vim /etc/paths
Enter your password, when prompted.
Open a new terminal window then type:
echo $PATH
You should see the new path appended to the end of the PATH.
I got these details from this post:
MS SQL knowledge based - How to know open SQL database connection(s) and occupied on which host.
Using below query you will find list database, Host name and total number of open connection count, based on that you will have idea, which host has occupied SQL connection.
SELECT DB_NAME(dbid) as DBName, hostname ,COUNT(dbid) as NumberOfConnections
FROM sys.sysprocesses with (nolock)
WHERE dbid > 0
and len(hostname) > 0
--and DB_NAME(dbid)='master' /* Open this line to filter Database by Name */
Group by DB_NAME(dbid),hostname
order by DBName
The accepted answer works well and one can also just use the
If Exists (...) Then ... End If;
syntax in Mysql procedures (if acceptable for circumstance) and it will behave as desired/expected. Here's a link to a more thorough source/description: https://dba.stackexchange.com/questions/99120/if-exists-then-update-else-insert
One problem with the solution by @SnowyR is that it does not really behave like "If Exists" in that the (Select 1 = 1 ...) subquery could return more than one row in some circumstances and so it gives an error. I don't have permissions to respond to that answer directly so I thought I'd mention it here in case it saves someone else the trouble I experienced and so others might know that it is not an equivalent solution to MSSQLServer "if exists"!
I am new to XAMPP, but I find that a combination of these suggestions works best (At least on Windows 8.1 with the latest version of XAMPP. Note that the computer I tested this on, also had skype).
First logon to skype and navigate to "Tools < Options < Advanced < Connection." Then check the box that says "Use port 80 and 443 for additional incoming connections." Save, close, and quit skype.
Next, on your XAMPP control panel, click "config < my.ini" and change lines 19 and 27 (should have port = 3306) from "3306" to "3307."
Also, you will need to navigate to xampp < phpMyAdmin < config.inc and change line 27, which should like something like this:
$cfg['Servers'][$i]['host'] = '127.0.0.1';
You will need to add "3307" as follows:
$cfg['Servers'][$i]['host'] = '127.0.0.1:3307';
Now, open your browser and you should see the xampp page when you type in "localhost." Additionally, if this is your first time using xampp, you may see a warning about your lack of password (highlighted in pink) on your localhost/phpmyadmin/ page. This is easily remedied by going to the "user accounts" tab in phpmyadmin, clicking on "edit privileges" and entering password. Remember to save the hashed version of any and all passwords you create as we will use this next! -I opened a notepad and saved (and numbered) them. Note that phpMyadmin will notify you of when you are changing the password for your current session (this will be displayed at the top of your phpMyadmin page and is very important, as you will need THAT specific hashed version of your password).
Next, you will need to navigate to the following location "xampp < phpMyAdmin < config.inc" on your computer and open and edit the file with a text editor. You will want to put in the hashed version of your password between the single quotes for password and change "AllowNoPassword" from true to false.
And, that ought to do it.
Old question, but posting the answer incase it helps someone. Already build path was configured to use JDK 1.2.81 However, build was failing with the error below:
lambda expressions are not supported in -source 1.5
[ERROR] (use -source 8 or higher to enable lambda expressions)
In the latest Eclipse (Photon), adding the below entry to pom.xml worked.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
There is also array_pad. You can use it like this:
$data = array_pad($data,$number_of_items,0);
For initializing with zeros the $number_of_items positions of the array $data.
You can use this code:
var vid = document.getElementById("video1");
function slowPlaySpeed() {
vid.playbackRate = 0.5;
}
function normalPlaySpeed() {
vid.playbackRate = 1;
}
function fastPlaySpeed() {
vid.playbackRate = 2;
}
One thing you can do is to set your axis range by yourself by using matplotlib.pyplot.axis.
matplotlib.pyplot.axis
from matplotlib import pyplot as plt
plt.axis([0, 10, 0, 20])
0,10 is for x axis range. 0,20 is for y axis range.
or you can also use matplotlib.pyplot.xlim or matplotlib.pyplot.ylim
matplotlib.pyplot.ylim
plt.ylim(-2, 2)
plt.xlim(0,10)
Could anybody post a working solution for doing this in the terminal?
ANDROID_HOME
is usually a directory like .android
. Its where things like the Debug Key will be stored.
export ANDROID_HOME=~/.android
You can automate it for your login. Just add it to your .bash_profile
(below is from my OS X 10.8.5 machine):
$ cat ~/.bash_profile
# MacPorts Installer addition on 2012-07-19 at 20:21:05
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Android
export ANDROID_NDK_ROOT=/opt/android-ndk-r9
export ANDROID_SDK_ROOT=/opt/android-sdk
export JAVA_HOME=`/usr/libexec/java_home`
export ANDROID_HOME=~/.android
export PATH="$ANDROID_SDK_ROOT/tools/":"$ANDROID_SDK_ROOT/platform-tools/":"$PATH"
According to David Turner on the NDK Mailing List, both ANDROID_NDK_ROOT
and ANDROID_SDK_ROOT
need to be set because other tools depend on those values (see Recommended NDK Directory?).
After modifying ~/.bash_profile
, then perform the following (or logoff and back on):
source ~/.bash_profile
Haru is a free, cross platform, open-sourced software library for generating PDF written in ANSI-C. It can work as both a static-library (.a, .lib) and a shared-library (.so, .dll).
Didn't try it myself, but maybe it can help you
ZonedDateTime.parse(
"Jun 13 2003 23:11:52.454 UTC" ,
DateTimeFormatter.ofPattern ( "MMM d uuuu HH:mm:ss.SSS z" )
)
.toInstant()
.toEpochMilli()
1055545912454
This Answer expands on the Answer by Lockni.
DateTimeFormatter
First define a formatting pattern to match your input string by creating a DateTimeFormatter
object.
String input = "Jun 13 2003 23:11:52.454 UTC";
DateTimeFormatter f = DateTimeFormatter.ofPattern ( "MMM d uuuu HH:mm:ss.SSS z" );
ZonedDateTime
Parse the string as a ZonedDateTime
. You can think of that class as: ( Instant
+ ZoneId
).
ZonedDateTime zdt = ZonedDateTime.parse ( "Jun 13 2003 23:11:52.454 UTC" , f );
zdt.toString(): 2003-06-13T23:11:52.454Z[UTC]
I do not recommend tracking date-time values as a count-from-epoch. Doing so makes debugging tricky as humans cannot discern a meaningful date-time from a number so invalid/unexpected values may slip by. Also such counts are ambiguous, in granularity (whole seconds, milli, micro, nano, etc.) and in epoch (at least two dozen in by various computer systems).
But if you insist you can get a count of milliseconds from the epoch of first moment of 1970 in UTC (1970-01-01T00:00:00
) through the Instant
class. Be aware this means data-loss as you are truncating any nanoseconds to milliseconds.
Instant instant = zdt.toInstant ();
instant.toString(): 2003-06-13T23:11:52.454Z
long millisSinceEpoch = instant.toEpochMilli() ;
1055545912454
The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date
, Calendar
, & SimpleDateFormat
.
To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.
The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.
You may exchange java.time objects directly with your database. Use a JDBC driver compliant with JDBC 4.2 or later. No need for strings, no need for java.sql.*
classes.
Where to obtain the java.time classes?
The ThreeTen-Extra project extends java.time with additional classes. This project is a proving ground for possible future additions to java.time. You may find some useful classes here such as Interval
, YearWeek
, YearQuarter
, and more.
I just benchmarked these two approaches on data frame with 663,552 rows using the following code:
system.time(
resultsByLevel$subject <- sapply(resultsByLevel$variable, function(x) {
s <- strsplit(x, ".", fixed=TRUE)[[1]]
s[length(s)]
})
)
user system elapsed
3.722 0.000 3.594
and
system.time(
resultsByLevel$subject <- sapply(resultsByLevel$variable, function(x) {
s <- strsplit(x, ".", fixed=TRUE)[[1]]
tail(s, n=1)
})
)
user system elapsed
28.174 0.000 27.662
So, assuming you're working with vectors, accessing the length position is significantly faster.
git status #then file which you need to push git add example.FileExtension
git commit "message is example"
git push -u origin(or whatever name you used) master(or name of some branch where you want to push it)
You have to catch the SIGINT signal (we are talking POSIX right?)
See @Gab Royer´s answer for sigaction.
Example:
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
void my_handler(sig_t s){
printf("Caught signal %d\n",s);
exit(1);
}
int main(int argc,char** argv)
{
signal (SIGINT,my_handler);
while(1);
return 0;
}
Here is my enhanced version that when we want to load css files or there are image references in the part to print.
In these cases, we have to wait until the css files or the images are fully loaded before calling the print() function. Therefor, we'd better to move the print() and close() function calls into the html. Following is the code example:
var prtContent = document.getElementById("order-to-print");
var WinPrint = window.open('', '', 'left=0,top=0,width=384,height=900,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write('<html><head>');
WinPrint.document.write('<link rel="stylesheet" href="assets/css/print/normalize.css">');
WinPrint.document.write('<link rel="stylesheet" href="assets/css/print/receipt.css">');
WinPrint.document.write('</head><body onload="print();close();">');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.write('</body></html>');
WinPrint.document.close();
WinPrint.focus();
-ErrorAction Stop
is changing things for you. Try adding this and see what you get:
Catch [System.Management.Automation.ActionPreferenceStopException] {
"caught a StopExecution Exception"
$error[0]
}
Here is the link to documentation INSERT ... ON DUPLICATE Statement.
My 2 cents, from a current implementation Point of View and for SWIG users on k8 (x86_64) architecture.
First long long
and long int
are different types
but sizeof(long long) == sizeof(long int) == sizeof(int64_t)
First try to find where and how the compiler define int64_t and uint64_t
grepc -rn "typedef.*INT64_TYPE" /lib/gcc
/lib/gcc/x86_64-linux-gnu/9/include/stdint-gcc.h:43:typedef __INT64_TYPE__ int64_t;
/lib/gcc/x86_64-linux-gnu/9/include/stdint-gcc.h:55:typedef __UINT64_TYPE__ uint64_t;
So we need to find this compiler macro definition
gcc -dM -E -x c /dev/null | grep __INT64
#define __INT64_C(c) c ## L
#define __INT64_MAX__ 0x7fffffffffffffffL
#define __INT64_TYPE__ long int
gcc -dM -E -x c++ /dev/null | grep __INT64
#define __INT64_C(c) c ## L
#define __INT64_MAX__ 0x7fffffffffffffffL
#define __INT64_TYPE__ long int
clang -dM -E -x c++ /dev/null | grep INT64_TYPE
#define __INT64_TYPE__ long int
#define __UINT64_TYPE__ long unsigned int
Clang, GNU compilers:
-dM
dumps a list of macros.
-E
prints results to stdout instead of a file.
-x c
and -x c++
select the programming language when using a file without a filename extension, such as /dev/null
note: for swig user, on Linux x86_64 use -DSWIGWORDSIZE64
On Catalina 10.15 IIRC
clang -dM -E -x c++ /dev/null | grep INT64_TYPE
#define __INT64_TYPE__ long long int
#define __UINT64_TYPE__ long long unsigned int
Clang:
-dM
dumps a list of macros.
-E
prints results to stdout instead of a file.
-x c
and -x c++
select the programming language when using a file without a filename extension, such as /dev/null
note: for swig user, on macOS x86_64 don't use -DSWIGWORDSIZE64
First
sizeof(long int) == 4
and sizeof(long long) == 8
in stdint.h
we have:
#if _VCRT_COMPILER_PREPROCESSOR
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
note: for swig user, on windows x86_64 don't use -DSWIGWORDSIZE64
First see https://github.com/swig/swig/blob/3a329566f8ae6210a610012ecd60f6455229fe77/Lib/stdint.i#L20-L24 so you can control the typedef using SWIGWORDSIZE64
but...
now the bad: SWIG Java and SWIG CSHARP do not take it into account
So you may want to use
#if defined(SWIGJAVA)
#if defined(SWIGWORDSIZE64)
%define PRIMITIVE_TYPEMAP(NEW_TYPE, TYPE)
%clear NEW_TYPE;
%clear NEW_TYPE *;
%clear NEW_TYPE &;
%clear const NEW_TYPE &;
%apply TYPE { NEW_TYPE };
%apply TYPE * { NEW_TYPE * };
%apply TYPE & { NEW_TYPE & };
%apply const TYPE & { const NEW_TYPE & };
%enddef // PRIMITIVE_TYPEMAP
PRIMITIVE_TYPEMAP(long int, long long);
PRIMITIVE_TYPEMAP(unsigned long int, long long);
#undef PRIMITIVE_TYPEMAP
#endif // defined(SWIGWORDSIZE64)
#endif // defined(SWIGJAVA)
and
#if defined(SWIGCSHARP)
#if defined(SWIGWORDSIZE64)
%define PRIMITIVE_TYPEMAP(NEW_TYPE, TYPE)
%clear NEW_TYPE;
%clear NEW_TYPE *;
%clear NEW_TYPE &;
%clear const NEW_TYPE &;
%apply TYPE { NEW_TYPE };
%apply TYPE * { NEW_TYPE * };
%apply TYPE & { NEW_TYPE & };
%apply const TYPE & { const NEW_TYPE & };
%enddef // PRIMITIVE_TYPEMAP
PRIMITIVE_TYPEMAP(long int, long long);
PRIMITIVE_TYPEMAP(unsigned long int, unsigned long long);
#undef PRIMITIVE_TYPEMAP
#endif // defined(SWIGWORDSIZE64)
#endif // defined(SWIGCSHARP)
So int64_t
aka long int
will be bind to Java/C# long
on Linux...
In this answer I am using an example posted by Justin Grammens.
JSON stands for JavaScript Object Notation. In JavaScript properties can be referenced both like this object1.name
and like this object['name'];
. The example from the article uses this bit of JSON.
The Parts
A fan object with email as a key and [email protected] as a value
{
fan:
{
email : '[email protected]'
}
}
So the object equivalent would be fan.email;
or fan['email'];
. Both would have the same value
of '[email protected]'
.
The following is what our author used to make a HttpClient Request. I do not claim to be an expert at all this so if anyone has a better way to word some of the terminology feel free.
public static HttpResponse makeRequest(String path, Map params) throws Exception
{
//instantiates httpclient to make request
DefaultHttpClient httpclient = new DefaultHttpClient();
//url with the post data
HttpPost httpost = new HttpPost(path);
//convert parameters into JSON object
JSONObject holder = getJsonObjectFromMap(params);
//passes the results to a string builder/entity
StringEntity se = new StringEntity(holder.toString());
//sets the post request as the resulting string
httpost.setEntity(se);
//sets a request header so the page receving the request
//will know what to do with it
httpost.setHeader("Accept", "application/json");
httpost.setHeader("Content-type", "application/json");
//Handles what is returned from the page
ResponseHandler responseHandler = new BasicResponseHandler();
return httpclient.execute(httpost, responseHandler);
}
If you are not familiar with the Map
data structure please take a look at the Java Map reference. In short, a map is similar to a dictionary or a hash.
private static JSONObject getJsonObjectFromMap(Map params) throws JSONException {
//all the passed parameters from the post request
//iterator used to loop through all the parameters
//passed in the post request
Iterator iter = params.entrySet().iterator();
//Stores JSON
JSONObject holder = new JSONObject();
//using the earlier example your first entry would get email
//and the inner while would get the value which would be '[email protected]'
//{ fan: { email : '[email protected]' } }
//While there is another entry
while (iter.hasNext())
{
//gets an entry in the params
Map.Entry pairs = (Map.Entry)iter.next();
//creates a key for Map
String key = (String)pairs.getKey();
//Create a new map
Map m = (Map)pairs.getValue();
//object for storing Json
JSONObject data = new JSONObject();
//gets the value
Iterator iter2 = m.entrySet().iterator();
while (iter2.hasNext())
{
Map.Entry pairs2 = (Map.Entry)iter2.next();
data.put((String)pairs2.getKey(), (String)pairs2.getValue());
}
//puts email and '[email protected]' together in map
holder.put(key, data);
}
return holder;
}
Please feel free to comment on any questions that arise about this post or if I have not made something clear or if I have not touched on something that your still confused about... etc whatever pops in your head really.
(I will take down if Justin Grammens does not approve. But if not then thanks Justin for being cool about it.)
I just happend to get a comment about how to use the code and realized that there was a mistake in the return type. The method signature was set to return a string but in this case it wasnt returning anything. I changed the signature to HttpResponse and will refer you to this link on Getting Response Body of HttpResponse the path variable is the url and I updated to fix a mistake in the code.
Here is what i have done to find the version:
just write SELECT @@version
and it will give you the version.
Using the Window.URL API - https://developer.mozilla.org/en-US/docs/Web/API/Window/URL
Works with http(s), ports etc.
var url = new URL('/path/to/websocket', window.location.href);
url.protocol = url.protocol.replace('http', 'ws');
url.href // => ws://www.example.com:9999/path/to/websocket
bit rate : no of bits(0 or 1 for binary signal) transmitted per second.
baud rate : no of symbols per second.
A symbol consists of 'n' number of bits.
Baud rate = (bit rate)/n
So baud rate is always less than or equal to bit rate.It is equal when signal is binary.
There are 2 options to find matching text; string.match
or string.find
.
Both of these perform a regex search on the string to find matches.
string.find()
string.find(subject string, pattern string, optional start position, optional plain flag)
Returns the startIndex
& endIndex
of the substring found.
The plain
flag allows for the pattern to be ignored and intead be interpreted as a literal. Rather than (tiger)
being interpreted as a regex capture group matching for tiger
, it instead looks for (tiger)
within a string.
Going the other way, if you want to regex match but still want literal special characters (such as .()[]+-
etc.), you can escape them with a percentage; %(tiger%)
.
You will likely use this in combination with string.sub
str = "This is some text containing the word tiger."
if string.find(str, "tiger") then
print ("The word tiger was found.")
else
print ("The word tiger was not found.")
end
string.match()
string.match(s, pattern, optional index)
Returns the capture groups found.
str = "This is some text containing the word tiger."
if string.match(str, "tiger") then
print ("The word tiger was found.")
else
print ("The word tiger was not found.")
end
With lombok it's easy to declare a Pair
class:
@Data(staticConstructor = "of")
public class Pair<A, B> {
private final A left;
private final B right;
}
This will generates getters, static constructor named "of", equals()
, hashcode()
and toString()
.
see @Data
documentation for more information
What you are asking is thoroughly covered by Eric Lippert in his blog post Closing over the loop variable considered harmful and its sequel.
For me, the most convincing argument is that having new variable in each iteration would be inconsistent with for(;;)
style loop. Would you expect to have a new int i
in each iteration of for (int i = 0; i < 10; i++)
?
The most common problem with this behavior is making a closure over iteration variable and it has an easy workaround:
foreach (var s in strings)
{
var s_for_closure = s;
query = query.Where(i => i.Prop == s_for_closure); // access to modified closure
My blog post about this issue: Closure over foreach variable in C#.
Try this, remember to include moment js,
function getDates(startDate, stopDate) {
var dateArray = [];
var currentDate = moment(startDate);
var stopDate = moment(stopDate);
while (currentDate <= stopDate) {
dateArray.push( moment(currentDate).format('YYYY-MM-DD') )
currentDate = moment(currentDate).add(1, 'days');
}
return dateArray;
}
Based on @ArchCodeMonkey answer.
If you have declare(strict_types=1)
you must cast second argument to string
I liked the solution in the earlier post.
I made a mini-class, called it class AlphabeticalHash
. It also has a method called ap
, which accepts one argument, a Hash
, as input: ap variable
. Akin to pp (pp variable
)
But it will (try and) print in alphabetical list (its keys). Dunno if anyone else wants to use this, it's available as a gem, you can install it as such: gem install alphabetical_hash
For me, this is simple enough. If others need more functionality, let me know, I'll include it into the gem.
EDIT: Credit goes to Peter, who gave me the idea. :)
View(function_name)
- eg. View(mean)
Make sure to use uppercase [V]. The read-only code will open in the editor.
Try .replace(/ /g,"_");
Edit: or .split(' ').join('_')
if you have an aversion to REs
Edit: John Resig said:
If you're searching and replacing through a string with a static search and a static replace it's faster to perform the action with .split("match").join("replace") - which seems counter-intuitive but it manages to work that way in most modern browsers. (There are changes going in place to grossly improve the performance of .replace(/match/g, "replace") in the next version of Firefox - so the previous statement won't be the case for long.)
SQL query to change the id column into first:
ALTER TABLE `student` CHANGE `id` `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT FIRST;
or by using:
ALTER TABLE `student` CHANGE `id` `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT AFTER 'column_name'
This code
var title = news.title;
var link = news.link;
arr.push({title : link});
is not doing what you think it does. What gets pushed is a new object with a single member named "title" and with link
as the value ... the actual title
value is not used.
To save an object with two fields you have to do something like
arr.push({title:title, link:link});
or with recent Javascript advances you can use the shortcut
arr.push({title, link}); // Note: comma "," and not colon ":"
If instead you want the key of the object to be the content of the variable title
you can use
arr.push({[title]: link}); // Note that title has been wrapped in brackets
We used this in our HRMS System you will find it useful
SELECT CAST(DAYNAME(daydate) as CHAR) as dayname,daydate
FROM
(select CAST((date_add('20110101', interval H.i*100 + T.i*10 + U.i day) )as DATE) as daydate
from erp_integers as H
cross
join erp_integers as T
cross
join erp_integers as U
where date_add('20110101', interval H.i*100 + T.i*10 + U.i day ) <= '20110228'
order
by daydate ASC
)Days
You have indented part of your code in settings.py:
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
#'django.contrib.admindocs',
'tinymce',
'sorl.thumbnail',
'south',
'django_facebook',
'djcelery',
'devserver',
'main',
Therefore, it is giving you an error.
The easiest way to remove any link from the My Account panel in Magento is to first copy:
app/design/frontend/base/default/template/customer/account/navigation.phtml
to
app/design/frontend/enterprise/YOURSITE/template/customer/account/navigation.phtml
Open the file and fine this line, it should be around line 34:
<?php $_index = 1; ?>
Right below it add this:
<?php $_count = count($_links); /* Add or Remove Account Left Navigation Links Here -*/
unset($_links['tags']); /* My Tags */
unset($_links['invitations']); /* My Invitations */
unset($_links['enterprise_customerbalance']); /* Store Credit */
unset($_links['OAuth Customer Tokens']); /* My Applications */
unset($_links['enterprise_reward']); /* Reward Points */
unset($_links['giftregistry']); /* Gift Registry */
unset($_links['downloadable_products']); /* My Downloadable Products */
unset($_links['recurring_profiles']); /* Recurring Profiles */
unset($_links['billing_agreements']); /* Billing Agreements */
unset($_links['enterprise_giftcardaccount']); /* Gift Card Link */
?>
Just remove any of the links here that you DO want to appear.
On Android 4.4.4, it seems the only way I could stop an alpha fading animation on a View was calling View.animate().cancel()
(i.e., calling .cancel()
on the View's ViewPropertyAnimator
).
Here's the code I'm using for compatibility before and after ICS:
public void stopAnimation(View v) {
v.clearAnimation();
if (canCancelAnimation()) {
v.animate().cancel();
}
}
... with the method:
/**
* Returns true if the API level supports canceling existing animations via the
* ViewPropertyAnimator, and false if it does not
* @return true if the API level supports canceling existing animations via the
* ViewPropertyAnimator, and false if it does not
*/
public static boolean canCancelAnimation() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
}
Here's the animation that I'm stopping:
v.setAlpha(0f);
v.setVisibility(View.VISIBLE);
// Animate the content view to 100% opacity, and clear any animation listener set on the view.
v.animate()
.alpha(1f)
.setDuration(animationDuration)
.setListener(null);
giving a form element a name of submit will simple shadow the submit property . make sure you don't have a form element with the name submit and you should be able to access the submit function just fine .
When your activity is recreated after it was previously destroyed, you can recover your saved state from the Bundle that the system passes your activity. Both the onCreate() and onRestoreInstanceState() callback methods receive the same Bundle that contains the instance state information.
Because the onCreate() method is called whether the system is creating a new instance of your activity or recreating a previous one, you must check whether the state Bundle is null before you attempt to read it. If it is null, then the system is creating a new instance of the activity, instead of restoring a previous one that was destroyed.
static final String STATE_USER = "user";
private String mUser;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Check whether we're recreating a previously destroyed instance
if (savedInstanceState != null) {
// Restore value of members from saved state
mUser = savedInstanceState.getString(STATE_USER);
} else {
// Probably initialize members with default values for a new instance
mUser = "NewUser";
}
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
savedInstanceState.putString(STATE_USER, mUser);
// Always call the superclass so it can save the view hierarchy state
super.onSaveInstanceState(savedInstanceState);
}
http://developer.android.com/training/basics/activity-lifecycle/recreating.html
someone here may find it useful. hhb_curl_exec2 works pretty much like curl_exec, but arg3 is an array which will be populated with the returned http headers (numeric index), and arg4 is an array which will be populated with the returned cookies ($cookies["expires"]=>"Fri, 06-May-2016 05:58:51 GMT"), and arg5 will be populated with... info about the raw request made by curl.
the downside is that it requires CURLOPT_RETURNTRANSFER to be on, else it error out, and that it will overwrite CURLOPT_STDERR and CURLOPT_VERBOSE, if you were already using them for something else.. (i might fix this later)
example of how to use it:
<?php
header("content-type: text/plain;charset=utf8");
$ch=curl_init();
$headers=array();
$cookies=array();
$debuginfo="";
$body="";
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$body=hhb_curl_exec2($ch,'https://www.youtube.com/',$headers,$cookies,$debuginfo);
var_dump('$cookies:',$cookies,'$headers:',$headers,'$debuginfo:',$debuginfo,'$body:',$body);
and the function itself..
function hhb_curl_exec2($ch, $url, &$returnHeaders = array(), &$returnCookies = array(), &$verboseDebugInfo = "")
{
$returnHeaders = array();
$returnCookies = array();
$verboseDebugInfo = "";
if (!is_resource($ch) || get_resource_type($ch) !== 'curl') {
throw new InvalidArgumentException('$ch must be a curl handle!');
}
if (!is_string($url)) {
throw new InvalidArgumentException('$url must be a string!');
}
$verbosefileh = tmpfile();
$verbosefile = stream_get_meta_data($verbosefileh);
$verbosefile = $verbosefile['uri'];
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $verbosefileh);
curl_setopt($ch, CURLOPT_HEADER, 1);
$html = hhb_curl_exec($ch, $url);
$verboseDebugInfo = file_get_contents($verbosefile);
curl_setopt($ch, CURLOPT_STDERR, NULL);
fclose($verbosefileh);
unset($verbosefile, $verbosefileh);
$headers = array();
$crlf = "\x0d\x0a";
$thepos = strpos($html, $crlf . $crlf, 0);
$headersString = substr($html, 0, $thepos);
$headerArr = explode($crlf, $headersString);
$returnHeaders = $headerArr;
unset($headersString, $headerArr);
$htmlBody = substr($html, $thepos + 4); //should work on utf8/ascii headers... utf32? not so sure..
unset($html);
//I REALLY HOPE THERE EXIST A BETTER WAY TO GET COOKIES.. good grief this looks ugly..
//at least it's tested and seems to work perfectly...
$grabCookieName = function($str)
{
$ret = "";
$i = 0;
for ($i = 0; $i < strlen($str); ++$i) {
if ($str[$i] === ' ') {
continue;
}
if ($str[$i] === '=') {
break;
}
$ret .= $str[$i];
}
return urldecode($ret);
};
foreach ($returnHeaders as $header) {
//Set-Cookie: crlfcoookielol=crlf+is%0D%0A+and+newline+is+%0D%0A+and+semicolon+is%3B+and+not+sure+what+else
/*Set-Cookie:ci_spill=a%3A4%3A%7Bs%3A10%3A%22session_id%22%3Bs%3A32%3A%22305d3d67b8016ca9661c3b032d4319df%22%3Bs%3A10%3A%22ip_address%22%3Bs%3A14%3A%2285.164.158.128%22%3Bs%3A10%3A%22user_agent%22%3Bs%3A109%3A%22Mozilla%2F5.0+%28Windows+NT+6.1%3B+WOW64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F43.0.2357.132+Safari%2F537.36%22%3Bs%3A13%3A%22last_activity%22%3Bi%3A1436874639%3B%7Dcab1dd09f4eca466660e8a767856d013; expires=Tue, 14-Jul-2015 13:50:39 GMT; path=/
Set-Cookie: sessionToken=abc123; Expires=Wed, 09 Jun 2021 10:18:14 GMT;
//Cookie names cannot contain any of the following '=,; \t\r\n\013\014'
//
*/
if (stripos($header, "Set-Cookie:") !== 0) {
continue;
/**/
}
$header = trim(substr($header, strlen("Set-Cookie:")));
while (strlen($header) > 0) {
$cookiename = $grabCookieName($header);
$returnCookies[$cookiename] = '';
$header = substr($header, strlen($cookiename) + 1); //also remove the =
if (strlen($header) < 1) {
break;
}
;
$thepos = strpos($header, ';');
if ($thepos === false) { //last cookie in this Set-Cookie.
$returnCookies[$cookiename] = urldecode($header);
break;
}
$returnCookies[$cookiename] = urldecode(substr($header, 0, $thepos));
$header = trim(substr($header, $thepos + 1)); //also remove the ;
}
}
unset($header, $cookiename, $thepos);
return $htmlBody;
}
function hhb_curl_exec($ch, $url)
{
static $hhb_curl_domainCache = "";
//$hhb_curl_domainCache=&$this->hhb_curl_domainCache;
//$ch=&$this->curlh;
if (!is_resource($ch) || get_resource_type($ch) !== 'curl') {
throw new InvalidArgumentException('$ch must be a curl handle!');
}
if (!is_string($url)) {
throw new InvalidArgumentException('$url must be a string!');
}
$tmpvar = "";
if (parse_url($url, PHP_URL_HOST) === null) {
if (substr($url, 0, 1) !== '/') {
$url = $hhb_curl_domainCache . '/' . $url;
} else {
$url = $hhb_curl_domainCache . $url;
}
}
;
curl_setopt($ch, CURLOPT_URL, $url);
$html = curl_exec($ch);
if (curl_errno($ch)) {
throw new Exception('Curl error (curl_errno=' . curl_errno($ch) . ') on url ' . var_export($url, true) . ': ' . curl_error($ch));
// echo 'Curl error: ' . curl_error($ch);
}
if ($html === '' && 203 != ($tmpvar = curl_getinfo($ch, CURLINFO_HTTP_CODE)) /*203 is "success, but no output"..*/ ) {
throw new Exception('Curl returned nothing for ' . var_export($url, true) . ' but HTTP_RESPONSE_CODE was ' . var_export($tmpvar, true));
}
;
//remember that curl (usually) auto-follows the "Location: " http redirects..
$hhb_curl_domainCache = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL), PHP_URL_HOST);
return $html;
}
Dim shll : Set shll = CreateObject("WScript.Shell")
Set Rt = shll.Exec("Notepad") : wscript.sleep 4000 : Rt.Terminate
Run the process with .Exec
.
Then wait for 4 seconds.
After that kill this process.
Well you can simply use Math.pow(a,b)
as you have used earlier and just convert its value by using (int)
before it. Below could be used as an example to it.
int x = (int) Math.pow(a,b);
where a
and b
could be double
or int
values as you want.
This will simply convert its output to an integer value as you required.
Here is firefox profile default prefs from python selenium 2.31.0 firefox_profile.py
and type "about:config" in firefox address bar to see all prefs
reference to the entries in about:config: http://kb.mozillazine.org/About:config_entries
DEFAULT_PREFERENCES = {
"app.update.auto": "false",
"app.update.enabled": "false",
"browser.download.manager.showWhenStarting": "false",
"browser.EULA.override": "true",
"browser.EULA.3.accepted": "true",
"browser.link.open_external": "2",
"browser.link.open_newwindow": "2",
"browser.offline": "false",
"browser.safebrowsing.enabled": "false",
"browser.search.update": "false",
"extensions.blocklist.enabled": "false",
"browser.sessionstore.resume_from_crash": "false",
"browser.shell.checkDefaultBrowser": "false",
"browser.tabs.warnOnClose": "false",
"browser.tabs.warnOnOpen": "false",
"browser.startup.page": "0",
"browser.safebrowsing.malware.enabled": "false",
"startup.homepage_welcome_url": "\"about:blank\"",
"devtools.errorconsole.enabled": "true",
"dom.disable_open_during_load": "false",
"extensions.autoDisableScopes" : 10,
"extensions.logging.enabled": "true",
"extensions.update.enabled": "false",
"extensions.update.notifyUser": "false",
"network.manage-offline-status": "false",
"network.http.max-connections-per-server": "10",
"network.http.phishy-userpass-length": "255",
"offline-apps.allow_by_default": "true",
"prompts.tab_modal.enabled": "false",
"security.fileuri.origin_policy": "3",
"security.fileuri.strict_origin_policy": "false",
"security.warn_entering_secure": "false",
"security.warn_entering_secure.show_once": "false",
"security.warn_entering_weak": "false",
"security.warn_entering_weak.show_once": "false",
"security.warn_leaving_secure": "false",
"security.warn_leaving_secure.show_once": "false",
"security.warn_submit_insecure": "false",
"security.warn_viewing_mixed": "false",
"security.warn_viewing_mixed.show_once": "false",
"signon.rememberSignons": "false",
"toolkit.networkmanager.disable": "true",
"toolkit.telemetry.enabled": "false",
"toolkit.telemetry.prompted": "2",
"toolkit.telemetry.rejected": "true",
"javascript.options.showInConsole": "true",
"browser.dom.window.dump.enabled": "true",
"webdriver_accept_untrusted_certs": "true",
"webdriver_enable_native_events": "true",
"webdriver_assume_untrusted_issuer": "true",
"dom.max_script_run_time": "30",
}
Thanks to @Bolling idea I have implement to support to avoid any nullable from List
public void setList(ArrayList<ThisIsAdapterListObject> _newList) {
//get the current items
if (ThisIsAdapterList != null) {
int currentSize = ThisIsAdapterList.size();
ThisIsAdapterList.clear();
//tell the recycler view that all the old items are gone
notifyItemRangeRemoved(0, currentSize);
}
if (_newList != null) {
if (ThisIsAdapterList == null) {
ThisIsAdapterList = new ArrayList<ThisIsAdapterListObject>();
}
ThisIsAdapterList.addAll(_newList);
//tell the recycler view how many new items we added
notifyItemRangeInserted(0, _newList.size());
}
}
ffmpeg -i movie.mp4 -vf trim=3:8 cut.mp4
Drop everything except from second 3 to second 8.
Use the aggregate MAX(signin)
grouped by id. This will list the most recent signin
for each id
.
SELECT
id,
MAX(signin) AS most_recent_signin
FROM tbl
GROUP BY id
To get the whole single record, perform an INNER JOIN
against a subquery which returns only the MAX(signin)
per id.
SELECT
tbl.id,
signin,
signout
FROM tbl
INNER JOIN (
SELECT id, MAX(signin) AS maxsign FROM tbl GROUP BY id
) ms ON tbl.id = ms.id AND signin = maxsign
WHERE tbl.id=1
Take a look at this. a clean and simple solution using jQuery.
<h1 onmouseover="go('The dog is in its shed')" onmouseout="clear()">lalala</h1>
<div id="goy"></div>
<script type="text/javascript">
$(function() {
$("h1").on('mouseover', function() {
$("#goy").text('The dog is in its shed');
}).on('mouseout', function() {
$("#goy").text("");
});
});
The simple way is:
function Foo(a) {
var that=this;
function privateMethod() { .. }
// public methods
that.add = function(b) {
return a + b;
};
that.avg = function(b) {
return that.add(b) / 2; // calling another public method
};
}
var x = new Foo(10);
alert(x.add(2)); // 12
alert(x.avg(20)); // 15
The reason for that
is that this
can be bound to something else if you give a method as an event handler, so you save the value during instantiation and use it later.
Edit: it's definitely not the best way, just a simple way. I'm waiting for good answers too!
The apiKey in this configuration snippet just identifies your Firebase project on the Google servers. It is not a security risk for someone to know it. In fact, it is necessary for them to know it, in order for them to interact with your Firebase project. This same configuration data is also included in every iOS and Android app that uses Firebase as its backend.
In that sense it is very similar to the database URL that identifies the back-end database associated with your project in the same snippet: https://<app-id>.firebaseio.com
. See this question on why this is not a security risk: How to restrict Firebase data modification?, including the use of Firebase's server side security rules to ensure only authorized users can access the backend services.
If you want to learn how to secure all data access to your Firebase backend services is authorized, read up on the documentation on Firebase security rules. These rules control access to file storage and database access, and are enforced on the Firebase servers. So no matter if it's your code, or somebody else's code that uses you configuration data, it can only do what the security rules allow it to do.
For another explanation of what Firebase uses these values for, and for which of them you can set quotas, see the Firebase documentation on using and managing API keys.
If you'd like to reduce the risk of committing this configuration data to version control, consider using the SDK auto-configuration of Firebase Hosting. While the keys will still end up in the browser in the same format, they won't be hard-coded into your code anymore with that.
For html generated in JS , do as below (we are using single quote as string wrapper). Each argument has to wrapped in a single quote else all of yours argument will be considered as a single argument like functionName('a,b') , now its a single argument with value a,b.
We have to use string escape character backslash() to close first argument with single quote, give a separator comma in between and then start next argument with a single quote. (This is the magic code to use
'\',\''
)
$('#ValuationAssignedTable').append('<tr> <td><a href=# onclick="return ReAssign(\'' + valuationId +'\',\'' + user + '\')">Re-Assign</a> </td> </tr>');
In my case it was the use of the call_command
module that posed a problem.
I added set DJANGO_SETTINGS_MODULE=mysite.settings
but it didn't work.
I finally found it:
add these lines at the top of the script, and the order matters.
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
import django
django.setup()
from django.core.management import call_command
When creating a new project - Maven - Java application in Netbeans the IDE is not recognizing the Main class on 1st class entry. (in Step 8 below we see no classes).
When first a generic class is created and then the Main class is created Netbeans is registering the Main class and the app could be run and debugged.
Steps that worked for me:
Hope this works for others as well.
Vince Huston has these criteria, which seem reasonable to me:
Singleton should be considered only if all three of the following criteria are satisfied:
- Ownership of the single instance cannot be reasonably assigned
- Lazy initialization is desirable
- Global access is not otherwise provided for
If ownership of the single instance, when and how initialization occurs, and global access are not issues, Singleton is not sufficiently interesting.
Date todayDate = new Date();
todayDate.getDay();
todayDate.getHours();
todayDate.getMinutes();
todayDate.getMonth();
todayDate.getTime();
I resolved this issue for myself. Though, the internal and SD memory was showing a lot of free space. It was an issue with phone memory, which was almost full.
Hence, I moved many of my apps from the phone memory to internal iemory, to free up the phone memory: Settings -> Storage -> Apps (under the internal storage section) -> Internal tab
Here are the ones which are not checked and that are occupying the space on the phone memory.
Click on the Apps (one by one) Click on the button: 'Move to Internal Storage'.
Once you free up a considerable amount of space on the phone memory this way, the error should not come.
The command you have typed is /startup.sh
, if you have to start a shell script you have to fire the command as shown below:
$ cd /home/mpatil/softwares/apache-tomcat-7.0.47/bin
$ sh startup.sh
or
$ ./startup.sh
Please try that, you also have to go to your tomcat's bin-folder (by using the cd-command) to execute this shell script. In your case this is /home/mpatil/softwares/apache-tomcat-7.0.47/bin
.
Absolute path routing
There are 2 methods for navigation, .navigate()
and .navigateByUrl()
You can use the method .navigateByUrl()
for absolute path routing:
import {Router} from '@angular/router';
constructor(private router: Router) {}
navigateToLogin() {
this.router.navigateByUrl('/login');
}
You put the absolute path to the URL of the component you want to navigate to.
Note: Always specify the complete absolute path when calling router's navigateByUrl
method. Absolute paths must start with a leading /
// Absolute route - Goes up to root level
this.router.navigate(['/root/child/child']);
// Absolute route - Goes up to root level with route params
this.router.navigate(['/root/child', crisis.id]);
Relative path routing
If you want to use relative path routing, use the .navigate()
method.
NOTE: It's a little unintuitive how the routing works, particularly parent, sibling, and child routes:
// Parent route - Goes up one level
// (notice the how it seems like you're going up 2 levels)
this.router.navigate(['../../parent'], { relativeTo: this.route });
// Sibling route - Stays at the current level and moves laterally,
// (looks like up to parent then down to sibling)
this.router.navigate(['../sibling'], { relativeTo: this.route });
// Child route - Moves down one level
this.router.navigate(['./child'], { relativeTo: this.route });
// Moves laterally, and also add route parameters
// if you are at the root and crisis.id = 15, will result in '/sibling/15'
this.router.navigate(['../sibling', crisis.id], { relativeTo: this.route });
// Moves laterally, and also add multiple route parameters
// will result in '/sibling;id=15;foo=foo'.
// Note: this does not produce query string URL notation with ? and & ... instead it
// produces a matrix URL notation, an alternative way to pass parameters in a URL.
this.router.navigate(['../sibling', { id: crisis.id, foo: 'foo' }], { relativeTo: this.route });
Or if you just need to navigate within the current route path, but to a different route parameter:
// If crisis.id has a value of '15'
// This will take you from `/hero` to `/hero/15`
this.router.navigate([crisis.id], { relativeTo: this.route });
Link parameters array
A link parameters array holds the following ingredients for router navigation:
['/hero']
['/hero', hero.id]
or ['/hero', { id: hero.id, foo: baa }]
Directory-like syntax
The router supports directory-like syntax in a link parameters list to help guide route name lookup:
./
or no leading slash is relative to the current level.
../
to go up one level in the route path.
You can combine relative navigation syntax with an ancestor path. If you must navigate to a sibling route, you could use the ../<sibling>
convention to go up one level, then over and down the sibling route path.
Important notes about relative nagivation
To navigate a relative path with the Router.navigate
method, you must supply the ActivatedRoute
to give the router knowledge of where you are in the current route tree.
After the link parameters array, add an object with a relativeTo
property set to the ActivatedRoute
. The router then calculates the target URL based on the active route's location.
From official Angular Router Documentation
At the time of my writing this answer, the accepted answer to this question appears to state that browsers are not required to delete a cookie when receiving a replacement cookie whose Expires
value is in the past. That claim is false. Setting Expires
to be in the past is the standard, spec-compliant way of deleting a cookie, and user agents are required by spec to respect it.
Using an Expires
attribute in the past to delete a cookie is correct and is the way to remove cookies dictated by the spec. The examples section of RFC 6255 states:
Finally, to remove a cookie, the server returns a Set-Cookie header with an expiration date in the past. The server will be successful in removing the cookie only if the Path and the Domain attribute in the Set-Cookie header match the values used when the cookie was created.
The User Agent Requirements section includes the following requirements, which together have the effect that a cookie must be immediately expunged if the user agent receives a new cookie with the same name whose expiry date is in the past
If [when receiving a new cookie] the cookie store contains a cookie with the same name, domain, and path as the newly created cookie:
- ...
- ...
- Update the creation-time of the newly created cookie to match the creation-time of the old-cookie.
- Remove the old-cookie from the cookie store.
Insert the newly created cookie into the cookie store.
A cookie is "expired" if the cookie has an expiry date in the past.
The user agent MUST evict all expired cookies from the cookie store if, at any time, an expired cookie exists in the cookie store.
Points 11-3, 11-4, and 12 above together mean that when a new cookie is received with the same name, domain, and path, the old cookie must be expunged and replaced with the new cookie. Finally, the point below about expired cookies further dictates that after that is done, the new cookie must also be immediately evicted. The spec offers no wiggle room to browsers on this point; if a browser were to offer the user the option to disable cookie expiration, as the accepted answer suggests some browsers do, then it would be in violation of the spec. (Such a feature would also have little use, and as far as I know it does not exist in any browser.)
Why, then, did the OP of this question observe this approach failing? Though I have not dusted off a copy of Internet Explorer to check its behaviour, I suspect it was because the OP's Expires
value was malformed! They used this value:
expires=Thu, Jan 01 1970 00:00:00 UTC;
However, this is syntactically invalid in two ways.
The syntax section of the spec dictates that the value of the Expires
attribute must be a
rfc1123-date, defined in [RFC2616], Section 3.3.1
Following the second link above, we find this given as an example of the format:
Sun, 06 Nov 1994 08:49:37 GMT
and find that the syntax definition...
requires that dates be written in day month year format, not month day year format as used by the question asker.
Specifically, it defines rfc1123-date
as follows:
rfc1123-date = wkday "," SP date1 SP time SP "GMT"
and defines date1
like this:
date1 = 2DIGIT SP month SP 4DIGIT
; day month year (e.g., 02 Jun 1982)
and
doesn't permit UTC
as a timezone.
The spec contains the following statement about what timezone offsets are acceptable in this format:
All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT), without exception.
What's more if we dig deeper into the original spec of this datetime format, we find that in its initial spec in https://tools.ietf.org/html/rfc822, the Syntax section lists "UT" (meaning "universal time") as a possible value, but does not list not UTC (Coordinated Universal Time) as valid. As far as I know, using "UTC" in this date format has never been valid; it wasn't a valid value when the format was first specified in 1982, and the HTTP spec has adopted a strictly more restrictive version of the format by banning the use of all "zone" values other than "GMT".
If the question asker here had instead used an Expires
attribute like this, then:
expires=Thu, 01 Jan 1970 00:00:00 GMT;
then it would presumably have worked.
use zzz instead of TZD
Example:
DateTime.Now.ToString("yyyy-MM-ddThh:mm:sszzz");
Response:
2011-08-09T11:50:00:02+02:00
sorted_by_second = sorted(data, key=lambda tup: tup[1])
or:
data.sort(key=lambda tup: tup[1]) # sorts in place
Turns out I have not looked good enough at my stack trace, the problem is not that the external JAR is not included.
The problem is that Android platform is missing javax.naming.* and many other packages that the external JAR has dependencies too.
Adding external JAR files, and setting Order and Export in Eclipse works as expected with Android projects.
The Ookii Dialogs for WPF library has a class that provides an implementation of a folder browser dialog for WPF.
There's also a version that works with Windows Forms.
Check if element's ID is exist
if ($('#id').attr('id') == 'id')_x000D_
{_x000D_
//OK_x000D_
}
_x000D_
In jQuery 1.4 you get the $.isEmptyObject function, but if you are forced to use an older version of jQ like us poor Drupal developers just steal use this code:
// This is a function similar to the jQuery 1.4 $.isEmptyObject.
function isObjectEmpty(obj) {
for ( var name in obj ) {
return false;
}
return true;
}
Use it like:
console.log(isObjectEmpty(the_object)); // Returns true or false.
If you look at the docs for bytes
, it points you to bytearray
:
bytearray([source[, encoding[, errors]]])
Return a new array of bytes. The bytearray type is a mutable sequence of integers in the range 0 <= x < 256. It has most of the usual methods of mutable sequences, described in Mutable Sequence Types, as well as most methods that the bytes type has, see Bytes and Byte Array Methods.
The optional source parameter can be used to initialize the array in a few different ways:
If it is a string, you must also give the encoding (and optionally, errors) parameters; bytearray() then converts the string to bytes using str.encode().
If it is an integer, the array will have that size and will be initialized with null bytes.
If it is an object conforming to the buffer interface, a read-only buffer of the object will be used to initialize the bytes array.
If it is an iterable, it must be an iterable of integers in the range 0 <= x < 256, which are used as the initial contents of the array.
Without an argument, an array of size 0 is created.
So bytes
can do much more than just encode a string. It's Pythonic that it would allow you to call the constructor with any type of source parameter that makes sense.
For encoding a string, I think that some_string.encode(encoding)
is more Pythonic than using the constructor, because it is the most self documenting -- "take this string and encode it with this encoding" is clearer than bytes(some_string, encoding)
-- there is no explicit verb when you use the constructor.
Edit: I checked the Python source. If you pass a unicode string to bytes
using CPython, it calls PyUnicode_AsEncodedString, which is the implementation of encode
; so you're just skipping a level of indirection if you call encode
yourself.
Also, see Serdalis' comment -- unicode_string.encode(encoding)
is also more Pythonic because its inverse is byte_string.decode(encoding)
and symmetry is nice.
Another solution if you want to keep this column as index.
pd.read_csv('filename.csv', index_col='Unnamed: 0')
You may think JDBC is a rich API and ResultSet has got so many methods then why not just a getCount() method? Well, For many databases e.g. Oracle, MySQL and SQL Server, ResultSet is a streaming API, this means that it does not load (or maybe even fetch) all the rows from the database server. By iterating to the end of the ResultSet you may add significantly to the time taken to execute in certain cases.
Btw, if you have to there are a couple of ways to do it e.g. by using ResultSet.last() and ResultSet.getRow() method, that's not the best way to do it but it works if you absolutely need it.
Though, getting the column count from a ResultSet is easy in Java. The JDBC API provides a ResultSetMetaData class which contains methods to return the number of columns returned by a query and hold by ResultSet.
My version of the regular expressions technique that's been suggested already:
values=(foo bar)
requestedValue=bar
requestedValue=${requestedValue##[[:space:]]}
requestedValue=${requestedValue%%[[:space:]]}
[[ "${values[@]/#/X-}" =~ "X-${requestedValue}" ]] || echo "Unsupported value"
What's happening here is that you're expanding the entire array of supported values into words and prepending a specific string, "X-" in this case, to each of them, and doing the same to the requested value. If this one is indeed contained in the array, then the resulting string will at most match one of the resulting tokens, or none at all in the contrary. In the latter case the || operator triggers and you know you're dealing with an unsupported value. Prior to all of that the requested value is stripped of all leading and trailing whitespace through standard shell string manipulation.
It's clean and elegant, I believe, though I'm not too sure of how performant it may be if your array of supported values is particularly large.
I like a lot of answers, particularly @saineshwar 's one. I'm using .net Core 3.0 with AutoMapper 9.0, so I feel it's time to update its answer.
What worked for me was in Startup.ConfigureServices(...) register the service in this way:
services.AddAutoMapper(cfg => cfg.AddProfile<MappingProfile>(),
AppDomain.CurrentDomain.GetAssemblies());
I think that rest of @saineshwar answer keeps perfect. But if anyone is interested my controller code is:
[HttpGet("{id}")]
public async Task<ActionResult> GetIic(int id)
{
// _context is a DB provider
var Iic = await _context.Find(id).ConfigureAwait(false);
if (Iic == null)
{
return NotFound();
}
var map = _mapper.Map<IicVM>(Iic);
return Ok(map);
}
And my mapping class:
public class MappingProfile : Profile
{
public MappingProfile()
{
CreateMap<Iic, IicVM>()
.ForMember(dest => dest.DepartmentName, o => o.MapFrom(src => src.Department.Name))
.ForMember(dest => dest.PortfolioTypeName, o => o.MapFrom(src => src.PortfolioType.Name));
//.ReverseMap();
}
}
----- EDIT -----
After reading the docs linked in the comments by Lucian Bargaoanu, I think it's better to change this answer a bit.
The parameterless services.AddAutoMapper()
(that had the @saineshwar answer) doesn't work anymore (at least for me). But if you use the NuGet assembly AutoMapper.Extensions.Microsoft.DependencyInjection, the framework is able to inspect all the classes that extend AutoMapper.Profile (like mine, MappingProfile).
So, in my case, where the class belong to the same executing assembly, the service registration can be shortened to services.AddAutoMapper(System.Reflection.Assembly.GetExecutingAssembly());
(A more elegant approach could be a parameterless extension with this coding).
Thanks, Lucian!
I wouldn't suggest using the Eclipse tool to generate the WS Client because I had bad experience with it:
I am not really sure if this matters but I had to consume a WS written in .NET. When I used the Eclipse's "New Web Service Client" tool it generated the Java classes using Axis (version 1.x) which as you can check is old (last version from 2006). There is a newer version though that is has some major changes but Eclipse doesn't use it.
Why the old version of Axis matters you'll say? Because when using OpenJDK you can run into some problems like missing cryptography algorithms in OpenJDK that are presented in the Oracle's JDK and some libraries like this one depend on them.
So I just used the wsimport tool and ended my headaches.
The obvious subtext of this question is:
why can't you just use
==
to check if two strings are the same?
Perl doesn't have distinct data types for text vs. numbers. They are both represented by the type "scalar". Put another way, strings are numbers if you use them as such.
if ( 4 == "4" ) { print "true"; } else { print "false"; }
true
if ( "4" == "4.0" ) { print "true"; } else { print "false"; }
true
print "3"+4
7
Since text and numbers aren't differentiated by the language, we can't simply overload the ==
operator to do the right thing for both cases. Therefore, Perl provides eq
to compare values as text:
if ( "4" eq "4.0" ) { print "true"; } else { print "false"; }
false
if ( "4.0" eq "4.0" ) { print "true"; } else { print "false"; }
true
In short:
==
or !=
, to compare two operands as numberseq
or ne
, to compare two operands as textThere are many other functions and operators that can be used to compare scalar values, but knowing the distinction between these two forms is an important first step.
UPDATED
DEMO: http://jsbin.com/uneti3/3
your code is wrong, it should be something like this:
$(bla).click(function() {
var disable = $target.toggleClass('open').hasClass('open');
$target.prev().prop("disabled", disable);
});
you are using the toggleClass function in wrong way
a bit more convoluted solution that fully matches your spec
echo `expr $FILENAME : '\(.*\)\.[^.]*'`_`date +%d-%m-%y`.`expr $FILENAME : '.*\.\([^.]*\)'`
where first 'expr' extracts file name without extension, second 'expr' extracts extension
the above all look good
but do you want to keep the result?
if so...
you can use the following
result = [element for element in data if element[1] == search]
then a simple
len(result)
lets you know if anything was found (and now you can do stuff with the results)
of course this does not handle elements which are length less than one (which you should be checking unless you know they always are greater than length 1, and in that case should you be using a tuple? (tuples are immutable))
if you know all items are a set length you can also do:
any(second == search for _, second in data)
or for len(data[0]) == 4:
any(second == search for _, second, _, _ in data)
...and I would recommend using
for element in data:
...
instead of
for i in range(len(data)):
...
(for future uses, unless you want to save or use 'i', and just so you know the '0' is not required, you only need use the full syntax if you are starting at a non zero value)
If I am to define the same proptypes for a particular shape multiple times, I like abstract it out to a proptypes file so that if the shape of the object changes, I only have to change the code in one place. It helps dry up the codebase a bit.
Example:
// Inside my proptypes.js file
import PT from 'prop-types';
export const product = {
id: PT.number.isRequired,
title: PT.string.isRequired,
sku: PT.string.isRequired,
description: PT.string.isRequired,
};
// Inside my component file
import PT from 'prop-types';
import { product } from './proptypes;
List.propTypes = {
productList: PT.arrayOf(product)
}
Try to use Aspose.cells library (not free, but trial is enough to read), it is quite good
Install-package Aspose.cells
There is sample code:
using Aspose.Cells;
using System;
namespace ExcelReader
{
class Program
{
static void Main(string[] args)
{
// Replace path for your file
readXLS(@"C:\MyExcelFile.xls"); // or "*.xlsx"
Console.ReadKey();
}
public static void readXLS(string PathToMyExcel)
{
//Open your template file.
Workbook wb = new Workbook(PathToMyExcel);
//Get the first worksheet.
Worksheet worksheet = wb.Worksheets[0];
//Get cells
Cells cells = worksheet.Cells;
// Get row and column count
int rowCount = cells.MaxDataRow;
int columnCount = cells.MaxDataColumn;
// Current cell value
string strCell = "";
Console.WriteLine(String.Format("rowCount={0}, columnCount={1}", rowCount, columnCount));
for (int row = 0; row <= rowCount; row++) // Numeration starts from 0 to MaxDataRow
{
for (int column = 0; column <= columnCount; column++) // Numeration starts from 0 to MaxDataColumn
{
strCell = "";
strCell = Convert.ToString(cells[row, column].Value);
if (String.IsNullOrEmpty(strCell))
{
continue;
}
else
{
// Do your staff here
Console.WriteLine(strCell);
}
}
}
}
}
}
102 is the rule of thumb, convert (varchar, creat_tms, 102) > '2011'
this.state.myArray.push('new value')
returns the length of the extended array, instead of the array itself.Array.prototype.push().
I guess you expect the returned value to be the array.
It seems it's rather the behaviour of React:
NEVER mutate this.state directly, as calling setState() afterwards may replace the mutation you made. Treat this.state as if it were immutable.React.Component.
I guess, you would do it like this (not familiar with React):
var joined = this.state.myArray.concat('new value');
this.setState({ myArray: joined })
Try Emmet plug-in command Go To Matching Pair:
http://docs.emmet.io/actions/go-to-pair/
Shortcut (Mac): Shift + Control + T
Shortcut (PC): Control + Alt + J
The problem is that the base class foo
has no parameterless constructor. So you must call constructor of the base class with parameters from constructor of the derived class:
public bar(int a, int b) : base(a, b)
{
c = a * b;
}
Running just "npm install" will look for dependencies listed in your package.json. The error you're getting says that you don't have a package.json file set up (or you're in the wrong directory).
If you're trying to install a specific package, you should use 'npm install {package name}'. See here for more info about the command.
Otherwise, you'll need to create a package.json file for your dependencies or go to the right directory and then run 'npm install'.
Try using .+
instead of [(\w)(\W)(\s)]+
.
Note that this actually includes more than you need - ASCII only defines the first 128 characters.
Use dates.tolist()
to convert to native datetime objects, then simply access year
. Example:
>>> dates = np.array(['2010-10-17', '2011-05-13', '2012-01-15'], dtype='datetime64')
>>> [x.year for x in dates.tolist()]
[2010, 2011, 2012]
This is basically the same idea exposed in https://stackoverflow.com/a/35281829/2192272, but using simpler syntax.
Tested with python 3.6 / numpy 1.18.
It can be done with simple Makefile:
sleep%:
sleep $(subst sleep,,$@)
@echo $@ done.
Use -j
option.
$ make -j sleep3 sleep2 sleep1
sleep 3
sleep 2
sleep 1
sleep1 done.
sleep2 done.
sleep3 done.
Without -j
option it executes in serial.
$ make -j sleep3 sleep2 sleep1
sleep 3
sleep3 done.
sleep 2
sleep2 done.
sleep 1
sleep1 done.
You can also do dry run with `-n' option.
$ make -j -n sleep3 sleep2 sleep1
sleep 3
sleep 2
sleep 1
Here's a more flexible way.
let's say this is your form.
<form>
<input type='checkbox' name='user_ids[]' value='1'id='checkbox_1' />
<input type='checkbox' name='user_ids[]' value='2'id='checkbox_2' />
<input type='checkbox' name='user_ids[]' value='3'id='checkbox_3' />
<input name="confirm" type="button" value="confirm" onclick="submit_form();" />
</form>
And this is your jquery ajax below...
// Don't get confused at this portion right here
// cuz "var data" will get all the values that the form
// has submitted in the $_POST. It doesn't matter if you
// try to pass a text or password or select form element.
// Remember that the "form" is not a name attribute
// of the form, but the "form element" itself that submitted
// the current post method
var data = $("form").serialize();
$.ajax({
url: "link/of/your/ajax.php", // link of your "whatever" php
type: "POST",
async: true,
cache: false,
data: data, // all data will be passed here
success: function(data){
alert(data) // The data that is echoed from the ajax.php
}
});
And in your ajax.php, you try echoing or print_r your post to see what's happening inside it. This should look like this. Only checkboxes that you checked will be returned. If you didn't checked any, it will return an error.
<?php
print_r($_POST); // this will be echoed back to you upon success.
echo "This one too, will be echoed back to you";
Hope that is clear enough.
You can simply read each line from the file and assign it to an array.
#!/bin/bash
i=0
while read line
do
arr[$i]="$line"
i=$((i+1))
done < file.txt
Under normal circumstances,out of bound of array when you encounter the error. So,check uo your array subscript.
AJAX requests may not complete in the order they were started. Instead of aborting, you can choose to ignore all AJAX responses except for the most recent one:
Rough outline of code:
var xhrCount = 0;
function sendXHR() {
// sequence number for the current invocation of function
var seqNumber = ++xhrCount;
$.post("/echo/json/", { delay: Math.floor(Math.random() * 5) }, function() {
// this works because of the way closures work
if (seqNumber === xhrCount) {
console.log("Process the response");
} else {
console.log("Ignore the response");
}
});
}
sendXHR();
sendXHR();
sendXHR();
// AJAX requests complete in any order but only the last
// one will trigger "Process the response" message
You can un-check the build automatically in Project menu and then build by hand by type Ctrl + B, or clicking an icon the appears to the right of the printer icon.
I deactivated my "Arno's Iptables Firewall" for testing, and then the messages are gone
Note in 2018: readAsBinaryString
is outdated. For use cases where previously you'd have used it, these days you'd use readAsArrayBuffer
(or in some cases, readAsDataURL
) instead.
readAsBinaryString
says that the data must be represented as a binary string, where:
...every byte is represented by an integer in the range [0..255].
JavaScript originally didn't have a "binary" type (until ECMAScript 5's WebGL support of Typed Array* (details below) -- it has been superseded by ECMAScript 2015's ArrayBuffer) and so they went with a String with the guarantee that no character stored in the String would be outside the range 0..255. (They could have gone with an array of Numbers instead, but they didn't; perhaps large Strings are more memory-efficient than large arrays of Numbers, since Numbers are floating-point.)
If you're reading a file that's mostly text in a western script (mostly English, for instance), then that string is going to look a lot like text. If you read a file with Unicode characters in it, you should notice a difference, since JavaScript strings are UTF-16** (details below) and so some characters will have values above 255, whereas a "binary string" according to the File API spec wouldn't have any values above 255 (you'd have two individual "characters" for the two bytes of the Unicode code point).
If you're reading a file that's not text at all (an image, perhaps), you'll probably still get a very similar result between readAsText
and readAsBinaryString
, but with readAsBinaryString
you know that there won't be any attempt to interpret multi-byte sequences as characters. You don't know that if you use readAsText
, because readAsText
will use an encoding determination to try to figure out what the file's encoding is and then map it to JavaScript's UTF-16 strings.
You can see the effect if you create a file and store it in something other than ASCII or UTF-8. (In Windows you can do this via Notepad; the "Save As" as an encoding drop-down with "Unicode" on it, by which looking at the data they seem to mean UTF-16; I'm sure Mac OS and *nix editors have a similar feature.) Here's a page that dumps the result of reading a file both ways:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>Show File Data</title>
<style type='text/css'>
body {
font-family: sans-serif;
}
</style>
<script type='text/javascript'>
function loadFile() {
var input, file, fr;
if (typeof window.FileReader !== 'function') {
bodyAppend("p", "The file API isn't supported on this browser yet.");
return;
}
input = document.getElementById('fileinput');
if (!input) {
bodyAppend("p", "Um, couldn't find the fileinput element.");
}
else if (!input.files) {
bodyAppend("p", "This browser doesn't seem to support the `files` property of file inputs.");
}
else if (!input.files[0]) {
bodyAppend("p", "Please select a file before clicking 'Load'");
}
else {
file = input.files[0];
fr = new FileReader();
fr.onload = receivedText;
fr.readAsText(file);
}
function receivedText() {
showResult(fr, "Text");
fr = new FileReader();
fr.onload = receivedBinary;
fr.readAsBinaryString(file);
}
function receivedBinary() {
showResult(fr, "Binary");
}
}
function showResult(fr, label) {
var markup, result, n, aByte, byteStr;
markup = [];
result = fr.result;
for (n = 0; n < result.length; ++n) {
aByte = result.charCodeAt(n);
byteStr = aByte.toString(16);
if (byteStr.length < 2) {
byteStr = "0" + byteStr;
}
markup.push(byteStr);
}
bodyAppend("p", label + " (" + result.length + "):");
bodyAppend("pre", markup.join(" "));
}
function bodyAppend(tagName, innerHTML) {
var elm;
elm = document.createElement(tagName);
elm.innerHTML = innerHTML;
document.body.appendChild(elm);
}
</script>
</head>
<body>
<form action='#' onsubmit="return false;">
<input type='file' id='fileinput'>
<input type='button' id='btnLoad' value='Load' onclick='loadFile();'>
</form>
</body>
</html>
If I use that with a "Testing 1 2 3" file stored in UTF-16, here are the results I get:
Text (13): 54 65 73 74 69 6e 67 20 31 20 32 20 33 Binary (28): ff fe 54 00 65 00 73 00 74 00 69 00 6e 00 67 00 20 00 31 00 20 00 32 00 20 00 33 00
As you can see, readAsText
interpreted the characters and so I got 13 (the length of "Testing 1 2 3"), and readAsBinaryString
didn't, and so I got 28 (the two-byte BOM plus two bytes for each character).
* XMLHttpRequest.response with responseType = "arraybuffer"
is supported in HTML 5.
** "JavaScript strings are UTF-16" may seem like an odd statement; aren't they just Unicode? No, a JavaScript string is a series of UTF-16 code units; you see surrogate pairs as two individual JavaScript "characters" even though, in fact, the surrogate pair as a whole is just one character. See the link for details.
Give your button a custom background: @drawable/material_btn_blue
Escaping Brackets: String Interpolation $("") :
Now, you can also use c# string interpolation like this (feature available in C# 6.0)
var inVal= "1, 2, 3";
var outVal= $" foo {{{inVal}}}";
//Output will be: foo {1, 2, 3}
Change your configuration to this (add a slash):
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Or the solution outlined below (proposed by @absiddiqueLive) will work for any domain:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
If you need to support http and https and preserve the protocol choice try the following:
RewriteRule ^login\$ https://www.%{HTTP_HOST}/login [R=301,L]
Where you replace login
with checkout.php
or whatever URL you need to support HTTPS on.
I'd argue this is a bad idea though. For the reasoning please read this answer.
A1: Business Logic goes to Model
part in MVC
. Role of Model
is to contain data and business logic. Controller
on the other hand is responsible to receive user input and decide what to do.
A2: A Business Rule
is part of Business Logic
. They have a has a
relationship. Business Logic
has Business Rules
.
Take a look at Wikipedia entry for MVC
. Go to Overview where it mentions the flow of MVC
pattern.
Also look at Wikipedia entry for Business Logic
. It is mentioned that Business Logic
is comprised of Business Rules
and Workflow
.
Simple jQuery plugin to prevent keyboard showing for inputs:
(function ($) {
$.fn.preventKeyboard = function () {
return this
.filter('input')
.on('focus', function () {
$(this)
.attr('readonly', 'readonly')
.blur()
.removeAttr('readonly');
});
};
}(jQuery));
Usage
It's useful for date fields with some datepicker attached.
$('#my_datepicker_field').preventKeyboard();
Try the snippet below on your smartphone!
(or see it on https://jsfiddle.net/dtyzLjhw/)
(function($) {_x000D_
// Create plugin that prevents showing the keyboard_x000D_
$.fn.preventKeyboard = function() {_x000D_
return this_x000D_
.filter('input')_x000D_
.on('focus', function() {_x000D_
$(this)_x000D_
.attr('readonly', 'readonly')_x000D_
.blur()_x000D_
.removeAttr('readonly');_x000D_
});_x000D_
};_x000D_
_x000D_
$(document).ready(function($) {_x000D_
// Date field has datepicker attached._x000D_
$('input[name=date]').datepicker();_x000D_
_x000D_
// Prevent showing keyboard for the date field._x000D_
$('input[name=date]').preventKeyboard();_x000D_
});_x000D_
}(jQuery));
_x000D_
/*!_x000D_
* Datepicker for Bootstrap v1.8.0 (https://github.com/uxsolutions/bootstrap-datepicker)_x000D_
*_x000D_
* Licensed under the Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0)_x000D_
*/_x000D_
_x000D_
.datepicker {_x000D_
padding: 4px;_x000D_
-webkit-border-radius: 4px;_x000D_
-moz-border-radius: 4px;_x000D_
border-radius: 4px;_x000D_
direction: ltr;_x000D_
}_x000D_
_x000D_
.datepicker-inline {_x000D_
width: 220px;_x000D_
}_x000D_
_x000D_
.datepicker-rtl {_x000D_
direction: rtl;_x000D_
}_x000D_
_x000D_
.datepicker-rtl.dropdown-menu {_x000D_
left: auto;_x000D_
}_x000D_
_x000D_
.datepicker-rtl table tr td span {_x000D_
float: right;_x000D_
}_x000D_
_x000D_
.datepicker-dropdown {_x000D_
top: 0;_x000D_
left: 0;_x000D_
}_x000D_
_x000D_
.datepicker-dropdown:before {_x000D_
content: '';_x000D_
display: inline-block;_x000D_
border-left: 7px solid transparent;_x000D_
border-right: 7px solid transparent;_x000D_
border-bottom: 7px solid #999;_x000D_
border-top: 0;_x000D_
border-bottom-color: rgba(0, 0, 0, 0.2);_x000D_
position: absolute;_x000D_
}_x000D_
_x000D_
.datepicker-dropdown:after {_x000D_
content: '';_x000D_
display: inline-block;_x000D_
border-left: 6px solid transparent;_x000D_
border-right: 6px solid transparent;_x000D_
border-bottom: 6px solid #fff;_x000D_
border-top: 0;_x000D_
position: absolute;_x000D_
}_x000D_
_x000D_
.datepicker-dropdown.datepicker-orient-left:before {_x000D_
left: 6px;_x000D_
}_x000D_
_x000D_
.datepicker-dropdown.datepicker-orient-left:after {_x000D_
left: 7px;_x000D_
}_x000D_
_x000D_
.datepicker-dropdown.datepicker-orient-right:before {_x000D_
right: 6px;_x000D_
}_x000D_
_x000D_
.datepicker-dropdown.datepicker-orient-right:after {_x000D_
right: 7px;_x000D_
}_x000D_
_x000D_
.datepicker-dropdown.datepicker-orient-bottom:before {_x000D_
top: -7px;_x000D_
}_x000D_
_x000D_
.datepicker-dropdown.datepicker-orient-bottom:after {_x000D_
top: -6px;_x000D_
}_x000D_
_x000D_
.datepicker-dropdown.datepicker-orient-top:before {_x000D_
bottom: -7px;_x000D_
border-bottom: 0;_x000D_
border-top: 7px solid #999;_x000D_
}_x000D_
_x000D_
.datepicker-dropdown.datepicker-orient-top:after {_x000D_
bottom: -6px;_x000D_
border-bottom: 0;_x000D_
border-top: 6px solid #fff;_x000D_
}_x000D_
_x000D_
.datepicker table {_x000D_
margin: 0;_x000D_
-webkit-touch-callout: none;_x000D_
-webkit-user-select: none;_x000D_
-khtml-user-select: none;_x000D_
-moz-user-select: none;_x000D_
-ms-user-select: none;_x000D_
user-select: none;_x000D_
}_x000D_
_x000D_
.datepicker td,_x000D_
.datepicker th {_x000D_
text-align: center;_x000D_
width: 20px;_x000D_
height: 20px;_x000D_
-webkit-border-radius: 4px;_x000D_
-moz-border-radius: 4px;_x000D_
border-radius: 4px;_x000D_
border: none;_x000D_
}_x000D_
_x000D_
.table-striped .datepicker table tr td,_x000D_
.table-striped .datepicker table tr th {_x000D_
background-color: transparent;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.day:hover,_x000D_
.datepicker table tr td.day.focused {_x000D_
background: #eee;_x000D_
cursor: pointer;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.old,_x000D_
.datepicker table tr td.new {_x000D_
color: #999;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.disabled,_x000D_
.datepicker table tr td.disabled:hover {_x000D_
background: none;_x000D_
color: #999;_x000D_
cursor: default;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.highlighted {_x000D_
background: #d9edf7;_x000D_
border-radius: 0;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.today,_x000D_
.datepicker table tr td.today:hover,_x000D_
.datepicker table tr td.today.disabled,_x000D_
.datepicker table tr td.today.disabled:hover {_x000D_
background-color: #fde19a;_x000D_
background-image: -moz-linear-gradient(to bottom, #fdd49a, #fdf59a);_x000D_
background-image: -ms-linear-gradient(to bottom, #fdd49a, #fdf59a);_x000D_
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#fdd49a), to(#fdf59a));_x000D_
background-image: -webkit-linear-gradient(to bottom, #fdd49a, #fdf59a);_x000D_
background-image: -o-linear-gradient(to bottom, #fdd49a, #fdf59a);_x000D_
background-image: linear-gradient(to bottom, #fdd49a, #fdf59a);_x000D_
background-repeat: repeat-x;_x000D_
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fdd49a', endColorstr='#fdf59a', GradientType=0);_x000D_
border-color: #fdf59a #fdf59a #fbed50;_x000D_
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);_x000D_
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);_x000D_
color: #000;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.today:hover,_x000D_
.datepicker table tr td.today:hover:hover,_x000D_
.datepicker table tr td.today.disabled:hover,_x000D_
.datepicker table tr td.today.disabled:hover:hover,_x000D_
.datepicker table tr td.today:active,_x000D_
.datepicker table tr td.today:hover:active,_x000D_
.datepicker table tr td.today.disabled:active,_x000D_
.datepicker table tr td.today.disabled:hover:active,_x000D_
.datepicker table tr td.today.active,_x000D_
.datepicker table tr td.today:hover.active,_x000D_
.datepicker table tr td.today.disabled.active,_x000D_
.datepicker table tr td.today.disabled:hover.active,_x000D_
.datepicker table tr td.today.disabled,_x000D_
.datepicker table tr td.today:hover.disabled,_x000D_
.datepicker table tr td.today.disabled.disabled,_x000D_
.datepicker table tr td.today.disabled:hover.disabled,_x000D_
.datepicker table tr td.today[disabled],_x000D_
.datepicker table tr td.today:hover[disabled],_x000D_
.datepicker table tr td.today.disabled[disabled],_x000D_
.datepicker table tr td.today.disabled:hover[disabled] {_x000D_
background-color: #fdf59a;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.today:active,_x000D_
.datepicker table tr td.today:hover:active,_x000D_
.datepicker table tr td.today.disabled:active,_x000D_
.datepicker table tr td.today.disabled:hover:active,_x000D_
.datepicker table tr td.today.active,_x000D_
.datepicker table tr td.today:hover.active,_x000D_
.datepicker table tr td.today.disabled.active,_x000D_
.datepicker table tr td.today.disabled:hover.active {_x000D_
background-color: #fbf069 \9;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.today:hover:hover {_x000D_
color: #000;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.today.active:hover {_x000D_
color: #fff;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.range,_x000D_
.datepicker table tr td.range:hover,_x000D_
.datepicker table tr td.range.disabled,_x000D_
.datepicker table tr td.range.disabled:hover {_x000D_
background: #eee;_x000D_
-webkit-border-radius: 0;_x000D_
-moz-border-radius: 0;_x000D_
border-radius: 0;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.range.today,_x000D_
.datepicker table tr td.range.today:hover,_x000D_
.datepicker table tr td.range.today.disabled,_x000D_
.datepicker table tr td.range.today.disabled:hover {_x000D_
background-color: #f3d17a;_x000D_
background-image: -moz-linear-gradient(to bottom, #f3c17a, #f3e97a);_x000D_
background-image: -ms-linear-gradient(to bottom, #f3c17a, #f3e97a);_x000D_
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f3c17a), to(#f3e97a));_x000D_
background-image: -webkit-linear-gradient(to bottom, #f3c17a, #f3e97a);_x000D_
background-image: -o-linear-gradient(to bottom, #f3c17a, #f3e97a);_x000D_
background-image: linear-gradient(to bottom, #f3c17a, #f3e97a);_x000D_
background-repeat: repeat-x;_x000D_
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f3c17a', endColorstr='#f3e97a', GradientType=0);_x000D_
border-color: #f3e97a #f3e97a #edde34;_x000D_
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);_x000D_
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);_x000D_
-webkit-border-radius: 0;_x000D_
-moz-border-radius: 0;_x000D_
border-radius: 0;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.range.today:hover,_x000D_
.datepicker table tr td.range.today:hover:hover,_x000D_
.datepicker table tr td.range.today.disabled:hover,_x000D_
.datepicker table tr td.range.today.disabled:hover:hover,_x000D_
.datepicker table tr td.range.today:active,_x000D_
.datepicker table tr td.range.today:hover:active,_x000D_
.datepicker table tr td.range.today.disabled:active,_x000D_
.datepicker table tr td.range.today.disabled:hover:active,_x000D_
.datepicker table tr td.range.today.active,_x000D_
.datepicker table tr td.range.today:hover.active,_x000D_
.datepicker table tr td.range.today.disabled.active,_x000D_
.datepicker table tr td.range.today.disabled:hover.active,_x000D_
.datepicker table tr td.range.today.disabled,_x000D_
.datepicker table tr td.range.today:hover.disabled,_x000D_
.datepicker table tr td.range.today.disabled.disabled,_x000D_
.datepicker table tr td.range.today.disabled:hover.disabled,_x000D_
.datepicker table tr td.range.today[disabled],_x000D_
.datepicker table tr td.range.today:hover[disabled],_x000D_
.datepicker table tr td.range.today.disabled[disabled],_x000D_
.datepicker table tr td.range.today.disabled:hover[disabled] {_x000D_
background-color: #f3e97a;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.range.today:active,_x000D_
.datepicker table tr td.range.today:hover:active,_x000D_
.datepicker table tr td.range.today.disabled:active,_x000D_
.datepicker table tr td.range.today.disabled:hover:active,_x000D_
.datepicker table tr td.range.today.active,_x000D_
.datepicker table tr td.range.today:hover.active,_x000D_
.datepicker table tr td.range.today.disabled.active,_x000D_
.datepicker table tr td.range.today.disabled:hover.active {_x000D_
background-color: #efe24b \9;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.selected,_x000D_
.datepicker table tr td.selected:hover,_x000D_
.datepicker table tr td.selected.disabled,_x000D_
.datepicker table tr td.selected.disabled:hover {_x000D_
background-color: #9e9e9e;_x000D_
background-image: -moz-linear-gradient(to bottom, #b3b3b3, #808080);_x000D_
background-image: -ms-linear-gradient(to bottom, #b3b3b3, #808080);_x000D_
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#b3b3b3), to(#808080));_x000D_
background-image: -webkit-linear-gradient(to bottom, #b3b3b3, #808080);_x000D_
background-image: -o-linear-gradient(to bottom, #b3b3b3, #808080);_x000D_
background-image: linear-gradient(to bottom, #b3b3b3, #808080);_x000D_
background-repeat: repeat-x;_x000D_
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#b3b3b3', endColorstr='#808080', GradientType=0);_x000D_
border-color: #808080 #808080 #595959;_x000D_
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);_x000D_
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);_x000D_
color: #fff;_x000D_
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);_x000D_
}_x000D_
_x000D_
.datepicker table tr td.selected:hover,_x000D_
.datepicker table tr td.selected:hover:hover,_x000D_
.datepicker table tr td.selected.disabled:hover,_x000D_
.datepicker table tr td.selected.disabled:hover:hover,_x000D_
.datepicker table tr td.selected:active,_x000D_
.datepicker table tr td.selected:hover:active,_x000D_
.datepicker table tr td.selected.disabled:active,_x000D_
.datepicker table tr td.selected.disabled:hover:active,_x000D_
.datepicker table tr td.selected.active,_x000D_
.datepicker table tr td.selected:hover.active,_x000D_
.datepicker table tr td.selected.disabled.active,_x000D_
.datepicker table tr td.selected.disabled:hover.active,_x000D_
.datepicker table tr td.selected.disabled,_x000D_
.datepicker table tr td.selected:hover.disabled,_x000D_
.datepicker table tr td.selected.disabled.disabled,_x000D_
.datepicker table tr td.selected.disabled:hover.disabled,_x000D_
.datepicker table tr td.selected[disabled],_x000D_
.datepicker table tr td.selected:hover[disabled],_x000D_
.datepicker table tr td.selected.disabled[disabled],_x000D_
.datepicker table tr td.selected.disabled:hover[disabled] {_x000D_
background-color: #808080;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.selected:active,_x000D_
.datepicker table tr td.selected:hover:active,_x000D_
.datepicker table tr td.selected.disabled:active,_x000D_
.datepicker table tr td.selected.disabled:hover:active,_x000D_
.datepicker table tr td.selected.active,_x000D_
.datepicker table tr td.selected:hover.active,_x000D_
.datepicker table tr td.selected.disabled.active,_x000D_
.datepicker table tr td.selected.disabled:hover.active {_x000D_
background-color: #666666 \9;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.active,_x000D_
.datepicker table tr td.active:hover,_x000D_
.datepicker table tr td.active.disabled,_x000D_
.datepicker table tr td.active.disabled:hover {_x000D_
background-color: #006dcc;_x000D_
background-image: -moz-linear-gradient(to bottom, #08c, #0044cc);_x000D_
background-image: -ms-linear-gradient(to bottom, #08c, #0044cc);_x000D_
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#08c), to(#0044cc));_x000D_
background-image: -webkit-linear-gradient(to bottom, #08c, #0044cc);_x000D_
background-image: -o-linear-gradient(to bottom, #08c, #0044cc);_x000D_
background-image: linear-gradient(to bottom, #08c, #0044cc);_x000D_
background-repeat: repeat-x;_x000D_
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#08c', endColorstr='#0044cc', GradientType=0);_x000D_
border-color: #0044cc #0044cc #002a80;_x000D_
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);_x000D_
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);_x000D_
color: #fff;_x000D_
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);_x000D_
}_x000D_
_x000D_
.datepicker table tr td.active:hover,_x000D_
.datepicker table tr td.active:hover:hover,_x000D_
.datepicker table tr td.active.disabled:hover,_x000D_
.datepicker table tr td.active.disabled:hover:hover,_x000D_
.datepicker table tr td.active:active,_x000D_
.datepicker table tr td.active:hover:active,_x000D_
.datepicker table tr td.active.disabled:active,_x000D_
.datepicker table tr td.active.disabled:hover:active,_x000D_
.datepicker table tr td.active.active,_x000D_
.datepicker table tr td.active:hover.active,_x000D_
.datepicker table tr td.active.disabled.active,_x000D_
.datepicker table tr td.active.disabled:hover.active,_x000D_
.datepicker table tr td.active.disabled,_x000D_
.datepicker table tr td.active:hover.disabled,_x000D_
.datepicker table tr td.active.disabled.disabled,_x000D_
.datepicker table tr td.active.disabled:hover.disabled,_x000D_
.datepicker table tr td.active[disabled],_x000D_
.datepicker table tr td.active:hover[disabled],_x000D_
.datepicker table tr td.active.disabled[disabled],_x000D_
.datepicker table tr td.active.disabled:hover[disabled] {_x000D_
background-color: #0044cc;_x000D_
}_x000D_
_x000D_
.datepicker table tr td.active:active,_x000D_
.datepicker table tr td.active:hover:active,_x000D_
.datepicker table tr td.active.disabled:active,_x000D_
.datepicker table tr td.active.disabled:hover:active,_x000D_
.datepicker table tr td.active.active,_x000D_
.datepicker table tr td.active:hover.active,_x000D_
.datepicker table tr td.active.disabled.active,_x000D_
.datepicker table tr td.active.disabled:hover.active {_x000D_
background-color: #003399 \9;_x000D_
}_x000D_
_x000D_
.datepicker table tr td span {_x000D_
display: block;_x000D_
width: 23%;_x000D_
height: 54px;_x000D_
line-height: 54px;_x000D_
float: left;_x000D_
margin: 1%;_x000D_
cursor: pointer;_x000D_
-webkit-border-radius: 4px;_x000D_
-moz-border-radius: 4px;_x000D_
border-radius: 4px;_x000D_
}_x000D_
_x000D_
.datepicker table tr td span:hover,_x000D_
.datepicker table tr td span.focused {_x000D_
background: #eee;_x000D_
}_x000D_
_x000D_
.datepicker table tr td span.disabled,_x000D_
.datepicker table tr td span.disabled:hover {_x000D_
background: none;_x000D_
color: #999;_x000D_
cursor: default;_x000D_
}_x000D_
_x000D_
.datepicker table tr td span.active,_x000D_
.datepicker table tr td span.active:hover,_x000D_
.datepicker table tr td span.active.disabled,_x000D_
.datepicker table tr td span.active.disabled:hover {_x000D_
background-color: #006dcc;_x000D_
background-image: -moz-linear-gradient(to bottom, #08c, #0044cc);_x000D_
background-image: -ms-linear-gradient(to bottom, #08c, #0044cc);_x000D_
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#08c), to(#0044cc));_x000D_
background-image: -webkit-linear-gradient(to bottom, #08c, #0044cc);_x000D_
background-image: -o-linear-gradient(to bottom, #08c, #0044cc);_x000D_
background-image: linear-gradient(to bottom, #08c, #0044cc);_x000D_
background-repeat: repeat-x;_x000D_
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#08c', endColorstr='#0044cc', GradientType=0);_x000D_
border-color: #0044cc #0044cc #002a80;_x000D_
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);_x000D_
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);_x000D_
color: #fff;_x000D_
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);_x000D_
}_x000D_
_x000D_
.datepicker table tr td span.active:hover,_x000D_
.datepicker table tr td span.active:hover:hover,_x000D_
.datepicker table tr td span.active.disabled:hover,_x000D_
.datepicker table tr td span.active.disabled:hover:hover,_x000D_
.datepicker table tr td span.active:active,_x000D_
.datepicker table tr td span.active:hover:active,_x000D_
.datepicker table tr td span.active.disabled:active,_x000D_
.datepicker table tr td span.active.disabled:hover:active,_x000D_
.datepicker table tr td span.active.active,_x000D_
.datepicker table tr td span.active:hover.active,_x000D_
.datepicker table tr td span.active.disabled.active,_x000D_
.datepicker table tr td span.active.disabled:hover.active,_x000D_
.datepicker table tr td span.active.disabled,_x000D_
.datepicker table tr td span.active:hover.disabled,_x000D_
.datepicker table tr td span.active.disabled.disabled,_x000D_
.datepicker table tr td span.active.disabled:hover.disabled,_x000D_
.datepicker table tr td span.active[disabled],_x000D_
.datepicker table tr td span.active:hover[disabled],_x000D_
.datepicker table tr td span.active.disabled[disabled],_x000D_
.datepicker table tr td span.active.disabled:hover[disabled] {_x000D_
background-color: #0044cc;_x000D_
}_x000D_
_x000D_
.datepicker table tr td span.active:active,_x000D_
.datepicker table tr td span.active:hover:active,_x000D_
.datepicker table tr td span.active.disabled:active,_x000D_
.datepicker table tr td span.active.disabled:hover:active,_x000D_
.datepicker table tr td span.active.active,_x000D_
.datepicker table tr td span.active:hover.active,_x000D_
.datepicker table tr td span.active.disabled.active,_x000D_
.datepicker table tr td span.active.disabled:hover.active {_x000D_
background-color: #003399 \9;_x000D_
}_x000D_
_x000D_
.datepicker table tr td span.old,_x000D_
.datepicker table tr td span.new {_x000D_
color: #999;_x000D_
}_x000D_
_x000D_
.datepicker .datepicker-switch {_x000D_
width: 145px;_x000D_
}_x000D_
_x000D_
.datepicker .datepicker-switch,_x000D_
.datepicker .prev,_x000D_
.datepicker .next,_x000D_
.datepicker tfoot tr th {_x000D_
cursor: pointer;_x000D_
}_x000D_
_x000D_
.datepicker .datepicker-switch:hover,_x000D_
.datepicker .prev:hover,_x000D_
.datepicker .next:hover,_x000D_
.datepicker tfoot tr th:hover {_x000D_
background: #eee;_x000D_
}_x000D_
_x000D_
.datepicker .prev.disabled,_x000D_
.datepicker .next.disabled {_x000D_
visibility: hidden;_x000D_
}_x000D_
_x000D_
.datepicker .cw {_x000D_
font-size: 10px;_x000D_
width: 12px;_x000D_
padding: 0 2px 0 5px;_x000D_
vertical-align: middle;_x000D_
}_x000D_
_x000D_
.input-append.date .add-on,_x000D_
.input-prepend.date .add-on {_x000D_
cursor: pointer;_x000D_
}_x000D_
_x000D_
.input-append.date .add-on i,_x000D_
.input-prepend.date .add-on i {_x000D_
margin-top: 3px;_x000D_
}_x000D_
_x000D_
.input-daterange input {_x000D_
text-align: center;_x000D_
}_x000D_
_x000D_
.input-daterange input:first-child {_x000D_
-webkit-border-radius: 3px 0 0 3px;_x000D_
-moz-border-radius: 3px 0 0 3px;_x000D_
border-radius: 3px 0 0 3px;_x000D_
}_x000D_
_x000D_
.input-daterange input:last-child {_x000D_
-webkit-border-radius: 0 3px 3px 0;_x000D_
-moz-border-radius: 0 3px 3px 0;_x000D_
border-radius: 0 3px 3px 0;_x000D_
}_x000D_
_x000D_
.input-daterange .add-on {_x000D_
display: inline-block;_x000D_
width: auto;_x000D_
min-width: 16px;_x000D_
height: 20px;_x000D_
padding: 4px 5px;_x000D_
font-weight: normal;_x000D_
line-height: 20px;_x000D_
text-align: center;_x000D_
text-shadow: 0 1px 0 #fff;_x000D_
vertical-align: middle;_x000D_
background-color: #eee;_x000D_
border: 1px solid #ccc;_x000D_
margin-left: -5px;_x000D_
margin-right: -5px;_x000D_
}_x000D_
_x000D_
.datepicker.dropdown-menu {_x000D_
position: absolute;_x000D_
top: 100%;_x000D_
left: 0;_x000D_
z-index: 1000;_x000D_
float: left;_x000D_
display: none;_x000D_
min-width: 160px;_x000D_
list-style: none;_x000D_
background-color: #fff;_x000D_
border: 1px solid #ccc;_x000D_
border: 1px solid rgba(0, 0, 0, 0.2);_x000D_
-webkit-border-radius: 5px;_x000D_
-moz-border-radius: 5px;_x000D_
border-radius: 5px;_x000D_
-webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);_x000D_
-moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);_x000D_
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);_x000D_
-webkit-background-clip: padding-box;_x000D_
-moz-background-clip: padding;_x000D_
background-clip: padding-box;_x000D_
*border-right-width: 2px;_x000D_
*border-bottom-width: 2px;_x000D_
color: #333333;_x000D_
font-size: 13px;_x000D_
line-height: 20px;_x000D_
}_x000D_
_x000D_
.datepicker.dropdown-menu th,_x000D_
.datepicker.datepicker-inline th,_x000D_
.datepicker.dropdown-menu td,_x000D_
.datepicker.datepicker-inline td {_x000D_
padding: 4px 5px;_x000D_
}_x000D_
_x000D_
_x000D_
/*# sourceMappingURL=bootstrap-datepicker.standalone.css.map */
_x000D_
<!-- Require libs to show example -->_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.8.0/js/bootstrap-datepicker.min.js"></script>_x000D_
_x000D_
<!-- Simple form with two text fields -->_x000D_
<form>_x000D_
<input name="foo" type=text value="Click to see keyboard" />_x000D_
<br/><br/><br/>_x000D_
<input name="date" type=text />_x000D_
</form>
_x000D_
This may be an improved way (also with regexp and connect by):
with temp as
(
select 108 Name, 'test' Project, 'Err1, Err2, Err3' Error from dual
union all
select 109, 'test2', 'Err1' from dual
)
select distinct
t.name, t.project,
trim(regexp_substr(t.error, '[^,]+', 1, levels.column_value)) as error
from
temp t,
table(cast(multiset(select level from dual connect by level <= length (regexp_replace(t.error, '[^,]+')) + 1) as sys.OdciNumberList)) levels
order by name
EDIT: Here is a simple (as in, "not in depth") explanation of the query.
length (regexp_replace(t.error, '[^,]+')) + 1
uses regexp_replace
to erase anything that is not the delimiter (comma in this case) and length +1
to get how many elements (errors) are there. The select level from dual connect by level <= (...)
uses a hierarchical query to create a column with an increasing number of matches found, from 1 to the total number of errors.
Preview:
select level, length (regexp_replace('Err1, Err2, Err3', '[^,]+')) + 1 as max
from dual connect by level <= length (regexp_replace('Err1, Err2, Err3', '[^,]+')) + 1
table(cast(multiset(.....) as sys.OdciNumberList))
does some casting of oracle types.
cast(multiset(.....)) as sys.OdciNumberList
transforms multiple collections (one collection for each row in the original data set) into a single collection of numbers, OdciNumberList.table()
function transforms a collection into a resultset.FROM
without a join creates a cross join between your dataset and the multiset.
As a result, a row in the data set with 4 matches will repeat 4 times (with an increasing number in the column named "column_value").
Preview:
select * from
temp t,
table(cast(multiset(select level from dual connect by level <= length (regexp_replace(t.error, '[^,]+')) + 1) as sys.OdciNumberList)) levels
trim(regexp_substr(t.error, '[^,]+', 1, levels.column_value))
uses the column_value
as the nth_appearance/ocurrence parameter for regexp_substr
.t.name, t.project
as an example) for easy visualization.Some references to Oracle docs:
Let me tell you an annoying thing that happened with the N'
prefix - I wasn't able to fix it for two days.
My database collation is SQL_Latin1_General_CP1_CI_AS.
It has a table with a column called MyCol1. It is an Nvarchar
This query fails to match Exact Value That Exists.
SELECT TOP 1 * FROM myTable1 WHERE MyCol1 = 'ESKI'
// 0 result
using prefix N'' fixes it
SELECT TOP 1 * FROM myTable1 WHERE MyCol1 = N'ESKI'
// 1 result - found!!!!
Why? Because latin1_general doesn't have big dotted I that's why it fails I suppose.
Having a look at the blog here I found the solution in one of the comments. Make sure you got the rpmforge
repository added to your CentOS yum and just run the flowing command:
yum --disablerepo=base,updates --enablerepo=rpmforge-extras install git
If you already have git installed then use:
yum --disablerepo=base,updates --enablerepo=rpmforge-extras update git
Related question(s):
Thanks to Anthony Hatzopoulos, for git v1.8x
you'll need to use git18 as in:
yum --disablerepo=base,updates --enablerepo=rpmforge-extras install git18
Also thanks to @Axlrod for the below hint and @Hiphip for the feedback:
Change the rpmforge.repo
file to have rpmforge-extras
to enabled,
yum update git
. Otherwise it complained about dependency problems.
Installing a specific version of git say 2.x I found this nice and easy-to-follow guide on how to download the GIT source and compile it yourself (and install it). If the accepted answer does not give you the version you want, try the following instructions:
http://tecadmin.net/install-git-2-0-on-centos-rhel-fedora/
(And pasted/reformatted from above source in case it is removed later)
Step 1: Install Required Packages
Firstly we need to make sure that we have installed required packages on your system. Use following command to install required packages before compiling Git source.
# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
# yum install gcc perl-ExtUtils-MakeMaker
Step 2: Uninstall old Git RPM
Now remove any prior installation of Git through RPM file or Yum package manager. If your older version is also compiled through source, then skip this step.
# yum remove git
Step 3: Download and Compile Git Source
Download git source code from kernel git or simply use following command to download Git 2.0.4.
# cd /usr/src
# wget https://www.kernel.org/pub/software/scm/git/git-2.0.4.tar.gz
# tar xzf git-2.0.4.tar.gz
After downloading and extracting Git source code, Use following command to compile source code.
# cd git-2.0.4
# make prefix=/usr/local/git all
# make prefix=/usr/local/git install
#
# echo 'export PATH=$PATH:/usr/local/git/bin' >> /etc/bashrc
# or
# echo 'export PATH=$PATH:/usr/local/git/bin' > /etc/profile.d/git.sh
#
# source /etc/bashrc
HINT 1: Updated method of adding compiled git bin directory to bashrc. Because
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
used "" instead of '', it would expand the current session's value for $PATH instead of keeping it as a variable, and could adversely affect the entire system. At the minimum, it should use '' instead of "" and should really be a separate script in/etc/profile.d/
HINT 2 (@DJB):
/usr/local/git/bin
before$PATH
, since the older version of git was already on $PATH:export PATH=/usr/local/git/bin:$PATH
Step 4. Check Git Version
One completion of above steps, you have successfully install Git in your system. Let use following command to check git version
# git --version
git version 2.0.4
I also wanted to add that the "Getting Started" guide at the GIT website also includes instructions on how to download and compile it yourself:
http://git-scm.com/book/en/v2/Getting-Started-Installing-Git
.dex file
Compiled Android application code file.
Android programs are compiled into .dex (Dalvik Executable) files, which are in turn zipped into a single .apk file on the device. .dex files can be created automatically by Android, by translating the compiled applications written in the Java programming language.
Assuming C++11, here is a one-liner loop body, if this is consistent with your programming style:
using Map = std::map<K,V>;
Map map;
// Erase members that satisfy needs_removing(itr)
for (Map::const_iterator itr = map.cbegin() ; itr != map.cend() ; )
itr = needs_removing(itr) ? map.erase(itr) : std::next(itr);
A couple of other minor style changes:
Map::const_iterator
) when possible/convenient, over using auto
.using
for template types, to make ancillary types (Map::const_iterator
) easier to read/maintain.If you have DotPeek
from JetBrains
, you can see it in Assembly Explorer
.
LocalDate.parse(
"01-23-2017" ,
DateTimeFormatter.ofPattern( "MM-dd-uuuu" )
)
I have a java.util.Date in the format yyyy-mm-dd
As other mentioned, the Date
class has no format. It has a count of milliseconds since the start of 1970 in UTC. No strings attached.
The other Answers use troublesome old legacy date-time classes, now supplanted by the java.time classes.
If you have a java.util.Date
, convert to a Instant
object. The Instant
class represents a moment on the timeline in UTC with a resolution of nanoseconds (up to nine (9) digits of a decimal fraction).
Instant instant = myUtilDate.toInstant();
The other Answers ignore the crucial issue of time zone. Determining a date requires a time zone. For any given moment, the date varies around the globe by zone. A few minutes after midnight in Paris France is a new day, while still “yesterday” in Montréal Québec.
Define the time zone by which you want context for your Instant
.
ZoneId z = ZoneId.of( "America/Montreal" );
Apply the ZoneId
to get a ZonedDateTime
.
ZonedDateTime zdt = instant.atZone( z );
LocalDate
If you only care about the date without a time-of-day, extract a LocalDate
.
LocalDate localDate = zdt.toLocalDate();
To generate a string in standard ISO 8601 format, YYYY-MM-DD, simply call toString
. The java.time classes use the standard formats by default when generating/parsing strings.
String output = localDate.toString();
2017-01-23
If you want a MM-DD-YYYY format, define a formatting pattern.
DateTimeFormatter f = DateTimeFormatter.ofPattern( "MM-dd-uuuu" );
String output = localDate.format( f );
Note that the formatting pattern codes are case-sensitive. The code in the Question incorrectly used mm
(minute of hour) rather than MM
(month of year).
Use the same DateTimeFormatter
object for parsing. The java.time classes are thread-safe, so you can keep this object around and reuse it repeatedly even across threads.
LocalDate localDate = LocalDate.parse( "01-23-2017" , f );
The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date
, Calendar
, & SimpleDateFormat
.
The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.
To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.
Where to obtain the java.time classes?
The ThreeTen-Extra project extends java.time with additional classes. This project is a proving ground for possible future additions to java.time. You may find some useful classes here such as Interval
, YearWeek
, YearQuarter
, and more.
As has been mentioned here for JRE6 and JRE5, I will update for JRE1.4:
You will need to run the jpicpl32.exe application in the jre/bin directory of your java installation (e.g. c:\java\jdk1.4.2_07\jre\bin\jpicpl32.exe).
This is an earlier version of the application mentioned in Daniel Cassidy's post.
Here is the missing example
library(rjson)
url <- 'http://someurl/data.json'
document <- fromJSON(file=url, method='C')
try a generalized linear model with a gaussian family
y = np.array([-6, -5, -10, -5, -8, -3, -6, -8, -8])
X = np.array([
[-4.95, -4.55, -10.96, -1.08, -6.52, -0.81, -7.01, -4.46, -11.54],
[-5.87, -4.52, -11.64, -3.36, -7.45, -2.36, -7.33, -7.65, -10.03],
[-0.76, -0.71, -0.98, 0.75, -0.86, -0.50, -0.33, -0.94, -1.03],
[14.73, 13.74, 15.49, 24.72, 16.59, 22.44, 13.93, 11.40, 18.18],
[4.02, 4.47, 4.18, 4.96, 4.29, 4.81, 4.32, 4.43, 4.28],
[0.20, 0.16, 0.19, 0.16, 0.10, 0.15, 0.21, 0.16, 0.21],
[0.45, 0.50, 0.53, 0.60, 0.48, 0.53, 0.50, 0.49, 0.55],
])
X=zip(*reversed(X))
df=pd.DataFrame({'X':X,'y':y})
columns=7
for i in range(0,columns):
df['X'+str(i)]=df.apply(lambda row: row['X'][i],axis=1)
df=df.drop('X',axis=1)
print(df)
#model_formula='y ~ X0+X1+X2+X3+X4+X5+X6'
model_formula='y ~ X0'
model_family = sm.families.Gaussian()
model_fit = glm(formula = model_formula,
data = df,
family = model_family).fit()
print(model_fit.summary())
# Extract coefficients from the fitted model wells_fit
#print(model_fit.params)
intercept, slope = model_fit.params
# Print coefficients
print('Intercept =', intercept)
print('Slope =', slope)
# Extract and print confidence intervals
print(model_fit.conf_int())
df2=pd.DataFrame()
df2['X0']=np.linspace(0.50,0.70,50)
df3=pd.DataFrame()
df3['X1']=np.linspace(0.20,0.60,50)
prediction0=model_fit.predict(df2)
#prediction1=model_fit.predict(df3)
plt.plot(df2['X0'],prediction0,label='X0')
plt.ylabel("y")
plt.xlabel("X0")
plt.show()
In a bash terminal I like to use the double dash. Using VS Code, you can right click on the spec file in the explorer, or on the open tab. Then select 'Copy Relative Path'. Run the command below pasting the relative path in from the clipboard.
npm t -- --include relative/path/to/file.spec.ts
The double dash signals the end of your command options for npm t
and passes anything after that to the next command which is pointing to ng t
. It's doesn't require any modification and quickly gives desired results.
One simple way is rename your package name and run again
To answer your updated question you can do
String[] lines = ("Name = Bob\n" +
"Age = 27\n" +
"Occupation = Student\n" +
"Status = Single").split("\n");
for (String line : lines) {
String[] parts = line.split(" = +");
System.out.printf("%-19s %s%n", parts[0] + " =", parts[1]);
}
prints
Name = Bob
Age = 27
Occupation = Student
Status = Single
It's also very possible that typing show create table <table_name>
in the hive cli will give you the exact location of your hive table.
Since String
IS-A CharSequence
, you can pass a String
wherever you need a CharSequence
, or assign a String
to a CharSequence
:
CharSequence cs = "string";
String s = cs.toString();
foo(s); // prints "string"
public void foo(CharSequence cs) {
System.out.println(cs);
}
If you want to convert a CharSequence
to a String
, just use the toString
method that must be implemented by every concrete implementation of CharSequence
.
Hope it helps.
I'm not allowed to comment, so regarding Shane's answer, keep in mind that
wp_localize_scripts()
must be hooked to wp or admin enqueue scripts. So a good example would be as follows:
function local() {
wp_localize_script( 'js-file-handle', 'ajax', array(
'url' => admin_url( 'admin-ajax.php' )
) );
}
add_action('admin_enqueue_scripts', 'local');
add_action('wp_enqueue_scripts', 'local');`
In case you need a declarative solution, you can use dict.update()
to change values in a dict.
Either like this:
my_dict.update({'key1': 'value1', 'key2': 'value2'})
or like this:
my_dict.update(key1='value1', key2='value2')
Since Python 3.5 you can also use dictionary unpacking for this:
my_dict = { **my_dict, 'key1': 'value1', 'key2': 'value2'}
Note: This creates a new dictionary.
Since Python 3.9 you can also use the merge operator on dictionaries:
my_dict = my_dict | {'key1': 'value1', 'key2': 'value2'}
Note: This creates a new dictionary.
Or you can use the update operator:
my_dict |= {'key1': 'value1', 'key2': 'value2'}
Yes, it is possible.
There is a perfect open-source Python (.PYC) decompiler, called Decompyle++ https://github.com/zrax/pycdc/
Decompyle++ aims to translate compiled Python byte-code back into valid and human-readable Python source code. While other projects have achieved this with varied success, Decompyle++ is unique in that it seeks to support byte-code from any version of Python.
You can use readfile and output the image headers which you can get from getimagesize like this:
$remoteImage = "http://www.example.com/gifs/logo.gif";
$imginfo = getimagesize($remoteImage);
header("Content-type: {$imginfo['mime']}");
readfile($remoteImage);
The reason you should use readfile here is that it outputs the file directly to the output buffer where as file_get_contents will read the file into memory which is unnecessary in this content and potentially intensive for large files.
Here is my understanding of it so far, in case it helps someone.
core.autocrlf=true
and core.safecrlf = true
You have a repository where all the line endings are the same, but you work on different platforms. Git will make sure your lines endings are converted to the default for your platform. Why does this matter? Let's say you create a new file. The text editor on your platform will use its default line endings. When you check it in, if you don't have core.autocrlf set to true, you've introduced a line ending inconsistency for someone on a platform that defaults to a different line ending. I always set safecrlf too because I would like to know that the crlf operation is reversible. With these two settings, git is modifying your files, but it verifies that the modifications are reversible.
core.autocrlf=false
You have a repository that already has mixed line endings checked in and fixing the incorrect line endings could break other things. Its best not to tell git to convert line endings in this case, because then it will exacerbate the problem it was designed to solve - making diffs easier to read and merges less painful. With this setting, git doesn't modify your files.
core.autocrlf=input
I don't use this because the reason for this is to cover a use case where you created a file that has CRLF line endings on a platform that defaults to LF line endings. I prefer instead to make my text editor always save new files with the platform's line ending defaults.
public demo1() {
initComponents();
ImageIcon img = new ImageIcon("C:\\Users\\AMIT TIWARI\\Documents\\NetBeansProjects\\try\\src\\com\\dd.jpeg"); //full path of image
Image img2 = img.getImage().getScaledInstance(mylabel.getWidth(), mylabel.getHeight(),1);
ImageIcon img3 = new ImageIcon(img2);
mylabel.setIcon(img3);
}
Would something like work?
Add angular cookie lib : angular-cookies.js
You can use $cookies or $cookieStore parameter to the respective controller
Main controller add this inject 'ngCookies':
angular.module("myApp", ['ngCookies']);
Use Cookies in your controller like this way:
app.controller('checkoutCtrl', function ($scope, $rootScope, $http, $state, $cookies) {
//store cookies
$cookies.putObject('final_total_price', $rootScope.fn_pro_per);
//Get cookies
$cookies.getObject('final_total_price'); }
And make sure your route in the list of routes:
./manage.py show_urls | grep path_or_name