INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
jquery best practice - add data to element or pass it with the event
Which is best practice for passing data from a DOM element to the attached event:
var input = '<input type="text" class="myplugin-input">';
this.$el.append(input);
var inputEl = this.$el.find('.myplugin-input'),
inputData = {
pluginObj : this,
someData : 'xyz',
otherData : 50
};
//* Option 1 - is this best practice?
inputEl.on('keyup', inputData, this.inputHandler);
//* Option 2 - is this best practice?
$.data(inputEl, 'myPluginInputKey', inputData);
|
If the data is only needed within the event handler, then I'd go with Option 1 to keep the data stored only for the consumer of the data. If you may want access to the data from elsewhere in your program, then use `.data()` to store it for anyone to access.
FYI, an alternate form of option #2 is a little more readable and more consistent with how most jQuery operations read:
inputEL.data('myPluginInputKey', inputData);
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "jquery, jquery plugins"
}
|
Pipe external process's output into running C++ script
I am making a simple bash terminal with the SFML framework for C++. I understand how to begin an external process with the system() fn, but I need a way to stream a child process's output into the current script. Is there a simple way to do this? Perhaps using an fstream hack? I am using Unix.
|
You need to use pipe()s - . The basic idea is to fork() then to dup2() the file descriptors 0 (stdin), 1 (stdout) and, respectively, 2 (stderr) into the specific pipes and then to waitpid() in your "main" branch of the fork until you get an `WIFEXITED` on the "child" branch.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "c++, stream, terminal"
}
|
A better way to update C++ application for windows
I'm trying to develop `C++` application for a client. So far, i have added the basic functionalities and it works as expected but i will likely to gradually grow the application in future (i.e. adding more feature to it) and the client will likely to update those feature in their app. Now my questions are the following:
1. For adding feature, i have decided to add features to a `dll` and the client will likely replace the old `dll` with the new one (in order to use latest features). Is there a better approach for updating `C++` app?
2. Why some developer use ordinal values instead of function names while exporting symbols, whats the benefit of using ordinal values other than less binary file size ?
I don't want my client to recompile/link the app, i just want to keep the updating process as smooth as possible. Need advice.
P.S: Environment = Windows + Visual Studio
|
@Vasilij way is the way to go. If you update only de `DLL`, how you application will know that there are new functions to call? You have to dynamically adapt your menus and so on.
Just create an `exe` stub that runs the real application (may be in a subprocess it can kill) and update the whole app (not the stub) and `DLL`s when necessary. That stub can check for updates also and suggest the restart after downloading.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c++, dll"
}
|
What is wrong in F# code?
In F# I am trying to get last element of give list. I wrote below code
let rec findLast t =
match t with
| hd :: [] -> hd
| hd :: tl -> findLast tl
| _ -> -1
printfn "%A" (findLast [1,2,3,4,5])
But when I tried to execute it in F# Interactive it complain as below
> error FS0001: This expression was expected to have type int but here has type 'a * 'b * 'c * 'd * 'e
I just want to know what is wrong in above code. I know there are different smart and elegant ways to get last element from list in F#. But I am interested to know what is wrong in above code ?
|
`1,2,3,4,5` is a tuple. `'a * 'b * 'c * 'd * 'e` is a tuple definition. Create a list with semicolons `[1;2;3;4;5]`. `[1,2,3,4,5]` is a list of tuples with one item which is a quintuple.
let rec findLast t =
match t with
| hd :: [] -> hd
| hd :: tl -> findLast tl
| _ -> -1
printfn "%A" (findLast [1;2;3;4;5])
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "f#, f# interactive, f# 3.0"
}
|
Evaluate $\sum_{n=0}^\infty (-1)^n \ln\frac{2+2n}{1+2n}$
I'm trying to evaluate:
$$\sum_{n=0}^\infty (-1)^n \ln\frac{2+2n}{1+2n}$$
I'm not too sure where to start. I've tried writing it as a telescoping sum, but that doesn't work. I'm thinking it's related to the Wallis Product or some infinite product of Gamma's somehow, but I can't figure anything out.
I've rewritten it as:
$$\sum_{n=0}^\infty \ln\frac{(2+4n)(3+4n)}{(1+4n)(4+4n)}=\ln\prod_{n=0}^\infty\frac{(2+4n)(3+4n)}{(1+4n)(4+4n)}$$
but to no avail.
|
We have the series expansion of the digamma function:
$$\psi(z)=-\gamma+\sum_{n=0}^\infty\frac1{n+1}-\frac1{n+z}$$
Integrating both sides gives
$$\ln\Gamma(z)=(1-z)\gamma+\sum_{n=0}^\infty\frac{z-1}{n+1}+\ln\left[\frac{n+1}{n+z}\right]$$
Hence we have
$$\ln\Gamma(1)+\ln\Gamma(1/4)-\ln\Gamma(1/2)-\ln\Gamma(3/4)=\sum_{n=0}^\infty\ln\left[\frac{(n+1/2)(n+3/4)}{(n+1)(n+1/4)}\right]$$
> $$\ln\left[\frac{\Gamma(1/4)}{\Gamma(3/4)}\right]-\frac12\ln(\pi)=\sum_{n=0}^\infty\ln\left[\frac{(4n+2)(4n+3)}{(4n+4)(4n+1)}\right]$$
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 6,
"tags": "sequences and series, summation, infinite product"
}
|
Delete ROW that a namedRange is Associated With in Google Apps Scripts
I know I can delete the actual namedRange, but that is not what I am looking for. I have a cell that has a namedRange associated with it. I want the script to determine what row this cell resides in and delete that entire row.
Doing something like below only deletes the namedRange, not the row it is associated with. Any ideas how I would go about doing that? Thanks!
var namedRanges = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1').getNamedRanges();
namedRanges('namedRange1').remove();
|
Try this:
function delRow(name) {
var ss=SpreadsheetApp.getActive();
var rg=ss.getRangeByName(name);
rg.getSheet().deleteRow(rg.getRow());
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "google apps script, google sheets, named ranges"
}
|
Bubblewrap error on iOS7 in Rubymotion
I downloaded iOS7 GM earlier and an the following error appeared when building on simulator and/or device:
_Terminating app due to uncaught exception 'NameError', reason: 'uninitialized constant BubbleWrap::Device::Camera::KUTTypeMovie (NameError)._
What's strange is that I only require bubble-wrap/core in my Rakefile. Also the only functions I use from bubblewrap are BW::JSON and App.Persistence.
If I change the xcode-select path back to xcode4, the app runs again.
Any ideas?
P.S. I have the latest rubymotion and (I think) the latest BubbleWrap (since in the Gemfile, I have the following line, but I'm new to rubymotion/ruby:
gem 'bubble-wrap', :git => '
Edit: Also tried requiring bubble-wrap/camera (even if I don't use the camera), updating xcode command line tool.
|
Seems I was a little bit to hasty. From @rubymotion on Twitter, GM is not supported yet but should be really soon. Meanwhile, a user on the rubymotion google groups post a monkey patch
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ios7, rubymotion, xcode5"
}
|
Having trouble using Capybara and Selenium to find an svg tag on a page
I had a test case like this:
scenario "there should be an SVG tag" do
...
page.find("svg")
end
For some reason, Capybara could not find the svg tag even though when I looked in the page's source, the tag was there (and also visually).
I was only able to get it to find the SVG tag after I did something like:
scenario "there should be an SVG tag" do
...
page.find("#layers *[xmlns='
end
(Note, the svg is within the "layers" ID).
Does anyone have any ideas? I use Selenium as the driver.
|
It turns out this is an issue with Firefox's built in xpath evaluator.
Using FireBug, I was able to verify that the call that Selenium uses:
document.evaluate("//svg", document, null, 9, null).singleNodeValue
doesn't return any elements, whereas
document.evaluate("//div", document, null, 9, null).singleNodeValue
returns the first div on the page.
There may be some namespacing issues that could get FireFox to return svg elements. For now I've just looked for elements with my svg xmlns attribute.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 4,
"tags": "selenium, svg, capybara"
}
|
Ant Design Form field with array of objects
I want to edit an entity with one-to-many relation
{
id: 1,
title: 'Title',
tags: [
{ id: 1 },
{ id: 2 },
],
}
With the code
<Form.Item
name={["tags", "id"]}
>
<Select mode={'multiple'} {...selectProps} />
</Form.Item>
On submit I get such object:
{
id: 1,
title: 'Title',
tags: { id: [1, 2]},
}
How can I get tags as array of objects?
|
Try using the `normalize` callback on `Form.Item`
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "typescript, forms, antd"
}
|
Code Analysis recommends using const in definition but how in global.asax?
Code
public class Global : System.Web.HttpApplication
{
public const string globalServernameSHA = string.Empty;
public static string globalSqlConnection = string.Empty;
protected void Application_Start(object sender, EventArgs e)
{
globalServernameSHA = ConfigurationManager.AppSettings["varServernameSHA"].ToString();
globalSqlConnection = ConfigurationManager.ConnectionStrings["varConnectionString"].ToString();
}
These variables should be read just once and definitely should be read only. They have to be available for whole project and therefore should be public.
Is there a way how to define const in code like this ?
Thanks
|
Declare them as readonly and move initialization to constructor:
public class Global : System.Web.HttpApplication
{
public readonly string globalServernameSHA;
public readonly string globalSqlConnection;
public Global()
{
globalServernameSHA = ConfigurationManager.AppSettings["varServernameSHA"].ToString();
globalSqlConnection = ConfigurationManager.ConnectionStrings["varConnectionString"].ToString();
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": ".net, security, optimization, constants, global asax"
}
|
How to compare dates for a nested dictionary values
Data={
0:{
'country1': "Ryan lives in America",
'country_one': "5",
'med_dict':{
0: {
'endDate': "732",
'endTime': "89",
}
},
},
1: {
'country1': "Sam lives in america",
'country_three': "90",
'med_dict': {
0: {
'endDate': "245",
'endTime': "222",
}
},
}
}
res = [v1['country1'] for k1, v1 in Data.items()]
print(res)
I have got the output as `['Ryan lives in America', 'Sam lives in america']`. I want to print True if word `'America/america'` is present in both the string or else print False. Need to check for the case sensitivity as lower or upper. How to do it?
|
If maybe you want to check multiple words, you can create list of words and use `any`.
chk = ['America', 'americ']
res = [any(c in v1['country1'] for c in chk) for k1,v1 in Data.items()]
print(res)
# If you want to check and print
if all(res):
print('True')
else:
print('False')
* * *
[True, True]
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "python, dictionary"
}
|
How To Draw a circle using using CxImage in VC++
I have loaded and displayed an image using CxImage functionality. now i need to draw some default shapes like circles and rectangles and lines. There is no defined function in CxImage for these only Line function is available. With that have i drawn rectangle. But no idea on how to draw circle.
if not possible using CxImage then what are the other ways and how this can be made with CxImage complaint(ie: I dont want to rewrite my functions for Save, New, Load Etc).
|
To draw circle, you can have a look on _Bresenham Circle Algorithm_. Start with Wikipedia < you will find nice simple C implementation and an optimized version. Adaptation to CxImage is straightforward.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "image, visual c++"
}
|
Formatting graphs and figures: why and when is it bad to include horizontal lines?
I am TAing a course where students are required to turn in their lab reports formatted like a submission to the journal _Ecology_. Figures and graphs in this journal do not have the horizontal lines that are the default setting in MS Excel, so I am constantly taking off points because students forget to delete them.
!enter image description here
I'd like to provide some justification to students as to why this small part of making a figure is important, besides "because I say so."
Is the use of horizontal lines in figures just the convention of different academic fields and journals, or are there established reasons why its usually best to not include these lines?
|
I think about it this way: When I prepare a figure for a paper, I usually want to both show data and make some point about the data. Anything that helps these goals in a simple clear way is a worthwhile addition, anything else should be removed (without distorting the data of course).
In the case of horizontal (or vertical) lines, I would use them only if: (1) It is difficult to tell the exact values for data points and I think that this is important information; (2) I want the viewer to be able to compare the exact y-axis (or x-axis) positions of data points (e.g. to see that two point have exactly the same value, or differ by a specific amount).
Specifically in the figure you show, it seems that the data can only have a limited amount of y values and thus it is easy to tell the value by eye, making the horizontal lines useless in this case.
|
stackexchange-stats
|
{
"answer_score": 6,
"question_score": 6,
"tags": "data visualization, excel"
}
|
Ambiguous occurrence "map" error in WinHugs / Haskell
In WinHugs I've implemented the following function:
map :: (a -> b) -> [a] -> [b]
map f [] = []
map f (x:l) = f x : map f l
This should simply run a function for each number in a list like:
Hugs> map (+ 1) [1,2,3]
should give
[2,3,4].
But when I try to load that *.hs script WinHugs gives the errormessage
ERROR file:.\script.hs:3 - Ambiguous variable occurrence "map"
*** Could refer to: Main.map Hugs.Prelude.map
line 3 is `map f (x:l) = f x : map f l`
How can I avoid that problem? I guess something in my preferences/settings is wrong.
|
You’re seeing the error because the Haskell Prelude already defines a function named `map`. A simple–minded fix is to rename your definition, _e.g._ ,
mymap :: (a -> b) -> [a] -> [b]
mymap f [] ...
The more sophisticated approach is to exclude the Prelude’s definition of `map` with
import Prelude hiding (map)
at the top of your module.
The accommodating approach is to leave the definition alone and apply the function you want by its full name, either
Main.map (+ 1) [1, 2, 3]
or
Prelude.map (+ 1) [1, 2, 3]
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "haskell"
}
|
An odd json usage
I saw a part of javascript code on MDN and I am wondering how to work below code and what does it mean ?
var obj = { get x() { return 17; } };
|
As far as I know the keyword `get` just classifies `x()` as a getter, and appears to self-invoke. It's not supported in jScript (IE) and it's not a reserved word.
You'd reference it like so: `obj.x; // 17`
In lamen's terms, these will behave identically:
var foo = { get x() { return 17; } };
document.write(foo.x); // 17
var bar = { x: function() { return 17; } };
document.write(bar.x()); // 17
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 4,
"tags": "javascript, json"
}
|
Perl Program to Print Unicode From Hex Value
I am starting up with Perl and confused on how to render unicode characters given a hex string variable.
#!/usr/bin/perl
use warnings;
foreach my $i (0..10000) {
my $hex = sprintf("%X", $i);
print("unicode of $i is \x{$hex}\n");
}
print("\x{2620}\n");
print("\x{BEEF}\n");
Gives me the warning: `Illegal hexadecimal digit '$' ignored at perl.pl line 9.`
and no value prints for `\x{$hex}`
|
Both `chr($num)` and `pack('W', $num)` produce a string consisting of the single character with the specified value, just like `"\x{XXXX}"` does.
As such, you can use
print("unicode of $i is ".chr(hex($hex))."\n");
or just
print("unicode of $i is ".chr($i)."\n");
* * *
Note that your program makes no sense without
use open ':std', ':encoding(UTF-8)';
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 6,
"tags": "string, perl, unicode, text rendering"
}
|
Oracle data distribution across date index
There's a situation that arises in large database tables (~50 million rows) where users need to browse date-indexed records.
But users browsing the data do not necessarily know where on the timeline data occurs and where the gaps are. In past projects, I've quantized the records into 24-hour "buckets", and used that to create a bar-graph timeline, where the height of the bar indicates the number of records in that period. This allowed users to focus in on areas where data actually exists.
The drawback of this solution is that the record counts must be continually updated and maintained (if data can be inserted/removed from any point on the timeline).
Is there a more elegant solution to getting these aggregate record counts? For instance, by peeking at a date index and seeing how many values there are associated with that index?
|
I'm not sure if this will actually work for you, but it sounds like what you're looking for are histograms. If a histogram exists for your index, you can query `USER_HISTOGRAMS` to get a rough idea of the distribution of values across the index. The downside of this is that it will only be accurate as of the last time statistics were gathered for your index, so if your data changes often, it may not be up-to-date.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "oracle, indexing"
}
|
Looking for ColorChooser.jar
I am beginner, and I need `ColorChooser.jar`.
Does it come with Netbeans or I need to download it? (if I need to download it where I can find it?)
Thanks
|
It comes with NetBeans. It is buried in the installation directory. Search for the file in your operating system if you have NetBeans installed.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "java, swing, jar"
}
|
How to sequence my data table using linq
I have a `DataTable` that looks like below:
| ItemName | ItemPro
A HWH
A BRB
A EAH
B HWH
B BRB
B EAH
B HWH
C BRB
C EAH
I want to group above `DataTable` by `ItemName` and sort these groups
How can I achieve this?
Note: after sorting, I want my table like below;
| ItemName | ItemPro
A HWH
B BRB
c EAH
A HWH
B BRB
C EAH
A HWH
B BRB
B EAH
|
You don't have to group your values by `ItemName` instead you can apply sorting on `ItemName` like:
var sortedQuery = dt.AsEnumerable()
.OrderBy(r=> r.Field<string>("ItemName"));
If you want the second field to be sorted as well then use `Enumerable.ThenBy` like:
var sortedQuery = dt.AsEnumerable()
.OrderBy(r => r.Field<string>("ItemName"))
.ThenBy(r => r.Field<string>("ItemPro"));
If you want result in a new `DataTable` then:
DataTable sortedDt = dt.AsEnumerable()
.OrderBy(r => r.Field<string>("ItemName"))
.ThenBy(r => r.Field<string>("ItemPro"))
.CopyToDataTable();
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "linq, c# 4.0, datatable"
}
|
Select All Checkboxes By ID/Class
I'm really bad at Javascript and I'm struggling to get my head round it.
What I'm trying to do is get something to select all checkboxes. However everything I have found tries to do it by name, I want to do it by ID or class. Select all by name is just inpractical isn't it?
|
Using JQuery, you can do this very easilly!
$(".ClassName").attr("checked", "true");
or a single ID
$("#ID").attr("checked", "true");
See: Check All Checkboxes with JQuery.
|
stackexchange-stackoverflow
|
{
"answer_score": 19,
"question_score": 19,
"tags": "javascript"
}
|
Going backwards after decrypting a message using RSA
I am trying to learn how RSA cryptography work. I think I have figured out everything, except getting back the characters I started with.
For example, lets say I have a base of 26 (Eng alphabet) and sections of 4 characters at a time. I have a string "ABCD" I want to encrypt. What I do is assign each character to a number, starting from 0. So $$"ABCD" \implies (0,1,2,3)$$ After that I add the base $$0*26^{0}+1*26^{1}+2*26^{2}+3*26^{3} \implies 54106 := M$$ So $M$ is my unencrypted string. Lets just stop here, lets say I cryptate it and send it over to a buddy, he decrypts it and end up with $54106$, how should he go from there?
I have to end up with $0*26^{0}+1*26^{1}+2*26^{2}+3*26^{3}$ again so I can pick out the letters otherwise it makes no sense. Anyone who know?
|
This is only remotely related to RSA or cryptography. What you want is just a base conversion between base 10 and base 26. You have already done the direction $10\rightarrow 26$. The inverse is a repeated application of the Euclidian division:
Suppose you want to convert the number $n$ to base $B.$ Then perform
$$q_{k+1} = \lfloor q_k / B\rfloor, \;r_{k+1} = q_k \bmod B$$
with $q_0 = n$ until a $q_k$ becomes zero. The base-B representation is the reverse concatenation of the remainders. For you example
q_k r_k
54106 -
2081 0
80 1
3 2
0 3
So $59106_{10} = 3210_{26} = 3\cdot 26^3 + 2\cdot 26^2 + 1\cdot 26^1 + 0\cdot 26^0$
For more info see e.g. <
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "discrete mathematics, cryptography"
}
|
Non-increasing Monotone Sequence Convergence Proof
My goal is to prove the monotone convergence of a non-increasing sequence of real numbers. There are some steps in the proof that I'm not sure about. The question:
If $S$ is a non-increasing sequence bounded below, show that it converges.
Here is what I have so far:
Since S is non-increasing and bounded below, by the Greatest Lower Bound property, it has an inf.
Let $c$ = inf($S$). Goal: Show that $S$ converges to $c$.
By definition of infimum, for every $\epsilon$ $> 0$, $\exists N$ such that $S_N$ $< c + \epsilon$ (Otherwise, $c + \epsilon$ would be a lower bound of $S$ and that contradicts $c$ being the infimum of $S$.
Here is where I am unsure about my proof:
Because $S$ is non-increasing, if $n > N$, $\epsilon > \mid S_n - c \mid \geq \mid S_N - c\mid$.
So, that proves that $S$ converges to $c$, which is inf($S$).
|
You are correct for the most part. You just have to be careful about the final inequalities -- switch $n$ and $N$.
Since the sequence is non-increasing, if $n \geq N$ then $S_n \leq S_N$, and
$c \leq S_n < c + \epsilon$.
So
$0 \leq S_n-c < \epsilon$
and
$|S_n - c| < \epsilon$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 4,
"tags": "convergence divergence, proof verification, sequences and series"
}
|
Kotlin - How to pass a Runnable as this in Handler
I'm beginner in kotlin. I try to create a task that will repeat every 2 seconds. So I created something like this.
val handler = Handler()
handler.postDelayed(Runnable {
// TODO - Here is my logic
// Repeat again after 2 seconds
handler.postDelayed(this, 2000)
}, 2000)
But in postDelayed(this) it gives error - `required Runnable!, found MainActivity`. I've tried even `this@Runnable` but it didn't work.
But when I write the same function like this, it works
val handler = Handler()
handler.postDelayed(object : Runnable {
override fun run() {
// TODO - Here is my logic
// Repeat again after 2 seconds
handler.postDelayed(this, 2000)
}
}, 2000)
So why the `this` keyword doesn't work in first function, but in second function it works good?
|
You have several options to go about here:
1. make both the runnable and the handler be in the same scope
//class scope
val handler = Handler()
val runnable = object : Runnable {
override fun run () {
handler.removeCallbacksAndMessages(null)
//make sure you cancel the
previous task in case you scheduled one that has not run yet
//do your thing
handler.postDelayed(runnable,time)
}
}
then in some function
handler.postDelayed(runnable,time)
2. You can run a `timertask`, which would be better in this case
val task = TimerTask {
override fun run() {
//do your thing
}
}
val timer = Timer()
timer.scheduleAtFixedRate(task,0L, timeBetweenTasks)
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 10,
"tags": "android, kotlin, handler, runnable"
}
|
Manipulating DisplayMember before it is displayed
Let's say I am using databinding like this:
List<Entity> Entities = <some data>
entityBinding.DataSource = Entities;
lstEntities.DisplayMember = "Description";
which works fine. However, I want to manipulate the string coming back as the Entity's "Description". How can I call a function on DisplayMember?
|
You cannot call a function on that field - but you could create a new property on your entity called `MyDescription` which does to `Description` whatever it is you want to do, and then use that new property as your `DisplayMember`
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 4,
"tags": "c#, winforms, data binding, datasource"
}
|
jquery - remove duplicate consecutive element
<div>something i need</div>
<span>x</span>
<div>something i need</div>
<span>x</span>
<div>something i need</div>
<span>x</span><span>x</span><span>x</span>
<div>something i need</div>
On the row where I have 3 span elements, how do I remove all but one? I only want to have one between each element.
edit: made the html correct so people focus on the actual issue.
|
$('span').each(function() {
while($(this).prop('tagName') == $(this).next().prop('tagName'))
$(this).next().remove();
});
As you can see, consecutive spans have been removed, and there is only one `x` in-between the divs instead of three: **<
It would be a good practice to wrap the above elements in a container, and only perform the removal in that container. i.e.:
$('#myDiv span').each(function() {
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "jquery"
}
|
C++ Sending a private class variable into a function
I'm writing a program dealing with binary search trees in C++. I'm using a .h file that contains a class "treeNode" and I have a function that searches the tree for a specific number and returns a boolean as to whether the number was found or not. My problem is that I have a private class variable for the "treeNode" class called "root" that is a pointer and points to the first element within the tree. I need to somehow send that variable into the search function from the .cpp file as a function parameter.
How do I do this? Every time I try, I get an error telling me that it's a private class variable. Classes confuse me a little.
Thanks!
|
You can refer this skeleton and build your classes.
class treeNode
{
private:
int data;
};
class tree
{
private:
treeNode* root;
public:
bool search(int data)
{
//root is accessible here. No need to pass as argument
}
};
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "c++, class, private"
}
|
How to close a lot of open ports on home laptop
I scanned my laptop for open ports. Nmap found about 1000+ open ports with unknown services. I tried to create rules in the Windows firewall that closed these ports, but this did not help. Also I used other programms for close that ports and it also didn't help. How can I close them?
. You don't need to close them. Please see _Nmap scan produces all “unknown”_.
Fragments of two answers published there:
> The problem is with Windows and scanning the local machine. Nmap on Windows does not work the same way as it does on Linux due to differences in how the NIC is accessed. It is not actually connecting to each port from a separate process, but is connecting to itself.
> This output is expected when scanning from Windows to localhost (127.0.0.1, ::1, or an IP address that belongs to the scanning system itself), but only for Nmap versions released prior to July 2016. Nmap 7.25BETA1 added Windows localhost scanning with the use of the new Npcap packet capture library, so this will not be an issue any more.
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 0,
"tags": "windows 7, internet, port, nmap"
}
|
Convert number to time in Python
I have a large CSV-file with a column called TIME. It's written as 1318 and I would like to use Python/Pandas to convert the data as 13:18 and see it as time instead of int64.
I've tried something like this but this is not what I want:
df['TIME'] = pd.to_datetime(df['TIME'])
Because I get this:
1970-01-01 00:00:00.000001318
1970-01-01 00:00:00.000001041
1970-01-01 00:00:00.000000853
Any ideas?
|
If you pass a format param to `to_datetime` you will get the following:
In [111]:
t="1318"
pd.to_datetime(t, format='%H%M')
Out[111]:
Timestamp('1900-01-01 13:18:00')
However, I don't know if you want a default date here.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 5,
"tags": "python, pandas, datetime"
}
|
how to remove the duplicate values from string list in c#
i used this code:
List<string> lists=new List<string>("apple","orange","banana","apple","mang0","orange");
string names;
names=lists.Distinct()
is that correct?
|
No, the variable `names` has to be a collection. The `Distinct` method returns an enumerator, so you probably want to enumerate the result and realise it as a list:
List<string> names = lists.Distinct().ToList();
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -4,
"tags": "c#"
}
|
Python Regex for a Specific Word
I have the below texts in a column called actions.
"Why don't you clean this table : J$CLAB"
"http("J$MANG.create"): 21/01/06 23:24:05 INFO"
i would like to extract the words that start with J$... till the end. e.g. J$MANG & add it in a new column.
here is what i have done so far, not working as needed
file['fileName'] = [re.split(r'[^J$A-Z\.$]|[^J$A-Z\s$]', val.strip()) for val in file['action']]
file['fileName'] = [' '.join(val) for val in file['fileName']]
any suggestions. Thx
|
You can use
file['fileName'] = file['action'].str.extract(r'\b(J\$\w*)', expand=False)
See the regex demo
_Details_ :
* `\b` \- a word boundary
* `(J\$\w*)` \- Group 1: `J` and zero or more word chars.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python, python 3.x, regex, pandas, extract"
}
|
Can the openGauss database be installed on SUSE 15?
I've installed openGauss on Centos and it works great so far. Can I install it on SUSE 15?
|
The following official documents: ARM: openEuler 20.03LTS (recommended) Kirin V10 x86: openEuler 20.03LTS CentOS 7.6 Description: The current installation package can be installed only on the English operating system.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "suse"
}
|
Como obter informações do IIS via c#?
Como fazer para obter em c# algumas informações do IIS como Versão e **algumas configurações como Roles e Services**.
*Obs: Minha aplicação não é Web.
|
As informações sobre o seu IIS podem ser obtidas usando o provedor ADSI. Os exemplos são do IIS 6, mas não haveria motivo para não funcionar em versões posteriores do IIS.
Neste artigo há exemplos de como obter algumas informações e até mesmo criar sites no IIS.
Além disso, ainda há o excelente artigo que ensina como obter configurações do IIS pelo Active Directory.
Este artigo também é um esforço mais direcionado para ler as configurações do IIS.
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 2,
"question_score": 4,
"tags": "c#, iis"
}
|
Adding a deathrattle to a card that already has one
Suppose I have a card with a deathrattle, such as Cairne Bloodhoof. What happens if I use a card that gives a minion a deathrattle, Ancestral Spirit, to the minion?
I can see two possibilities:
* The minion's deathrattle is replaced
* The minion is given an additional deathrattle
|
From the Hearthstone Wiki: Minions may benefit from multiple Deathrattles at the same time.
In your example, Cairne's bloodrattle would go off first, summoning the 4/5 Baine. After that, Ancestral Spirit would resummon Cairne.
|
stackexchange-gaming
|
{
"answer_score": 10,
"question_score": 10,
"tags": "hearthstone"
}
|
req.body is empty when when header is { 'Authorization': 'Bearer ' + token }
I am using Angular 2 as front end. I tried to send an Object `{ test: 'Hi' }`.
When my http header is like this:
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
I can get the content I sent on the server side using `req.body`.
However, when my http header is like this:
let headers = new Headers({ 'Authorization': 'Bearer ' + token });
let options = new RequestOptions({ headers: headers });
When I use `req.body` again, I got an empty Object `{}`.
My server is using Express.js, and my bodyParser is like this:
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
How can I do it correctly? Thanks
|
You should send both headers to express:
let headers = new Headers({
'Content-Type': 'application/json',
'Authorization': 'Bearer ....'
});
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "http, express, angular, typescript, angular2 universal"
}
|
Rails meta-search: Check if filter is set
Is it possible to check if a filter on a search-object from the rails gem meta-search is set? I've got this code in my controller:
@search = Tree.search(params[:search])
when i do @search.search_attributes.empty? i got true if i the form never has been sent. But if i send the form, even if its blank i get false (which is logic)
What is the best solution to check (from the view) if there is no filter active?
I hope someone can help me with this, thanks!
|
Instead of empty u can check using present.
@search.search_attributes.present?
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ruby on rails, view, filter, meta search"
}
|
Is it helpful to have a captcha on a login screen?
I introduced recaptcha to the login screen of a system.
My goal was all about security things like dictionary/bots attacks or other thing of that type.
The users now hate it, Some did not even understand it and I had to remove it.
When I look around, I don't see many systems with that on the login screen, most of the times on other forms like contact us or sometimes like in stack exchange when you want to post.
It made me wonder is it a good idea to have it on the login screen?
|
The way I've seen some large systems do it is to only require a captcha after sequential failed login attempts (ie: reset the count after a valid login). If you are worried about automated cracking, you could put the captcha at some high number of failures like 20, 50, 100 failed attempts. Almost no legitimate user will see the captcha, but an automated attack will get hit by it.
Is it worth it to add this complexity? Security and UX are trade-offs. You need to find the correct trade-off for your risk profile.
|
stackexchange-security
|
{
"answer_score": 53,
"question_score": 34,
"tags": "authentication, captcha"
}
|
Would like to vectorize while loop for performance
1. I am trying to set values for a window of an array based on the current value of another array.
2. It should ignore values that the windown overrides.
3. I need to be able to change the size of the window for different runs.
This works but it is very slow. I thought there would be a vectorized solution somewhere.
window_size=3
def signal(self):
signal = pd.Series(data=0, index=arr.index)
i = 0
while i < len(self.arr) - 1:
s = self.arr.iloc[i]
if s in [-1, 1]:
j = i + window_size
signal.iloc[i: j] = s
i = i + window_size
else:
i += 1
return signal
arr = [0 0 0 0 1 0 0 0 0 0 0 -1 -1 0 0 0 0 ]
signal = [0 0 0 0 1 1 1 0 0 0 0 -1 -1 -1 0 0 0 ]
|
You could use `shift` function of `pd.Series`
arr_series = pd.Series(arr)
arr_series + arr_series.shift(periods=1, fill_value=0) + arr_series.shift(periods=2, fill_value=0)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, numpy"
}
|
How to put a colon to the left of a set of equations?
Currently I have the following code
\begin{equation*}
\begin{split}
\Omega : \dot x &= \omega(b) \\
p &= \sigma(z)
\end{split}
\end{equation*}
Which generates
 \\
