Adding only android-support-v7-appcompat.jar
to library dependencies is not enough, you have also to import in your project the module that you can find in your SDK at the path \android-sdk\extras\android\support\v7\appcompat
and after that add module dependencies configuring the project structure in this way
otherwise are included only the class files of support library and the app is not able to load the other resources causing the error.
In addition as reVerse suggested replace this
public CustomActionBarDrawerToggle(Activity mActivity,
DrawerLayout mDrawerLayout) {
super(mActivity, mDrawerLayout,new Toolbar(MyActivity.this) ,
R.string.ns_menu_open, R.string.ns_menu_close);
}
with
public CustomActionBarDrawerToggle(Activity mActivity,
DrawerLayout mDrawerLayout) {
super(mActivity, mDrawerLayout, R.string.ns_menu_open, R.string.ns_menu_close);
}
Here are the three working and tested methods:
BufferedReader
package io;
import java.io.*;
public class ReadFromFile2 {
public static void main(String[] args)throws Exception {
File file = new File("C:\\Users\\pankaj\\Desktop\\test.java");
BufferedReader br = new BufferedReader(new FileReader(file));
String st;
while((st=br.readLine()) != null){
System.out.println(st);
}
}
}
Scanner
package io;
import java.io.File;
import java.util.Scanner;
public class ReadFromFileUsingScanner {
public static void main(String[] args) throws Exception {
File file = new File("C:\\Users\\pankaj\\Desktop\\test.java");
Scanner sc = new Scanner(file);
while(sc.hasNextLine()){
System.out.println(sc.nextLine());
}
}
}
FileReader
package io;
import java.io.*;
public class ReadingFromFile {
public static void main(String[] args) throws Exception {
FileReader fr = new FileReader("C:\\Users\\pankaj\\Desktop\\test.java");
int i;
while ((i=fr.read()) != -1){
System.out.print((char) i);
}
}
}
Scanner
classpackage io;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class ReadingEntireFileWithoutLoop {
public static void main(String[] args) throws FileNotFoundException {
File file = new File("C:\\Users\\pankaj\\Desktop\\test.java");
Scanner sc = new Scanner(file);
sc.useDelimiter("\\Z");
System.out.println(sc.next());
}
}
import java.io.*;
import java.util.*;
import com.google.common.collect.*;
class finTech{
public static void main(String args[]){
Multimap<String, String> multimap = ArrayListMultimap.create();
multimap.put("1","11");
multimap.put("1","14");
multimap.put("1","12");
multimap.put("1","13");
multimap.put("11","111");
multimap.put("12","121");
System.out.println(multimap);
System.out.println(multimap.get("11"));
}
}
Output:
{"1"=["11","12","13","14"],"11"=["111"],"12"=["121"]}
["111"]
This is Google-Guava library for utility functionalities. This is the required solution.
What I did is first check what are the running processes by
SELECT * FROM pg_stat_activity WHERE state = 'active';
Find the process you want to kill, then type:
SELECT pg_cancel_backend(<pid of the process>)
This basically "starts" a request to terminate gracefully, which may be satisfied after some time, though the query comes back immediately.
If the process cannot be killed, try:
SELECT pg_terminate_backend(<pid of the process>)
You can directly access a global variable inside a function. If you want to change the value of that global variable, use "global variable_name". See the following example:
var = 1
def global_var_change():
global var
var = "value changed"
global_var_change() #call the function for changes
print var
Generally speaking, this is not a good programming practice. By breaking namespace logic, code can become difficult to understand and debug.
function fireMouseEvent(obj, evtName) {
if (obj.dispatchEvent) {
//var event = new Event(evtName);
var event = document.createEvent("MouseEvents");
event.initMouseEvent(evtName, true, true, window,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
obj.dispatchEvent(event);
} else if (obj.fireEvent) {
event = document.createEventObject();
event.button = 1;
obj.fireEvent("on" + evtName, event);
obj.fireEvent(evtName);
} else {
obj[evtName]();
}
}
var obj = document.getElementById("......");
fireMouseEvent(obj, "click");
.circle {
border-radius: 50%;
width: 500px;
height: 500px;
background: red;
}
<div class="circle"></div>
see this FIDDLE
One correct way to get selected value would be
var selected_value = $('#fruit_name').val()
And then you should do
if(selected_value) { ... }
There are many ways mentioned above. But I use rather simple way (well not simple as SELECT @@SERVERNAME). When you start SQL server management studio you will prompt below GUI
In there Server name is your server name (There may have multiple servers according to you dev environment choose correct one). Hope this helps :)
try if( $(response).filter('#result').length ) // do something
Use <object>
instead (of course, replace each URL with your own):
.BackgroundImage {_x000D_
background: url('https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg') no-repeat scroll left top;_x000D_
width: 400px;_x000D_
height: 600px;_x000D_
}
_x000D_
<!DOCTYPE html>_x000D_
<html>_x000D_
<head>_x000D_
<title>SVG Test</title>_x000D_
</head>_x000D_
<body>_x000D_
<div id="ObjectTag">_x000D_
<object type="image/svg+xml" data="https://upload.wikimedia.org/wikipedia/commons/b/bd/Test.svg" width="400" height="600">_x000D_
Your browser does not support SVG._x000D_
</object>_x000D_
</div>_x000D_
<div class="BackgroundImage"></div>_x000D_
</body>_x000D_
</html>
_x000D_
You can use conda remove --force
.
The documentation says:
--force Forces removal of a package without removing packages
that depend on it. Using this option will usually
leave your environment in a broken and inconsistent
state
When you're using Data Type: int you can select the row which you want to get autoincremented and go to the column properties tag. There you can set the identity to 'yes'. The starting value for autoincrement can also be edited there. Hope I could help ;)
anyItem
is a method and the System.out.println
call is after your return statement so that won't compile anyway since it is unreachable.
Might want to re-write it like:
import java.util.ArrayList;
import java.util.Random;
public class Catalogue
{
private Random randomGenerator;
private ArrayList<Item> catalogue;
public Catalogue()
{
catalogue = new ArrayList<Item>();
randomGenerator = new Random();
}
public Item anyItem()
{
int index = randomGenerator.nextInt(catalogue.size());
Item item = catalogue.get(index);
System.out.println("Managers choice this week" + item + "our recommendation to you");
return item;
}
}
Within options place your onclick and call the function you need as an example the ajax you need, I'll leave the example so that every click on a point tells you the value and you can use it in your new function.
options: {
plugins: {
// Change options for ALL labels of THIS CHART
datalabels: {
color: 'white',
//backgroundColor:'#ffce00',
align: 'start'
}
},
scales: {
yAxes: [{
ticks: {
beginAtZero:true,
fontColor: "white"
},gridLines: {
color: 'rgba(255,255,255,0.1)',
display: true
}
}],
xAxes: [{
ticks: {
fontColor: "white"
},gridLines: {
display: false
}
}]
},
legend: {
display: false
},
//onClick: abre
onClick:function(e){
var activePoints = myChart.getElementsAtEvent(e);
var selectedIndex = activePoints[0]._index;
alert(this.data.datasets[0].data[selectedIndex]);
}
}
As with all good examples, you've simplified what you're actually trying to do. This is good, but it is worth noting that python has a lot of flexibility when it comes to class versus instance variables. The same can be said of methods. For a good list of possibilities, I recommend reading Michael Fötsch' new-style classes introduction, especially sections 2 through 6.
One thing that takes a lot of work to remember when getting started is that python is not java. More than just a cliche. In java, an entire class is compiled, making the namespace resolution real simple: any variables declared outside a method (anywhere) are instance (or, if static, class) variables and are implicitly accessible within methods.
With python, the grand rule of thumb is that there are three namespaces that are searched, in order, for variables:
{begin pedagogy}
There are limited exceptions to this. The main one that occurs to me is that, when a class definition is being loaded, the class definition is its own implicit namespace. But this lasts only as long as the module is being loaded, and is entirely bypassed when within a method. Thus:
>>> class A(object):
foo = 'foo'
bar = foo
>>> A.foo
'foo'
>>> A.bar
'foo'
but:
>>> class B(object):
foo = 'foo'
def get_foo():
return foo
bar = get_foo()
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
class B(object):
File "<pyshell#11>", line 5, in B
bar = get_foo()
File "<pyshell#11>", line 4, in get_foo
return foo
NameError: global name 'foo' is not defined
{end pedagogy}
In the end, the thing to remember is that you do have access to any of the variables you want to access, but probably not implicitly. If your goals are simple and straightforward, then going for Foo.bar or self.bar will probably be sufficient. If your example is getting more complicated, or you want to do fancy things like inheritance (you can inherit static/class methods!), or the idea of referring to the name of your class within the class itself seems wrong to you, check out the intro I linked.
@m59 Directives will work for ng-bind-html you just need to wait for $viewContentLoaded
to finish
app.directive('targetBlank', function($timeout) {
return function($scope, element) {
$scope.initializeTarget = function() {
return $scope.$on('$viewContentLoaded', $timeout(function() {
var elems;
elems = element.prop('tagName') === 'A' ? element : element.find('a');
elems.attr('target', '_blank');
}));
};
return $scope.initializeTarget();
};
});
The main problem you may find with changing overflow to auto
or hidden
is that everything can become scrollable with the middle mouse buttom and a user can mess up the entire site layout.
ng-init
is a directive that can be placed inside div
's, span
's, whatever, whereas onload
is an attribute specific to the ng-include
directive that functions as an ng-init
. To see what I mean try something like:
<span onload="a = 1">{{ a }}</span>
<span ng-init="b = 2">{{ b }}</span>
You'll see that only the second one shows up.
An isolated scope is a scope which does not prototypically inherit from its parent scope. In laymen's terms if you have a widget that doesn't need to read and write to the parent scope arbitrarily then you use an isolate scope on the widget so that the widget and widget container can freely use their scopes without overriding each other's properties.
data = pd.DataFrame({"a":[1,2,3,34],"b":[5,6,7,8]})
new_data = pd.melt(data)
new_data.set_index("variable", inplace=True)
This gives a dataframe with index as column name of data and all data are present in "values" column
Don't put the DB::insert() inside of the Schema::create(), because the create method has to finish making the table before you can insert stuff. Try this instead:
public function up()
{
// Create the table
Schema::create('users', function($table){
$table->increments('id');
$table->string('email', 255);
$table->string('password', 64);
$table->boolean('verified');
$table->string('token', 255);
$table->timestamps();
});
// Insert some stuff
DB::table('users')->insert(
array(
'email' => '[email protected]',
'verified' => true
)
);
}
A simple method: enable logging in recent versions of Requests (1.x and higher.)
Requests uses the http.client
and logging
module configuration to control logging verbosity, as described here.
Code excerpted from the linked documentation:
import requests
import logging
# These two lines enable debugging at httplib level (requests->urllib3->http.client)
# You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
# The only thing missing will be the response.body which is not logged.
try:
import http.client as http_client
except ImportError:
# Python 2
import httplib as http_client
http_client.HTTPConnection.debuglevel = 1
# You must initialize logging, otherwise you'll not see debug output.
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
requests.get('https://httpbin.org/headers')
$ python requests-logging.py
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): httpbin.org
send: 'GET /headers HTTP/1.1\r\nHost: httpbin.org\r\nAccept-Encoding: gzip, deflate, compress\r\nAccept: */*\r\nUser-Agent: python-requests/1.2.0 CPython/2.7.3 Linux/3.2.0-48-generic\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
header: Content-Type: application/json
header: Date: Sat, 29 Jun 2013 11:19:34 GMT
header: Server: gunicorn/0.17.4
header: Content-Length: 226
header: Connection: keep-alive
DEBUG:requests.packages.urllib3.connectionpool:"GET /headers HTTP/1.1" 200 226
You can use date
to get time and date of a day:
[pengyu@GLaDOS ~]$date
Tue Aug 27 15:01:27 CST 2013
Also hwclock
would do:
[pengyu@GLaDOS ~]$hwclock
Tue 27 Aug 2013 03:01:29 PM CST -0.516080 seconds
For customized output, you can either redirect the output of date
to something like awk
, or write your own program to do that.
Remember to put your own executable scripts/binary into your PATH
(e.g. /usr/bin) to make it invokable anywhere.
With pure CSS you can't manage to do it; at least I haven't. However you can do it with jQuery very simply. I'll explain my problem, and with a little change you can use it.
So for a start, I wanted my element to have a fixed top (from top of the window), and a left component to inherit from the parent element (because the parent element is centered). To set the left component, just put your element into the parent and set position:relative
for the parent element.
Then you need to know how much from the top your element is when the a scroll bar is on top (y zero scrolled); there are two options again. First is that is static (some number) or you have to read it from the parent element.
In my case it's 150 pixels from top static. So when you see 150 it's how much is the element from the top when we haven't scrolled.
#parent-element{position:relative;}
#promo{position:absolute;}
$(document).ready(function() { //This check window scroll bar location on start
wtop=parseInt($(window).scrollTop());
$("#promo").css('top',150+wtop+'px');
});
$(window).scroll(function () { //This is when the window is scrolling
wtop=parseInt($(window).scrollTop());
$("#promo").css('top',150+wtop+'px');
});
`n
is a line feed character. Notepad (prior to Windows 10) expects linebreaks to be encoded as `r`n
(carriage return + line feed, CR-LF). Open the file in some useful editor (SciTE, Notepad++, UltraEdit-32, Vim, ...) and convert the linebreaks to CR-LF. Or use PowerShell:
(Get-Content $logpath | Out-String) -replace "`n", "`r`n" | Out-File $logpath
You need to parse your time format using strptime.
>>> import time
>>> from datetime import datetime
>>> ts, ms = '20.12.2016 09:38:42,76'.split(',')
>>> ts
'20.12.2016 09:38:42'
>>> ms
'76'
>>> dt = datetime.strptime(ts, '%d.%m.%Y %H:%M:%S')
>>> time.mktime(dt.timetuple())*1000 + int(ms)*10
1482223122760.0
For a cross browser implementation I'd sugguest you look at prototype.js $A
function
function $A(iterable) {
if (!iterable) return [];
if ('toArray' in Object(iterable)) return iterable.toArray();
var length = iterable.length || 0, results = new Array(length);
while (length--) results[length] = iterable[length];
return results;
}
It doesn't use Array.prototype.slice
probably because it isn't available on every browser. I'm afraid the performance is pretty bad as there a the fall back is a javascript loop over the iterable
.
Simple read example below:
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
//.....
private void button1_Click(object sender, EventArgs e)
{
HSSFWorkbook hssfwb;
using (FileStream file = new FileStream(@"c:\test.xls", FileMode.Open, FileAccess.Read))
{
hssfwb= new HSSFWorkbook(file);
}
ISheet sheet = hssfwb.GetSheet("Arkusz1");
for (int row = 0; row <= sheet.LastRowNum; row++)
{
if (sheet.GetRow(row) != null) //null is when the row only contains empty cells
{
MessageBox.Show(string.Format("Row {0} = {1}", row, sheet.GetRow(row).GetCell(0).StringCellValue));
}
}
}
By the way: on NPOI website here in Download section there is example package - a pack of C# examples. Try it, if you haven't yet. :)
Simple. Just instantiate your entity, set it to an object and pass it to your view in your controller.
Entity
VehicleInfoEntities db = new VehicleInfoEntities();
Stored Procedure
dbo.prcGetMakes()
or
you can add any parameters in your stored procedure inside the brackets ()
dbo.prcGetMakes("BMW")
Controller
public class HomeController : Controller
{
VehicleInfoEntities db = new VehicleInfoEntities();
public ActionResult Index()
{
var makes = db.prcGetMakes(null);
return View(makes);
}
}
What a pity I did not see the question before - I've wrote library shell-framework which contains among others the maps(Associative arrays). The last version of it can be found here.
Example:
#!/bin/bash
#include map library
shF_PATH_TO_LIB="/usr/lib/shell-framework"
source "${shF_PATH_TO_LIB}/map"
#simple example get/put
putMapValue "mapName" "mapKey1" "map Value 2"
echo "mapName[mapKey1]: $(getMapValue "mapName" "mapKey1")"
#redefine old value to new
putMapValue "mapName" "mapKey1" "map Value 1"
echo "after change mapName[mapKey1]: $(getMapValue "mapName" "mapKey1")"
#add two new pairs key/values and print all keys
putMapValue "mapName" "mapKey2" "map Value 2"
putMapValue "mapName" "mapKey3" "map Value 3"
echo -e "mapName keys are \n$(getMapKeys "mapName")"
#create new map
putMapValue "subMapName" "subMapKey1" "sub map Value 1"
putMapValue "subMapName" "subMapKey2" "sub map Value 2"
#and put it in mapName under key "mapKey4"
putMapValue "mapName" "mapKey4" "subMapName"
#check if under two key were placed maps
echo "is map mapName[mapKey3]? - $(if isMap "$(getMapValue "mapName" "mapKey3")" ; then echo Yes; else echo No; fi)"
echo "is map mapName[mapKey4]? - $(if isMap "$(getMapValue "mapName" "mapKey4")" ; then echo Yes; else echo No; fi)"
#print map with sub maps
printf "%s\n" "$(mapToString "mapName")"
The main difference is GIF is patented and a bit more widely supported. PNG is an open specification and alpha transparency is not supported in IE6. Support was improved in IE7, but not completely fixed.
As far as file sizes go, GIF has a smaller default color pallet, so they tend to be smaller file sizes at first glance. PNG files have a larger default pallet, however you can shrink their color pallet so that, when you do, they result in a smaller file size than GIF. The issue again is that this feature isn't as supported in Internet Explorer.
Also, because PNGs can support alpha transparency, they're the only option if you want a variation of transparency other than binary transparency.
You can do so by extending jQuerys functionality. This will shorten the amount of text you have to write for the selector.
$.extend($.expr[':'], {
unchecked: function (obj) {
return ((obj.type == 'checkbox' || obj.type == 'radio') && !$(obj).is(':checked'));
}
}
);
You can then use $("input:unchecked")
to get all checkboxes and radio buttons that are checked.
What you show looks like a mesh warp. That would be straightforward using OpenGL, but "straightforward OpenGL" is like straightforward rocket science.
I wrote an iOS app for my company called Face Dancerthat's able to do 60 fps mesh warp animations of video from the built-in camera using OpenGL, but it was a lot of work. (It does funhouse mirror type changes to faces - think "fat booth" live, plus lots of other effects.)
Simply the response is already parsed, you don't need to parse it again. if you parse it again it will give you "unexpected token o" however you have to specify datatype in your request to be of type dataType='json'
Try something like this to convert JToken to JArray:
static public JArray convertToJArray(JToken obj)
{
// if ((obj).Type == JTokenType.Null) --> You can check if it's null here
if ((obj).Type == JTokenType.Array)
return (JArray)(obj);
else
return new JArray(); // this will return an empty JArray
}
You can define the section by RenderSection method in layout.
Layout
<head>
<link href="@Url.Content("~/Content/themes/base/Site.css")"
rel="stylesheet" type="text/css" />
@RenderSection("heads", required: false)
</head>
Then you can include your css files in section area in your view except partial view.
The section work in view, but not work in partial view by design.
<!--your code -->
@section heads
{
<link href="@Url.Content("~/Content/themes/base/AnotherPage.css")"
rel="stylesheet" type="text/css" />
}
If you really want to using section area in partial view, you can follow the article to redefine RenderSection method.
Razor, Nested Layouts and Redefined Sections – Marcin On ASP.NET
The above answer for webkit appearance worked, but the button still looked kind pale/dull compared to the browser on other devices/desktop. I also had to set opacity to full (ranges from 0 to 1)
-webkit-appearance:none;
opacity: 1
After setting the opacity, the button looked the same on all the different devices/emulator/desktop.
Add the servlet-api.jar
to your classpath. You can take it from tomcat's lib folder.
If you want to pass the variable to your proxy backend, you have to set it with the proxy module.
location / {
proxy_pass http://example.com;
proxy_set_header Host example.com;
proxy_set_header HTTP_Country-Code $geoip_country_code;
proxy_pass_request_headers on;
}
And now it's passed to the proxy backend.
Create Generated Column
String generatedColumns[] = { "ID" };
Pass this geneated Column to your statement
PreparedStatement stmtInsert = conn.prepareStatement(insertSQL, generatedColumns);
Use ResultSet
object to fetch the GeneratedKeys on Statement
ResultSet rs = stmtInsert.getGeneratedKeys();
if (rs.next()) {
long id = rs.getLong(1);
System.out.println("Inserted ID -" + id); // display inserted record
}
Run cmd
and then run node server.js
. In your example, you are trying to use the REPL to run your command, which is not going to work. The ellipsis is node.js expecting more tokens before closing the current scope (you can type code in and run it on the fly here)
You don't need a function at all. You can work on a whole column directly.
Example data:
>>> df = pd.DataFrame({'a': [100, 1000], 'b': [200, 2000], 'c': [300, 3000]})
>>> df
a b c
0 100 200 300
1 1000 2000 3000
Half all the values in column a
:
>>> df.a = df.a / 2
>>> df
a b c
0 50 200 300
1 500 2000 3000
After discussion posting updated answer:
Option Explicit
Sub test()
Dim wk As String, yr As String
Dim fname As String, fpath As String
Dim owb As Workbook
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.EnableEvents = False
End With
wk = ComboBox1.Value
yr = ComboBox2.Value
fname = yr & "W" & wk
fpath = "C:\Documents and Settings\jammil\Desktop\AutoFinance\ProjectControl\Data"
On Error GoTo ErrorHandler
Set owb = Application.Workbooks.Open(fpath & "\" & fname)
'Do Some Stuff
With owb
.SaveAs fpath & Format(Date, "yyyymm") & "DB" & ".xlsx", 51
.Close
End With
With Application
.DisplayAlerts = True
.ScreenUpdating = True
.EnableEvents = True
End With
Exit Sub
ErrorHandler: If MsgBox("This File Does Not Exist!", vbRetryCancel) = vbCancel Then
Else: Call Clear
End Sub
Error Handling:
You could try something like this to catch a specific error:
On Error Resume Next
Set owb = Application.Workbooks.Open(fpath & "\" & fname)
If Err.Number = 1004 Then
GoTo FileNotFound
Else
End If
...
Exit Sub
FileNotFound: If MsgBox("This File Does Not Exist!", vbRetryCancel) = vbCancel Then
Else: Call Clear
This should work. Make sure each button has a unique ID. (Replace Choose_Yes and Choose_No with the IDs of your two radio buttons)
document.getElementById("Choose_Yes").checked = false;
document.getElementById("Choose_No").checked = false;
An example of how the radio buttons should be named:
<input type="radio" name="Choose" id="Choose_Yes" value="1" /> Yes
<input type="radio" name="Choose" id="Choose_No" value="2" /> No
Ok, here's a simple box that follows the cursor
Doing the rest is a simple case of remembering the last cursor position and applying a formula to get the box to move other than exactly where the cursor is. A timeout would also be handy if the box has a limited acceleration and must catch up to the cursor after it stops moving. Replacing the box with an image is simple CSS (which can replace most of the setup code for the box). I think the actual thinking code in the example is about 8 lines.
Select the right image (use a sprite) to orientate the rocket.
Yeah, annoying as hell. :-)
function getMouseCoords(e) {
var e = e || window.event;
document.getElementById('container').innerHTML = e.clientX + ', ' +
e.clientY + '<br>' + e.screenX + ', ' + e.screenY;
}
var followCursor = (function() {
var s = document.createElement('div');
s.style.position = 'absolute';
s.style.margin = '0';
s.style.padding = '5px';
s.style.border = '1px solid red';
s.textContent = ""
return {
init: function() {
document.body.appendChild(s);
},
run: function(e) {
var e = e || window.event;
s.style.left = (e.clientX - 5) + 'px';
s.style.top = (e.clientY - 5) + 'px';
getMouseCoords(e);
}
};
}());
window.onload = function() {
followCursor.init();
document.body.onmousemove = followCursor.run;
}
_x000D_
#container {
width: 1000px;
height: 1000px;
border: 1px solid blue;
}
_x000D_
<div id="container"></div>
_x000D_
This has been discussed on SO multiple times. Here are a few links to get you started:
SO: Capturing image from webcam in java?
openCVF applet: http://www.colorfulwolf.com/blog/2011/07/05/accessing-the-webcam-from-inside-a-java-applet/
config: http://ganeshtiwaridotcomdotnp.blogspot.in/2011/12/opencv-javacv-eclipse-project.html
Another option is to use numpy.full
, an option available in NumPy 1.8+
a = np.full([height, width, 9], np.nan)
This is pretty flexible and you can fill it with any other number that you want.
If you already have a directory in /usr/local
for the package you're installing, you can try deleting this directory.
In my case I had previously installed the package I was trying to install without using brew, and had then uninstalled it. There was a directory /usr/local/<my_package>/
left over from that previous install. I deleted this folder (sudo rm -rf /usr/local/<my_package>/
) and after that the brew link step was successful.
I realize that this is an old question, with an established answer. The reason I'm posting is that is the accepted answer has many elements of k-NN (k-nearest neighbors), a different algorithm.
Both k-NN and NaiveBayes are classification algorithms. Conceptually, k-NN uses the idea of "nearness" to classify new entities. In k-NN 'nearness' is modeled with ideas such as Euclidean Distance or Cosine Distance. By contrast, in NaiveBayes, the concept of 'probability' is used to classify new entities.
Since the question is about Naive Bayes, here's how I'd describe the ideas and steps to someone. I'll try to do it with as few equations and in plain English as much as possible.
Before someone can understand and appreciate the nuances of Naive Bayes', they need to know a couple of related concepts first, namely, the idea of Conditional Probability, and Bayes' Rule. (If you are familiar with these concepts, skip to the section titled Getting to Naive Bayes')
Conditional Probability in plain English: What is the probability that something will happen, given that something else has already happened.
Let's say that there is some Outcome O. And some Evidence E. From the way these probabilities are defined: The Probability of having both the Outcome O and Evidence E is: (Probability of O occurring) multiplied by the (Prob of E given that O happened)
One Example to understand Conditional Probability:
Let say we have a collection of US Senators. Senators could be Democrats or Republicans. They are also either male or female.
If we select one senator completely randomly, what is the probability that this person is a female Democrat? Conditional Probability can help us answer that.
Probability of (Democrat and Female Senator)= Prob(Senator is Democrat) multiplied by Conditional Probability of Being Female given that they are a Democrat.
P(Democrat & Female) = P(Democrat) * P(Female | Democrat)
We could compute the exact same thing, the reverse way:
P(Democrat & Female) = P(Female) * P(Democrat | Female)
Conceptually, this is a way to go from P(Evidence| Known Outcome) to P(Outcome|Known Evidence). Often, we know how frequently some particular evidence is observed, given a known outcome. We have to use this known fact to compute the reverse, to compute the chance of that outcome happening, given the evidence.
P(Outcome given that we know some Evidence) = P(Evidence given that we know the Outcome) times Prob(Outcome), scaled by the P(Evidence)
The classic example to understand Bayes' Rule:
Probability of Disease D given Test-positive =
P(Test is positive|Disease) * P(Disease)
_______________________________________________________________
(scaled by) P(Testing Positive, with or without the disease)
Now, all this was just preamble, to get to Naive Bayes.
So far, we have talked only about one piece of evidence. In reality, we have to predict an outcome given multiple evidence. In that case, the math gets very complicated. To get around that complication, one approach is to 'uncouple' multiple pieces of evidence, and to treat each of piece of evidence as independent. This approach is why this is called naive Bayes.
P(Outcome|Multiple Evidence) =
P(Evidence1|Outcome) * P(Evidence2|outcome) * ... * P(EvidenceN|outcome) * P(Outcome)
scaled by P(Multiple Evidence)
Many people choose to remember this as:
P(Likelihood of Evidence) * Prior prob of outcome
P(outcome|evidence) = _________________________________________________
P(Evidence)
Notice a few things about this equation:
base rates
and they are a way to scale our predicted probabilities.Just run the formula above for each possible outcome. Since we are trying to classify, each outcome is called a class
and it has a class label.
Our job is to look at the evidence, to consider how likely it is to be this class or that class, and assign a label to each entity.
Again, we take a very simple approach: The class that has the highest probability is declared the "winner" and that class label gets assigned to that combination of evidences.
Let's try it out on an example to increase our understanding: The OP asked for a 'fruit' identification example.
Let's say that we have data on 1000 pieces of fruit. They happen to be Banana, Orange or some Other Fruit. We know 3 characteristics about each fruit:
This is our 'training set.' We will use this to predict the type of any new fruit we encounter.
Type Long | Not Long || Sweet | Not Sweet || Yellow |Not Yellow|Total
___________________________________________________________________
Banana | 400 | 100 || 350 | 150 || 450 | 50 | 500
Orange | 0 | 300 || 150 | 150 || 300 | 0 | 300
Other Fruit | 100 | 100 || 150 | 50 || 50 | 150 | 200
____________________________________________________________________
Total | 500 | 500 || 650 | 350 || 800 | 200 | 1000
___________________________________________________________________
We can pre-compute a lot of things about our fruit collection.
The so-called "Prior" probabilities. (If we didn't know any of the fruit attributes, this would be our guess.) These are our base rates.
P(Banana) = 0.5 (500/1000)
P(Orange) = 0.3
P(Other Fruit) = 0.2
Probability of "Evidence"
p(Long) = 0.5
P(Sweet) = 0.65
P(Yellow) = 0.8
Probability of "Likelihood"
P(Long|Banana) = 0.8
P(Long|Orange) = 0 [Oranges are never long in all the fruit we have seen.]
....
P(Yellow|Other Fruit) = 50/200 = 0.25
P(Not Yellow|Other Fruit) = 0.75
Let's say that we are given the properties of an unknown fruit, and asked to classify it. We are told that the fruit is Long, Sweet and Yellow. Is it a Banana? Is it an Orange? Or Is it some Other Fruit?
We can simply run the numbers for each of the 3 outcomes, one by one. Then we choose the highest probability and 'classify' our unknown fruit as belonging to the class that had the highest probability based on our prior evidence (our 1000 fruit training set):
P(Banana|Long, Sweet and Yellow)
P(Long|Banana) * P(Sweet|Banana) * P(Yellow|Banana) * P(banana)
= _______________________________________________________________
P(Long) * P(Sweet) * P(Yellow)
= 0.8 * 0.7 * 0.9 * 0.5 / P(evidence)
= 0.252 / P(evidence)
P(Orange|Long, Sweet and Yellow) = 0
P(Other Fruit|Long, Sweet and Yellow)
P(Long|Other fruit) * P(Sweet|Other fruit) * P(Yellow|Other fruit) * P(Other Fruit)
= ____________________________________________________________________________________
P(evidence)
= (100/200 * 150/200 * 50/200 * 200/1000) / P(evidence)
= 0.01875 / P(evidence)
By an overwhelming margin (0.252 >> 0.01875
), we classify this Sweet/Long/Yellow fruit as likely to be a Banana.
Look at what it eventually comes down to. Just some counting and multiplication. We can pre-compute all these terms, and so classifying becomes easy, quick and efficient.
Let z = 1 / P(evidence).
Now we quickly compute the following three quantities.
P(Banana|evidence) = z * Prob(Banana) * Prob(Evidence1|Banana) * Prob(Evidence2|Banana) ...
P(Orange|Evidence) = z * Prob(Orange) * Prob(Evidence1|Orange) * Prob(Evidence2|Orange) ...
P(Other|Evidence) = z * Prob(Other) * Prob(Evidence1|Other) * Prob(Evidence2|Other) ...
Assign the class label of whichever is the highest number, and you are done.
Despite the name, Naive Bayes turns out to be excellent in certain applications. Text classification is one area where it really shines.
Hope that helps in understanding the concepts behind the Naive Bayes algorithm.
Just in case anybody faces the same problem as me and no suggest answer here helps.
For me the cause was, that the Android studio refactor is buggy. I moved an innerclass outside of a class, which was a View and therefore also had a xml, where the direct path was set. This path will not get refactored by studio! And no error will be thrown.
Hope this helps anybody. Cheers.
This is because you're using getActivity()
inside an inner class. Try using:
SherlockFragmentActivity.this.getActivity()
instead, though there's really no need for the getActivity()
part. In your case,
SherlockFragmentActivity .this
should suffice.
Above answer didn't work for me, just do click File -> Invalidate/cache -> Invalidate and Restart.
You can do it with the following command:
php artisan make:model post -mcr
Brief :
-m, to create migration
-c to create controller
-r to specify the controller has resource
You need to say math.sqrt
when you use it. Or, do from math import sqrt
.
Hmm, I just read your question more thoroughly.... How are you importing math
? I just tried import math
and then math.sqrt
which worked perfectly. Are you doing something like import math as m
? If so, then you have to prefix the function with m
(or whatever name you used after as
).
pow
is working because there are two versions: an always available version in __builtin__
, and another version in math
.
Old question, but Guzzle adds the response within the exception object. So a simple try-catch on GuzzleHttp\Exception\ClientException
and then using getResponse
on that exception to see what 400-level error and continuing from there.
If you added JComponent
to already visible Container, then you have call
frame.getContentPane().validate();
frame.getContentPane().repaint();
for example
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setSize(460, 500);
frame.setTitle("Circles generator");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
frame.setVisible(true);
}
});
String input = JOptionPane.showInputDialog("Enter n:");
CustomComponents0 component = new CustomComponents0();
frame.add(component);
frame.getContentPane().validate();
frame.getContentPane().repaint();
}
static class CustomComponents0 extends JLabel {
private static final long serialVersionUID = 1L;
@Override
public Dimension getMinimumSize() {
return new Dimension(200, 100);
}
@Override
public Dimension getPreferredSize() {
return new Dimension(300, 200);
}
@Override
public void paintComponent(Graphics g) {
int margin = 10;
Dimension dim = getSize();
super.paintComponent(g);
g.setColor(Color.red);
g.fillRect(margin, margin, dim.width - margin * 2, dim.height - margin * 2);
}
}
}
Ivan's answer above is good:
composer global show -i
Added info: if you get a message somewhat like:
Composer could not find a composer.json file in ~/.composer
...you might have no packages installed yet. If so, you can ignore the next part of the message containing:
... please create a composer.json file ...
...as once you install a package the message will go away.
You can use SQL Server recursive CTE
DECLARE
@MinDate DATE = '2020-01-01',
@MaxDate DATE = '2020-02-01';
WITH Dates(day) AS
(
SELECT CAST(@MinDate as Date) as day
UNION ALL
SELECT CAST(DATEADD(day, 1, day) as Date) as day
FROM Dates
WHERE CAST(DATEADD(day, 1, day) as Date) < @MaxDate
)
SELECT* FROM dates;
I don't believe this is a good pattern to use in general. Link will run your onClick event and then navigate to the route, so there will be a slight delay navigating to the new route. A better strategy is to navigate to the new route with the 'to' prop as you have done, and in the new component's componentDidMount() function you can fire your hello function or any other function. It will give you the same result, but with a much smoother transition between routes.
For context, I noticed this while updating my redux store with an onClick event on Link like you have here, and it caused a ~.3 second blank-white-screen delay before mounting the new route's component. There was no api call involved, so I was surprised the delay was so big. However, if you're just console logging 'hello' the delay might not be noticeable.
The three things that get installed that you will need to delete are:
Now on my linux system these live in:
But on a windows system they are more likely to be entirely within the Python distribution directory. I have no idea about OSX except it is more likey to follow the linux pattern.
Using res.json with Express:
function random(response) {
console.log("response.json sets the appropriate header and performs JSON.stringify");
response.json({
anObject: { item1: "item1val", item2: "item2val" },
anArray: ["item1", "item2"],
another: "item"
});
}
Alternatively:
function random(response) {
console.log("Request handler random was called.");
response.writeHead(200, {"Content-Type": "application/json"});
var otherArray = ["item1", "item2"];
var otherObject = { item1: "item1val", item2: "item2val" };
var json = JSON.stringify({
anObject: otherObject,
anArray: otherArray,
another: "item"
});
response.end(json);
}
Enable TextWrapping="Wrap"
and AcceptsReturn="True"
on your TextBox.
You might also wish to enable AcceptsTab
and SpellCheck.IsEnabled
too.
NOTE - it looks like the question has changed some. The answer to the question of how you call an instance method from a static method is that you can't without passing an instance in as an argument or instantiating that instance inside the static method.
What follows is mostly to answer "how do you call a static method from another static method":
Bear in mind that there is a difference between static methods and class methods in Python. A static method takes no implicit first argument, while a class method takes the class as the implicit first argument (usually cls
by convention). With that in mind, here's how you would do that:
If it's a static method:
test.dosomethingelse()
If it's a class method:
cls.dosomethingelse()
Change
from urllib.request import urlopen
to
from urllib import urlopen
I was able to solve this problem by changing like this. For Python2.7
in macOS10.14
Your JSON sample is:
{
"status": "ok",
"comment": "",
"result": {
"id": 276,
"firstName": "mohamed",
"lastName": "hussien",
"players": [
"player 1",
"player 2",
"player 3",
"player 4",
"player 5"
]
}
so if you want to save arraylist of modules in your SharedPrefrences so :
1- will convert your returned arraylist for json format using this method
public static String toJson(Object jsonObject) {
return new Gson().toJson(jsonObject);
}
2- Save it in shared prefreneces
PreferencesUtils.getInstance(context).setString("players", toJson((.....ArrayList you want to convert.....)));
3- to retrieve it at any time get JsonString from Shared preferences like that
String playersString= PreferencesUtils.getInstance(this).getString("players");
4- convert it again to array list
public static Object fromJson(String jsonString, Type type) {
return new Gson().fromJson(jsonString, type);
}
ArrayList<String> playersList= (ArrayList<String>) fromJson(playersString,
new TypeToken<ArrayList<String>>() {
}.getType());
this solution also doable if you want to parse ArrayList of Objects Hope it's help you by using Gson Library .
I was able to solve this problem by removing node_modules
then running npm install
Here author performed tests showed that integer unix timestamp is better than DateTime. Note, he used MySql. But I feel no matter what DB engine you use comparing integers are slightly faster than comparing dates so int index is better than DateTime index. Take T1 - time of comparing 2 dates, T2 - time of comparing 2 integers. Search on indexed field takes approximately O(log(rows)) time because index based on some balanced tree - it may be different for different DB engines but anyway Log(rows) is common estimation. (if you not use bitmask or r-tree based index). So difference is (T2-T1)*Log(rows) - may play role if you perform your query oftenly.
I had a similar issue as you, although I was trying to use start
to open Chrome and using the file path. I used only start chrome.exe
and it opened just fine. You may want to try to do the same with exe file. Using the file path may be unnecessary.
Here are some examples (using the file name you gave in a comment on another answer):
Instead of C:\Program^ Files\temp.exe
you can try temp.exe
.
Instead of start C:\Program^ Files\temp.exe
you can try start
temp.exe
Mockito comes with a helper class to save you some reflection boiler plate code:
import org.mockito.internal.util.reflection.Whitebox;
//...
@Mock
private Person mockedPerson;
private Test underTest;
// ...
@Test
public void testMethod() {
Whitebox.setInternalState(underTest, "person", mockedPerson);
// ...
}
Update: Unfortunately the mockito team decided to remove the class in Mockito 2. So you are back to writing your own reflection boilerplate code, use another library (e.g. Apache Commons Lang), or simply pilfer the Whitebox class (it is MIT licensed).
Update 2: JUnit 5 comes with its own ReflectionSupport and AnnotationSupport classes that might be useful and save you from pulling in yet another library.
Yet another variant of Gavriel's applog.sh
with support of several devices and applications with multiple processes:
#!/bin/sh
PKG=$1
shift
APPIDS=`adb $@ shell ps | awk -v PKG="$PKG" '
(NR == 1){appcolumn=2; for (i=1; i<=NF; i++) if ($i=="PID") {appcolumn=i}}
index($0,PKG){print $(appcolumn)}' | paste -d \| -s`
echo "PID's: $APPIDS"
adb $@ logcat -v color | awk "(\$3 ~ /$APPIDS/){print \$0}"
Usage: applog.sh com.example.my.package [-s <specific device>]
It's now 2018, and we finally have cheap ways to do something around it...
Indeed, since the 2d context API now has a filter
property, and that this filter property can accept SVGFilters, we can build an SVGFilter that will keep only fully opaque pixels from our drawings, and thus eliminate the default anti-aliasing.
So it won't deactivate antialiasing per se, but provides a cheap way both in term of implementation and of performances to remove all semi-transparent pixels while drawing.
I am not really a specialist of SVGFilters, so there might be a better way of doing it, but for the example, I'll use a <feComponentTransfer>
node to grab only fully opaque pixels.
var ctx = canvas.getContext('2d');_x000D_
ctx.fillStyle = '#ABEDBE';_x000D_
ctx.fillRect(0,0,canvas.width,canvas.height);_x000D_
ctx.fillStyle = 'black';_x000D_
ctx.font = '14px sans-serif';_x000D_
ctx.textAlign = 'center';_x000D_
_x000D_
// first without filter_x000D_
ctx.fillText('no filter', 60, 20);_x000D_
drawArc();_x000D_
drawTriangle();_x000D_
// then with filter_x000D_
ctx.setTransform(1, 0, 0, 1, 120, 0);_x000D_
ctx.filter = 'url(#remove-alpha)';_x000D_
// and do the same ops_x000D_
ctx.fillText('no alpha', 60, 20);_x000D_
drawArc();_x000D_
drawTriangle();_x000D_
_x000D_
// to remove the filter_x000D_
ctx.filter = 'none';_x000D_
_x000D_
_x000D_
function drawArc() {_x000D_
ctx.beginPath();_x000D_
ctx.arc(60, 80, 50, 0, Math.PI * 2);_x000D_
ctx.stroke();_x000D_
}_x000D_
_x000D_
function drawTriangle() {_x000D_
ctx.beginPath();_x000D_
ctx.moveTo(60, 150);_x000D_
ctx.lineTo(110, 230);_x000D_
ctx.lineTo(10, 230);_x000D_
ctx.closePath();_x000D_
ctx.stroke();_x000D_
}_x000D_
// unrelated_x000D_
// simply to show a zoomed-in version_x000D_
var zCtx = zoomed.getContext('2d');_x000D_
zCtx.imageSmoothingEnabled = false;_x000D_
canvas.onmousemove = function drawToZoommed(e) {_x000D_
var x = e.pageX - this.offsetLeft,_x000D_
y = e.pageY - this.offsetTop,_x000D_
w = this.width,_x000D_
h = this.height;_x000D_
_x000D_
zCtx.clearRect(0,0,w,h);_x000D_
zCtx.drawImage(this, x-w/6,y-h/6,w, h, 0,0,w*3, h*3);_x000D_
}
_x000D_
<svg width="0" height="0" style="position:absolute;z-index:-1;">_x000D_
<defs>_x000D_
<filter id="remove-alpha" x="0" y="0" width="100%" height="100%">_x000D_
<feComponentTransfer>_x000D_
<feFuncA type="discrete" tableValues="0 1"></feFuncA>_x000D_
</feComponentTransfer>_x000D_
</filter>_x000D_
</defs>_x000D_
</svg>_x000D_
_x000D_
<canvas id="canvas" width="250" height="250" ></canvas>_x000D_
<canvas id="zoomed" width="250" height="250" ></canvas>
_x000D_
And for the ones that don't like to append an <svg>
element in their DOM, you can also save it as an external svg file and set the filter
property to path/to/svg_file.svg#remove-alpha
.
There's three ways to get this sort of count, each with their own tradeoffs.
If you want a true count, you have to execute the SELECT statement like the one you used against each table. This is because PostgreSQL keeps row visibility information in the row itself, not anywhere else, so any accurate count can only be relative to some transaction. You're getting a count of what that transaction sees at the point in time when it executes. You could automate this to run against every table in the database, but you probably don't need that level of accuracy or want to wait that long.
The second approach notes that the statistics collector tracks roughly how many rows are "live" (not deleted or obsoleted by later updates) at any time. This value can be off by a bit under heavy activity, but is generally a good estimate:
SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;
That can also show you how many rows are dead, which is itself an interesting number to monitor.
The third way is to note that the system ANALYZE command, which is executed by the autovacuum process regularly as of PostgreSQL 8.3 to update table statistics, also computes a row estimate. You can grab that one like this:
SELECT
nspname AS schemaname,relname,reltuples
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE
nspname NOT IN ('pg_catalog', 'information_schema') AND
relkind='r'
ORDER BY reltuples DESC;
Which of these queries is better to use is hard to say. Normally I make that decision based on whether there's more useful information I also want to use inside of pg_class or inside of pg_stat_user_tables. For basic counting purposes just to see how big things are in general, either should be accurate enough.
I consider Ashwin's answer to be the most correct, my old answer is below.
docker run -dti foo bash
You can then enter the container and run bash with
docker exec -ti ID_of_foo bash
No need to install sshd :)
Use to_datetime
, there is no need for a format string the parser is man/woman enough to handle it:
In [51]:
pd.to_datetime(df['I_DATE'])
Out[51]:
0 2012-03-28 14:15:00
1 2012-03-28 14:17:28
2 2012-03-28 14:50:50
Name: I_DATE, dtype: datetime64[ns]
To access the date/day/time component use the dt
accessor:
In [54]:
df['I_DATE'].dt.date
Out[54]:
0 2012-03-28
1 2012-03-28
2 2012-03-28
dtype: object
In [56]:
df['I_DATE'].dt.time
Out[56]:
0 14:15:00
1 14:17:28
2 14:50:50
dtype: object
You can use strings to filter as an example:
In [59]:
df = pd.DataFrame({'date':pd.date_range(start = dt.datetime(2015,1,1), end = dt.datetime.now())})
df[(df['date'] > '2015-02-04') & (df['date'] < '2015-02-10')]
Out[59]:
date
35 2015-02-05
36 2015-02-06
37 2015-02-07
38 2015-02-08
39 2015-02-09
You must use a .ts
file - e.g. test.ts
to get Typescript validation, intellisense typing
of vars, return types, as well as "typed" error checking (e.g. passing a string
to a method that expects an number
param will error out).
It will be transpiled into (standard) .js
via tsc
.
Clarification needed based on down-votes, very helpful comments and other answers.
types
Yes, you can do type
checking in VS Code in .js
files with @ts-check
- as shown in the animation
What I originally was referring to for Typescript types
is something like this in .ts
which isn't quite the same thing:
hello-world.ts
function hello(str: string): string {
return 1;
}
function foo(str:string):void{
console.log(str);
}
This will not compile. Error: Type "1" is not assignable to String
if you tried this syntax in a Javascript hello-world.js
file:
//@ts-check
function hello(str: string): string {
return 1;
}
function foo(str:string):void{
console.log(str);
}
The error message referenced by OP is shown: [js] 'types' can only be used in a .ts file
If there's something I missed that covers this as well as the OP's context, please add. Let's all learn.
Sorry not sure what was going on this worked in the end:
<VirtualHost *>
ServerName example.com
DocumentRoot /var/www/html/mjp
Alias /ncn "/var/www/html/ncn"
<Directory "/var/www/html/ncn">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Isn't the easiest way to create a class contining all the needed variables? Then you have one object with all curretn variables, and if you need you can overwrite this variable?
If you are looking for a fast unrolled version, this should do the trick, assuming a byte array called "b" with a length of 8:
byte[] -> long
long l = ((long) b[7] << 56)
| ((long) b[6] & 0xff) << 48
| ((long) b[5] & 0xff) << 40
| ((long) b[4] & 0xff) << 32
| ((long) b[3] & 0xff) << 24
| ((long) b[2] & 0xff) << 16
| ((long) b[1] & 0xff) << 8
| ((long) b[0] & 0xff);
long -> byte[] as an exact counterpart to the above
byte[] b = new byte[] {
(byte) lng,
(byte) (lng >> 8),
(byte) (lng >> 16),
(byte) (lng >> 24),
(byte) (lng >> 32),
(byte) (lng >> 40),
(byte) (lng >> 48),
(byte) (lng >> 56)};
-(void)sendingAnHTTPPOSTRequestOniOSWithUserEmailId: (NSString *)emailId withPassword: (NSString *)password{
//Init the NSURLSession with a configuration
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: nil delegateQueue: [NSOperationQueue mainQueue]];
//Create an URLRequest
NSURL *url = [NSURL URLWithString:@"http://www.example.com/apis/login_api"];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
//Create POST Params and add it to HTTPBody
NSString *params = [NSString stringWithFormat:@"email=%@&password=%@",emailId,password];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];
//Create task
NSURLSessionDataTask *dataTask = [defaultSession dataTaskWithRequest:urlRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
//Handle your response here
NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
NSLog(@"%@",responseDict);
}];
[dataTask resume];
}
The Build number is an internal number that indicates the current state of the app. It differs from the Version number in that it's typically not user facing and doesn't denote any difference/features/upgrades like a version number typically would.
Think of it like this:
CFBundleVersion
): The number of the build. Usually you start this at 1 and increase by 1 with each build of the app. It quickly allows for comparisons of which build is more recent and it denotes the sense of progress of the codebase. These can be overwhelmingly valuable when working with QA and needing to be sure bugs are logged against the right builds.CFBundleShortVersionString
): The user-facing number you are using to denote this version of your app. Usually this follows a Major.minor version scheme (e.g. MyAwesomeApp 1.2) to let users know which releases are smaller maintenance updates and which are big deal new features.To use this effectively in your projects, Apple provides a great tool called agvtool
. I highly recommend using this as it is MUCH more simple than scripting up plist changes. It allows you to easily set both the build number and the marketing version. It is particularly useful when scripting (for instance, easily updating the build number on each build or even querying what the current build number is). It can even do more exotic things like tag your SVN for you when you update the build number.
To use it:
agvtool new-version 1
(set the Build number to 1)agvtool new-marketing-version 1.0
(set the Marketing version to 1.0)See the man page of agvtool
for a ton of good info
For pages that rely on external CSS (most pages nowadays) a simple and reliable solution is to kill the head
element:
document.querySelector("head").remove();
Right-click this page (in Chrome/Firefox), select Inspect, paste the code in the devtools console and press Enter.
A bookmarklet version of the same code that you can paste as the URL of a bookmark:
javascript:(function(){document.querySelector("head").remove();})()
Now clicking the bookmark on in your Favorites bar will show the page without any css stylesheets.
Removing the head will not work for pages that use inline styles.
If you happen to use Safari on MacOS then:
map HTTP request header Content-Type
, handle request body.
@RequestParam
? application/x-www-form-urlencoded
,
@RequestBody
? application/json
,
@RequestPart
? multipart/form-data
,
RequestParam (Spring Framework 5.1.9.RELEASE API)
map to query parameters, form data, and parts in multipart requests.
RequestParam
is likely to be used with name-value form fields
RequestBody (Spring Framework 5.1.9.RELEASE API)
bound to the body of the web request. The body of the request is passed through an HttpMessageConverter to resolve the method argument depending on the
content type
of the request. (e.g. JSON, XML)
RequestPart (Spring Framework 5.1.9.RELEASE API)
used to associate the part of a "
multipart/form-data
" request
RequestPart
is likely to be used with parts containing more complex content
HttpMessageConverter (Spring Framework 5.1.9.RELEASE API)
a converter that can convert from and to HTTP requests and responses.
All Known Implementing Classes: ..., AbstractJsonHttpMessageConverter, AbstractXmlHttpMessageConverter, ...
I dont know if you want to achieve that in js or java, in js the simplest way to get the unix timestampt (this is time in seconds from 1/1/1970) it's as follows:
var myDate = new Date();
console.log(+myDate); // +myDateObject give you the unix from that date
You can stash
(save the changes in temporary box) then, back to master
branch HEAD.
$ git add .
$ git stash
$ git checkout master
Jump Over Commits Back and Forth:
Go to a specific commit-sha
.
$ git checkout <commit-sha>
If you have uncommitted changes here then, you can checkout to a new branch | Add | Commit | Push the current branch to the remote.
# checkout a new branch, add, commit, push
$ git checkout -b <branch-name>
$ git add .
$ git commit -m 'Commit message'
$ git push origin HEAD # push the current branch to remote
$ git checkout master # back to master branch now
If you have changes in the specific commit and don't want to keep the changes, you can do stash
or reset
then checkout to master
(or, any other branch).
# stash
$ git add -A
$ git stash
$ git checkout master
# reset
$ git reset --hard HEAD
$ git checkout master
After checking out a specific commit if you have no uncommitted change(s) then, just back to master
or other
branch.
$ git status # see the changes
$ git checkout master
# or, shortcut
$ git checkout - # back to the previous state
I personally use import because, we can import the required methods, members by using import.
import {foo, bar} from "dep";
FileName: dep.js
export foo function(){};
export const bar = 22
Credit goes to Paul Shan. More info.
You can use Recordmp3js from GitHub to achieve your requirements. You can record from user's microphone and then get the file as an mp3. Finally upload it to your server.
I used this in my demo. There is a already a sample available with the source code by the author in this location : https://github.com/Audior/Recordmp3js
The demo is here: http://audior.ec/recordmp3js/
But currently works only on Chrome and Firefox.
Seems to work fine and pretty simple. Hope this helps.
The problem with overriding using !important
is that you will loose the fade in effect.
So the actual best trick to change the modal-backdrop opacity without breaking the fadeIn effect and without having to use the shameless !important
is to use this :
.modal-backdrop{
opacity:0; transition:opacity .2s;
}
.modal-backdrop.in{
opacity:.7;
}
@sass
.modal-backdrop{
opacity:0; transition:opacity .2s;
&.in{opacity:.7;}
}
Simple and clean.
Sometimes it works fine on development machines and not in servers. In my case I had to put :
<globalization uiCulture="es" culture="es-CO" />
In the web.config file.
The timezone in the machine (Server) was right (to the CO locale) but the web app did not. This setting done and it worked fine again.
Off course, all dates had value.
:D
You don't need hibernate-entitymanager-xxx.jar
, because of you use a Hibernate session approach (not JPA
). You need to close the SessionFactory
too and rollback a transaction on errors. But, the problem, of course, is not with those.
This is returned by a database
#
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sa"
#
Looks like you've provided an incorrect username or (and) password.
Like user2680100 said, in Golang you can have the structure:
if <statement>; <evaluation> {
[statements ...]
} else {
[statements ...]
}
This is useful to shortcut some expressions that need error checking, or another kind of boolean checking, like:
var number int64
if v := os.Getenv("NUMBER"); v != "" {
if number, err = strconv.ParseInt(v, 10, 64); err != nil {
os.Exit(42)
}
} else {
os.Exit(1)
}
With this you can achieve something like (in C):
Sprite *buffer = get_sprite("foo.png");
Sprite *foo_sprite = (buffer != 0) ? buffer : donut_sprite
But is evident that this sugar in Golang have to be used with moderation, for me, personally, I like to use this sugar with max of one level of nesting, like:
var number int64
if v := os.Getenv("NUMBER"); v != "" {
number, err = strconv.ParseInt(v, 10, 64)
if err != nil {
os.Exit(42)
}
} else {
os.Exit(1)
}
You can also implement ternary expressions with functions like func Ternary(b bool, a interface{}, b interface{}) { ... }
but i don't like this approach, looks like a creation of a exception case in syntax, and creation of this "features", in my personal opinion, reduce the focus on that matters, that is algorithm and readability, but, the most important thing that makes me don't go for this way is that fact that this can bring a kind of overhead, and bring more cycles to in your program execution.
Alternate form of the answer by @rumpel
with open(filename, 'w'): pass
You use something like
from flask import send_file
@app.route('/get_image')
def get_image():
if request.args.get('type') == '1':
filename = 'ok.gif'
else:
filename = 'error.gif'
return send_file(filename, mimetype='image/gif')
to send back ok.gif
or error.gif
, depending on the type query parameter. See the documentation for the send_file
function and the request
object for more information.
You may already know that putting your Button inside of a ToolBar gives you this behavior, but if you want something that will work across ALL current themes with any sort of predictability, you'll need to create a new ControlTemplate.
Prashant's solution does not work with a Button not in a toolbar when the Button has focus. It also doesn't work 100% with the default theme in XP -- you can still see faint gray borders when your container Background is white.
Try this
function removeElements(){
$('#models').html("");
}
You can do this
@Html.DropDownList("Sortby", new SelectListItem[] { new SelectListItem()
{
Text = "Newest to Oldest", Value = "0" }, new SelectListItem() { Text = "Oldest to Newest", Value = "1" } , new
{
onchange = @"form.submit();"
}
})
Yes, this can be scripted with VBScript. For example the following code can create a zip from a directory:
Dim fso, winShell, MyTarget, MySource, file
Set fso = CreateObject("Scripting.FileSystemObject")
Set winShell = createObject("shell.application")
MyTarget = Wscript.Arguments.Item(0)
MySource = Wscript.Arguments.Item(1)
Wscript.Echo "Adding " & MySource & " to " & MyTarget
'create a new clean zip archive
Set file = fso.CreateTextFile(MyTarget, True)
file.write("PK" & chr(5) & chr(6) & string(18,chr(0)))
file.close
winShell.NameSpace(MyTarget).CopyHere winShell.NameSpace(MySource).Items
do until winShell.namespace(MyTarget).items.count = winShell.namespace(MySource).items.count
wscript.sleep 1000
loop
Set winShell = Nothing
Set fso = Nothing
You may also find http://www.naterice.com/blog/template_permalink.asp?id=64 helpful as it includes a full Unzip/Zip implementation in VBScript.
If you do a size check every 500 ms rather than a item count it works better for large files. Win 7 writes the file instantly although it's not finished compressing:
set fso=createobject("scripting.filesystemobject")
Set h=fso.getFile(DestZip)
do
wscript.sleep 500
max = h.size
loop while h.size > max
Works great for huge amounts of log files.
For Multiple columns you can use code similar to one given below.I was just going through this and found answer to check multiple columns in Datatable.
private bool IsAllColumnExist(DataTable tableNameToCheck, List<string> columnsNames)
{
bool iscolumnExist = true;
try
{
if (null != tableNameToCheck && tableNameToCheck.Columns != null)
{
foreach (string columnName in columnsNames)
{
if (!tableNameToCheck.Columns.Contains(columnName))
{
iscolumnExist = false;
break;
}
}
}
else
{
iscolumnExist = false;
}
}
catch (Exception ex)
{
}
return iscolumnExist;
}
Actually, all of those examples on the web wherein the common content/file type like "js", "css", "img", etc is been used as library name are misleading.
To start, let's look at how existing JSF implementations like Mojarra and MyFaces and JSF component libraries like PrimeFaces and OmniFaces use it. No one of them use resource libraries this way. They use it (under the covers, by @ResourceDependency
or UIViewRoot#addComponentResource()
) the following way:
<h:outputScript library="javax.faces" name="jsf.js" />
<h:outputScript library="primefaces" name="jquery/jquery.js" />
<h:outputScript library="omnifaces" name="omnifaces.js" />
<h:outputScript library="omnifaces" name="fixviewstate.js" />
<h:outputScript library="omnifaces.combined" name="[dynamicname].js" />
<h:outputStylesheet library="primefaces" name="primefaces.css" />
<h:outputStylesheet library="primefaces-aristo" name="theme.css" />
<h:outputStylesheet library="primefaces-vader" name="theme.css" />
It should become clear that it basically represents the common library/module/theme name where all of those resources commonly belong to.
This way it's so much easier to specify and distinguish where those resources belong to and/or are coming from. Imagine that you happen to have a primefaces.css
resource in your own webapp wherein you're overriding/finetuning some default CSS of PrimeFaces; if PrimeFaces didn't use a library name for its own primefaces.css
, then the PrimeFaces own one wouldn't be loaded, but instead the webapp-supplied one, which would break the look'n'feel.
Also, when you're using a custom ResourceHandler
, you can also apply more finer grained control over resources coming from a specific library when library
is used the right way. If all component libraries would have used "js" for all their JS files, how would the ResourceHandler
ever distinguish if it's coming from a specific component library? Examples are OmniFaces CombinedResourceHandler
and GraphicResourceHandler
; check the createResource()
method wherein the library is checked before delegating to next resource handler in chain. This way they know when to create CombinedResource
or GraphicResource
for the purpose.
Noted should be that RichFaces did it wrong. It didn't use any library
at all and homebrewed another resource handling layer over it and it's therefore impossible to programmatically identify RichFaces resources. That's exactly the reason why OmniFaces CombinedResourceHander
had to introduce a reflection-based hack in order to get it to work anyway with RichFaces resources.
Your own webapp does not necessarily need a resource library. You'd best just omit it.
<h:outputStylesheet name="css/style.css" />
<h:outputScript name="js/script.js" />
<h:graphicImage name="img/logo.png" />
Or, if you really need to have one, you can just give it a more sensible common name, like "default" or some company name.
<h:outputStylesheet library="default" name="css/style.css" />
<h:outputScript library="default" name="js/script.js" />
<h:graphicImage library="default" name="img/logo.png" />
Or, when the resources are specific to some master Facelets template, you could also give it the name of the template, so that it's easier to relate each other. In other words, it's more for self-documentary purposes. E.g. in a /WEB-INF/templates/layout.xhtml
template file:
<h:outputStylesheet library="layout" name="css/style.css" />
<h:outputScript library="layout" name="js/script.js" />
And a /WEB-INF/templates/admin.xhtml
template file:
<h:outputStylesheet library="admin" name="css/style.css" />
<h:outputScript library="admin" name="js/script.js" />
For a real world example, check the OmniFaces showcase source code.
Or, when you'd like to share the same resources over multiple webapps and have created a "common" project for that based on the same example as in this answer which is in turn embedded as JAR in webapp's /WEB-INF/lib
, then also reference it as library (name is free to your choice; component libraries like OmniFaces and PrimeFaces also work that way):
<h:outputStylesheet library="common" name="css/style.css" />
<h:outputScript library="common" name="js/script.js" />
<h:graphicImage library="common" name="img/logo.png" />
Another main advantage is that you can apply resource library versioning the right way on resources provided by your own webapp (this doesn't work for resources embedded in a JAR). You can create a direct child subfolder in the library folder with a name in the \d+(_\d+)*
pattern to denote the resource library version.
WebContent
|-- resources
| `-- default
| `-- 1_0
| |-- css
| | `-- style.css
| |-- img
| | `-- logo.png
| `-- js
| `-- script.js
:
When using this markup:
<h:outputStylesheet library="default" name="css/style.css" />
<h:outputScript library="default" name="js/script.js" />
<h:graphicImage library="default" name="img/logo.png" />
This will generate the following HTML with the library version as v
parameter:
<link rel="stylesheet" type="text/css" href="/contextname/javax.faces.resource/css/style.css.xhtml?ln=default&v=1_0" />
<script type="text/javascript" src="/contextname/javax.faces.resource/js/script.js.xhtml?ln=default&v=1_0"></script>
<img src="/contextname/javax.faces.resource/img/logo.png.xhtml?ln=default&v=1_0" alt="" />
So, if you have edited/updated some resource, then all you need to do is to copy or rename the version folder into a new value. If you have multiple version folders, then the JSF ResourceHandler
will automatically serve the resource from the highest version number, according to numerical ordering rules.
So, when copying/renaming resources/default/1_0/*
folder into resources/default/1_1/*
like follows:
WebContent
|-- resources
| `-- default
| |-- 1_0
| | :
| |
| `-- 1_1
| |-- css
| | `-- style.css
| |-- img
| | `-- logo.png
| `-- js
| `-- script.js
:
Then the last markup example would generate the following HTML:
<link rel="stylesheet" type="text/css" href="/contextname/javax.faces.resource/css/style.css.xhtml?ln=default&v=1_1" />
<script type="text/javascript" src="/contextname/javax.faces.resource/js/script.js.xhtml?ln=default&v=1_1"></script>
<img src="/contextname/javax.faces.resource/img/logo.png.xhtml?ln=default&v=1_1" alt="" />
This will force the webbrowser to request the resource straight from the server instead of showing the one with the same name from the cache, when the URL with the changed parameter is been requested for the first time. This way the endusers aren't required to do a hard refresh (Ctrl+F5 and so on) when they need to retrieve the updated CSS/JS resource.
Please note that library versioning is not possible for resources enclosed in a JAR file. You'd need a custom ResourceHandler
. See also How to use JSF versioning for resources in jar.
Profiting from the MS Excel 365 function UNIQUE()
In order to enrich the valid solutions above:
Sub ExampleCall()
Dim rng As Range: Set rng = Sheet1.Range("A2:A11") ' << change to your sheet's Code(Name)
Dim a: a = rng
a = getUniques(a)
arrInfo a
End Sub
Function getUniques(a, Optional ZeroBased As Boolean = True)
Dim tmp: tmp = Application.Transpose(WorksheetFunction.Unique(a))
If ZeroBased Then ReDim Preserve tmp(0 To UBound(tmp) - 1)
getUniques = tmp
End Function
select employee_name
from employees
where employee_name LIKE 'A%' OR employee_name LIKE 'B%'
order by employee_name
new Date(date) === 'Invalid Date'
only works in Firefox and Chrome. IE8 (the one I have on my machine for testing purposes) gives NaN.
As was stated to the accepted answer, Date.parse(date)
will also work for numbers. So to get around that, you could also check that it is not a number (if that's something you want to confirm).
var parsedDate = Date.parse(date);
// You want to check again for !isNaN(parsedDate) here because Dates can be converted
// to numbers, but a failed Date parse will not.
if (isNaN(date) && !isNaN(parsedDate)) {
/* do your work */
}
You can set default width and height for all Columns and Rows as below only with one loop.
// DataGridView Name= dgvMachineStatus
foreach (DataGridViewColumn column in dgvMachineStatus.Columns)
{
column.Width = 155;
}
foreach (DataGridViewRow row in dgvMachineStatus.Rows)
{
row.Height = 45;
}
.class {
background-color:none;
}
This is not a valid property. W3C validator will display following error:
Value Error : background-color none is not a background-color value : none
transparent
may have been selected as better term instead of 0
or none
values during the development of specification of CSS.
To export data to csv/excel from Kibana follow the following steps:-
Click on Visualize Tab & select a visualization (if created). If not created create a visualziation.
Click on caret symbol (^) which is present at the bottom of the visualization.
Then you will get an option of Export:Raw Formatted as the bottom of the page.
Please find below attached image showing Export option after clicking on caret symbol.
The following works by starting the jar with a batch file, in case the program runs as a stand alone:
public static void startExtJarProgram(){
String extJar = Paths.get("C:\\absolute\\path\\to\\batchfile.bat").toString();
ProcessBuilder processBuilder = new ProcessBuilder(extJar);
processBuilder.redirectError(new File(Paths.get("C:\\path\\to\\JavaProcessOutput\\extJar_out_put.txt").toString()));
processBuilder.redirectInput();
try {
final Process process = processBuilder.start();
try {
final int exitStatus = process.waitFor();
if(exitStatus==0){
System.out.println("External Jar Started Successfully.");
System.exit(0); //or whatever suits
}else{
System.out.println("There was an error starting external Jar. Perhaps path issues. Use exit code "+exitStatus+" for details.");
System.out.println("Check also C:\\path\\to\\JavaProcessOutput\\extJar_out_put.txt file for additional details.");
System.exit(1);//whatever
}
} catch (InterruptedException ex) {
System.out.println("InterruptedException: "+ex.getMessage());
}
} catch (IOException ex) {
System.out.println("IOException. Faild to start process. Reason: "+ex.getMessage());
}
System.out.println("Process Terminated.");
System.exit(0);
}
In the batchfile.bat then we can say:
@echo off
start /min C:\path\to\jarprogram.jar
This answer uses the jQuery UI Datepicker, which is a separate include. There are other ways to do this without including jQuery UI.
First, you simply need to add the datepicker
class to the textbox, in addition to form-control
:
<div class="form-group input-group-sm">
@Html.LabelFor(model => model.DropOffDate)
@Html.TextBoxFor(model => model.DropOffDate, new { @class = "form-control datepicker", placeholder = "Enter Drop-off date here..." })
@Html.ValidationMessageFor(model => model.DropOffDate)
</div>
Then, to be sure the javascript is triggered after the textbox is rendered, you have to put the datepicker call in the jQuery ready function:
<script type="text/javascript">
$(function () { // will trigger when the document is ready
$('.datepicker').datepicker(); //Initialise any date pickers
});
</script>
I think if you want to add content directly to the body, the best way is:
document.body.innerHTML = document.body.innerHTML + "bla bla";
To replace it, use:
document.body.innerHTML = "bla bla";
You can change author of last commit using the command below.
git commit --amend --author="Author Name <[email protected]>"
However, if you want to change more than one commits author name, it's a bit tricky. You need to start an interactive rebase then mark commits as edit then amend them one by one and finish.
Start rebasing with git rebase -i
. It will show you something like this.
Change the pick
keyword to edit
for the commits you want to change the author name.
Then close the editor. For the beginners, hit Escape
then type :wq
and hit Enter
.
Then you will see your terminal like nothing happened. Actually you are in the middle of an interactive rebase. Now it's time to amend your commit's author name using the command above. It will open the editor again. Quit and continue rebase with git rebase --continue
. Repeat the same for the commit count you want to edit. You can make sure that interactive rebase finished when you get the No rebase in progress?
message.
Following what curl does internally for the request (via the method outlined in this answer to "Php - Debugging Curl") answers the question: No, it is not possible to use the curl_setopt
call with CURLOPT_HTTPHEADER
. The second call will overwrite the headers of the first call.
Instead the function needs to be called once with all headers:
$headers = array(
'Content-type: application/xml',
'Authorization: gfhjui',
);
curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $headers);
Related (but different) questions are:
Make a Facebook app with these simple steps I have written below:
This is shorter and works
<connectionStrings>
<add name="DBConnection"
connectionString="data source=SERVER\INSTANCE;
Initial Catalog=MyDB;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
</connectionStrings>
Persist Security Info not needed
public class DA
{
public static class VersionNetFramework
{
public static string GetVersion()
{
return Environment.Version.ToString();
}
public static string GetVersionDicription()
{
int Major = Environment.Version.Major;
int Minor = Environment.Version.Minor;
int Build = Environment.Version.Build;
int Revision = Environment.Version.Revision;
//http://dzaebel.net/NetVersionen.htm
//http://stackoverflow.com/questions/12971881/how-to-reliably-detect-the-actual-net-4-5-version-installed
//4.0.30319.42000 = .NET 4.6 on Windows 8.1 64 - bit
if ((Major >=4) && (Minor >=0) && (Build >= 30319) && (Revision >= 42000))
return @".NET 4.6 on Windows 8.1 64 - bit or later";
//4.0.30319.34209 = .NET 4.5.2 on Windows 8.1 64 - bit
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 34209))
return @".NET 4.5.2 on Windows 8.1 64 - bit or later";
//4.0.30319.34209 = .NET 4.5.2 on Windows 7 SP1 64 - bit
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 34209))
return @".NET 4.5.2 on Windows 7 SP1 64 - bit or later";
//4.0.30319.34014 = .NET 4.5.1 on Windows 8.1 64 - bit
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 34014))
return @".NET 4.5.1 on Windows 8.1 64 - bit or later";
//4.0.30319.18444 = .NET 4.5.1 on Windows 7 SP1 64 - bit(with MS14 - 009 security update)
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 18444))
return @".NET 4.5.1 on Windows 7 SP1 64 - bit(with MS14 - 009 security update) or later";
//4.0.30319.18408 = .NET 4.5.1 on Windows 7 SP1 64 - bit
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 18408))
return @".NET 4.5.1 on Windows 7 SP1 64 - bit or later";
//4.0.30319.18063 = .NET 4.5 on Windows 7 SP1 64 - bit(with MS14 - 009 security update)
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 18063))
return @".NET 4.5 on Windows 7 SP1 64 - bit(with MS14 - 009 security update) or later";
//4.0.30319.18052 = .NET 4.5 on Windows 7 SP1 64 - bit
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 18052))
return @".NET 4.5 on Windows 7 SP1 64 - bit or later";
//4.0.30319.18010 = .NET 4.5 on Windows 8
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 18010))
return @".NET 4.5 on Windows 8 or later";
//4.0.30319.17929 = .NET 4.5 RTM
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 17929))
return @".NET 4.5 RTM or later";
//4.0.30319.17626 = .NET 4.5 RC
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 17626))
return @".NET 4.5 RC or later";
//4.0.30319.17020.NET 4.5 Preview, September 2011
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 17020))
return @".NET 4.5 Preview, September 2011 or later";
//4.0.30319.2034 = .NET 4.0 on Windows XP SP3, 7, 7 SP1(with MS14 - 009 LDR security update)
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 2034))
return @".NET 4.0 on Windows XP SP3, 7, 7 SP1(with MS14 - 009 LDR security update) or later";
//4.0.30319.1026 = .NET 4.0 on Windows XP SP3, 7, 7 SP1(with MS14 - 057 GDR security update)
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 1026))
return @".NET 4.0 on Windows XP SP3, 7, 7 SP1(with MS14 - 057 GDR security update) or later";
//4.0.30319.1022 = .NET 4.0 on Windows XP SP3, 7, 7 SP1(with MS14 - 009 GDR security update)
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 1022))
return @".NET 4.0 on Windows XP SP3, 7, 7 SP1(with MS14 - 009 GDR security update) or later";
//4.0.30319.1008 = .NET 4.0 on Windows XP SP3, 7, 7 SP1(with MS13 - 052 GDR security update)
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 1008))
return @".NET 4.0 on Windows XP SP3, 7, 7 SP1(with MS13 - 052 GDR security update) or later";
//4.0.30319.544 = .NET 4.0 on Windows XP SP3, 7, 7 SP1(with MS12 - 035 LDR security update)
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 544))
return @".NET 4.0 on Windows XP SP3, 7, 7 SP1(with MS12 - 035 LDR security update) or later";
//4.0.30319.447 yes built by: RTMLDR, .NET 4.0 Platform Update 1, April 2011
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 447))
return @"built by: RTMLDR, .NET 4.0 Platform Update 1, April 2011 or later";
//4.0.30319.431 yes built by: RTMLDR, .NET 4.0 GDR Update, March 2011 / with VS 2010 SP1 / or.NET 4.0 Update
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 431))
return @"built by: RTMLDR, .NET 4.0 GDR Update, March 2011 / with VS 2010 SP1 / or.NET 4.0 Update or later";
//4.0.30319.296 = .NET 4.0 on Windows XP SP3, 7(with MS12 - 074 GDR security update)
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 296))
return @".NET 4.0 on Windows XP SP3, 7(with MS12 - 074 GDR security update) or later";
//4.0.30319.276 = .NET 4.0 on Windows XP SP3 (4.0.3 Runtime update)
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 276))
return @".NET 4.0 on Windows XP SP3 (4.0.3 Runtime update) or later";
//4.0.30319.269 = .NET 4.0 on Windows XP SP3, 7, 7 SP1(with MS12 - 035 GDR security update)
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 269))
return @".NET 4.0 on Windows XP SP3, 7, 7 SP1(with MS12 - 035 GDR security update) or later";
//4.0.30319.1 yes built by: RTMRel, .NET 4.0 RTM Release, April 2010
if ((Major >= 4) && (Minor >= 0) && (Build >= 30319) && (Revision >= 1))
return @"built by: RTMRel, .NET 4.0 RTM Release, April 2010 or later";
//4.0.30128.1 built by: RC1Rel, .NET 4.0 Release Candidate, Feb 2010
if ((Major >=4) && (Minor >=0) && (Build >= 30128) && (Revision >= 1))
return @"built by: RC1Rel, .NET 4.0 Release Candidate, Feb 2010 or later";
//4.0.21006.1 built by: B2Rel, .NET 4.0 Beta2, Oct 2009
if ((Major >=4) && (Minor >=0) && (Build >= 21006) && (Revision >=1))
return @"built by: B2Rel, .NET 4.0 Beta2, Oct 2009 or later";
//4.0.20506.1 built by: Beta1, .NET 4.0 Beta1, May 2009
if ((Major >=4) && (Minor >=0) && (Build >= 20506) && (Revision >=1))
return @"built by: Beta1, .NET 4.0 Beta1, May 2009 or later";
//4.0.11001.1 built by: CTP2 VPC, .NET 4.0 CTP, October 2008
if ((Major >=4) && (Minor >=0) && (Build >= 11001) && (Revision >=1))
return @"built by: CTP2 VPC, .NET 4.0 CTP, October 2008 or later";
//3.5.30729.5420 yes built by: Win7SP1, .NET 3.5.1 Sicherheits - Update, 12 April 2011
if ((Major >=3) && (Minor >=5) && (Build >= 30729) && (Revision >= 5420))
return @"built by: Win7SP1, .NET 3.5.1 Sicherheits - Update, 12 April 2011 or later";
//3.5.30729.5004 yes built by: NetFXw7 / Windows 7..Rel., Jan 2010 / +Data functions KB976127 .NET 3.5 SP1
if ((Major >=3) && (Minor >=5) && (Build >= 30729) && (Revision >= 5004))
return @"built by: NetFXw7 / Windows 7..Rel., Jan 2010 / +Data functions KB976127 .NET 3.5 SP1 or later";
//3.5.30729.4466 yes built by: NetFXw7 / Windows XP..Rel. , Jan 2010 / +Data functions KB976127 .NET 3.5 SP1
if ((Major >=3) && (Minor >=5) && (Build >= 30729) && (Revision >= 4466))
return @"built by: NetFXw7 / Windows XP..Rel. , Jan 2010 / +Data functions KB976127 .NET 3.5 SP1 or later";
//3.5.30729.4926 yes built by: NetFXw7 / Windows 7 Release, Oct 2009 / .NET 3.5 SP1 + Hotfixes
if ((Major >=3) && (Minor >=5) && (Build >= 30729) && (Revision >= 4926))
return @"built by: NetFXw7 / Windows 7 Release, Oct 2009 / .NET 3.5 SP1 + Hotfixes or later";
//3.5.30729.4918 built by: NetFXw7 / Windows 7 Release Candidate, June 2009
if ((Major >=3) && (Minor >=5) && (Build >= 30729) && (Revision >= 4918))
return @"built by: NetFXw7 / Windows 7 Release Candidate, June 2009 or later";
//3.5.30729.196 yes built by: QFE, .NET 3.5 Family Update Vista / W2008, Dec 2008
if ((Major >= 3) && (Minor >= 5) && (Build >= 30729) && (Revision >=196))
return @"built by: QFE, .NET 3.5 Family Update Vista / W2008, Dec 2008 or later";
//3.5.30729.1 yes built by: SP, .NET 3.5 SP1, Aug 2008
if ((Major >= 3) && (Minor >= 5) && (Build >= 30729) && (Revision >=1))
return @"built by: SP, .NET 3.5 SP1, Aug 2008 or later";
//3.5.30428.1 built by: SP1Beta1, .NET 3.5 SP1 BETA1, May 2008
if ((Major >=3) && (Minor >=5) && (Build >= 30428) && (Revision >=1))
return @"built by: SP1Beta1, .NET 3.5 SP1 BETA1, May 2008 or later";
//3.5.21022.8 yes built by: RTM, Jan 2008
if ((Major >=3) && (Minor >=5) && (Build >= 21022) && (Revision >= 8))
return @"built by: RTM, Jan 2008 or later";
//3.5.20706.1 built by: Beta2, Orcas Beta2, Oct 2007
if ((Major >=3) && (Minor >=5) && (Build >= 20706) && (Revision >= 1))
return @"built by: Beta2, Orcas Beta2, Oct 2007 or later";
//3.5.20526.0 built by: MCritCTP, Orcas Beta1, Mar 2007
if ((Major >=3) && (Minor >=5) && (Build >= 20526) && (Revision >=0))
return @"built by: MCritCTP, Orcas Beta1, Mar 2007 or later";
//3.0.6920.1500 yes built by: QFE, Family Update Vista / W2008, Dez 2008, KB958483
if ((Major >=3) && (Minor >=0) && (Build >= 6920) && (Revision >= 1500))
return @"built by: QFE, Family Update Vista / W2008, Dez 2008, KB958483 or later";
//3.0.4506.4926 yes(NetFXw7.030729 - 4900) / Windows 7 Release, Oct 2009
if ((Major >=3) && (Minor >=0) && (Build >= 4506) && (Revision >= 4926))
return @"(NetFXw7.030729 - 4900) / Windows 7 Release, Oct 2009 or later";
//3.0.4506.4918(NetFXw7.030729 - 4900) / Windows 7 Release Candidate, June 2009
if ((Major >=3) && (Minor >=5) && (Build >= 4506) && (Revision >= 4918))
return @"(NetFXw7.030729 - 4900) / Windows 7 Release Candidate, June 2009 or later";
//3.0.4506.2152 3.0.4506.2152(SP.030729 - 0100) / .NET 4.0 Beta1 / May 2009
if ((Major >= 3) && (Minor >= 5) && (Build >= 4506) && (Revision >= 2152))
return @"3.0.4506.2152(SP.030729 - 0100) / .NET 4.0 Beta1 / May 2009 or later";
//3.0.4506.2123 yes(NetFX.030618 - 0000).NET 3.0 SP2, Aug 2008
if ((Major >= 3) && (Minor >= 5) && (Build >= 4506) && (Revision >= 2123))
return @"s(NetFX.030618 - 0000).NET 3.0 SP2, Aug 2008 or later";
//3.0.4506.2062(SP1Beta1.030428 - 0100), .NET 3.0 SP1 BETA1, May 2008
if ((Major >= 3) && (Minor >= 5) && (Build >= 4506) && (Revision >= 2062))
return @"(SP1Beta1.030428 - 0100), .NET 3.0 SP1 BETA1, May 2008 or later";
//3.0.4506.590(winfxredb2.004506 - 0590), Orcas Beta2, Oct 2007
if ((Major >= 3) && (Minor >= 5) && (Build >= 4506) && (Revision >= 590))
return @"(winfxredb2.004506 - 0590), Orcas Beta2, Oct 2007 or later";
//3.0.4506.577(winfxred.004506 - 0577), Orcas Beta1, Mar 2007
if ((Major >= 3) && (Minor >= 5) && (Build >= 4506) && (Revision >= 577))
return @"(winfxred.004506 - 0577), Orcas Beta1, Mar 2007 or later";
//3.0.4506.30 yes Release (.NET Framework 3.0) Nov 2006
if ((Major >= 3) && (Minor >= 5) && (Build >= 4506) && (Revision >= 30))
return @"Release (.NET Framework 3.0) Nov 2006 or later";
//3.0.4506.25 yes(WAPRTM.004506 - 0026) Vista Ultimate, Jan 2007
if ((Major >= 3) && (Minor >= 5) && (Build >= 4506) && (Revision >= 25))
return @"(WAPRTM.004506 - 0026) Vista Ultimate, Jan 2007 or later";
//2.0.50727.4927 yes(NetFXspW7.050727 - 4900) / Windows 7 Release, Oct 2009
if ((Major >=2) && (Minor >=0) && (Build >= 50727) && (Revision >= 4927))
return @"(NetFXspW7.050727 - 4900) / Windows 7 Release, Oct 2009 or later";
//2.0.50727.4918(NetFXspW7.050727 - 4900) / Windows 7 Release Candidate, June 2009
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 4918))
return @"(NetFXspW7.050727 - 4900) / Windows 7 Release Candidate, June 2009 or later";
//2.0.50727.4200 yes(NetFxQFE.050727 - 4200).NET 2.0 SP2, KB974470, Securityupdate, Oct 2009
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 4200))
return @"(NetFxQFE.050727 - 4200).NET 2.0 SP2, KB974470, Securityupdate, Oct 2009 or later";
//2.0.50727.3603(GDR.050727 - 3600).NET 4.0 Beta 2, Oct 2009
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 3603))
return @"(GDR.050727 - 3600).NET 4.0 Beta 2, Oct 2009 or later";
//2.0.50727.3082 yes(QFE.050727 - 3000), .NET 3.5 Family Update XP / W2003, Dez 2008, KB958481
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 3082))
return @"(QFE.050727 - 3000), .NET 3.5 Family Update XP / W2003, Dez 2008, KB958481 or later";
//2.0.50727.3074 yes(QFE.050727 - 3000), .NET 3.5 Family Update Vista / W2008, Dez 2008, KB958481
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 3074))
return @"(QFE.050727 - 3000), .NET 3.5 Family Update Vista / W2008, Dez 2008, KB958481 or later";
//2.0.50727.3053 yes(netfxsp.050727 - 3000), .NET 2.0 SP2, Aug 2008
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 3053))
return @"yes(netfxsp.050727 - 3000), .NET 2.0 SP2, Aug 2008 or later";
//2.0.50727.3031(netfxsp.050727 - 3000), .NET 2.0 SP2 Beta 1, May 2008
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 3031))
return @"(netfxsp.050727 - 3000), .NET 2.0 SP2 Beta 1, May 2008 or later";
//2.0.50727.1434 yes(REDBITS.050727 - 1400), Windows Server 2008 and Windows Vista SP1, Dez 2007
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 1434))
return @"(REDBITS.050727 - 1400), Windows Server 2008 and Windows Vista SP1, Dez 2007 or later";
//2.0.50727.1433 yes(REDBITS.050727 - 1400), .NET 2.0 SP1 Release, Nov 2007, http://www.microsoft.com/downloads/details.aspx?FamilyID=79bc3b77-e02c-4ad3-aacf-a7633f706ba5
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 1433))
return @"(REDBITS.050727 - 1400), .NET 2.0 SP1 Release, Nov 2007 or later";
//2.0.50727.1378(REDBITSB2.050727 - 1300), Orcas Beta2, Oct 2007
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 1378))
return @"(REDBITSB2.050727 - 1300), Orcas Beta2, Oct 2007 or later";
//2.0.50727.1366(REDBITS.050727 - 1300), Orcas Beta1, Mar 2007
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 1366))
return @"(REDBITS.050727 - 1300), Orcas Beta1, Mar 2007 or later";
//2.0.50727.867 yes(VS Express Edition 2005 SP1), Apr 2007, http://www.microsoft.com/downloads/details.aspx?FamilyId=7B0B0339-613A-46E6-AB4D-080D4D4A8C4E
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 867))
return @"(VS Express Edition 2005 SP1), Apr 2007 or later";
//2.0.50727.832(Fix x86 VC++2005), Apr 2007, http://support.microsoft.com/kb/934586/en-us
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 832))
return @"(Fix x86 VC++2005), Apr 2007 or later";
//2.0.50727.762 yes(VS TeamSuite SP1), http://www.microsoft.com/downloads/details.aspx?FamilyId=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 762))
return @"(VS TeamSuite SP1) or later";
//2.0.50727.312 yes(rtmLHS.050727 - 3100) Vista Ultimate, Jan 2007
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 312))
return @"(rtmLHS.050727 - 3100) Vista Ultimate, Jan 2007 or later";
//2.0.50727.42 yes Release (.NET Framework 2.0) Oct 2005
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 42))
return @"Release (.NET Framework 2.0) Oct 2005 or later";
//2.0.50727.26 Version 2.0(Visual Studio Team System 2005 Release Candidate) Oct 2005
if ((Major >= 2) && (Minor >= 0) && (Build >= 50727) && (Revision >= 26))
return @"Version 2.0(Visual Studio Team System 2005 Release Candidate) Oct 2005 or later";
//2.0.50712 Version 2.0(Visual Studio Team System 2005(Drop3) CTP) July 2005
if ((Major >=2) && (Minor >=0) && (Build >= 50712))
return @"Version 2.0(Visual Studio Team System 2005(Drop3) CTP) July 2005 or later";
//2.0.50215 Version 2.0(WinFX SDK for Indigo / Avalon 2005 CTP) July 2005
if ((Major >=2) && (Minor >=0) && (Build >= 50215))
return @"Version 2.0(WinFX SDK for Indigo / Avalon 2005 CTP) July 2005 or later";
//2.0.50601.0 Version 2.0(Visual Studio.NET 2005 CTP) June 2005
if ((Major >=2) && (Minor >=0) && (Build >= 50601) && (Revision >=0))
return @"Version 2.0(Visual Studio.NET 2005 CTP) June 2005 or later";
//2.0.50215.44 Version 2.0(Visual Studio.NET 2005 Beta 2, Visual Studio Express Beta 2) Apr 2005
if ((Major >=2) && (Minor >=0) && (Build >= 50215) && (Revision >= 44))
return @"Version 2.0(Visual Studio.NET 2005 Beta 2, Visual Studio Express Beta 2) Apr 2005 or later";
//2.0.50110.28 Version 2.0(Visual Studio.NET 2005 CTP, Professional Edition) Feb 2005
if ((Major >=2) && (Minor >=0) && (Build >= 50110) && (Revision >=28))
return @"Version 2.0(Visual Studio.NET 2005 CTP, Professional Edition) Feb 2005 or later";
//2.0.41115.19 Version 2.0(Visual Studio.NET 2005 Beta 1, Team System Refresh) Dec 2004
if ((Major >=2 ) && (Minor >=0 ) && (Build >= 41115) && (Revision >= 19))
return @"Version 2.0(Visual Studio.NET 2005 Beta 1, Team System Refresh) Dec 2004 or later";
//2.0.40903.0 Version 2.0(Whidbey CTP, Visual Studio Express) Oct 2004
if ((Major >=2) && (Minor >=0) && (Build >= 40903) && (Revision >=0))
return @"Version 2.0(Whidbey CTP, Visual Studio Express) Oct 2004 or later";
//2.0.40607.85 Version 2.0(Visual Studio.NET 2005 Beta 1, Team System Refresh) Aug 2004 *
if ((Major >=2) && (Minor >=0) && (Build >= 40607) && (Revision >= 85))
return @"Version 2.0(Visual Studio.NET 2005 Beta 1, Team System Refresh) Aug 2004 * or later";
//2.0.40607.42 Version 2.0(SQL Server Yukon Beta 2) July 2004
if ((Major >=2) && (Minor >=0) && (Build >= 40607) && (Revision >= 42))
return @"Version 2.0(SQL Server Yukon Beta 2) July 2004 or later";
//2.0.40607.16 Version 2.0(Visual Studio.NET 2005 Beta 1, TechEd Europe 2004) June 2004
if ((Major >=2) && (Minor >=0) && (Build >= 40607) && (Revision >= 16))
return @"Version 2.0(Visual Studio.NET 2005 Beta 1, TechEd Europe 2004) June 2004 or later";
//2.0.40301.9 Version 2.0(Whidbey CTP, WinHEC 2004) March 2004 *
if ((Major >=0) && (Minor >=0) && (Build >= 40301) && (Revision >=9))
return @"Version 2.0(Whidbey CTP, WinHEC 2004) March 2004 * or later";
//1.2.30703.27 Version 1.2(Whidbey Alpha, PDC 2004) Nov 2003 *
if ((Major >=1) && (Minor >=2) && (Build >= 30703) && (Revision >= 27))
return @"Version 1.2(Whidbey Alpha, PDC 2004) Nov 2003 * or later";
//1.2.21213.1 Version 1.2(Whidbey pre - Alpha build) *
if ((Major >=1) && (Minor >=2) && (Build >= 21213) && (Revision >=1))
return @"Version 1.2(Whidbey pre - Alpha build) * or later";
//1.1.4322.2443 yes Version 1.1 Servicepack 1, KB953297, Oct 2009
if ((Major >=1) && (Minor >=1) && (Build >= 4322) && (Revision >=2443))
return @"Version 1.1 Servicepack 1, KB953297, Oct 2009 or later";
//1.1.4322.2407 yes Version 1.1 RTM
if ((Major >=1) && (Minor >=1) && (Build >= 4322) && (Revision >= 2407))
return @"Version 1.1 RTM or later";
//1.1.4322.2407 Version 1.1 Orcas Beta2, Oct 2007
if ((Major >=1) && (Minor >=1) && (Build >= 4322) && (Revision >= 2407))
return @"Version 1.1 Orcas Beta2, Oct 2007 or later";
//1.1.4322.2379 Version 1.1 Orcas Beta1, Mar 2007
if ((Major >=1) && (Minor >=1) && (Build >= 4322) && (Revision >= 2379))
return @"Version 1.1 Orcas Beta1, Mar 2007 or later";
//1.1.4322.2032 yes Version 1.1 SP1 Aug 2004
if ((Major >=1) && (Minor >=1) && (Build >= 4322) && (Revision >= 2032))
return @"Version 1.1 SP1 Aug 2004 or later";
//1.1.4322.573 yes Version 1.1 RTM(Visual Studio.NET 2003 / Windows Server 2003) Feb 2003 *
if ((Major >=1) && (Minor >=1) && (Build >= 4322) && (Revision >= 573))
return @"Version 1.1 RTM(Visual Studio.NET 2003 / Windows Server 2003) Feb 2003 * or later";
//1.1.4322.510 Version 1.1 Final Beta Oct 2002 *
if ((Major >=1) && (Minor >=1) && (Build >= 4322) && (Revision >= 510))
return @"Version 1.1 Final Beta Oct 2002 * or later";
//1.0.3705.6018 yes Version 1.0 SP3 Aug 2004
if ((Major >=1) && (Minor >=0) && (Build >= 3705) && (Revision >= 6018))
return @"Version 1.0 SP3 Aug 2004 or later";
//1.0.3705.288 yes Version 1.0 SP2 Aug 2002 *
if ((Major >=1) && (Minor >=0) && (Build >= 3705) && (Revision >= 288))
return @"Version 1.0 SP2 Aug 2002 * or later";
//1.0.3705.209 yes Version 1.0 SP1 Mar 2002 *
if ((Major >=1) && (Minor >=0) && (Build >= 3705) && (Revision >=209))
return @"Version 1.0 SP1 Mar 2002 * or later";
//1.0.3705.0 yes Version 1.0 RTM(Visual Studio.NET 2002) Feb 2002 *
if ((Major >=1) && (Minor >=0) && (Build >= 3705) && (Revision >=0))
return @"Version 1.0 RTM(Visual Studio.NET 2002) Feb 2002 * or later";
//1.0.3512.0 Version 1.0 Pre - release RC3(Visual Studio.NET 2002 RC3)
if ((Major >=1) && (Minor >=0) && (Build >= 3512) && (Revision >=0))
return @"Version 1.0 Pre - release RC3(Visual Studio.NET 2002 RC3) or later";
//1.0.2914.16 Version 1.0 Public Beta 2 Jun 2001 *
if ((Major >=1) && (Minor >=0) && (Build >= 2914) && (Revision >= 16))
return @"Version 1.0 Public Beta 2 Jun 2001 * or later";
//1.0.2204.21 Version 1.0 Public Beta 1 Nov 2000 *
if ((Major >=1) && (Minor >=0) && (Build >= 2204) && (Revision >=21))
return @"Version 1.0 Public Beta 1 Nov 2000 * or later";
return @"Unknown .NET version";
}
}
}
You can send the file and data over in one request using the multipart/form-data content type:
In many applications, it is possible for a user to be presented with a form. The user will fill out the form, including information that is typed, generated by user input, or included from files that the user has selected. When the form is filled out, the data from the form is sent from the user to the receiving application.
The definition of MultiPart/Form-Data is derived from one of those applications...
From http://www.faqs.org/rfcs/rfc2388.html:
"multipart/form-data" contains a series of parts. Each part is expected to contain a content-disposition header [RFC 2183] where the disposition type is "form-data", and where the disposition contains an (additional) parameter of "name", where the value of that parameter is the original field name in the form. For example, a part might contain a header:
Content-Disposition: form-data; name="user"
with the value corresponding to the entry of the "user" field.
You can include file information or field information within each section between boundaries. I've successfully implemented a RESTful service that required the user to submit both data and a form, and multipart/form-data worked perfectly. The service was built using Java/Spring, and the client was using C#, so unfortunately I don't have any Grails examples to give you concerning how to set up the service. You don't need to use JSON in this case since each "form-data" section provides you a place to specify the name of the parameter and its value.
The good thing about using multipart/form-data is that you're using HTTP-defined headers, so you're sticking with the REST philosophy of using existing HTTP tools to create your service.
Highlight the cells, format cells, select Custom then select zero.
NaN
means “Not a Number” and is basically a representation of a special floating point value in the IEE 754 floating point standard. NaN generally means that the value is something that cannot be expressed with a valid floating point number.
A conversion will result in this value, when the value being converted is something else, for example when converting a string that does not represent a number.
I'd rather like to answer comprehensively.
LocalbroadcastManager included in android 3.0 and above so you have to use support library v4 for early releases. see instructions here
Create a broadcast receiver:
private BroadcastReceiver onNotice= new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// intent can contain anydata
Log.d("sohail","onReceive called");
tv.setText("Broadcast received !");
}
};
Register your receiver in onResume of activity like:
protected void onResume() {
super.onResume();
IntentFilter iff= new IntentFilter(MyIntentService.ACTION);
LocalBroadcastManager.getInstance(this).registerReceiver(onNotice, iff);
}
//MyIntentService.ACTION is just a public static string defined in MyIntentService.
unRegister receiver in onPause:
protected void onPause() {
super.onPause();
LocalBroadcastManager.getInstance(this).unregisterReceiver(onNotice);
}
Now whenever a localbroadcast is sent from applications' activity or service, onReceive of onNotice will be called :).
Edit: You can read complete tutorial here LocalBroadcastManager: Intra application message passing
Assuming you actually mean timestamp
because there is no datetime
in Postgres
Cast the timestamp column to a date, that will remove the time part:
select *
from the_table
where the_timestamp_column::date = date '2015-07-15';
This will return all rows from July, 15th.
Note that the above will not use an index on the_timestamp_column
. If performance is critical, you need to either create an index on that expression or use a range condition:
select *
from the_table
where the_timestamp_column >= timestamp '2015-07-15 00:00:00'
and the_timestamp_column < timestamp '2015-07-16 00:00:00';
It means there's no default document in that directory (index.html, index.php, etc...). On most webservers, that would mean it would show a listing of the directory's contents. But showing that directory is forbidden by server configuration (Options -Indexes
)
You can aliasing both query and Selecting them in the select query
http://sqlfiddle.com/#!2/ca27b/1
SELECT x.a, y.b FROM (SELECT * from a) as x, (SELECT * FROM b) as y
No you are not required to close anything BUT the connection. Per JDBC specs closing any higher object will automatically close lower objects. Closing Connection
will close any Statement
s that connection has created. Closing any Statement
will close all ResultSet
s that were created by that Statement
. Doesn't matter if Connection
is poolable or not. Even poolable connection has to clean before returning to the pool.
Of course you might have long nested loops on the Connection
creating lots of statements, then closing them is appropriate. I almost never close ResultSet
though, seems excessive when closing Statement
or Connection
WILL close them.
Use JQuery keydown event.
$(document).keypress(function(){
if(event.which == 70){ //f
console.log("You have payed respect");
}
});
In JS; keyboard keys are identified by Javascript keycodes
C++ doesn't have introspection, so you can't determine this kind of thing at run-time.
Tomcat 8.5. Inside catalina.properties, located in the /conf directory set:
tomcat.util.scan.StandardJarScanFilter.jarsToSkip=\*.jar
Or go into context.xml, located in Tomcat's /conf directory and add:
<JarScanner scanClassPath="false"/>
To remove all columns after the one you want, below code should work. It will remove at index 10 (remember Columns are 0 based), until the Column count is 10 or less.
DataTable dt;
int desiredSize = 10;
while (dt.Columns.Count > desiredSize)
{
dt.Columns.RemoveAt(desiredSize);
}
It's not a cut and paste. The CASE
expression must return a value, and you are returning a string containing SQL (which is technically a value but of a wrong type). This is what you wanted to write, I think:
SELECT * FROM [Purchasing].[Vendor] WHERE
CASE
WHEN @url IS null OR @url = '' OR @url = 'ALL'
THEN PurchasingWebServiceURL LIKE '%'
WHEN @url = 'blank'
THEN PurchasingWebServiceURL = ''
WHEN @url = 'fail'
THEN PurchasingWebServiceURL NOT LIKE '%treyresearch%'
ELSE PurchasingWebServiceURL = '%' + @url + '%'
END
I also suspect that this might not work in some dialects, but can't test now (Oracle, I'm looking at you), due to not having booleans.
However, since @url
is not dependent on the table values, why not make three different queries, and choose which to evaluate based on your parameter?
the event property seems to be string first you have to parse it to json :
var req = { mandrill_events: '[{"event":"inbound","ts":1426249238}]' };
var event = JSON.parse(req.mandrill_events);
var ts = event[0].ts
As the question is Chrome-specific, you can get the Postman extension which allows you to set the request content type.
//To clear When Clear Button is Clicked
firstName = (EditText) findViewById(R.id.firstName);
clear = (Button) findViewById(R.id.clearsearchSubmit);
clear.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (v.getId() == R.id.clearsearchSubmit);
firstName.setText("");
}
});
This will help to clear the wrong keywords that you have typed in so instead of pressing backspace again and again you can simply click the button to clear everything.It Worked For me. Hope It Helps
Just for completeness, here is a recursive version that would allow tail call optimization. I'm not sure if tail call optimizations are performed in JavaScript though..
function rFact(n, acc)
{
if (n == 0 || n == 1) return acc;
else return rFact(n-1, acc*n);
}
To call it:
rFact(x, 1);
To answer the question more generally, the answer is:
select: function( event , ui ) {
alert( "You selected: " + ui.item.label );
}
Complete example :
$('#test').each(function(i, el) {_x000D_
var that = $(el);_x000D_
that.autocomplete({_x000D_
source: ['apple','banana','orange'],_x000D_
select: function( event , ui ) {_x000D_
alert( "You selected: " + ui.item.label );_x000D_
}_x000D_
});_x000D_
});
_x000D_
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>_x000D_
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />_x000D_
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>_x000D_
_x000D_
Type a fruit here: <input type="text" id="test" />
_x000D_
For anyone looking for how to do it programmatically:
Drawable bckgrndDr = new ColorDrawable(Color.RED);
Drawable secProgressDr = new ColorDrawable(Color.GRAY);
Drawable progressDr = new ScaleDrawable(new ColorDrawable(Color.BLUE), Gravity.LEFT, 1, -1);
LayerDrawable resultDr = new LayerDrawable(new Drawable[] { bckgrndDr, secProgressDr, progressDr });
//setting ids is important
resultDr.setId(0, android.R.id.background);
resultDr.setId(1, android.R.id.secondaryProgress);
resultDr.setId(2, android.R.id.progress);
Setting ids to drawables is crucial, and takes care of preserving bounds and actual state of progress bar
Even though this solution might seem obvious, I just wanted to post it here so the next guy will google it faster.
If you still want to have the model as a parameter in the method, you can create a DelegatingHandler
to buffer the content.
internal sealed class BufferizingHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
await request.Content.LoadIntoBufferAsync();
var result = await base.SendAsync(request, cancellationToken);
return result;
}
}
And add it to the global message handlers:
configuration.MessageHandlers.Add(new BufferizingHandler());
This solution is based on the answer by Darrel Miller.
This way all the requests will be buffered.
Not recommended to allow all domains for http. Make an exception for just the necessary domains.
Source: Configuring App Transport Security Exceptions in iOS 9 and OSX 10.11
Add the following to the info.plist file of your app:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
I made a mix of the answers here, took the code of @Julian and ideas from the others, seems clearer to me, this is what's left:
//store the element
var $cache = $('.my-sticky-element');
//store the initial position of the element
var vTop = $cache.offset().top - parseFloat($cache.css('marginTop').replace(/auto/, 0));
$(window).scroll(function (event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// whether that's below the form
if (y >= vTop) {
// if so, ad the fixed class
$cache.addClass('stuck');
} else {
// otherwise remove it
$cache.removeClass('stuck');
}
});
.my-sticky-element.stuck {
position:fixed;
top:0;
box-shadow:0 2px 4px rgba(0, 0, 0, .3);
}
(?:vnc|s3|ssh|scp|sftp|ftp|http|https)\:\/\/[\w\.]+(?:\:?\d{0,5})|(?:mailto|)\:[\w\.]+\@[\w\.]+
If you want an explanation of each part, try in regexr[.]com where you will get a great explanation of every character.
This is split by an "|" or "OR" because not all useable URI have "//" so this is where you can create a list of schemes as or conditions that you would be interested in matching.
I believe that join()
is just a convenience method. Try df1.merge(df2)
instead, which allows you to specify left_on
and right_on
:
In [30]: left.merge(right, left_on="key1", right_on="key2")
Out[30]:
key1 lval key2 rval
0 foo 1 foo 4
1 bar 2 bar 5
var outputString = String.Join("", inputString.Where(Char.IsDigit));
Get all numbers in the string. So if you use for examaple '1 plus 2' it will get '12'.
You could use dplyr::filter()
and negate a grepl()
match:
library(dplyr)
df %>%
filter(!grepl('REVERSE', Name))
Or with dplyr::filter()
and negating a stringr::str_detect()
match:
library(stringr)
df %>%
filter(!str_detect(Name, 'REVERSE'))
A different approach:
The vrapper plugin emulates vim
inside the Eclipse editor. One of its features is visual block
mode which works fine inside Eclipse.
It is by default mapped to Ctrl-V
which interferes with the paste command in Eclipse. You can either remap the visual block
mode to a different shortcut, or remap the paste
command to a different key. I chose the latter: remapped the paste
command to Ctrl-Shift-V
to match my terminal's behavior.
You use an anchor and a hash. For example:
Target of the Link:
<a name="name_of_target">Content</a>
Link to the Target:
<a href="#name_of_target">Link Text</a>
Or, if linking from a different page:
<a href="http://path/to/page/#name_of_target">Link Text</a>
Hmmm ... the closest I saw to a convenient answer was using the command line to try the import. But I prefer to even avoid that.
How about 'pip freeze | grep pkgname'? I tried it and it works well. It also shows you the version it has and whether it is installed under version control (install) or editable (develop).
Try to use setStyle() in onCreate and override onCreateDialog make dialog without title
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
return dialog;
}
or just override onCreate() and setStyle fellow the code.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme);
}
You don't set value to default in a table. You should clear the option "Default value or Binding" first.
<TouchableHighlight>
element can have only one child inside Difference between pass and continue in a for loop:
So why pass in python?
If you want to create a empty class, method or block.
Examples:
class MyException(Exception):
pass
try:
1/0
except:
pass
without 'pass' in the above examples will throw IndentationError.
use this code
//print the vector element in reverse order by normal iterator.
cout <<"print the vector element in reverse order by normal iterator." <<endl;
vector<string>::iterator iter=vec.end();
--iter;
while (iter != vec.begin())
{
cout << *iter << " ";
--iter;
}
With jQuery 1.6 version you can use the .promise()
method.
$(selector).fadeOut('slow');
$(selector).promise().done(function(){
// will be called when all the animations on the queue finish
});
You should be aware of the fact that your original attempt
int count = map.containsKey(word) ? map.get(word) : 0;
contains two potentially expensive operations on a map, namely containsKey
and get
. The former performs an operation potentially pretty similar to the latter, so you're doing the same work twice!
If you look at the API for Map, get
operations usually return null
when the map does not contain the requested element.
Note that this will make a solution like
map.put( key, map.get(key) + 1 );
dangerous, since it might yield NullPointerException
s. You should check for a null
first.
Also note, and this is very important, that HashMap
s can contain nulls
by definition. So not every returned null
says "there is no such element". In this respect, containsKey
behaves differently from get
in actually telling you whether there is such an element. Refer to the API for details.
For your case, however, you might not want to distinguish between a stored null
and "noSuchElement". If you don't want to permit null
s you might prefer a Hashtable
. Using a wrapper library as was already proposed in other answers might be a better solution to manual treatment, depending on the complexity of your application.
To complete the answer (and I forgot to put that in at first, thanks to the edit function!), the best way of doing it natively, is to get
into a final
variable, check for null
and put
it back in with a 1
. The variable should be final
because it's immutable anyway. The compiler might not need this hint, but its clearer that way.
final HashMap map = generateRandomHashMap(); final Object key = fetchSomeKey(); final Integer i = map.get(key); if (i != null) { map.put(i + 1); } else { // do something }
If you do not want to rely on autoboxing, you should say something like map.put(new Integer(1 + i.getValue()));
instead.
As Seth stated thread safe means that a method or class instance can be used by multiple threads at the same time without any problems occuring.
Consider the following method:
private int myInt = 0;
public int AddOne()
{
int tmp = myInt;
tmp = tmp + 1;
myInt = tmp;
return tmp;
}
Now thread A
and thread B
both would like to execute AddOne()
. but A
starts first and reads the value of myInt (0)
into tmp
. Now for some reason the scheduler decides to halt thread A
and defer execution to thread B
. Thread B
now also reads the value of myInt
(still 0
) into it's own variable tmp
. Thread B
finishes the entire method, so in the end myInt = 1
. And 1
is returned. Now it's Thread A
's turn again. Thread A
continues. And adds 1
to tmp
(tmp
was 0
for thread A
). And then saves this value in myInt
. myInt
is again 1
.
So in this case the method AddOne()
was called two times, but because the method was not implemented in a thread safe way the value of myInt
is not 2
, as expected, but 1
because the second thread read the variable myInt
before the first thread finished updating it.
Creating thread safe methods is very hard in non trivial cases. And there are quite a few techniques. In Java you can mark a method as synchronized, this means that only one thread can execute that method at a given time. The other threads wait in line. This makes a method thread safe, but if there is a lot of work to be done in a method, then this wastes a lot of time. Another technique is to 'mark only a small part of a method as synchronized' by creating a lock or semaphore, and locking this small part (usually called the critical section). There are even some methods that are implemented as lockless thread safe, which means that they are built in such a way that multiple threads can race through them at the same time without ever causing problems, this can be the case when a method only executes one atomic call. Atomic calls are calls that can't be interrupted and can only be done by one thread at a time.
Sending Authorization header is not possible.
Attaching a token query parameter is an option. However, in some circumstances, it may be undesirable to send your main login token in plain text as a query parameter because it is more opaque than using a header and will end up being logged whoknowswhere. If this raises security concerns for you, an alternative is to use a secondary JWT token just for the web socket stuff.
Create a REST endpoint for generating this JWT, which can of course only be accessed by users authenticated with your primary login token (transmitted via header). The web socket JWT can be configured differently than your login token, e.g. with a shorter timeout, so it's safer to send around as query param of your upgrade request.
Create a separate JwtAuthHandler for the same route you register the SockJS eventbusHandler on. Make sure your auth handler is registered first, so you can check the web socket token against your database (the JWT should be somehow linked to your user in the backend).
Okay, with a little HTML in your R code, I did the following code to generate pure text in R Markdown. The <h3 style="text-indent: 15em;">
indents the text 15 spaces. For the original question, change the 15 to 6.
## Option: Du Pont Ratio Concept - (ROE Decomposition)
### (Closed Quotes/Total Premium) = (Closed Quotes/Quotes Issued) X <br>
<h3 style="text-indent: 15em;">
(Quotes Issued/Renewal Premium) X <br></h3>
<h3 style="text-indent: 15em;">
(Renewal Premium/Total Premium)</h3>
So the resulting code gives my desired output format. I am using tabs for the Markdown document and was looking to line up the () text which worked.
GridLinked posted a PubSub solution which seems to be designed pretty well. The service can be found, here.
Also a diagram of their service:
You can just do it in your Activity's onCreate() method. For example:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Assign the button to a variable
Button button1 = (Button)findViewById(R.id.button1);
//Assign the ImageView to a final variable, so that it's
//accessible from an inner class
ImageView imageView = (ImageView)findViewById(R.id.imageview1);
//Assign it a new OnClickListener
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
imageView.setVisibility(View.VISIBLE);
}
}
}
I also had this problem when doing migration => after performing php artisan migrate:refresh --seed command
"Base table or view not found: 1146 Table posts do not exist" and I solved it, I was using "soft deletes" in a separate migration file, and my original migration for "posts" table which was responsible for creating the "posts" table was performing after the "soft deletes" migration in the database\migration folder, I simply needed to rename the "posts" migration file name and put it before "softdeletes" migration to perform sooner. the do the migration again => php artisan migrate:refresh --seed it's done.
It can be achieved using JS. Here is a 'one-line' solution using elastic.js:
$('#note').elastic();
Updated: Seems like elastic.js is not there anymore, but if you are looking for an external library, I can recommend autosize.js by Jack Moore. This is the working example:
autosize(document.getElementById("note"));
_x000D_
textarea#note {_x000D_
width:100%;_x000D_
box-sizing:border-box;_x000D_
direction:rtl;_x000D_
display:block;_x000D_
max-width:100%;_x000D_
line-height:1.5;_x000D_
padding:15px 15px 30px;_x000D_
border-radius:3px;_x000D_
border:1px solid #F7E98D;_x000D_
font:13px Tahoma, cursive;_x000D_
transition:box-shadow 0.5s ease;_x000D_
box-shadow:0 4px 6px rgba(0,0,0,0.1);_x000D_
font-smoothing:subpixel-antialiased;_x000D_
background:linear-gradient(#F9EFAF, #F7E98D);_x000D_
background:-o-linear-gradient(#F9EFAF, #F7E98D);_x000D_
background:-ms-linear-gradient(#F9EFAF, #F7E98D);_x000D_
background:-moz-linear-gradient(#F9EFAF, #F7E98D);_x000D_
background:-webkit-linear-gradient(#F9EFAF, #F7E98D);_x000D_
}
_x000D_
<script src="https://rawgit.com/jackmoore/autosize/master/dist/autosize.min.js"></script>_x000D_
<textarea id="note">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</textarea>
_x000D_
Check this similar topics too:
Autosizing textarea using Prototype
SQL injection should not be prevented by trying to validate your input; instead, that input should be properly escaped before being passed to the database.
How to escape input totally depends on what technology you are using to interface with the database. In most cases and unless you are writing bare SQL (which you should avoid as hard as you can) it will be taken care of automatically by the framework so you get bulletproof protection for free.
You should explore this question further after you have decided exactly what your interfacing technology will be.
Yes, the Jackson manual parser design is quite different from other libraries. In particular, you will notice that JsonNode
has most of the functions that you would typically associate with array nodes from other API's. As such, you do not need to cast to an ArrayNode
to use. Here's an example:
JSON:
{
"objects" : ["One", "Two", "Three"]
}
Code:
final String json = "{\"objects\" : [\"One\", \"Two\", \"Three\"]}";
final JsonNode arrNode = new ObjectMapper().readTree(json).get("objects");
if (arrNode.isArray()) {
for (final JsonNode objNode : arrNode) {
System.out.println(objNode);
}
}
Output:
"One"
"Two"
"Three"
Note the use of isArray
to verify that the node is actually an array before iterating. The check is not necessary if you are absolutely confident in your datas structure, but its available should you need it (and this is no different from most other JSON libraries).
Maybe it's not 'programmer' approach, but if you want save your time and get working solution instant try one of the apps which are dedicated to mock location available in Google Play:
Take a look here: http://longgoldenears.blogspot.com/2007/09/triple-equals-in-javascript.html
The 3 equal signs mean "equality without type coercion". Using the triple equals, the values must be equal in type as well.
0 == false // true
0 === false // false, because they are of a different type
1 == "1" // true, automatic type conversion for value only
1 === "1" // false, because they are of a different type
null == undefined // true
null === undefined // false
'0' == false // true
'0' === false // false
Create new Maven file with path as classpath and goal as class name
To keep the branching clean, you could do this:
git checkout newbranch
git branch newbranch2
git reset --hard <commit Id> # the commit at which you want to merge
git checkout master
git merge newbranch
git checkout newbranch2
This way, newbranch will end where it was merged into master, and you continue working on newbranch2.
The pythonic way to track state during iteration is with generators. The itertools way is quite hard to understand IMHO and trying to hack lambdas to do this is plain silly. I'd try:
def keep_last_empty(input):
last = None
for item in iter(input):
if item.name: yield item
else: last = item
if last is not None: yield last
output = list(keep_last_empty(input))
Overall, readability trumps compactness every time.
aapt dump badging <path-to-apk> | grep package:\ name
from Google
An .axd file is a HTTP Handler file. There are two types of .axd files.
These are files which are generated at runtime whenever you use ScriptManager in your Web app. This is being generated only once when you deploy it on the server.
Simply put the ScriptResource.AXD contains all of the clientside javascript routines for Ajax. Just because you include a scriptmanager that loads a script file it will never appear as a ScriptResource.AXD - instead it will be merely passed as the .js file you send if you reference a external script file. If you embed it in code then it may merely appear as part of the html as a tag and code but depending if you code according to how the ToolKit handles it - may or may not appear as as a ScriptResource.axd. ScriptResource.axd is only introduced with AJAX and you will never see it elsewhere
And ofcourse it is necessary
You can do it directly from eclipse using the Navigator view (Window -> Show View -> Navigator). In the Navigator view select the project and open it so that you can see the file .project
. Right click -> Open. You will get a XML editor view. Edit the content of the node natures
and insert a new child nature
with org.eclipse.jdt.core.javanature
as content. Save.
Now create a file .classpath
, it will open in the XML editor. Add a node named classpath
, add a child named classpathentry
with the attributes kind
with content con
and another one named path
and content org.eclipse.jdt.launching.JRE_CONTAINER
. Save-
Much easier: copy the files .project
and .classpath
from an existing Java project and edit the node result name
to the name of this project. Maybe you have to refresh the project (F5).
You'll get the same result as with the solution of Chris Marasti-Georg.
Well, it's clearly not a number since it has dashes in it. The error message and the two comments tell you that it is a factor but the commentators are apparently waiting and letting the message sink in. Dirk is suggesting that you do this:
EPL2011_12$Date2 <- as.Date( as.character(EPL2011_12$Date), "%d-%m-%y")
After that you can do this:
EPL2011_12FirstHalf <- subset(EPL2011_12, Date2 > as.Date("2012-01-13") )
R date functions assume the format is either "YYYY-MM-DD" or "YYYY/MM/DD". You do need to compare like classes: date to date, or character to character.
You can also throw an exception:
For the sake of readability each step of stream should be listed in new line.
players.stream()
.filter(player -> player.getName().contains(name))
.findFirst()
.orElseThrow(MyCustomRuntimeException::new);
if your logic is loosely "exception driven" such as there is one place in your code that catches all exceptions and decides what to do next. Only use exception driven development when you can avoid littering your code base with multiples try-catch
and throwing these exceptions are for very special cases that you expect them and can be handled properly.)
Very hard when you have to do this with three select statments
I tried all proposed techniques up there but it's in-vain
Please see below script. please advice if you have alternative solution
select distinct x.best_Achiver_ever,y.Today_best_Achiver ,z.Most_Violator from
(SELECT Top(4) ROW_NUMBER() over (order by tl.username) AS conj, tl.
[username] + '-->' + str(count(*)) as best_Achiver_ever
FROM[TiketFollowup].[dbo].N_FCR_Tikect_Log_Archive tl
group by tl.username
order by count(*) desc) x
left outer join
(SELECT
Top(4) ROW_NUMBER() over (order by tl.username) as conj, tl.[username] + '-->' + str(count(*)) as Today_best_Achiver
FROM[TiketFollowup].[dbo].[N_FCR_Tikect_Log] tl
where convert(date, tl.stamp, 121) = convert(date,GETDATE(),121)
group by tl.username
order by count(*) desc) y
on x.conj=y.conj
left outer join
(
select ROW_NUMBER() over (order by count(*)) as conj,username+ '--> ' + str( count(dbo.IsViolated(stamp))) as Most_Violator from N_FCR_Ticket
where dbo.IsViolated(stamp) = 'violated' and convert(date,stamp, 121) < convert(date,GETDATE(),121)
group by username
order by count(*) desc) z
on x.conj = z.conj
You had thead
in your selector, but there is no thead
in your table. Also you had your selectors backwards. As you mentioned above, you wanted to be adding the tr
class to the th
, not vice-versa (although your comment seems to contradict what you wrote up above).
$('tr th').each(function(index){ if($('tr td').eq(index).attr('class') != ''){ // get the class of the td var tdClass = $('tr td').eq(index).attr('class'); // add it to this th $(this).addClass(tdClass ); } });
On MAC High Sierra (10.13.6)
cd /Users/vkrishna/.sqldeveloper/18.2.0
nano product.conf
on the last line add
AddVMOption -Duser.language=en
Save the file and restart.
=======================================
If you are using standalone Oracle Data Modeller
find ~/ -name "datamodeler.conf"
and edit this file
cd /Users/vkrishna//Desktop/OracleDataModeler-18.2.0.179.0756.app/Contents/Resources/datamodeler/datamodeler/bin/
Add somewhere in the last
AddVMOption -Duser.language=en
save and restart, done!
May be it's too late. Your code is correct so please check again your url in filebrowserUploadUrl
CKEDITOR.replace( 'editor1', {
filebrowserUploadUrl: "upload/upload.php"
} );
And the Upload.php file
if (file_exists("images/" . $_FILES["upload"]["name"]))
{
echo $_FILES["upload"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["upload"]["tmp_name"],
"images/" . $_FILES["upload"]["name"]);
echo "Stored in: " . "images/" . $_FILES["upload"]["name"];
}
for example when you call a function that returns Generic Collections and you don't specify the generic parameters yourself.
for a function
List<String> getNames()
List names = obj.getNames();
will generate this error.
To solve it you would just add the parameters
List<String> names = obj.getNames();
get in $SPARK_HOME/conf
, then open file spark-env.sh
and add:
SPARK_MASTER_HOST= your-IP
SPARK_LOCAL_IP=127.0.0.1
There could be a very big misunderstanding related to string in the database are. Almost everyone has thought that database representation of numbers are more compact than for strings. They think that in db-s numbers are represented as in the memory. BUT it is not true. In most cases number representation is more close to A string like representation as to other.
The speed of using number or string is more dependent on the indexing then the type itself.
You can just set it to a class variable and read it from the main program:
class Foo:
def __init__(self):
#Do your stuff here
self.returncode = 42
bar = Foo()
baz = bar.returncode
check http://jsfiddle.net/Z22NU/12/
function fnselect(){
alert($("tr.selected td:first" ).html());
}
on delete button click event
public void delete(View v){
ListView listview1;
ArrayList<E> datalist;
final int position = listview1.getPositionForView((View) v.getParent());
datalist.remove(position);
myAdapter.notifyDataSetChanged();
}
In your servlet context listener contextDestroyed() method, manually deregister the drivers:
// This manually deregisters JDBC driver, which prevents Tomcat 7 from complaining about memory leaks wrto this class
Enumeration<Driver> drivers = DriverManager.getDrivers();
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
try {
DriverManager.deregisterDriver(driver);
LOG.log(Level.INFO, String.format("deregistering jdbc driver: %s", driver));
} catch (SQLException e) {
LOG.log(Level.SEVERE, String.format("Error deregistering driver %s", driver), e);
}
}
now.I can load the so success!
1.add the .so file to this path
Project:
|--src |--|--main |--|--|--java |--|--|--jniLibs |--|--|--|--armeabi |--|--|--|--|--.so files
2.add this code to gradle.build
android {
splits {
abi {
enable true
reset()
include 'x86', 'x86_64', 'arm64-v8a', 'armeabi-v7a', 'armeabi'
universalApk false
}
}
}
3.System.loadLibrary("yousoname");
Two generic ways to do the same thing... I'm not aware of any specific open solutions to do this, but it'd be rather trivial to do.
You could write a daily or weekly cron/jenkins job to scrape the previous time period's email from the archive looking for your keyworkds/combinations. Sending a batch digest with what it finds, if anything.
But personally, I'd Setup a specific email account to subscribe to the various security lists you're interested in. Add a simple automated script to parse the new emails for various keywords or combinations of keywords, when it finds a match forward that email on to you/your team. Just be sure to keep the keywords list updated with new products you're using.
You could even do this with a gmail account and custom rules, which is what I currently do, but I have setup an internal inbox in the past with a simple python script to forward emails that were of interest.
my start.sh file:
#/bin/bash
nohup forever -c php artisan your:command >>storage/logs/yourcommand.log 2>&1 &
There is one important thing only. FIRST COMMAND MUST BE "nohup", second command must be "forever" and "-c" parameter is forever's param, "2>&1 &" area is for "nohup". After running this line then you can logout from your terminal, relogin and run "forever restartall" voilaa... You can restart and you can be sure that if script halts then forever will restart it.
I <3 forever
A very good plugin management system to use. The included vimrc file is good enough for python programming and can be easily configured to your needs. See http://spf13.com/project/spf13-vim/
There is a hacky way to do it.
Set some boolean field to indicate whether the work was completed. Then before the block of code, set a timer to run a piece of code after your timeout. The timer will check if the block of code had finished executing, and if not, throw an exception. Otherwise it will do nothing.
The end of the block of code should, of course, set the field to true to indicate the work was done.
Eloquent has a method for that (Laravel 4.*/5.*);
Model::whereNotNull('sent_at')
Laravel 3:
Model::where_not_null('sent_at')
Recent versions of VSCode (e.g., Version 1.29 at the time of posting this answer) allow you to change the Tab/Space size to 1
(or any number between 1
and 8
). You may change the Tab/Space size from the bottom-right corner as shown in the below image:
Click on Spaces:4
. Then, select Indent Using Spaces or Indent Using Tabs and choose the size 1.
Hope it helps.
git clone <Repo> <DestinationDirectory>
Clone the repository located at Repo into the folder called DestinationDirectory on the local machine.
I see that you’re trying to export SQL data to Excel to avoid copy-pasting your very large data set into Excel.
You might be interested in learning how to export SQL data to Excel and update the export automatically (with any SQL database: MySQL, Microsoft SQL Server, PostgreSQL).
?
it is better to use json after post your resuest like below
var clien = new RestClient("https://smple.com/");
var request = new RestRequest("index", Method.POST);
request.AddHeader("Sign", signinstance);
request.AddJsonBody(JsonConvert.SerializeObject(yourclass));
var response = client.Execute<YourReturnclassSample>(request);
if (response.StatusCode == System.Net.HttpStatusCode.Created)
{
return Ok(response.Content);
}
I resolve my problem doing this. [IMPORTANT NOTE: It allows escalated (expanded) privileges to the particular account, possibly more than are needed for individual scenario].
i Use this for the week start from SUNDAY:
SELECT id FROM tbl
WHERE
date >= curdate() - INTERVAL DAYOFWEEK(curdate())+5 DAY
AND date < curdate() - INTERVAL DAYOFWEEK(curdate())-2 DAY
You can consider leveraging React's Context feature.
class NavigationContainer extends React.Component {
constructor(props) {
super(props);
this.goTo = this.goTo.bind(this);
}
goTo(location) {
...
}
getChildContext() {
// returns the context to pass to children
return {
goTo: this.goTo
}
}
...
}
// defines the context available to children
NavigationContainer.childContextTypes = {
goTo: PropTypes.func
}
class SomeViewContainer extends React.Component {
render() {
// grab the context provided by ancestors
const {goTo} = this.context;
return <button onClick={evt => goTo('somewhere')}>
Hello
</button>
}
}
// Define the context we want from ancestors
SomeViewContainer.contextTypes = {
goTo: PropTypes.func
}
With context
, you can pass data through the component tree without having to pass the props down manually at every level. There is a big warning on this being an experimental feature and may break in the future, but I would imagine this feature to be around given the majority of the popular frameworks like Redux use context
extensively.
The main advantage of using context
v.s. a global variable is context
is "scoped" to a subtree (this means you can define different scopes for different subtrees).
Do note that you should not pass your model data via context
, as changes in context
will not trigger React's component render cycle. However, I do find it useful in some use case, especially when implementing your own custom framework or workflow.
You've declared the class Thing
as a non-static inner class. That means it must be associated with an instance of the Hello
class.
In your code, you're trying to create an instance of Thing
from a static context. That is what the compiler is complaining about.
There are a few possible solutions. Which solution to use depends on what you want to achieve.
Move Thing
out of the Hello
class.
Change Thing
to be a static
nested class.
static class Thing
Create an instance of Hello
before creating an instance of Thing
.
public static void main(String[] args)
{
Hello h = new Hello();
Thing thing1 = h.new Thing(); // hope this syntax is right, typing on the fly :P
}
The last solution (a non-static nested class) would be mandatory if any instance of Thing
depended on an instance of Hello
to be meaningful. For example, if we had:
public class Hello {
public int enormous;
public Hello(int n) {
enormous = n;
}
public class Thing {
public int size;
public Thing(int m) {
if (m > enormous)
size = enormous;
else
size = m;
}
}
...
}
any raw attempt to create an object of class Thing
, as in:
Thing t = new Thing(31);
would be problematic, since there wouldn't be an obvious enormous
value to test 31 against it. An instance h
of the Hello
outer class is necessary to provide this h.enormous
value:
...
Hello h = new Hello(30);
...
Thing t = h.new Thing(31);
...
Because it doesn't mean a Thing
if it doesn't have a Hello
.
For more information on nested/inner classes: Nested Classes (The Java Tutorials)
You can do something like this:
SELECT id,name, REPLACE(REPLACE(hide,0,"false"),1,"true") AS hide FROM your-table
Hope this can help you.
Just a note here that you may actually be better off having 3 separate SELECTS for reasons of optimization. If you have one single SELECT then the generated plan will have to project all columns col1, col2, col3, col7, col8 etc, although, depending on the value of the runtime @var, only some are needed. This may result in plans that do unnecessary clustered index lookups because the non-clustered index Doesn't cover all columns projected by the SELECT.
On the other hand 3 separate SELECTS, each projecting the needed columns only may benefit from non-clustered indexes that cover just your projected column in each case.
Of course this depends on the actual schema of your data model and the exact queries, but this is just a heads up so you don't bring the imperative thinking mind frame of procedural programming to the declarative world of SQL.
You can try like this:-
if (string[0] == '\0') {
}
In your case it can be like:-
do {
...
} while (url[0] != '\0')
;
You CAN use UTF-8 in the POST request, all you need is to specify the charset in your request.
You should use this request:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" --data-ascii "content=derinhält&date=asdf" http://myserverurl.com/api/v1/somemethod
You will have to manually delete from the project explorer (your local machine hard drive), then delete the project in IntelliJ when it asks to re-open recent projects.
Use PHP's popen
command, e.g.:
pclose(popen("start c:\wamp\bin\php.exe c:\wamp\www\script.php","r"));
This will create a child process and the script will excute in the background without waiting for output.
Or use this for an English (or mix it up for custom) format:
StringFormat='{}{0:dd/MM/yyyy}'
Here is a simple example, using class:
$input = array(
'element1' => 'value1',
'element2' => 'value2',
'element3' => 'value3'
);
echo FlatData::flatArray($input,', ', '=');
class FlatData
{
public static function flatArray(array $input = array(), $separator_elements = ', ', $separator = ': ')
{
$output = implode($separator_elements, array_map(
function ($v, $k, $s) {
return sprintf("%s{$s}%s", $k, $v);
},
$input,
array_keys($input),
array_fill(0, count($input), $separator)
));
return $output;
}
}