p & = \sigma(z)
\end{aligned}
\end{equation*}
\end{document}
:
________________________________________________________________________________
| user1@MacBook-Pro {~} --- 2020-09-14 13:17:39
| $:
|
As others have already mentioned, there are built-in sequences for setting colours, like `%F{red}`. If you want to include more exotic terminal control codes, you can do it like this:
PS1=$'%{\e[1m%}%m%{\e[0m%}'
(This should make the prompt display your hostname in boldface, on most typical terminals.) There are two things to notice here
1. Using the `$'`... `'` quoting mechanism to include control characters in the string. This is described under QUOTING in the `zshmisc(1)` man page. (In other words, this is what makes `\e` work).
2. Using `%{`...`%}` to indicate that the enclosed sequence does not cause the cursor to move.
3. (`%m` expands to the host name. This is described under PROMPT SEQUENCES in `zshmisc(1)`, but you probably knew this already.)
(Alright then, three things. Monty Python fans will know what reference I would put here, others won't care. :-) )
|
stackexchange-apple
|
{
"answer_score": 7,
"question_score": 4,
"tags": "terminal, bash, zsh"
}
|
ActiveRecord Relationships : undefined method for nil:NilClass
Consider the following:
class Manager < ActiveRecord::Base
has_many :employees
end
class Employee < ActiveRecord::Base
belongs_to :manager
end
employee = Employee.first
puts employee.manager.name
If for some reason an employee does not have a manager I get this:
undefined method `name' for nil:NilClass
Which makes sense. However, is there a clean/suggested way to handle this, so I don't always have to check and see if an employee actually has a manager before I ask for the manager's name?
|
Try:
puts employee.manager.name unless employee.manager.nil?
Or:
puts (employee.manager.nil? ? "No manager" : employee.manager.name)
Which is equivalent in this case to:
puts (employee.manager ? employee.manager.name : "No manager")
(Equivalent as long as employee.manager can't return false.)
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "ruby on rails, activerecord"
}
|
Get Text Content of list item
I have two list items in my html page.I would like to access the "text content" of the "first list item" present in the "first unordered list".I need to do it with javascript and not jquery.This is what i tried but does'nt seem to work.
<html>
<head>
<title>dom</title>
<script type="text/javascript">
function createcontent(){
var val = document.getElementsByTagName("ul")[0].childNodes[0].nodeValue;
document.getElementById("content").innerHTML = val;
}
</script>
</head>
<body onload="createcontent();">
<ul>
<li>Milk</li>
<li>cured</li>
<li>eggs</li>
</ul>
<ul>
<li>cabbage</li>
<li>califlower</li>
<li>apple</li>
</ul>
<p id="content"></p>
</body>
</html>
|
<html>
<head>
<title>dom</title>
<script type="text/javascript">
function createcontent(){
var val = document.getElementsByTagName("ul")[0].children[0].innerText;
alert(val);
document.getElementById("content").innerHTML = val;
}
</script>
</head>
<body onload="createcontent();">
<ul>
<li>Milk</li>
<li>cured</li>
<li>eggs</li>
</ul>
<ul>
<li>cabbage</li>
<li>califlower</li>
<li>apple</li>
</ul>
<p id="content"></p>
</body>
</html>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, html, dom"
}
|
BGE shaking camera when i walk or run
I couldn't seem to find any videos on how to do this. I'm making a game and I want it so when I walk or run the camera shakes. how do I do this
|
You can make an animation with the camera. Click this little red button in the timeline.  Select the camera, press alt + a to start the timeline, press g to grab it, and shake it around. press escape when you are finished. You can do this a much more sophisticated way, of course. :) Save your action. In the logic editor, use whatever sensor that causes you to run and link it to the action actuator also (where your camera is animated.) Remember to set the beginning and end keyframes to be where you had started and stopped the shaking. If you want a much more controllable way to do it, try using something from this video: <
Hope that helps. ;) Tell me if you need more information. It would be a good idea to add more information to your question as well.
|
stackexchange-blender
|
{
"answer_score": 1,
"question_score": 0,
"tags": "game engine, camera"
}
|
what is difference between multilayer perceptron and multilayer neural network?
When do we say that a artificial neural network is a _multilayer Perceptron_?
And when do we say that a artificial neural network is a _multilayer_?
Is the term _perceptron_ related to learning rule to update the weights?
Or It is related to neuron units?
|
A perceptron is always **feedforward** , that is, all the arrows are going in the direction of the output. Neural networks in general might have loops, and if so, are often called _recurrent networks_. A recurrent network is much harder to train than a feedforward network.
In addition, it is assumed that in a perceptron, all the arrows are going from layer $i$ to layer $i+1$, and it is also usual (to start with having) that all the arcs from layer $i$ to $i+1$ are present.
Finally, having _multiple layers_ means more than two layers, that is, you have _hidden_ layers. A perceptron is a network with two layers, one input and one output. A multilayered network means that you have at least one hidden layer (we call all the layers between the input and output layers hidden).
|
stackexchange-cs
|
{
"answer_score": 22,
"question_score": 23,
"tags": "neural networks, perceptron"
}
|
Win32API - How to get file name of process from process handle?
How can I get the file name of process from a process handle? I'm using Win32 C++ (Visual C++ Express Edition).
Thanks.
|
Call `GetModuleFileNameEx`. Available as of Windows 2000.
DWORD WINAPI GetModuleFileNameEx(
__in HANDLE hProcess,
__in_opt HMODULE hModule,
__out LPTSTR lpFilename,
__in DWORD nSize
);
Use `NULL` for the second parameter to get the name of the EXE file.
|
stackexchange-stackoverflow
|
{
"answer_score": 14,
"question_score": 7,
"tags": "c++, winapi, process"
}
|
simple VB code help
I am a java devloper and I wish to convert following code to java can any VB devloper tell me what following does?
temp8Bit = 0
temp8Bit = Convert.ToByte(tempRMACode.ToCharArray().GetValue(0))
+ Convert.ToByte((tempRMACode.ToCharArray()).GetValue(7))
rmaValidationCode += String.Format("{0:X2}", temp8Bit)
tempRMACode is a string
|
It is adding the byte values of the 1st and the 8th characters of tempRMACode, then appending it to rmaValidationCode in the format of "0:X2" which is a 2-character hexadecimal representation of the string (temp8Bit).
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "vb.net"
}
|
Error in adding Pushe unity plugin to my android app
When I want to add pushe unity plugin to my app I saw the following error.
Anybody know whats going wrong?
Failed to compile resources with the following parameters:
-bootclasspath ".../UNITY/android-sdk\platforms\android-21\android.jar" -d
"..\unity-sample-master\Temp\StagingArea\bin\classes" -source 1.6 -target 1.6 -encoding UTF-8
"co\ronash\pushe\Manifest.java"
"co\ronash\pushe\R.java"
"com\google \android\gms\Manifest.java"
"com\google\android\gms\R.java"
"com\google\android\gms \base\Manifest.java"
"com\google\android\gms\base\R.java"
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
3 warnings
UnityEditor.HostView:OnGUI()
|
It seems that your unity is using `java 1.6` for compiling your project.
According to my experience, unity 5 needs `java 1.8` or higher. This applies to most recent unity plugins which are built with recent versions of unity, including `Pushe plugin`.
So try changing the java version which your unity uses to `1.8` or above following below path:
Edit -> Preferences -> External tools
Hope it helps.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "android, unity3d, pushe"
}
|
FusedLocationProviderApi: how does LocationRequest.setPriority work with "Location mode" device setting?
Two questions:
1. How does setting `LocationRequest.setPriority(priority)` work with the "Location mode" device setting?
If application calls `LocationRequest.setPriority(PRIORITY_HIGH_ACCURACY)` is called and device setting is set to "Battery saving", I assume the application won't be able to use GPS?
,
Settings.Secure.LOCATION_MODE);
Check locationMode for possible return values.
if(locationMode == LOCATION_MODE_HIGH_ACCURACY) {
//request location updates
} else { //redirect user to settings page
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "android, android fusedlocation"
}
|
What happened to VaadinWebSecurityConfigurerAdapter in Vaadin 19?
We are building a web app with Vaadin 19 Fusion, and I'm following this tutorial: < (I have selected the V19+ Docs and then Fusion)
In the tutorial there is a reference to `VaadinWebSecurityConfigurerAdapter` which is used for setting up the security with Spring, but this class is not available on the classpath. I have tried downloading a plain starter project (v19) from start.vaadin.com, and here I am also not able to use `VaadinWebSecurityConfigurerAdapter`.
Is there an alternative in v19 or am I missing a dependency? I have the same dependency tree as the starter project, so I was assuming the pom is correct.
|
It looks like the `VaadinWebSecurityConfigurerAdapter` will end up in V20, which is scheduled for release in June.
The documentation page you linked has a tag `V20 pre-release` at the top. This could certainly be made more visible.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 3,
"tags": "vaadin, vaadin spring boot, hilla, vaadin fusion"
}
|
Speed up repeated operation via Caching
How does caching works with App Engine? Is it enough just to add the `@Cached` annotation:
@Cached
public class MyEntity {
@Id Long id;
...
}
However, from Objectify docs:
"Objectify's global cache support prior to v3.1 suffered from synchronization problems under contention. **Do not use it for entities which require transactional integrity** , and you are strongly advised to apply an expiration period to all cache values."
Does it mean that if I have a code that have this form below I should not use it?
DAOT.repeatInTransaction(new Transactable() {
@Override
public void run(DAOT daot)
{
Counter count = daot.ofy().find(Counter.class, COUNTER_ID);
count.increment();
daot.ofy().put(count);
}
});
|
Objectify tries as hard as it can to make its global cache support as transactional as possible:
> The cache in 3.1 has been rewritten from scratch to provide near-transactional consistency with the datastore.
If your request or task runs right up against the deadline limit, for example, there is a possibility that a write could make it to the datastore but not update the cache:
> The cache is near-transactional. Under normal operation, the cache will not go out of sync with the datastore, even under heavy contention. The exception to this is DeadlineExceededException at the 30s (10m for tasks) hard deadline. If Google kills your process before the cache update occurs, there's nothing we can do.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "java, google app engine, objectify"
}
|
Use GPS with Windows Mobile Phone
My question might sound really stupid but,
I would like to get longitude & latitude using only GPS on a Windows Mobile Phone 7( **OFFLINE - WITHOUT THE NEED FOR A WIFI CONNECTION** ).
Is that possible or GPS is always assisted by a webservice in Windows Mobile phones?
|
If you set `Accuracy` to `High` \- you will have location from a `GPS` sensor
In the normal case you don't need to worry about how location is achieved, `Location Service` on WP7 is doing all hard work for you.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": ".net, windows phone 7, geolocation, gps"
}
|
Read from PDF and display on console
I tried reading from PDF file and display it on console but it displays some weird characters not sure what is it. I need to read from PDF file and display it on the console. here is my code
public class JavaApplication14 {
public static void main(String[] args) throws FileNotFoundException, IOException {
FileReader fr = new FileReader("F:\\abc.pdf");
char[] temp = new char[10000];
fr.read(temp);
System.out.println(temp);
}
}
|
You need to use a library for properly reading PDF documents. iText and PDFBox are examples.
The weird output is because the content is binary: it also contains fonts, images, colors, metadata...
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -2,
"tags": "java, file, pdf, io"
}
|
what do I tweak to manipulate the gaps between bullets/numbers and list items?
Simple question - what part of my CSS do I tweak to adjust the gap between a bullet/number and the first text character in an HTML list?
Bonus question - I've seen it mentioned here that controlling table spacing by adjust padding on `table tr td {}` is bad practice, but I haven't seen someone explain how you're really supposed to do it...?
|
margin and padding should do it.
i see no reason why you can't have padding on a td. i do it and it works well. i think what people are moving towards now is a model of using divs and placing them like tables using css.
<html>
<style>
ul {}
li { padding:0 0 0 30px ;}
</style>
<body>
<ul>
<li>one</li>
<li>two</li>
</ul>
</body>
</html>
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "css"
}
|
Using Python telnet lib w/o logout command
I am trying to use python's telnetlib module to get information from a remote device. Unfortunately, it looks like the remote device does not have a "logout" type of command. So you have to manually close the connection with CTRL-] (when manually telnetting). I tried using Telnet.close() but doesn't seem to return any data.
Suggestions?
HOST = "172.16.7.37"
user = "Netcrypt"
password = "Netcrypt"
tn = telnetlib.Telnet(HOST)
tn.read_until("User: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("session \n")
print tn.read_until("NC_HOST> ")
tn.close()
|
Have you tried writing the ASCII character for _**`CTRL` +`]`**_ to the telnet connection?
`tn.write('\x1d')`
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "python, telnetlib"
}
|
Why node shebang works for Angular CLI but doesn't for my file?
Internet is telling me Windows doesn't support shebang lines but apparently Angular Cuses it and it works. Example of file that uses it and works on Windows: <
If I open CMD, navigate to directory with that file and run simply `ng`, Windows will recognise that it should be run with node and executes (I presume) `node ng`. But if I try that with my own file, it doesn't work. Example of such file:
#!/usr/bin/env node
'use strict';
console.log("logging test");
If I save that file as `test` and run it, I get `'test' is not recognized as an internal or external command, operable program or batch file.` Why is that so?
Output of `where ng`:
C:\Users\Dread\AppData\Roaming\npm\ng
C:\Users\Dread\AppData\Roaming\npm\ng.cmd
|
From your output of `where ng` it is clear what is happening.
Windows does not support shebang lines, so what you have read is correct. What Windows does support is file extensions and you do have an executable extension available.
You _do_ have `ng` but it is not being run directly. `ng.cmd` is almost certainly a batch file that runs `node ng`.
When you run `ng` Windows searched your path for all possible executable file formats (`exe`, `bat`, `cmd`, etc) and ran the first one that matched: `ng.cmd`.
If you want to run your script then you will have to either run it as an argument to `node`, i.e. `node test`, or create a `test.cmd` file that does the same.
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 1,
"tags": "windows, cmd.exe, shebang"
}
|
convert a pdf for print
I have some pdf documents and I need to find a way to automate convert all the images included in the pdfs from RGB to CMYK.
I prefer to use c# as programing language. I worked in the past with iTextSharp but it doesn't allow me to do this (it doesn't or I don't know).
The question is: what should I use to extract all the images from a pdf, convert from RGB to CMYK and put all the converted images back (no other changes).
Thanks.
|
PDF files using only CMYK colorspaces are sometimes called PDF/X. If a commercial library is an option for you, you could give Amyuni PDF Converter a try. There is a web post called "Creating PDF/X-1 or PDF/X-3 with Amyuni PDF Converter" that explains the process you would need to apply: .
_Usual dislcaimer applies_
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 2,
"tags": "c#, pdf, image conversion"
}
|
Bin deploy rake (and IronRuby)
I'm on a .NET project, and I would like to migrate build script from MsBuild to Rake. I don't want to force developers (or build agent machines) to have to install anything, I want it to be self contained. If possible I'd prefer to use IronRuby.
Is it possible to just drop everything in /tools/rake and /tools/IronRuby and have it just work, the way everyone does with NAnt?
I would appreciate any pointers to tutorials on this or blogposts. I'm a complete noob when it comes to Ruby, rake and these gem things.
|
Yes it is possible, but you pay the cost of bringing the IronRuby runtime with you. That's about 2300 files to deploy so you'd need to pack 7zip with your lib to unpack IronRuby.
I did something similar where I wanted to pack LessCss with IronRuby in one managed wrapper. Turned out to be a totally impracticable solution:
<
greetings Daniel
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": ".net, build process, rake, ironruby"
}
|
Change combobox list to clear option
I've got combobox which is non editable with dropdownlist style. By deafult is blank when I open a form. When user choose an option of list and click button I want to set it back to non option position. How I can do that ?
|
Add the following line in your button click event. This will change the selected index of your combobox to -1 which will display nothing (blank).
comboBox1.SelectedIndex = -1;
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, wpf"
}
|
Efficient way of Writing algorithm
I was wondering when some one asks you to solve an algorithmic problem, is it a good way to actually start off with Hastable, Hashset or HashMap. Normally i have heard people saying you shouldn't come up with Hashes as your first answer.
So how should we go about in algorithms: In-place should be given importance or make sure time complexity is best
I'm not trying to generalise, but still some suggestions would be helpful.
Thanks
|
The best you can hope for is a generalized answer for your generalized question.
It depends.
The reason there are many different algorithms is because there is not always 1 algorithm that is the best. And many algorithms aim to solve different problems from each other. Some algorithms it makes no sense to even talk about hash tables.
If someone asks me to solve an algorithmic problem though, I will probably try to use something that is built in to the language I'm using before designing my own algorithm. The reason is because I value my time. If I find later that the code is not efficient enough, then I can look for a better way to do it.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "algorithm"
}
|
Get execution time from log using bash
I have some application that produce log file and at the end of file I have total processing time like:
> Processing done in 45.00031 sec
I can get this line using:
cat app.log | grep "Processing done in"
But how to parse string to get only number of seconds?
> 45.00031
|
If the pattern is set you can just use `cut` to select the 4th field from a space-delimited table:
cat app.log | grep "Processing done in" | cut -d " " -f 4
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "bash, logging"
}
|
How can I convert an Int to a CString?
I can convert a `Double` to a `CString` using `_ecvt`
result_str=_ecvt(int,15,&decimal,&sign);
So, is there a method like the one above that converts an `int` to `CString`?
|
Here's one way:
CString str;
str.Format("%d", 5);
In your case, try `_T("%d")` or `L"%d"` rather than `"%d"`
|
stackexchange-stackoverflow
|
{
"answer_score": 76,
"question_score": 32,
"tags": "c++, visual c++, mfc"
}
|
UI Components for Windows Mobile Applications (.NET Compact Framework)
Applications which run on mobile devices have special user interface requirements. I think Apple did a great job introducing innovative controls on the iPhone/iPod touch platform.
Now, I have to design an application for the Windows Mobile platform using the .NET Compact Framework (Visual Studio 2008). I wonder if there are some commercial or open source UI control sets available which are similar to the iPhone / iPod touch UI elements:
* Scrolling panels based on gestures
* Instead of a dropdownlist: a new panel with a large list of items
* Sliding panels
* _etc._
I couldn't find any useful products/code. Maybe there is somebody out there with more experience who could help.
|
A few months ago, I searched and found nothing (satisfactory). I had to implement my own control library. Lack of good existing "touch-aware" libraries makes me think I should commercialize mine, but it's very incomplete.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 13,
"tags": "windows mobile, compact framework, controls, user interface"
}
|
Add selector to object already stored in variable
I'm new to jQuery, apologies if my vocabulary is wrong, please correct me so I can learn the right way.
I'm attempting to use best practices for optimized performance. I've been told to store static objects in a variable when possible. I'm trying to store the parent object #mytable, then navigate down into child objects from there.
var count=1;
$('#eachselector').each(function(){
var MyTable = $('#mytable'+count);
$(MyTable+' td[condition=true][condition2=true]').attr('do', 'stuff');
$(MyTable+' table[condition=true][condition2=true]').attr('do', 'stuff');
count++;
});
This gives me the error "uncaught exception: Syntax error, unrecognized expression: [object Object]".
I suspect that I'm treating MyTable as a string when called inside of the each() but not sure what the syntax should look like.
Thanks!
|
Use this instead:
var MyTable = $('#mytable'+count);
MyTable.find('td[condition=true][condition2=true]').attr('do', 'stuff');
MyTable.find('table[condition=true][condition2=true]').attr('do', 'stuff');
This uses jQuery's `.find()` function to search the descendants of `$('#mytable'+count)`. The reason your code isn't working is that `MyTable` is a jQuery object not a string.
You could also use `$('selector', MyTable)` but internally it just maps to the `.find()` function.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 0,
"tags": "jquery, variables, object, syntax"
}
|
How does one invoke the MiKTeX port of "mft"?
I can see that MiKTeX 2.9 (of which I use the "Portable" version) has an executable for "`mft`", which (if run with no arguments) will crash and print:
Usage: mft inputfile changefile stylefile outputfile. (l.0)
I cant't find any other documentation, besides a brief one-line summary of the purpose of mft. This is the most I can get it to do:
E:\home\tex\metafont>touch null.ch
E:\home\tex\metafont>mft modes.mf null.ch \Tools\miktex-2.9\mft\plain.mft modes.tex
This is MFT, Version 2.0 (MiKTeX 2.9)
mft: Read operation failed.
Judging by the output of SysInternals' procmon tool, it looks like it must be objecting to "`null.ch`" being empty, but I haven't the foggiest idea why it demands such a file :-(. Any clues??
|
In general these more "exotic" (old) tools expects in miktex exactly the arguments they mention. I could run mft with the command line
mft script10.mf test.ch plain.mft script10.tex
test.ch is a text file with only a percentchar (%) as content (I minimized an existing ch-file). plain.mft I found on CTAN.
The output is a plainTeX-file. It doesn't have a \bye at the end (this is probably intended to that you can input it in another document), but apart from this one can compile it with pdftex.
|
stackexchange-tex
|
{
"answer_score": 2,
"question_score": 1,
"tags": "miktex, metafont"
}
|
How can I force a form action to use an absolute URL?
I am using the following form on my website staticmantest.github.io:
`<form class="js-form form" method="post" action="104.131.76.120:8080/v2/entry/StaticManTest/StaticManTest.github.io/master/reviews"> `
I intend a `POST` request to be sent to `104.131.76.120:8080/v2/entry/StaticManTest/StaticManTest.github.io/master/reviews`. However, instead it is being sent to ` What can I do to force this form action to be an absolute path?
|
Prefix you URL with
http://
so that it's
Otherwise it's treated as a relative URL.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 0,
"tags": "html"
}
|
Cropping images with no loss using .NET
I am trying to understand why after cropping an image in .NET i end up with an image 3 times the size of the original image. Listed below is the code i am using to crop the image
Private Shared Function CropImage(ByVal img As Image, ByVal cropArea As Rectangle) As Image
Dim bmpImage As Bitmap = New Bitmap(img)
Dim bmpCrop As Bitmap = bmpImage.Clone(cropArea, img.PixelFormat)
Return CType(bmpCrop, Image)
End Function
where img is the original image loaded from file into an image object.
How can i achieve a loss less cropping of my image?
|
Take a look at the second answer to this question:
High Quality Image Scaling Library
That code should help. The problem is that the .NET image handling library defaults the `System.Drawing.Imaging.Encoder.Quality` setting to 100%, which is literally three times the size of 90%, which has no visible difference in quality. Use the code in that question to save your image at lower quality settings and you should see a big difference in the size of your file.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": ".net, image, crop"
}
|
Why does YouTube API take so long to respond?
I use youtube API to get tags of 1 video in my android project. However, the server's response time is too long (about 30 seconds). Chrome loads the youtube API in just 1 second. I tried using another API on my project and the response time was only about 1 second. Please show me the reason and solution if possible?
<
{
thresholdVal <- 20
dFrame[dFrame >= thresholdVal] <- -1
return(dFrame)
}
Here is a dataframe example:
example_df <- data.frame(
myNums = c (1:5),
myChars = c("A","B","C","D","E"),
stringsAsFactors = FALSE
)
Thanks for the help!
|
Using `data.table`, we can avoid explicit loops and is faster. Here I've set the threshold value as 2:
# set to data table
setDT(example_df)
# get numeric columns
num_cols <- names(example_df)[sapply(example_df, is.numeric)]
# loop over all columns at once
example_df[,(num_cols) := lapply(.SD, function(x) ifelse(x>2,-1, x)), .SDcols=num_cols]
print(example_df)
myNums myChars
1: 1 A
2: 2 B
3: -1 C
4: -1 D
5: -1 E
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "r, dataframe"
}
|
Touch ID API - using just the PIN for non-touch ID phones?
Been searching around for this, but can't seem to find an appropriate answer. Currently I have a system in my app in place to opt for a PIN to enter the app. I'd like to incorporate Touch ID instead, but can't figure out what to do for non-Touch ID phones.
Question: Can we use the Touch ID API to request the user enter their phone PIN to enter the app for those who do not have the Touch ID hardware?
|
The following code is to to test if we can evaluate the policy, this test will tell us if Touch ID is available and enrolled. If `NO` you can use your own PIN view for authorization.
LAContext *context = [[LAContext alloc] init];
NSError *error;
BOOL test = [context canEvaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error];
if (test) {
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"For some reasons" reply:^(BOOL success, NSError *error) {
if (success) {
// authorized successfully
}
}];
} else {
NSLog(@"%@", error);
// use a pin code
}
As I have tried, you can't access to the built-in PIN and need to use a custom view instead.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "ios, iphone, ios8, touch id"
}
|
cakephp, how to store variables to be reusable inside another functions?
i have a controller with multiple functions that have a variable inside them. I would like to access those variables from another function. Any ideas?
class RoomsController extends AppController {
public $helpers = array('Js' => 'Jquery');
public $components = array('RequestHandler');
function test1(){
$balcony = $_REQUEST['qwe'];
$this->set('qwe',$qwe);
}
function test2() {
$occy = $_REQUEST['wer'];
$this->set('wer',$wer);
}
function test3() {
$deck = $_REQUEST['ert'];
$this->set('ert',$ert);
}
function success() {
// i want to use $qwe, $wer and $ert here
}
any ideas on how to do this? do i have to set up global variables `public $qwe;`?
thanks
|
You can create controller properties but it will break the design of the framework, so I suggest using Configuration class for this purpose, you can store variable values and retrieve using this class, here's a documentation:
<
You can store variables in Session if you need their values after redirect:
$this -> Session -> write("variable", "value");
and retrieve:
$this -> Session -> read("variable");
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "php, cakephp 1.3"
}
|
RegionMember with some tolerance?
Can I specify some tolerance for the new geometric-computation function?
RegionMember[Line[{{0, 0}, {1, 0}}], {.5, 0}]
(* True *)
While:
RegionMember[Line[{{0, 0}, {1, 10^-100}}], {.5, 0}]
(* False *)
RegionMember[Line[{{0, 0}, {1, 10.^-100}}], {.5, 0}]
(* True *)
RegionMember[Line[{{0, 0}, {1, 10.^-7}}], {.5, 0}]
(* False *)
|
There's `Internal`$EqualTolerance`. See How to make the computer consider two numbers equal up to a certain precision and its reference.
Block[{Internal`$EqualTolerance = 9.},
RegionMember[Line[{{0, 0}, {1, 10.^-7}}], {.5, 0}]
]
(* True *)
It's a relative tolerance, whereas gpap's & kguler's answers give absolute ones. The setting above, which is roughly equivalent to `Internal`$EqualTolerance = $MachinePrecision - 7`, says approximate numbers that agree to seven digits (or differ in at most the last nine) are to be considered equal.
Block[{Internal`$EqualTolerance = $MachinePrecision - 7},
{1. + 1.0000001*^-7 == 1, 1. + 1*^-7 == 1}
]
(* {False, True} *)
|
stackexchange-mathematica
|
{
"answer_score": 4,
"question_score": 6,
"tags": "numerics, regions, expression test"
}
|
Windows CE project with libraries problem
I am developing a Windows CE application which uses some libraries provided by other parts of our company.
When I deploy my application on "My Computer" (.NET compact application running on standard PC), everything works, but when I deploy to the device, the application hangs when trying to use methods from the library. The system also hangs. My Visual Studio 2008 sometime hangs, but sometime throws an exception "TypeLoadException: Could not load type from assembly Culture=neutral, PublicKeyToken=nu".
I couldn't include .NET Compact framework 3.5 because the image wouldn't compile, so I am using version 2.0. I use Visual Studio 2008 with deploy .NET framework option.
|
Most probably the problem is with version of the library you are using. Please cross check it.
Hope this link will help you.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "debugging, windows ce, libraries"
}
|
What causes a parent container to cut off content in child element?
On Mac Safari and Chrome, this dark select box appears correctly:
!enter image description here
In iOS Safari, it gets cut off at the border of the selected div:
!enter image description here
What could make that happen? Here are the styles of the selected parent:
!enter image description here
and on the select box:
!enter image description here
|
One of the parents of the select box had overflow-y hidden.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 3,
"tags": "css, uiwebview, mobile safari"
}
|
Update Azure Staging deployment will create new url
I am using cloud service for my web application currently it is in development phase. My all updated code is on staging environment, I have create staging server on May 13, 2012. Now from last two days my data is rolled back to May 13, 2013 means my server either restart or upgraded. I am using Visual Studio 2010 publish tool to upload my data. I want to know how can I upload my latest code so on roll back latest code remains on new server instance. Also I don't want to regenerate my staging url because we are using this in our other services so its not possible to change that url frequently.
|
The filesystem in your approot is non-persistent. Dynamically created files being deleted on rollback, update or duplication of a roleinstance.
Do you use Web Deploy to publish your changes? If so, your approot is just dynamically changed and changes get cleared on rollback.
If you do not want to lose your development-progress, you have to create a new package and update your whole role-instance.
"Also I don't want to regenerate my staging url" What do you mean with that? If you create a cloudservice you get a unique url for your staging enviroment, that does not change as long as you dont delete your enviroment!?
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "c#, visual studio 2010, azure, windows server 2008, azure storage"
}
|
How to deploy redhat decision central on tomcat
I am new to Redhat and trying to deploy Redhat decision manager( decision central) V7.2 on tomcat server(v 8).As per online help I don't see any documentation to deploy decision central on tomcat. Please let me know if anyone has tried it before?
|
Red Had Decision Manager is not supported for Tomcat. Only Kie Server can be used with Tomcat.
See Red Hat Decision Manager 7 Supported Configurations and anchor [5] near different servers for more details.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "drools, redhat, redhat brms, redhat bpm"
}
|
Replace the subsetted and modified data back into the main dataframe
I have a data frame with 20 rows, I randomly select `n` rows and modify them. How can I put the modified value back to the original data frame with only the modified value being different?
df<- data.frame(rnorm(n = 20, mean = 0, sd = 1))
n = 8
a<- data.frame(df[ c(1, sample(2:(nrow(df)-1), n), nrow(df) ), ])
a$changedvalue <- a[,1]*(2.5)
Now I want to replace the values of the original dataframe `df` with the values of `a$changedvalue` such that only the sampled values are changed while everything else is same in `df`. I tried doing something like this but it's not working.
df %>% a[order(as.numeric(rownames(a))),]
I just want to point out that in my original dataset the data are timeseries data, so maybe they can be used for the purpose.
|
Instead of writing `data.frame(df[ c(1, sample(2:(nrow(df)-1), n), nrow(df) ), ])`
You can define the rows you want to use, lets call it `rows`
`rows <- c(1, sample(2:(nrow(df)-1), n), nrow(df) )`
Now you can do
a<- data.frame(df[rows, ])
a$changedvalue <- a[,1]*(2.5)
df[rows, ] <- a$changedvalue
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "r, dataframe, sampling"
}
|
Freeform handwriting on iOS
I would like to put handwriting as a text input to my project.
Is there any existing code or libraries that will help me accomplish this? If not, is there an iPhone 4 has handwriting option like the chinese keyboard, which has handwriting tools, but in English?
As I did some research, I couldn't find anything, maybe I'm just looking in the wrong places? Can somebody help me?
If possible, I would like the input delay to be less than a second, but a half of a second would be preferable.
|
There is no handwriting recognition for the english language on iOS. As for the delay - that's because the system needs to make calculations for the recognition - so no, there's nothing you can do about it.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "iphone, ocr, textinput, handwriting"
}
|
Block attachment files without extensions in Postfix via mime_header_checks?
We know how to reject executables and other potentially dangerous file extensions via mime_header_checks directive:
mime_header_checks = regexp:/etc/postfix/mime_header_checks (main.cf)
/name=[^>]*\.(bat|com|exe|dll|vbs)/ REJECT (mime_header_checks)
This way bat,com,exe,dll,vbs are gone. But, since there's OS's that treats extensionless files like executables, it came to my mind that these should be blocked also.
How to have that/what would be regexp to match these files along with known executables?
|
How about adding
/name="[^>]*[^.]{7}"/ REJECT
It will match if there is dot anywhere else than for separating the (max. 4 character) extension
* NAME="=?ISO-8859-1?Q?document?="
* NAME="=?ISO-8859-1?Q?doc.ument?="
but won´t match
* NAME="=?ISO-8859-1?Q?document.pdf?="
* NAME="=?ISO-8859-1?Q?document.xlsx?="
Just add to number "{7}" if you wish to allow longer extensions.
|
stackexchange-serverfault
|
{
"answer_score": 2,
"question_score": 1,
"tags": "postfix, regex, anti virus"
}
|
SQL to find the number of rows per table in a database
My goal is to create a spreadsheet of all the tables in the current database that will display the table name and the number of rows in each table. A bonus would be to also be able to display when anything was last entered or changed in the table. I'm not sure if the last part is possible though.
This is what I have so far... its nothing much but I just can't beat my head around how to add the per table row count to it.
SELECT name, type, type_desc
FROM [scheme].sys.all_objects
WHERE type = 'U'
|
You can use this query against the system catalog views:
SELECT
t.NAME AS TableName,
p.rows AS RowCounts
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
WHERE
t.NAME NOT LIKE 'dt%'
AND t.is_ms_shipped = 0
AND i.OBJECT_ID > 255
GROUP BY
t.Name, p.Rows
ORDER BY
t.Name
to get the desired result - all tables in the current database, and the number of rows in each.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "sql server 2012, rowcount"
}
|
RIA Services - Two entity models share an entity name
I have two entity models hooked up to two different databases. However, the two databases both have a table named 'brand', for example. As such, there is a naming conflict in my models. Now, I've been able to add a namespace to each model, via Custom Tool Namespace in the model's properties, but the generated code in my Silverlight project will try to use both namespaces, and come up with this,
Imports MyProject.ModelA
Imports MyProject.ModelB
Public ReadOnly Property brands() As EntitySet(Of brand)
Get
Return MyBase.EntityContainer.GetEntitySet(Of brand)
End Get
End Property
giving me this exception:
'Error 1 'brand' is ambiguous, imported from the namespaces or types 'MyProject.ModelA,MyProject.ModelB'.
Has anyone had experience with naming conflicts like this using RIA services? How did you solve it?
|
Found the solution.
Unload the client (Silverlight) project.
Right click the unloaded project and edit the .csproj or .vbproj file.
Add `<RiaClientUseFullTypeNames>true</RiaClientUseFullTypeNames>` inside the `<PropertyGroup>` tag
Reload project. Do a full rebuild.
Now the generated code will use full type names (i.e., MyProject.ModelA.brand)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "silverlight, entity framework, namespaces, wcf ria services"
}
|
Powershell update on windows server having SP 2010
Can we upgrade the Powershell to the latest version on Windows server 2008R2 standard hosting a SharePoint 2010 farm ?
Will the farm have any impact?
Does it require any prerequisites before upgrading the PowerShell? The current version is 2.0
|
Yes, you can freely update it to the latest supported version. SharePoint 2010 will continue using the .NET 2.0 framework. In addition, your SharePoint Management Shell shortcut must have `-Version 2.0` tacked onto the run line in order to function. Any PowerShell window you open that needs access to SharePoint cmdlets/SSOM must also have `-Version 2.0` as a start switch.
|
stackexchange-sharepoint
|
{
"answer_score": 2,
"question_score": 2,
"tags": "sharepoint server, powershell, windows server 2008 r2"
}
|
Visualize character glyph in Pages application
Is it possible to visualize a particular character (even if it's a special one) in a Pages document ? (I need it for a third-party doc I'm using, to know if certains spaces are just spaces, tabs or something else, and also to get the Unicode value of some exotic characters). All I see in the right bar or the Show Fonts windows is the "style" info but not the glyph itself.
|
You should be able to use the app UnicodeChecker for this
|
stackexchange-apple
|
{
"answer_score": 1,
"question_score": 1,
"tags": "keyboard, text, text editor"
}
|
How to make SONY NEX F3 pictures display the date it was taken at the bottom right corner?
Is there a way to make SONY NEX F3 pictures display the date it was taken?
|
According to the camera manual, Sony NEX F3 does not have a feature for superimposing dates on images. By using “PlayMemories Home” on the CD-ROM (supplied), you can print or save images with the date.
|
stackexchange-photo
|
{
"answer_score": 1,
"question_score": 1,
"tags": "sony, display"
}
|
iOS - Change UISwitch button color and resize it
I would like to change a UISwitch' button color - not the background color.
I know about "tintColor" and "onTintColor", they work very well.

vlgaBuffer = vlgaStream.readlines()
vlgaStream.close()
But need a way to directly and efficiently read all of the lines from a file into a buffer?
|
Iterating over a file yields lines.
with open('vlgaChcWaves.txt', 'r+') as vlgaStream:
for line in vlgaStream:
dosomethingwith(line)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -2,
"tags": "python"
}
|
How do I put "tomato" in dialog when stressing the alternate pronouciation?
I want to have a character say "potato tomato" as a joke, stressing the tomahto pronunciation. How should I write this?
"Potato _tomahto_." ?
|
"Look here!" he spit through his teeth, red-faced, "You can't say 'Toe-MAH-toe' and expect to be treated like a local! Have you even heard all these ladies yammering over at the produce aisle?" At this point, there was no hope of remaining discreet. I just stared blankly back at him, waiting for the show to end. "They all said it like they were born here. Like _you_ were supposed to have been!"
"Toe-MAY-toe?"
"By God man! Not at all! Has your tongue been... Open up your mouth! Go ahead, I want to check if you have brought all your equipment. Is there a tongue in there?" He said this... tongue-in-cheek, I assumed. "Toe-MAH-toe! Go ahead, say it again!"
"Toe-MAH-toe?"
"Oh by the SAINTS you have done it man!!!" He wrangled me by my shoulders. "Soon we will be going into what that thing on the back of your car is again, and you'll blend right in."
"Oh, " I raised my finger as this reminded me, "We need to get some gas."
"PETROL! My... Oh, get in the car!"
|
stackexchange-writers
|
{
"answer_score": 1,
"question_score": 1,
"tags": "formatting"
}
|
A hard integral
Looking for a solution for an integral: $$I(k)=\int_0^{\infty } \frac{e^{-\frac{(\log (u)-k)^2}{2 s^2}}}{\sqrt{2 \pi } s \left(1+u\right)} \, du .$$ So far I tried substitutions and by parts to no avail.
|
The change of variable $v = \log u$ shows that you're trying to integrate the **logistic-normal integral**.
$$\int_{-\infty}^{\infty} \frac{e^{-\frac{1}{2}\left(\frac{v-k}{s}\right)^2}}{\sqrt{2\pi} s} \frac{1}{1+e^{-v}}~\mathrm{d}v$$
I doubt there is a closed form solution, and none seems known.
See for the approximation
$$\left|I(s,k)- \frac{1}{1+e^{-\frac{k}{\sqrt{1+\frac{\pi s^2}{8}}}}}\right| < 0.02$$
and < for a deeper discussion.
|
stackexchange-math
|
{
"answer_score": 8,
"question_score": 8,
"tags": "calculus, probability distributions, definite integrals, normal distribution, gamma function"
}
|
C language syntax: if { ... } while(0);
I am looking at < and I see from lines 608-713:
if (source.sin_addr.s_addr == 0) {
... // Omitted
} while(0);
Two questions:
1. How it compiles
2. What is the value of adding `while (0)` after if statement
|
It's two statements in succession. Entirely equivalent to this
if(/* ... */) {
// Body
}
while(0) {
// empty
}
`while(0);` is just a loop with a single empty statement for a body.
There is no value in adding it after the `if`. I suspect it's leftover from a previous refactoring, but the git history in that repository does not go that far.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 3,
"tags": "c"
}
|
I'm using Windows 10 why does this note appear when installing SQL Server 2017?
I'm trying to install SQL Server 2017 on Windows 10, when this note appears:
> Your operating system is not supported by SQL Server 2017
sql-server 2017 edition download
|
According to official documentation:
"Windows client operating systems, for example Windows 10 and Windows 8.1 are available as 32-bit or 64-bit architectures. All SQL Server features are supported on 64-bit client operating systems."
That is, not all SQL Server features will be availabl in 32-bit architectures.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sql server, windows 10, sql server 2017"
}
|
What does this graph mean?
Mathematica 11.3.0 includes a new command `FindEquationalProof` having good prospects. Studying it, I consider a somewhat modified example from the help
grouptheory = {ForAll[{a, b, c}, g[a, g[b, c]] == g[g[a, b], c]], ForAll[a, g[a, e] == a],
ForAll[a, g[a, inv[a]] == e], ForAll[a, g[a, a] == e]}
, where the assumption `ForAll[a, g[a, a] == e]` that each element of a group has order two is added. I try to prove that such group is Abelian by
proof = FindEquationalProof[ForAll[{a, b}, g[a, b] == g[b, a]], grouptheory]
and succeed at this proof. Nice. Next, I visualize the obtained proof by
proof["ProofGraph"]
 arrows appear to be used with substitution lemmas and show where the substitution comes from. It will be substituted into the branch coming from the dashed arrow.
|
stackexchange-mathematica
|
{
"answer_score": 3,
"question_score": 4,
"tags": "documentation, group theory, proof"
}
|
Validating API Gateway's HTTP API incoming payloads
Is it possible for AWS API Gateway to validate an HTTP API's incoming payloads before it executes the Lambda function, saving the expense of calling a Lambda function when the input is invalid?
I'm aware that the older REST API's can have their input validated by API Gateway, but I'm using HTTP APIs because they are lighter and **71% less expensive** and fit my needs very well.
Any suggestions/workarounds very welcome.
|
No its **not possible**. Only REST api support validation:
 "Test "
2) " String"
3) "Test string"
4) " Content"
5) "Test String Content"
Where in case of Method 1 just one string shall be created
1) "Test string Content"
Method 1 is should be preferred among these two methods
`StringBuilder` class is more efficient when you need to build a string that involves combining many string values.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "c#, string, string concatenation"
}
|
Optimizing Searchkick in Rails 4
I'm using ES and Searchkick gem to handle searches in my Rails app. I'm currently doing:
class Paper < ActiveRecord::Base
belongs_to :report
belongs_to :user
before_destroy :delete_dependant_papers
searchkick word_start: [:realname]
end
This works great but it is unnecessarily indexing every column. I want it to index only the "realname" column.
I then came across `search_data` in the Searchkick GitHub page. This allows me to index only certain columns:
class Product < ActiveRecord::Base
def search_data
as_json only: [:name, :active]
# or equivalently
{
name: name,
active: active
}
end
end
How would I combine both of these? So that only 1 column is indexed with realname and word_start?
|
`search_data` method will let you index `realname`, and `word_start` will let you partially match your data. So your model need to look like this:
class Paper < ActiveRecord::Base
belongs_to :report
belongs_to :user
before_destroy :delete_dependant_papers
searchkick word_start: [:realname]
def search_data
as_json only: [:realname]
end
end
You need to call `Paper.reindex` in your console after changing `search_data` method.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ruby on rails, ruby, elasticsearch, searchkick"
}
|
Mootools - set type="text" to an input that has type="password" does not work in IE8
I have the following Mootools code, to add a value on focus/blur in a password field:
$$('#connect_login_box #password-element > input').set('value','Password').set('type', 'text').addEvents({
focus: function(){
if (this.value=='Password') this.set('type', 'password').addClass('input_active').value=''; },
blur: function(){
if (this.value=='') this.set('type', 'text').removeClass('input_active').value='Password'; }
This code does not work in IE8, and it breaks all the other JS on the page. I am pretty sure that the error is produced when it gets to set('type', 'text')
Any idea how can I fix this?
Thanks!
|
You can't change the type of an input element once it has been set.
Remove the input element and create a new one to replace it.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, passwords, mootools"
}
|
Excel: Is it possible to copy cells only if cells match in other columns?
If it's an EXACT duplicate, not just some answer that MAY suggest an answer then please provide the link in a comment.
Say, I have dates in column A of Sheet-1, and also dates in column A of Sheet-2. the problem is that Sheet-2 misses some dates.
Sheet-1
A1:2015-06-24 B1:34
A2:2015-06-23 B2:29
A3:2015-06-22 B3:56
A4:2015-06-21 B4:88
Sheet-2
A1:2015-06-23 B1:29
A2:2015-06-21 B2:88
I need to copy B(sheet-1) to sheet 2 only if a cell in A sheet-1 matches a cell in A sheet-2. So I just want to copy B2 and B4 from sheet-1 and place them in Sheet-2 as B1 and B2.
Is it possible?
I was trying to modify this formula:
=IF($A1=Sheet1!$A1, VLOOKUP(Sheet1!$A1, Sheet1!$A1:$D1, 2),"")
Yet unsuccessfully, from this stackoverflow question
|
=INDEX(Sheet1!B:B,MATCH($A1,Sheet1!A:A,0))
should do the trick. It's a very basic use of INDEX/MATCH (or VLOOKUP). Try to google one of those keywords you will find beginner tutorials
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 1,
"tags": "microsoft excel, worksheet function"
}
|
Burninate [javahelp]
javahelp. Why does this tag exist? It seems totally inappropriate to have a tag for language help...
|
Yes, you need to explain this. javahelp is not a tag used by people asking for help in Java, it's "an online help system that developers can use to add online help to their Java platform applications." (Source)
As such, it is a software tool used by programmers. It doesn't really matter how many questions it is, it seems to be on-topic.
|
stackexchange-meta_stackoverflow
|
{
"answer_score": 9,
"question_score": -2,
"tags": "discussion, status declined, burninate request"
}
|
Есть ли готовые библиотеки календаря для telegram bot реализованные на php?
Возможно кому то встречались готовые решения(библиотеки) подобные этой < написанные на php Буду очень благодарен за любую информацию
|
github.com/miserenkov/telegram-bot-calendar
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, telegram bot"
}
|
Adding a Back Button on A Table View Controller
I am interested in implementing a back button to segue to a previous view controller. I have tried to embed a navigation bar onto the the top of the table view controller but the issue is when I do segue back to the first view controller, by default, Xcode keeps the navigation bar with a back button to go back to the table view controller. Is there a simpler way to implement a segue to go back to the first VC without the navigation bar remaining? , add the line of code inside your `viewDidLoad` method.
Swift 3:
self.navigationController?.navigationBar.isHidden = true
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "ios, swift, tableview, segue"
}
|
Pinch to lock iPhone
I've been having issues with my iPhone 5's lock button recently, I'm having to press it more forcefully to get it to work. Then I saw this video and got to a part where the person does a pinch gesture to lock his phone.
Is this a feature to iPhone 5S only or can this be unlocked through some set up in accessibility?
|
It's a custom gesture set up on the jailbroken iPhone. Pinch to lock is not a feature available in Accessibility or any other method on a non-jailbroken phone.
The gesture can be set up using a tweak such as Activator. Go to Settings → Activator → On Lock Screen → Icon Pinch → Lock Device to set it up.
|
stackexchange-apple
|
{
"answer_score": 1,
"question_score": 0,
"tags": "iphone, multi touch"
}
|
Cookieの使用に関する同意をとるサイトが増えたのはなぜでしょうか
WEBCookie
()
CookieP3P
|
2018525EU ( GDPR) EU GDPR
201611EUGDPRiEEA iiEEA EEA GDPR
※
|
stackexchange-ja_stackoverflow
|
{
"answer_score": 5,
"question_score": 7,
"tags": "cookie"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.