INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Dart RegExp, How can I change the pattern?
This is example code
RegExp exp = new RegExp(r"(\w+)");
String str = "Parse my string";
Iterable<RegExpMatch> matches = exp.allMatches(str);
What I want to do: Change the pattern after use
RegExp exp = RegExp(r"(\w+)");
String str = "Parse my string";
Iterable<RegExpMatch> matches = exp.allMatches(str);
exp.pattern = r'^XXX';
How can i do like?
|
You cannot change the pattern of a `RegExp` after it has been created. Dart `RegExp` objects are immutable.
You can, as already commented, create a new and different `RegExp` and assign it to the `exp` variable: `exp = RegExp(r"^XXX");`. Or you can assign it to a different variable.
It's unclear what problem you are actually trying to solve.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "regex, dart"
}
|
Not able to see localized images in iPhone simulator
I have an existing working iPhone project inside XCode 4.2. I localized an image (which is used on a button) and I always see the old version of it inside the iPhone simulator. Where does it find that old version?
What I've done:
1. Window -> Organizer -> Project -> Delete Derived Data
2. Product -> Clean
3. Inside the IPhone simulator, I tried resetting it.
4. I tried deleting the project and recreating it (from SVN)
5. I deleted everything in Library->Developer->Xcode, Library->Delveoper->Application Support->iPhone simulator, Library->Developer->Application->Interface Builder 3.0
And I still see the old version... Is it compiled somewhere inside the interface builder with the button or something like that? Weird... really weird.
Note: I'm able to localize an image button if I add a new image, but using old existing image is always showing me the old version.
|
**Solution :** My project contained images like [email protected] (for IPad I guess). By also localizing those + clean + build + reset IPhone Sim settings, it worked. Go figure.
Also, when I add another language for the @2x images, I have to manually add the image in the other xx.lproj (where XX is the language code) with the finder because somehow XCode doesn't it.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "ios, xcode, interface builder"
}
|
How to access NodePort without public IP of Node in AKS?
According to the official document of Azure Kubernetes Service (AKS), `AKS nodes don't require their own public IP addresses for communication.` So, is AKS ignoring the fact that we need the public IP address of the node to access the Kubernetes NodePort service? We can of course add the public IP of the node anyway( as stated in the document). But my concern is it seems enabling the public IP of a node is not the recommended way as per the document, so any alternative to use NodePort besides enabling the public IP of the node?
|
`AKS nodes don't require their own public IP addresses for communication.`
Correct, worker nodes communicate with each other using the instance private IP, rather than making round trips to the public network.
`...is AKS ignoring the fact that we need the public IP address of the node to access the Kubernetes NodePort service?`
You don't need public IP unless you want the NodePort to be accessible on the public network. Also, VM(s) within the same VNET can still access the NodePort using the VM private IP instead of public IP.
`...any alternative to use NodePort besides enabling the public IP of the node?`
Use `type: LoadBalancer`.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "kubernetes, azure aks"
}
|
Can CSHTML files run directly?
I'm just started asp.net using Razor V2 syntax. While I'm developing in Visual Studio, everything is fine however when i try to run .CSHTML files directly from browser, they do not work.
I want to know are .CSHTML files are intended to run directly or they must be used in other segments of web applications which can not be called by browser directly?
|
Yes - cshtml pages can be run directly. If you build an ASP.NET Web Pages (Razor) site, you can request .cshtml pages directly and they will be served (unless the file name starts with an underscore).
You can build a Razor Web Pages site by going to File » New » Web Site. You can get more information about ASP.NET Web Pages from here: < It is the recommended starting point for people who are new to ASP.NET development.
**[UPDATE]** They can also be run directly when used as part of a Razor Pages site which was introduced in ASP.NET Core 2.0.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 2,
"tags": "c#, asp.net, razor"
}
|
Differences between Assert.True and Assert.IsTrue in NUnit?
Is there any differences between those two?
|
No difference. `Assert.True()` and others (without `Is`) were added since v2.5.
From documentation for the version `2.5`: (nunit v2.5)
> Two forms are provided for the True, False, Null and NotNull conditions. The "Is" forms are compatible with earlier versions of the NUnit framework, while those without "Is" are provided for compatibility with NUnitLite
BTW, Disassembled nunit.framework.dll (using ILSPY)
public static void IsTrue(bool condition)
{
Assert.That(condition, Is.True, null, null);
}
public static void True(bool condition)
{
Assert.That(condition, Is.True, null, null);
}
|
stackexchange-stackoverflow
|
{
"answer_score": 57,
"question_score": 48,
"tags": "nunit, assert"
}
|
PHPUnit Test with host/useragent which defined in config.yml
I want to define the Test-Client useragent and hostname in my config.yml.
At the moment I use the same things in each configuration:
$client = static::createClient();
$container = $client->getContainer();
$client->setServerParameters(
array(
'HTTP_HOST' => 'Test',
'HTTP_USER_AGENT' => 'Test'
)
);
And I wish to use something like this
$client = static::createClient();
$container = $client->getContainer();
$client->setServerParameters(
array(
'HTTP_HOST' => $container->getParameter('test.host'),
'HTTP_USER_AGENT' => $container->getParameter('test.useragent')
)
);
But that fails.
> There is no extension able to load the configuration for "test" in config.yml. Looked for namespace "test", found "framework", "security", "twig", "monolog", "swiftmailer", "assetic", "doctrine" [...]
|
Add your values to the `parameter.yml`.
In general, just putting values into comfig.yml does not automatically add them to your container.
If you want to learn how you can make your code configurable via config.yml have a look at How to expose a Semantic Configuration for a Bundle
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "symfony, configuration, phpunit"
}
|
How do I write a printf() function in AssemblyScript?
I mostly need this for logging where I need to pass in arbitrary arguments (ints floats, objects).
One solution is to write
let i:i32 = 1;
let f:f32 = 1.1;
log ("Message "+i.toString()+" "+f.toString())
This is very awkward and verbose to write.
You can also have multiple log functions, again awkward
log_i (msg:string, i:i32);
log_i2 (msg:string, i:i32, i2:i32);
log_f (msg:string, f:f32);
etc
Seems like you cannot have a generic array that holds i32, f32 and objects at the same time. So not even sure how to pass in varargs. Maybe I can box them but it is again awkward without auto-boxing.
What would be a good solution for this straightforward usecase?
|
Simply use Typescript style Template strings.
log (`Message ${i} and ${f}.`)
Assemblyscript will automatically generate the toString() and string concatenate statements.
1. Simple and concise
2. More expressive logs rather than put all arguments at the end.
3. No awkward function calls, varargs, etc.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "printf, assemblyscript"
}
|
android unable to find app on play store with name
I am unable to find my app on play store even with putting its exact name. but while I put name without space then play store shows it on top of the searched list.
Can anyone explain what is the issue and how can I get rid of this?
thanks in advance.
|
i think the search function also considers the package name while searching like com.whatever.whatever. let your app gain popularity then you app will come on top of search result even when you put spaces
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "java, android, google play"
}
|
the same formatting control over Web documents that they have over - I can't make proper grammatical sense of it
> **Web designers sometimes try to achieve the same formatting control over Web documents that they have over, say, printed documents.** They want what they see on their screens with their browsers to be exactly what any visitor to their sites may also see. (Even if they can’t pronounce WYSIWYG, they want “what you see” to be “what you get.”) Two overarching problems prevent Web designers from achieving this control with HTML:
**Web designers sometimes try to achieve the same formatting control over Web documents that they have over...** And then little can I do to make grammatical sense of the rest of the sentence.
|
The author is implying that:
1\. One has a certain level of formatting control when creating printed documents.
2\. The level of formatting control available when creating web content is less than that.
3\. But web designers sometimes expect the two to be equal even though they aren't.
The 'say' is used as a synonym for "for example"
Put another way: if we call the level of control available for printed documents L1, and the level of control available for web documents L2, then the author is saying:
_web designers sometimes expect L2 to be the same as, for example, L1._
|
stackexchange-ell
|
{
"answer_score": 0,
"question_score": 1,
"tags": "grammar"
}
|
Declaring an array in Swift
What's the difference between these 3:
struct A {
let myVal: Array<Char>
let myVal2: [char]
let myVal3: Array<CChar>
}
Which one is more common or recommended to be used?
|
There is no difference between `Array<Thing>` and `[Thing]`; the latter is syntactic sugar for the former.
Hence the only difference between your three declarations is the difference between the three element types: Char (whatever that is), char (whatever that is - a type name starting with a small letter is really bad practice in Swift, though), and CChar (that's the only one I've ever heard of). The recommended one of those three is: whatever it is you want an array of.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "swift"
}
|
Should static_assert really succeed when testing existence of an operator that's declared but not defined?
Why does the `static_assert` below succeed? I have only made the `<<` operator a friend, but I haven't created it anywhere.
struct foo {
friend std::ostream &operator<<(std::ostream &stream, const foo &f);
};
template<typename T>
struct bar {
//succeeds:
static_assert(boost::has_left_shift<std::ostream,T>::value, "failure");
};
int main(int,char**) {
bar<foo> b;
return 0;
}
|
The friend declaration establishes that the operator exists. If you used it, the compiler would accept it:
std::cout << foo();
That's all the assertion can test, either. A program with this statement in it probably will not link because you haven't _defined_ the operator, but just like the compiler, the assertion cannot detect that. It has no idea whether some other translation unit might eventually provide a definition for that function.
Compiling and linking are separate phases.
If you do provide a definition in another file, and you compile that file, you can then link the two compiled files together to form a complete program. You won't have to recompile the first file. That's what _separate compilation_ is all about.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "c++, templates, boost, static assert"
}
|
Create Date from string with week number in Javascript
I have a string like 2020-44 which contains year and number of the week in the year. Is it possible to create Date object from this string in some easy way? Javascripot is able to create dates from string like new Date('2020-12-24'). But I would like to use it with format 2020-44. Is it possible or not?
|
This will return the first day of the given week:
var dateString = "2020-44";
function getDateFromWeek(str) {
var y = str.split('-')[0]
var w = str.split('-')[1]
var d = (1 + (w - 1) * 7); // 1st of January + 7 days for each week
return new Date(y, 0, d);
}
console.log(getDateFromWeek(dateString));
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "javascript, string, date"
}
|
How extract attributes from input tag and export with a json or xml?
How extract attributes from input tag and export with a json or xml?
My current regex `/(\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']?/g`
INPUT
<input name="title" type="text" max="10" min="5">
JSON[something like that]
{"title":[
{"max":10, "min": 5, "type": "text"}
]}
|
Don't do that with regex i advise using DomDocument for this. The code below should help you.
<?php
/* your Curl response html */
$html = '<input name="title" type="text" max="10" min="5">';
$domDocument = new DOMDocument();
$domDocument->loadHTML($html);
$inputsDOMNodeList = $domDocument->getElementsByTagName('input');
echo '<pre>';
var_dump($inputsDOMNodeList);
echo '</pre>';
$inputArray = array();
foreach ($inputsDOMNodeList as $inputDOMNodeList) {
$inputArray[][$inputDOMNodeList->getAttribute('name')] = array(
'max' => $inputDOMNodeList->getAttribute('max')
, 'min' => $inputDOMNodeList->getAttribute('min')
, 'type' => $inputDOMNodeList->getAttribute('type')
);
}
echo '<pre>';
var_dump($inputArray);
echo '</pre>';
echo '<pre>';
var_dump(json_encode($inputArray));
echo '</pre>';
?>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "json, regex, xml"
}
|
Control the way git prints file names so that they can be passed to rm?
When I print a file from git using the command, there are edge cases:
git diff --no-renames --name-only
Edge case 1: spaces
(added `--diff-filter=D` for illustrative purposes)
# format 1: unquoted
$: touch 'foo bar.txt'
$: git add 'foo bar.txt'
$: git commit -m 'test'
$: rm 'foo bar.txt'
$: git diff --no-renames --name-only --diff-filter=D
foo bar.txt
Edge case two: special chars
# format 2: quoted
$: touch 'foo
bar.txt'
$: git add 'foo$\nbar.txt'
$: git commit -m "test"
$: rm foo$'\n'bar.txt
$: git diff --no-renames --name-only --diff-filter=D
'foo\nbar.txt'
Neither `foo bar.txt` nor `'foo\nbar.txt'` can be submitted to `rm` for deletion as-is. And, they are inconsistent.
Is there a way to control how `git` forms the file names so that they can be removed by `rm` as is?
|
`git diff --no-renames --name-only -z | xargs -0 -I {} sh -c 'rm -- "{}"'` is what I went with.
|
stackexchange-unix
|
{
"answer_score": 0,
"question_score": 0,
"tags": "git, rm"
}
|
Save a string for later use in ASP.NET
I have a simple string that I would like to save for later use on an ASP.NET server. It is an authorization string for a web service. It mostly stays the same, but may expire every few months. It will be saved programmatically from a code-behind file. Is there a simple place I can save it?
Initial thoughts are:
1. File - seems reasonable
2. Database - we don't have one setup and it seems like a lot of overhead to hold a string
3. Session - this would be too short lived
4. Config file - Based on answer from MK_Dev this would require a web app restart. No go then.
5. Somewhere else that I don't know about, but would be perfect?
|
Another possibility is to create a custom registry key. Here is an article with some code examples: Manipulating and Editing Registry with .NET.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "asp.net, save"
}
|
Python run out of memory on mac
I am currently using python on a Mac. The task is to to scrape something from the web and store it in a csv file. What my problem right now is that if i create a new object in `for` loop lets say
for x in list:
y = classvar()
with open("test.csv") as f:
f.write(y)
where classvar() contains several dictionaries.
After around 1000 iterations, my mac crashes saying I don't have enough memory! I am just wondering what is the best solution to this? Should I use `del y` at the end of each for loop?
|
If `y` is something that is big, and isn't needed except in one iteration of the loop, you should use `with` on it as well:
for x in list:
with classvar() as y:
with open("test.csv", "w") as f:
f.write(y)
`classvar()` needs to have `__enter__` and `__exit__` methods, and the `__exit__` method should clean the object up.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, object, for loop"
}
|
What is the equivalent for flash/actionscirpt based addEventListener, removeEventListener and dispatchEvent in IOS
AS some one porting code from actionscript to IOS, We have a lot of custom components that follow the event dispatching mechanism in Flash/Actionscript:
E.g. dispatcher:
dispatchEvent(new CustomEvent(CustomEvent.DRAG_DROP));
Consumer:
dispatcher.addEventListener(CustomEvent.DRAG_DROP, actionHandler);
private function actionHandler(event:CustomEvent):void {
trace("actionHandler: " + event);
}
I know of NSNotificationCenter, KVO pattern, action-target, but none seem to be an exact match?
Where would I define CustomEvent? CustomEvent.DRAG_DROP? and how would the consumer listen for the event? How would a consumer know of all the events that a dispatcher can dispatch? I do not wish to use a delegate because there could be multiple consumers.
|
The closes way I know is selectors ...
// store event handler
SEL targetHandler;
// firing an event
[targetHandler performSelector:targetHandler withObject:eventObj];
// event handler in the listening class
- (void) onStuffHappened: (Event*) event
{
}
that's obviously a quick thought, I would extend NSObject and store handlers in NSMutableArray then run performSelector on all the stored handlers ... something like that
or you can use delegates for a cleaner way.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "ios, objective c, actionscript"
}
|
Knapsack problem question
Based on this video, the tutor explains the knapsack problem with dynamic programming approach. One thing is not cleared in this video, which is my main question.
All the values on the first row (except 0) are set to 1 because value and weight (on that row) are 1 hence, we cannot exceed that number
Below is the complete example of the tutor as linked in the above video. : I suppose the first row results would be `0,25,25,25,25,25,25,25`
Let me know if i am wrong. Thank you.
Note that the first row is important to be correct as every row depends on the previous one. The tutor's example in the video, is not the best as the first row value and weight are both 1.
|
First row indicates the optimal knapsack for each weight using only that item. Then each subproblem in that row asks what is the maximal value one can reach with using only first item and maximum weight indicated by the columns. Then because your first item would have a weight of 3, there is no way for you to include an item for any total knapsack of weight less than 3. Therefore the optimal knapsack for each weight less than 3 would be 0.
Then the first row would look like: 0 0 0 25 25 25 25 25
|
stackexchange-cs
|
{
"answer_score": 2,
"question_score": 0,
"tags": "algorithms, dynamic programming, knapsack problems"
}
|
Simple Turing Machine
Having a bit of trouble designing a turing-machine which recognizes the following language. The alphabet is $\Sigma$ = {a,b,c}.
$$ L_2 = \\{wcw^R | w \epsilon \\{a,b\\}^*\\} $$
The part which messes me up is the initial branching portion where the start value can take two paths. A high-level explanation would also be helpful if anything.
|
The Turing Machine can be implemented as follows :
At start, move to the center of the input ( till you get a 'c'). Go to the right, remember that character and overwrite it with 'c'. Then move left till you see a non-'c' character. If they both are not the same, return NO. If they are, overwrite it with 'c' and again move right till you see a non-'c' character. Keep doing this till the length of the input string is exhausted.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "algorithms, turing machines"
}
|
How do I select an option using prototype
Say I have a HTML form containing this select element:
<select name="mySelect" id="mySelect">
<option value="1" id="option1">1</option>
<option value="2" id="option2">2</option>
</select>
How can I use prototype to select one of the option elements?
The methods listed in the API reference of Form.Element don't seem to help with this.
edit: by "select" I mean the equivalent effect of the "selected" attribute on an option element.
|
var options = $$('select#mySelect option');
var len = options.length;
for (var i = 0; i < len; i++) {
console.log('Option text = ' + options[i].text);
console.log('Option value = ' + options[i].value);
}
`options` is an array of all option elements in `#mySelect` dropdown. If you want to mark one or more of them as selected just use `selected` property
// replace 1 with index of an item you want to select
options[1].selected = true;
|
stackexchange-stackoverflow
|
{
"answer_score": 34,
"question_score": 32,
"tags": "javascript, html, prototypejs"
}
|
NSValueTransformer, how to use?
I am using `NSValueTransformer` class to transform a `NSDictionary` object to custom object.
I have already implemented the subclass with the methods:
+ (Class)transformedValueClass
+ (BOOL)allowsReverseTransformation
- (id)transformedValue:(id)value
Then I have registered my subclass with:
[NSValueTransformer setValueTransformer:[[ClassNameTransformer alloc] init] forName:ClassNameTransformerName];
How I am supposed now to get my custom object from a `NSDictionary`. Since I have not found any info about this, only when used with bindings like in `CoreData` and `.xib` files.
Can I use `NSValueTransformer` for my purpose? -> Transform `NSDictionary` into my custom Object.
Thanks!
|
Of course you can use `NSValueTransformer` stand-alone
ClassNameTransformer *transformer = [[ClassNameTransformer alloc] init];
MyObject *object = (MyObject *)[transformer transformedValue:dictionary];
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "ios, objective c, nsvaluetransformer"
}
|
How to install PhpMyAdmin having MySQL database/logins through FTP
I have MySQL database. I have FTP logins. I am trying to install PhpMyAdmin through FTP. I have already uploaded PhpMyAdmin folder from phpmyadmin.net to FTP, what should I do now to connect PhpMyAdmin to MySQL database? I can't find any config files where I have to insert host url, database name, username and password from MySQL database. Thank you.
|
First of all, download phpmyadmin from their website. Next, unzip it to the preferred directory to the server using FTP, SSH, etc - anything you prefer. Find config.sample.inc.php file in the root directory of phpmyadmin, rename it to config.inc.php and edit necessary options.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 4,
"tags": "php, mysql, sql server, phpmyadmin"
}
|
Memory leak on using uimages
I am working on a project that contains lot of images. i just wanted to be sure that if any of my view controller that contains about 70 images and i have put those images via storyboard will that too consumes memory of about 2-3 MB ?,as it showing in instruments or it due to some memory leak?
|
As per your description there is no leak, your code should be able to give more info. So in short if application is loaded and images are rendered, the it takes up memory. However if you are not managing the memory correctly, it will leak and your question does not contain sufficient info to make any comment on that.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "iphone, memory management, memory leaks, storyboard, instruments"
}
|
Getting the char integer value from a std::string & std::wstring
I am attempting to convert a string into a number by summing the int value of each letter together in C++ WinAPI. So in ASCII; the std::string "AA" would equal 130 (65+65)
The string can either be a std::string or an std::wstring.
**Why does the following function always return the value of zero no matter what letter I put in it? Shouldn't it return either the ASCII or Unicode integer value of the letter?**
printf("TEST a: %d \n", _tstoi(_T("a")));
printf("TEST A: %d \n", _tstoi(_T("A")));
printf("TEST b: %d \n", _tstoi(_T("b")));
My VC++ application is currently in Unicode, & the previous code prints out zero for each letter. I remember hearing that Unicode is very different to ASCII strings, _can you clear up what exactly is different other than Unicode has a library of characters which is something like 30,000 long whilst ASCII is 256(I think?)?_
|
the *toi family of functions converts a string representation to integer representation, that is, "10" becomes 10. What you actually want to do is no conversion at all. Change it to:
printf("TEST a: %d \n", _T('a'));
printf("TEST A: %d \n", _T('A'));
printf("TEST b: %d \n", _T('b'));
As for unicode, the underlying representation depends on the encoding ( for example UTF-8, which is very popular, maps the LSB with the ASCII table ).
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c++, winapi, unicode, unicode string"
}
|
How to stop scrolling to first validation error message on magento2 on add to cart?
How to stop scrolling to top or first validation failure message

if (firstActive.length) {
$('html, body').animate({
scrollTop: firstActive.offset().top
});
firstActive.focus();
}
become
if (firstActive.length) {
firstActive.focus();
}
|
stackexchange-magento
|
{
"answer_score": 17,
"question_score": 10,
"tags": "magento2, magento2.3, magento2.3.1"
}
|
Aligning xilene isomeri with chemfig
Ho can vertical align this scheme to the red line?
\documentclass{article}
\usepackage[margin=1.5cm,top=1cm,headheight=16pt,headsep=0.1in,heightrounded]{geometry}
\usepackage{chemfig}
\setchemfig{%
% %scheme debug=true,
arrow offset=9pt,
arrow coeff=0.7,
% compound sep=5em,
+ sep left=0.6em,
+ sep right=0.6em,
atom sep=1.25em,
fixed length=true
}
\begin{document}
\begin{tikzpicture}
\drawred --++ (12,0);
\schemestart
\rotatebox{-90}{\chemfig{**6(---(-)-(-)--)}}
\arrow{<=>}
\rotatebox{-90}{\chemfig{**6(--(-)--(-)--)}}
\arrow{<=>}
\rotatebox{-90}{\chemfig{**6(-(-)---(-)--)}}
\schemestop
\end{tikzpicture}
\end{document}
-(-)--(-[,,,,,draw=none])-)}
%
\arrow{<=>}
%
\chemfig{[:-30]**6(-(-)--(-)--(-[,,,,,draw=none])-)}
%
\arrow{<=>}
%
\chemfig{[:-30]**6((-)---(-)---)}
\schemestop
\end{document}
 to run on my Centos 6 Server
I am working on an academic project and my aim is to install an Open Source Cloud (Paas) solution on my Centos 6 Server. Through which I will install open source application for academic purposes and more.
I am new to running a Linux Server command line. I will install my Cloud solution of Choice on a VirtualBox VM.
As of now I am narrowing down to DEIS, CLOUD FOUNDRY, FLYNN and OPEN SHIFT.
My Question is What Cloud Solution is Best for such implentation and what advice you have for a newbie with regards to this?
|
I had that same problem a few years ago. I ended up using Apache CloudStack because it was "open source". It's not the perfect solution but it gets the job done. I have also used vBoxxCloud for a while. It's a SaaS tool so I don't know if you can use it. But it has a decent synctool which helps a lot.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "saas, paas, iaas"
}
|
Why I am still getting answers on a question with an accepted answer?
I asked a python question yesterday and had an accepted answer that solved my problem. However I am still getting answers on this. I was under the impression that once a question had an accepted answer it could not be answered anymore. Is this correct?
It's not that I mind all the feedback, I just cannot fairly reward those SO users' other answers.
To clarify, I am not in disagreement with the paradigm that questions should continue to be able to be answered, I just was not aware that they could continue to be answered.
|
I'm glad to see that you are still getting answers for your question, even though you've accepted an answer.
Bear in mind: accepting an answer only means something explicitly to you; this indicates the answer that has best helped you at this moment in time. Others may come along later and provide more detailed information, and there's no benefit to preventing that.
If any of the answers have helped or provided you a way to think about your question, then feel encouraged to upvote them. That's pretty much the reward for their efforts.
|
stackexchange-meta_stackoverflow
|
{
"answer_score": 13,
"question_score": -4,
"tags": "support, answers, accepted answer"
}
|
Captain, there's a riddle for yar!
Captain, I am willing to bet,
That yar will never get,
The meaning of this riddle!
* * *
Many siblings live together,
Sister and brother equal in number,
Many many pets but not a fiddle!
* * *
Sometimes they're at war.
And sometimes they swindle yar,
But they truly amaze a kiddle!
|
I believe the answer is:
> A deck of cards (as Brent Hackers sort of points out in his answer and the comment from OP)
**Reasoning:**
Captain, I am willing to bet, That yar will never get, The meaning of this riddle!
> You bet on card games specifically the various forms of poker.
Many siblings live together,
> Referring to the Jack Queen King I believe
Sister and brother equal in number,
> There are 4 Queens and 4 Kings which I believe are the siblings
Many many pets but not a fiddle!
> No Idea, maybe the number cards are the pets
Sometimes they're at war.
> Refers to the card game war
And sometimes they swindle yar,
> Sometimes people cheat in betting card games
But they truly amaze a kiddle!
> A deck of cards is used in a lot of magic tricks that will amaze children (and adults alike)
|
stackexchange-puzzling
|
{
"answer_score": 3,
"question_score": 6,
"tags": "riddle, wordplay"
}
|
Call Instagram API from localhost
Is it possible to get **INSTAGRAM** user details through API from **localhost** ?
Because I am trying to doing this from localhost but unable to fetch the information. After click the login url it redirect me to the **INSTAGRAM** and after successfully login and authorize the apps it redirect me properly in my callback URL with code. But when I am trying to fetch the info (cURL) using access token then it return null.
But same code run perfectly in live.
|
Ultimately I resolved the problem. now I am able to connect to _Instagram_.
I use the _CodeIgniter Instagram Library by Ian Luckraft_. In config file I just change the
$config['instagram_ssl_verify'] = FALSE;
By default it was `TRUE`.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 4,
"tags": "php, api, instagram"
}
|
Why do some characters get moving headshots in the Babylon 5 season 3 intro sequence?
After re-watching season 3 of Babylon 5 I noticed a bit of a discrepancy which I cannot account for.
Some cast members 'headshots' are stationary whereas others turn. There doesn't appear to be any connection with who turns their head and what sequence they are in, or even with what role they take in the show.
Is there a reason for some being turned one way or straight on or not?
Here is the intro for reference:-
|
Nope, it doesn't mean a thing. Presumably it was done simply for style.
Showrunner J. Michael Straczynski answered this question on usenet. The following is referenced from The Lurker's Guide:
> **Q:** _Any significance to some characters heads turning in the opening credits?_
>
> **JMS :** _No, I don't think even I could ever manage to be that obscure._
|
stackexchange-scifi
|
{
"answer_score": 23,
"question_score": 17,
"tags": "babylon 5"
}
|
Geting custom metrics from Kubernetes pods
I was looking into Kubernetes Heapster and Metrics-server for getting metrics from the running pods. But the issue is, I need some custom metrics which might vary from pod to pod, and apparently Heapster only provides cpu and memory related metrics. Is there any tool already out there, which would provide me the functionality I want, or do I need to build one from scratch?
|
What you're looking for is application & infrastructure specific metrics. For this, the TICK stack could be helpful! Specifically Telegraf can be set up to gather detailed infrastructure metrics like Memory- and CPU pressure or even the resources used by individual docker containers, network and IO metrics etc... But it can also scrape Prometheus metrics from pods. These metrics are then shipped to influxdb and visualized using either chronograph or grafana.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "kubernetes, monitoring"
}
|
make: Could not find module 'System'
Yesterday I had a failing darcs install with cabal, today I get this when running ghc --make node.hs:
> node.hs:13:8: Could not find module `System': Use -v to see a list of the files searched for.
Somewhere along the lines cabal seem to have borked it's system module. What can I do to repair this?
I use version 7.0.1 of ghc on OSX.
|
GHC 7 uses the brand-new Haskell 2010 standard. Thus, it doesn't includes the legacy modules anymore. The recomment way is to use the new modules (like `System.IO`) instead or use the `-package haskell98` switch to enable the support again. For sure there is also a `LANGUAGE` pragma to do this.
|
stackexchange-stackoverflow
|
{
"answer_score": 20,
"question_score": 13,
"tags": "haskell, cabal"
}
|
Sum of inverse functions
Given a sequence $a_1,\ldots,a_n$, we can take the average $\bar{a}=\frac{\sum_{i=1}^n a_i}{n}$. For some real valued function $f$ it seems to me intuitively that $$\sum_{i=1}^n \frac{1}{f(a_i)}=\frac{n}{f(\bar{a})}.$$ Should this be true, I will go about trying to prove this via induction.
|
As a counter example consider $f(x)=x$, and $a_i=i.$ Then the left-hand-side grows like $\log(n)$, while the right-hand-side will converge to a constant.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": -3,
"tags": "real analysis, probability, sequences and series, sequence of function"
}
|
self и this
Здравствуйте, уважаемые хэшкодеры!
class Example
{
function __construct(){...};
function One(){...};
function Two(){ Нужно вызвать первую функцию! };
}
Вопрос - что лучше использовать: $this->One(); или self::One(); ? Работает и то и то, чем отличаются знаю, хотелось бы узнать как правильней с точки зрения парадигмы ООП, скорости выполнения, феншуя и УГ РФ.
|
Способы вызова функции класса в php
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "php"
}
|
How can I deploy a Liberty application with server.xml using Bluemix devOps service
I have a Java Web application that I want to deploy to Bluemix's Cloud Foundry runtime. I'd like to run it on the Liberty application server and customize the server configuration with the server.xml file. I know how to do this in the CLI with a server package or server directory, but how do I complete this task using the Bluemix DevOps service? By default, it only pushes the WAR package.
|
It can be done in this way:
1. Put the customized server.xml and jvm.options files in a sub-folder like "defaultServer";
2. Modify your build script to create a zip file with below structure:
|- server.xml
|- jvm.options
|- apps
|- myapp.war
3. Modify the manifest.yml file of the project to specify the path to be the zip file created in Step 2.
Note the server.xml need to define a web app that points to the WAR, for example:
<webApplication id="myapp" location="myapp.war" name="myapp" context-root="/" />
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "ibm cloud, websphere liberty, devops"
}
|
While loop in Async task block the execution of another Async task
I have started two services in an activity named StartServiceActivity.
In the On create method of the StartServiceActivity I have started two services, service 1 and service 2.
The services are creates successfully.
1. On the onstart method of **service 1** I have started an asynTask1.
The asynTask1 executed successfully and entered into the doInBackGround()
In the doInbackground() of asynctask1(service1) I have created a `while(true){`
2. On start method of service2 I have started an asynTask2.
Then I trying to start **asynTask2** but it failed to start. The doInBackground() of asynTask2 is not being executed
3. When I comment the `while(true){` in asynTask1 both asynTask1 and asynTask2 is started.
I want to execute async1 and asyn2 with `while(true)`.
|
The reason is because `AsyncTasks` run in serial order i.e. one after another. Take a look at Order of execution here.
So what is happening is: There is a while loop in the `task1` which runs first. The while loop doesn't finish so the `task2` doesn't get turn to be executed.
**Solution:**
You need to set the executor for the `AsyncTask` manually so that the default (serial) executor is not used. Do something like:
if (Build.VERSION.SDK_INT >= 11) {
//--post GB use serial executor by default --
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
//--GB uses ThreadPoolExecutor by default--
task.execute();
}
Take a look at this link
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "android, multithreading, android asynctask"
}
|
Might it be possible to block an entire US state from accessing my site, using PHP?
I have a client that would like to block an entire US state from accessing his site. He is OK with the idea of it not being perfect. Is this possible?
I found this service: <
|
PHP-Ip-Block uses Maxmind service you mentioned.
You need to change following lines in index.php; (lines that sould be changed)
$okc = array('Canada', 'United States'); //array of countries you want to let in
// Decide what to do with your country arrays
if (in_array($userco,$okc))
echo " "; //allowed in
else
header( 'Location: );//this is where to send countries not matched.
to this; (new lines)
$okc = array('United States'); //array of countries you want to NOT let in
// Decide what to do with your country arrays
if (!in_array($userco,$okc))
echo " "; //allowed in
else
header( 'Location: );//this is where to send countries matched.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 4,
"tags": "php, javascript, ip"
}
|
how to copy datagridview1 data to another datagridview?
I am working with visual basic 6.0 for school project , I want copy datagridview of form1 and paste it on datagridview of form2. when form2 load at that time all data show in datagridview. i use below code but it show only first row
DataGridView1.Columns.Clear()
For Each Col As DataGridViewColumn In View_Staff.DataGridView1.Columns
DataGridView1.Columns.Add(DirectCast(Col.Clone, DataGridViewColumn))
Next
DataGridView1.Rows.Add(View_Staff.DataGridView1.Rows(0).Cells.Cast(Of DataGridViewCell).Select(Function(c) c.Value).ToArray)
|
Well, the first thing you'll need to do is get rid of all of your code, since it doesn't run in VB 6.0. There isn't any DataGridView in VB 6.0, there isn't any DirectCast operator in VB 6.0.
Alternatively, if your school project is really in VB.Net, then two minutes of googling will reveal that this question has already been answered here.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "vb.net, datagridview"
}
|
Which day of the working week is called blue?
I heard that there is one, which is it? I couldn't find it. All I found was _Blue Monday (date)_ on Wikipedia) but here I am looking for a day of the week. Is there one?
|
You actually got it. The day of the working week is **_Monday_**. That's because after a nice weekend, people find it quite boring to go office and start working!
Dictionary.com defines it:
> Blue Monday - _a Monday regarded as a depressing workday in contrast to the pleasant relaxation of the weekend._
Note that the word _blue_ , informally, here means _sad (Sense #3)_. So, after having holidays for Saturday and Sunday, Monday is always sad to begin the work. :)
In fact, you do find articles on how to get rid of Monday Blues. One of the pages I found is on Forbes.
|
stackexchange-ell
|
{
"answer_score": 0,
"question_score": 0,
"tags": "word request"
}
|
Why React-router doesn't redirect immediately after calling browserHistory.push method ?
This is the code in my componentWillMount function:
if(expression) {
let path = '/something;
browserHistory.push(path);
}
let tokens = CookiesWrapper.getCookie('tokens');
if (!tokens) {
browserHistory.push('/login');
}
When I debugging I see strange behavior with browserHistory.push method, It looks code is executed asynchronously.
When it comes to line 3. code continue with execution on line 4, and 5, it doesn't redirect me immediately after calling push method. Any ideas why this happening?
|
If you don't use a `return` the parser will continue to execute code (in this case it'll move on to your `let` declaration and `if` statement).
if(expression) {
let path = '/something';
return browserHistory.push(path);
}
let tokens = CookiesWrapper.getCookie('tokens');
if (!tokens) {
return browserHistory.push('/login');
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "javascript, reactjs, react router"
}
|
Storing data in a table
I am trying to create a user table for my website, where the user can see their first name and last name in a table after they register and login. The user detail is stored in the HTML5 Local Storage. Is there a better way to update the table with more users, rather than creating more .
Here is my table:
<table id="rankTable">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Top Score</th>
</tr>
<tr>
<td id="_firstName"></td>
<td id="_lastName"></td>
<td></td>
</tr>
</table>
Here is the full working snippet: <
|
Assuming that u have stored your stored firstname and lastname as "fname" and "lname" in your localStorage
var table = document.getElementById("rankTable");
var row = table.insertRow(0);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
cell1.innerHTML = localStorage.getItem("fname");
cell2.innerHTML = localStorage.getItem("lname");
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 2,
"tags": "javascript, html"
}
|
Creating and executing the function in SQL Server
Im trying to complete this function that will take an input date and return a date that is a Sunday 3 weeks ago. For example: If my input date is 5/25/2016, then the result should be 5/1/2016 I have put together most of the function, just stumped as to what to do next.
IF OBJECT_ID (N'dbo.ufnSundayThreeWeeksBack', N'FN') IS NOT NULL
DROP FUNCTION ufnSundayThreeWeeksBack;
GO
CREATE FUNCTION dbo.ufnSundayThreeWeeksBack(@SOMEDATE datetime)
RETURNS date
AS
BEGIN
IF @SOMEDATE IS NULL
RETURN NULL;
DECLARE @result date;
SELECT @result = DATEADD(WEEK, -7, DATEADD(DAY, 1 - DATEPART(WEEKDAY, @SOMEDATE), @SOMEDATE))
RETURN @result;
END;
GO
|
Try this:
IF OBJECT_ID(N'dbo.ufnSundayThreeWeeksBack', N'FN') IS NOT NULL
DROP FUNCTION ufnSundayThreeWeeksBack;
GO
CREATE FUNCTION dbo.ufnSundayThreeWeeksBack ( @SOMEDATE DATETIME )
RETURNS DATE
AS
BEGIN
DECLARE @DateMinus3Weeks DATE = DATEADD(WEEK, -3, @SOMEDATE);
RETURN DATEADD(DAY, -(DATEPART(WEEKDAY, @DateMinus3Weeks)-1), @DateMinus3Weeks);
END;
GO
Basically subtracting 3 weeks from the given date and then subtracting the weekdaynumber to get to the sunday.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sql server, function, datetime"
}
|
How is InSight's temperature probe deployment location chosen?
On NASA's InSight Mars lander a temperature probe nicknamed "Mole" is designed to hammer itself 5 meters into the ground and measure the temperature of the martian regolith at different depths with temperature probes mounted in its cable (Science Tether).
I found this very interesting PDF on how the mole hammers itself and how temperature is acquired. There's also a video of it hammering itself into a regolith analog here on earth.
{
test_struct tstruct;
tstruct.test = 1;
tstruct.name = "asdfasdf";
char *testout;
int len;
testout = new char[sizeof(test_struct)];
memcpy(testout, &tstruct, sizeof(test_struct) );
std::cout<< testout;
}
However, nothing gets printed. What's wrong?
|
sizeof(std::string) yeilds same value always. It will not give you the runtime length of the string. To serialize using memcpy, either change the struct to contain char arrray such as `char buffer[20]` or compute the size of the required serialized buffer by defining a method on the struct which gives the runtime length of the bytes. If you want to use members like std::string, you need to go through each member of the struct and serialize.
memcpy(testout, (void *)&tstruct.test, sizeof(int) );
memcpy(testout+sizeof(int), tstruct.name.c_str(),tstruct.name.length() );
memcpy against the entire struct will not work in such scenarios.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c++, serialization"
}
|
Running java.exe as pre-build step in .NET Core/Standard fails with 9009
I am trying to run java.exe as a pre-build step in a C#-.NET Standard 2.0 project. The csproj file contains the following snippet:
<Target Name="Java" BeforeTargets="Build">
<Exec Command="c:\Windows\System32\java.exe"/>
</Target>
(I simplified the command line for testing.) The file java.exe exists in c:\windows\system32, but the build fails with error code 9009:
c:\Windows\System32\java.exe' is not recognized as an internal or external command,
1>operable program or batch file.
1>C:\workspace\Test.csproj(21,5): error MSB3073: The command "c:\Windows\System32\java.exe" exited with code 9009.
1>Done building project "Test.csproj" -- FAILED.
Running java.exe directly from the command line works fine.
|
Apparently, c:\windows\system32 is routed to another path because Visual Studio is a 32 bit application. Using the special alias "Sysnative" works:
<Target Name="Java" BeforeTargets="Build">
<Exec Command="c:\Windows\Sysnative\java.exe"/>
</Target>
More information here.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, build, .net core, .net standard"
}
|
Unexpected token : in jQuery ajax call
I'm trying to make a simple request to instagram as follows:
$.getJSON("
function(data) {
alert(JSON.stringify(data));
});
<
However it says Uncaught SyntaxError: Unexpected token : in the console, but the uri is ok and it works if I, for example, run it in Postman or directly in the browser. I've searched other questions but I cannot get to know my error. Thank you.
EDIT
If I don't put a callback=? there's another error: No 'Access-Control-Allow-Origin' header is present on the requested resource
|
> Actually when you are using any social app data like for facebook,linkedin or instagram in your case etc you need to register your app there so you get unique token & id which help them to authenticate you.So,they can fullfill your request through their provided public API .
Its happening because as per JSONP the result /responce should be wrapped inside callback which is not happening in this case.
EDIT :
you need to subscribe to instagram after which you get your ACCESS-TOKEN.
then form url like this one
which will give jsonp.
Please refer here for more
1. devloper
2. endpoints
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "javascript, jquery, ajax, instagram api"
}
|
Why is ASU asking for my wife's high school transcripts when she is already in college?
I know I graduated from the university many moons ago, but my wife has been attending community college for awhile and wants to transfer to an online program with Arizona State University (ASU).
My understanding is when you transfer from one institution of higher learning to another you transfer your transcripts. I am not sure how did conversation asking my wife for her high school transcripts from her country of origin, where she has to get them notarized and translated and what not ended up as part of the conversation.
It's a given she did this once already as that is how you get into a US accredited local community college already.
So can anyone help me out here because otherwise I am thinking they are hearing an accent and asking her what they shouldn't and just going down a road of treating her like she is some international student who is trying to apply to school here.
|
## The latest degree matters
She's joining a new institution from scratch. If she hasn't _graduated_ anything else, the new college is admitting a high school graduate, and they want to see these transcripts to verify that she _is_ a high school graduate. They have no reason to assume that some other organization did the verification in the way _they_ require. They may have some process to transfer (partial) credits for courses completed in the previous college, but that happens after she's been admitted.
|
stackexchange-academia
|
{
"answer_score": 10,
"question_score": 2,
"tags": "united states, transfer student, transcript of records"
}
|
Executing Commands from Windows on Unix via Batchfile
I have a problem that cannot find a solution for quite a while. I want to execute following line from a Batch file on my windows machine:
**ssh %1@%2 "D: && ssh %3@%4 cd /media/usbmsd/ && cp "$(ls -t /media/usbmsd | head -1)" /buffer"**
THis batch file will be later executed from a cmd line with the parameters. I am trying to access one system (windows) via ssh and that hop again via ssh to the another system(unix) and there I need to find the newest file in the /media/usbmsd directory and copy it to the folder buffer.
When I excetuting it from my cmd line i am getting following error:
**'head' is not recognized as an internal or external command, operable program or batch file.**
I have to say that I am not very experienced with this kind of application and am happy about any help
Greeting Denis
|
You could connect via a proxy jump, then you don't need a second ssh command.
Then a bit obscure escaping of the quotes is necessary.
(I tested this without the intermediate windows client) The first caret `^` is necessary to quote from the `cp` command, the backslashes are necessary to convince the first expansion to leave the quotes untouched.
ssh %3@%4 -o ProxyJump %1@%2 ^"cd /media/usbmsd/ && cp \"$(ls -t /media/usbmsd | head -1)\" /buffer'
But it should be much easier to place a script on the destination host **mycopyscript.sh**
cd /media/usbmsd/ && cp "$(ls -t /media/usbmsd | head -1)" /buffer
And then use:
ssh %3@%4 -o ProxyJump %1@%2 "./mycopyscript.sh"
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "bash, batch file, unix, ssh"
}
|
What elements of a capacitor make it higher voltage and higher capacitance
I know capacitors have 2 plates, and an insulator in between the plates. I am wondering what elements inside of a capacitor make the capacitance larger, and what makes the maximum voltage higher?
|
\$ C = \epsilon_0 \epsilon_r \dfrac{A}{d}\$
Where:
* \$C\$ is the capacity in Farad [F];
* \$\epsilon_0=8.854×10^{−12} \text{F/m}\$;
* \$\epsilon_r\$ is 'relative permittivity', its value is specific for the material used as insulator. See also @rawbrawb's comment;
* \$A\$ is the area of the plates that overlaps in square meters;
* \$d\$ is the distance between the plates in meters.
So:
* if the plate overlapping area increases, the capacity increases _and_
* if the distance between the plates increases, the capacity decreases.
The insulator that fills the space between both plates (A×d) has a limited strength when it comes to voltage between the plates. The insulator will breakdown at a certain maximum voltage, at that point it is no longer a capacitor, but probably a short.
|
stackexchange-electronics
|
{
"answer_score": 11,
"question_score": 8,
"tags": "capacitor"
}
|
Eclipse asks for a return statement though I have one
protected int readInt(String prompt) {
try {
System.out.print(prompt);
int i = keyboard.nextInt();
keyboard.nextLine();
return i;
} catch (java.util.InputMismatchException e) {
System.out.println("Error: Insert a number.");
}
}
Hi! Eclipse gives me this error at the method readInt(): "This method must return a result of type int." and gives the example solutions "Add return statement" and "Change return type to void". I've tried to put the return i statement outside the try-and-catch loop, but when I do, the return statement can't find the variable i.
I've been struggeling with this for a while now, and can't seem to make it work... I would appreciate any help! Thank you.
|
In my code `i` is declared outside of the `try-catch` block so that the return statement won't have any scope issues. Also it is given the value -1, so if an exception occurs then the function returns -1 to the caller.
protected int readInt(String prompt) {
int i=-1;
System.out.print(prompt);
try {
i = keyboard.nextInt();
keyboard.nextLine();
} catch (java.util.InputMismatchException e) {
System.out.println("Error: Insert a number.");
keyboard.next();
}
return i;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "java, int, return, try catch, inputmismatchexception"
}
|
Noun to be stuck in the past, to not progress
What's a noun that means "being stuck in the past", like, refusing to change, refusing to progress ('anti-progressionism' is a word I felt like making up for it, but obviously sounds wrong)?
> A society ruled by corruption and __________
I already rejected "tradition" because it doesn't have negative enough connotations.
|
**Entrenchment**
> The process or fact of an attitude, habit, or belief becoming so firmly established that change is very difficult or unlikely. Lexico - Oxford
When you are entrenched, you are not just habituated to the past. You are fixated on the righteousness of your ways, your system, your history -- stuck in the past, refusing to change or progress.
You dug your trench and expect to stay a while.
|
stackexchange-english
|
{
"answer_score": 16,
"question_score": 11,
"tags": "single word requests"
}
|
How to set cider using boot middle ware?
In Emacs with `cider` and `lein` installed, I can `M-x cider-jack-in` to start clojure repl. I installed `boot` and would like to switch from `lein` to `boot`. How to set `cider` to use `boot` middle ware?
(I don't want to remove leiningen right now.)
|
First follow these instructions on the Readme so that boot knows about CIDER.
> Boot users can configure the tool to include the middleware automatically in all of their projects using a `~/.boot/profile.boot` file like so:
(require 'boot.repl)
(swap! boot.repl/*default-dependencies*
concat '[[cider/cider-nrepl "0.9.1"]])
(swap! boot.repl/*default-middleware*
conj 'cider.nrepl/cider-middleware)
Then just invoke `cider-jack-in` on a project that contains a `build.boot` file. If this project also has a `project.clj` file, CIDER will ask you whether you want boot or lein.
|
stackexchange-emacs
|
{
"answer_score": 2,
"question_score": 2,
"tags": "clojure, cider"
}
|
Why "like doing something" or "like to do something" but only "dislike doing something"?
At a further education course for teachers, in Switzerland, (given by two native speakers of English), someone came up with the question of whether you could say "dislike doing something" and "dislike to do something", just as you can say "like doing something" and "like to do somehting".
The answer was you could not, and that it was a question of usage. Period!/Full stop!
Just learn this by heart and stop asking silly questions!
Will keeping your whys to yourself make you… wise?!
|
Of course, I don't think it will!
The difference of meaning between "to like doing something" and "to like to do something" is that the infinitive structure adds the idea of _choice_ to the one of simply liking something. "I like skiing." versus "I like to ski in powder snow in the early morning.": the second sentence means that I like skiing and that, for my greater enjoyment, I choose to go and ski in the early morning when it has just snowed.
So, of course, if you dislike something, then you are not going to choose when or how you are going to do it for your greater enjoyment… that would be absurd!
There IS an explanation, see…
|
stackexchange-english
|
{
"answer_score": -4,
"question_score": 4,
"tags": "grammar, usage, gerund vs infinitive"
}
|
Can I target .NET Framework 3.5 when creating a MOSS 2007 web part?
I'm creating a web part in Visual Studio 2008 that involves using the Open XML SDK 2.0. I'm getting an error saying I need to add a reference to the WindowsBase assembly.
However, I can only add this reference if I set the Target Framework for my web part project to be .NET Framework 3.5. If it is .NET Framework 2.0, the reference for WindowsBase is greyed out in the Add Reference window.
Will it cause me problems when I come to deploy the web part if it is targeted to .NET 3.5?
|
There really isn't a 3.5 .NET runtime. .NET 3.5 is the .NET 2.0 runtime + .NET 3.0 extensions (mostly WPF, WF, WCF) and .NET 3.5 extensions (mostly LINQ). If you properly setup your web.config to find the proper DLLs used for 3.5 you should be fine. Having said that I am not sure what the Open XML SDK is and if there are issues with SP 2007. We have used Web Parts under 2007 that utilize Linq to Sql (a 3.5 feature)
|
stackexchange-sharepoint
|
{
"answer_score": 2,
"question_score": 0,
"tags": "web part, visual studio, 2007"
}
|
Verilog input and output array
I am new to verilog, so I was trying this out with it like what I always do in Java, and it just doesn't compile, I tried Googling, but nothing came up ...so, thanks !
module two_to_one_com(SW,LEDR,LEDG);
input [15:0]SW ;
input SW17;
output [7:0]LEDR;
output [7:0]LEDG;
assign X = SW[7:0];
assign Y = SW[15:8];
assign s = SW17;
assign LEDR[7:0] = SW;
assign M = LEDG[7:0];
integer index = 0;
initial
begin
for(index=0;index<=7;index = index+1)
begin
assign M[index] = (~s &X[index])|(s&Y[index]);
end
end
endmodule
So, it just keeps telling me that array M,X and Y can't be indexed as they are undeclared ... Anyone know any solution?
|
You need to declare all signals with some type and a width (if greater than 1 bit); `assign` is not a declaration key word. For example, I use `wire`:
module two_to_one_com(SW,LEDR,LEDG,SW17);
input [15:0]SW ;
input SW17;
output [7:0]LEDR;
output [7:0]LEDG;
wire [7:0] X = SW[7:0];
wire [7:0] Y = SW[15:8];
wire s = SW17;
Note that I also added SW17 to the port list.
I am still getting complaints about `M`, but I need to know how wide it should be (# of bits).
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "verilog"
}
|
Matching regular expression with delimited string in unix
I need to match the below delimited regular expression in bash script:
number|my_name|number
I have tried the below but could not get it through end:
sed -e 's/[^[[digit]]*//g
|
you mean you are searching for patterns in a file not matching. Use `grep -v` for that.
grep -v "^[[:digit:]]\+|[^|]\+|[[:digit:]]\+$" <input
But basically you are asking about how to write regular expressions. Read `regex(7)` for that and keep in mind that each command uses other quotation rules for special characters. But most basic linux commands use the rules from `regex(7)`.
|
stackexchange-unix
|
{
"answer_score": 1,
"question_score": -1,
"tags": "bash"
}
|
Why $\operatorname{Hom}_A(e_jA, e_iA) \cong \operatorname{Hom}_A(e_jA, e_i\text{rad}A)$?
On line 6 of the proof of Corollary 3.4 of page 62 of the book Elements of Representation Theory of Associative Algebras, Volume 1, it is said that $\operatorname{Hom}_A(e_jA, e_iA) \cong \operatorname{Hom}_A(e_jA, e_i\text{rad}A)$. I think that it is possible that $e_iA \not\cong e_i\text{rad}A$. Why $\operatorname{Hom}_A(e_jA, e_iA) \cong \operatorname{Hom}_A(e_jA, e_i\text{rad}A)$? Thank you very much. !enter image description here
|
It is always the case for finite dimensional algebras that $e_iA\ncong e_i\operatorname{rad} A\cong \operatorname{rad} e_iA$. This is not the argument for the isomorphism.
The argument is that every non-isomorphism $e_jA\to e_iA$ has an image in the radical of $e_i A$. This is because $e_i A$ has one-dimensional top, hence every morphism $e_jA\to e_iA$ whose image does not lie in $\operatorname{rad} e_iA$ must be surjective. Thus, because we are talking about indecomposable projectives, we have an isomorphism.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 3,
"tags": "abstract algebra, representation theory"
}
|
Predefined way to convert generic NSStrings to NSDates
I'm looking to have a way for user-inputted "date text" (e.g. 3/3/1990 or 3-1-98) to be formatted as an NSDate.
I could implement it myself attempting to format the text with various date formatters but I have a sneaking suspicion that there is a much easier way to do this.
dateWithNaturalLanguageString: would probably work, but I hear rumor that this will cause rejection from the app store?
|
You are looking for `NSDataDetector` and it returns `NSTextCheckingResult` objects.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "ios, date, nsstring, nsdateformatter"
}
|
how combine 'utf-8' and 'unicode_escape' to correctly decode b'\xc3\xa4\\n-\\t-\\"foo\\"'?
I have a library that gives me encoded and escaped byte sequences like this one:
a=b'\xc3\xa4\\n-\\t-\\"foo\\"'
Which I want to translate back to:
ä
- -"foo"
I tried to just `.decode` a which _decodes_ the sequence as wanted:
>>> a.decode()
'ä\\n-\\t-\\"foo\\"'
But it does not un-escape. Then I found `'unicode_escape'` and I got
>>> print(a.decode('unicode_escape'))
ä
- -"foo"
Is there a way to decode and unescape the given sequence with a builtin method (i.e. without having to `.replace('\\n', '\n').replace(...)`)?
It would be also interesting to know how I can revert this operation (i.e. getting the same byte sequence from the translated result).
|
There is a way to _somehow_ do what I want and I can _almost_ go the other way, too but in my eyes it's ugly and incomplete, so I hope it's not the best option I have:
>>> import codecs
>>> decoded = codecs.escape_decode(a)[0].decode()
>>> print(decoded)
ä
- -"foo"
>>> reencoded = codecs.escape_encode(decoded.encode())
>>> print(reencoded)
(b'\\xc3\\xa4\\n-\\t-"foo"', 11) <--- qotes are note escaped
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "string, python 3.x, encoding, escaping"
}
|
Inserting multiple pictures with space for captions in Word 2010
I'm doing weekly lab reports for school and have a lot of screen shots (JPEG) that I need to insert into the reports.
If I click on Insert Picture and select all the files at once it will insert them into the report but with no space between them for me to write my little blurb about that section of the lab. They are also far too big and need to be reduced to about 40% of their size but that's another issue.
How can I insert all my pictures at once whilst still giving me some space between each one to write and/or add a caption?
|
1. Insert the images.
2. Click `CTRL`+`A` to select everything.
3. Click `CTRL`+`H` to open the Find and Replace dialog.
4. In the `Find what` textbox type `^g` to search for graphics.
5. In the `Replace with` textbox type `^&^p^p` to insert the image that was found along with two paragraph marks (the first one will be used to separate each image from the next, the second one will be used for the label).
6. Click `Replace All`.
.apply(lambda x: ','.join(x.dropna().astype(str)))
#what I have
22 23 24 LC_REF
TV | WATCH | HELLO | 2C16
SCREEN | SOCCER | WORLD | 2C16
TEST | HELP | RED | 2C17
SEND |PLEASE |PARFAIT | 2C17
#desired output
22 | TV,SCREEN
23 | WATCH, SOCCER
24 | HELLO, WORLD
25 | TEST, SEND
26 | HELP,PLEASE
27 | RED, PARFAIT
Or some sort of variation where column 22,23,24 is combined and grouped by LC_REF. My current code turns all of column 22 into one row, all of column 23 into one row, etc. I am so close I can feel it!! Any help is appreciated
|
It seems you need:
df = hp.groupby('LC_REF')
.agg(lambda x: ','.join(x.dropna().astype(str)))
.stack()
.rename_axis(('LC_REF','a'))
.reset_index(name='vals')
print (df)
LC_REF a vals
0 2C16 22 TV,SCREEN
1 2C16 23 WATCH,SOCCER
2 2C16 24 HELLO,WORLD
3 2C17 22 TEST,SEND
4 2C17 23 HELP,PLEASE
5 2C17 24 RED,PARFAIT
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "python, list, python 3.x, pandas"
}
|
Should I add an assistance exercise or drop the weight on my squats to work my adductors?
Now I'm lifting relatively heavy weight in the squat, sometimes on the way up my knees cave in. I've already googled the common causes and found that this can be due to weak hip muscles causing others to compensate thus bringing your knees in.
But what would be more beneficial for stretching out and strengthening these muscles, adding an assistance exercise or dropping the weight and focusing on really opening my hips up?
|
I do **not** think you should drop the weights down and “ _focusing on really opening my hips up._ ” As long as you are not bowing the knees in to much I believe that this is somewhat of a natural progression once someone move beyond being a novice and really has to grind and work for every pound. Bowing the knees in slightly help you get out of the hole (the bottom of the squat.)
This video was made by one of the strongest people on the plant and he talks about the very issue that this question is in regards to.
<
|
stackexchange-fitness
|
{
"answer_score": 1,
"question_score": 1,
"tags": "squats, stronglifts"
}
|
Python3 regex pattern counting with optional period at the end
I'm trying to count the occurrences of patterns using Python3 and regex.
My method is currently (based on another stackoverflow thread):
count = sum(1 for _ in re.finditer(r'\b{0}\b'.format(re.escape(vals)), doc))
However the search fails if 'vals' contains a period, such as:
vals = '42.'
doc = 'I like 42. a lot'
Of course to force this particular example to work I could include a period: `'{0}.'` but that work break values that don't contain a period at the end...
|
Wen vals is `42.`, your regex is `\b42\.\b`. Here, the `\b` asserts there must be a word boundary, and because `.` is _not_ a word character, that means it must not be followed by a word character.
You seem to always want your regex to be followed by a non-word character, whatever the last character of vals was, so just make your regex explicitly say that, changing to:
r'\b{0}(?!\w)'.format(re.escape(vals))
Similarly, you may want `\b` at the beginning changed to `(?<!\w)` (isn't preceded by a word character).
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "regex, string, python 3.x"
}
|
Any way to serve static html files from express without the extension?
I would like to serve an html file without specifying it's extension. Is there any way I can do this without defining a route? For instance instead of
/helloworld.html
I would like to do just
/helloworld
|
A quick'n'dirty solution is to attach `.html` to requests that don't have a period in them and for which an HTML-file exists in the public directory:
var fs = require('fs');
var publicdir = __dirname + '/public';
app.use(function(req, res, next) {
if (req.path.indexOf('.') === -1) {
var file = publicdir + req.path + '.html';
fs.exists(file, function(exists) {
if (exists)
req.url += '.html';
next();
});
}
else
next();
});
app.use(express.static(publicdir));
|
stackexchange-stackoverflow
|
{
"answer_score": 23,
"question_score": 26,
"tags": "node.js, express"
}
|
no such file to load -- .bundle/environment
I installed integrity app these days. and found some issues.
I follow this.
> $ gem install bundler $ git clone git://github.com/integrity/integrity $ cd integrity $ git checkout -b deploy v22 $ bundle install $ bundle lock $ rake db
at the end steps, I can't find and folders named ".bundle" in the integrity folder. and the .bundle/environment.rb too. so I was blocked there.
and btw, anybody can sent me a better way to install and config integrity app?
thank you very much
|
This is probably because you have a _too recent_ version of bundler installed. Integrity v22 is not compatible with bundler > 0.9, but relies on functionality that was in removed in the subsequent version. In my case I installed bundler 0.9 before I ran bundle install:
gem install bundler --version=0.9
You might have to uninstall the newer bundler version, too.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "ruby on rails, testing, integrity"
}
|
Is it possible to know when an IsolatedStorageFile was created without loading it?
we're caching these objects in xml files, and we wan't to ignore the cached file when 24+ have passed. I don't want to have to load the file to check if 24 hours have passed, so I'm wondering if there is a way to get the metadata of the file without loading it. Something like:
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
DateTime dateTimeCreated = file.GetAttributes(this.CacheFileName)["DateTimeCreated"];
}
Let me know. Thanks!
|
How about a log file? (or you could make a list of Date + Name in your app settings)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 4,
"tags": "windows phone 7"
}
|
How can I access blocked Yahoomail in my office?
Actually My network administrator blocked the **www.yahoomail.com** in my office. But i need to access it to read some important mails. Is there any possibilities?
I tried it by some third party website. After entering login credentials ( ** _username and password_** ). I got an error " **This page requires that you have Javascript enabled on your browser.** "
But it is already enabled in my browser.
Can anyone help me?
|
Although you have way to access Yahoomail but I think you should just ask Admin or your teamleader or PM to allow you to use Yahoomail at work.
If you get caught while trying to connect Yahoomail without permision, its gotta be worse :)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "networking, network programming, network protocols"
}
|
Heisenberg's Uncertainty Principle - finding uncertainty in wavelength
I am confused about this problem: {
System.out.println("I am Working");
}
}
The code is in the `Project\src` folder . I can see that the class file has been created in the `Project\classes` . But when I run the code I am getting the error.
java.lang.NoClassDefFoundError: Hello
Caused by: java.lang.ClassNotFoundException: Hello
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"
|
It appears _likely_ that that you are running a previous run configuration for a class that no longer exists, hence the `NoClassDefFoundError`.
Add a `String` array argument to the `main` method of the class `MyTry` so that the application may be run in `Eclipse`.
public static void main(String[] args){
Ensure that the class name in Eclipse matches the fully qualified classname for `MyTry` in the run configuration.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -4,
"tags": "java, eclipse"
}
|
Abrir uma pasta na máquina do usuário e abrir um arquivo(csv,txt ou xls)
Como eu faço para abrir uma pasta na máquina do usuário? Preciso abrir a pasta e carregar um arquivo csv, txt ou xls. Eu uso MVC5
Seria mais ou menos isso. Um botão que carrega na pasta e depois eu dou um carregar que seria tipo um upload, acho.
!inserir a descrição da imagem aqui
|
Como você está trabalhando com jQuery, você pode usar o jQuery File Upload.
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "c#, jquery, asp.net mvc 5"
}
|
Facebook Login in Laravel 5
I have registered my application with facebook, is using the Laravel socialite package.
I'm unable to find a solution regarding how I should set up Facebook in the services.php file.
**services.php**
'facebook' => [
'client_id' => env('FB_APP_ID'),
'client_secret' => env('FB_APP_SECRET'),
'redirect' => env(''), //???
],
Before I proceed I want to know which keys and values I need to provide in the facebook array and where I can find them. The first two, I believe, are correct but I'm uncertain about any other.
Thanks for your help.
|
You may find this article helpful, it details how to implement the Socialite package quite well.
As for your setup, it all looks fine for the ID side of things, however the redirect should be set to the call-back URL you wish to use. E.g `www.yoursite.com/account/facebook`.
You can then pick this up in your `routes.php` file and direct it to a controller function.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, facebook, laravel, laravel socialite"
}
|
Create mutli-page document dynamically using PDFBox
I am attempting to create a PDF report from a Java ResultSet. If the report was only one page, I would have no problem here. The issue comes from the fact that the report could be anywhere from one to ten pages long. Right now, I have this to create a single-page document:
PDDocument document = new PDDocument();
PDPage page = new PDPage(PDPage.PAGE_SIZE_LETTER);
document.addPage(page);
PDPageContentStream content = new PDPageContentStream(document,page);
So my question is, how do I create pages dynamically as they are needed. Is there an object-oriented answer staring me in the face and I just cannot see it?
|
As I expected, the answer was staring me right in the face, I just needed someone to point it out for me.
PDDocument document = new PDDocument();
PDPage page = new PDPage(PDPage.PAGE_SIZE_LETTER);
document.addPage(page);
PDPageContentStream content = new PDPageContentStream(document,page);
//generate data for first page
content.close();
//if number of results exceeds what can fit on the first page
page = new PDPage(PDPage.PAGE_SIZE_LETTER);
document.addPage(page);
content = new PDPageContentStream(document,page);
//generate data for second page
content.close();
Thanks to @mkl for the answer.
|
stackexchange-stackoverflow
|
{
"answer_score": 17,
"question_score": 16,
"tags": "java, pdf, pdfbox"
}
|
Using MFA to connect to windows shares on domain controller
I have a requirement to force MFA for all non-console administrative access to our Windows AD servers. I've sorted out log ins with RSA, but that does not prevent a domain admin from mapping a drive or connecting via \servername\share and making changes that way.
This is the PCI MFA requirement 8.3.1, for those that are familiar with PCI. I've been beating my head against a wall over this for months; I've grilled Windows admins, googled until my fingers bled, and asked for input from several QSAs. None have been able to pose even a potential solution.
Any thoughts, suggestions, or directions to look would be greatly appreciated. I'm stuck.
|
I know, two answers to one question isn't cool - but after I posted the first answer I discussed this with some friends in the industry because it really is a question that I believe wasn't thought about when the standard was drafted (and if you think htf can you say this then look at my profile).
So I think the intent of the standard would be met if an administrator who had the rights to NET USE a drive in the CDE was made to use MFA when they first logged into the domain, even if they had no desire or intent to access the CDE. What's important is that if the admin's password is compromised (malware, MITM, packet capture etc), that captured username and password would provide no privileged access into the CDE.
|
stackexchange-security
|
{
"answer_score": 1,
"question_score": 4,
"tags": "pci dss, multi factor"
}
|
What does $x*$ mean?
I am trying to understand what the operator $*$ means in Boolean algebra. If x is a Boolean variable, what does the expression $x*$ mean?
|
In these exercises, $s*$ means the dual of $s.$ This is obtained from $s$ (which is an expression of propositional calculus containing only the operations $\wedge, \vee,$ and $\neg$) by replacing $\wedge$ with $\vee$, $\vee$ with $\wedge$, $T$ with $F$, and $F$ with $T$.
In the edition of the book I looked at, the author defines _dual_ just before exercise 34, a few exercises above the one the OP referenced in a comment.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "boolean algebra"
}
|
Pokémon Go Plus while driving
I was thinking about ordering a Pokémon Go plus device, but I have read some quite different reviews... some people like it, some don't...
As you know, Pokémon Go doesn't work if you are driving, but how about Pokémon Go Plus? I saw a couple of people playing with a plus while driving. Is there a different speed limit for plus?
If I'm driving at a speed of 100km/h, I'm quite sure the egg distance won't count, but what about for the appearance of Pokémon?
|
You will be able to capture Pokemon while driving with the Pokemon Go Plus accessory.
From here:
> Capturing using the PoGo+ was a complete mixed bag, at home capturing the mons that spawn around my house I captured 5 out of 24, **whilst driving I captured 10 out of 12.**
Here is another:
> Sooo I never play while driving, but with the Plus on my steering wheel, i can keep my thumb on the button.
>
> In 30 minutes, I caught 25 pokemon, and 15 got away.
Also, this link alludes to encountering Pokémon while driving:
> And if you’re wearing the Plus band while driving or riding in a car or bus, the Plus band might feel like it never stops buzzing. It’s a much safer option than trying to play on your phone while driving, but the vibrations can be overwhelming if you’re driving through a populous area.
|
stackexchange-gaming
|
{
"answer_score": 2,
"question_score": 4,
"tags": "pokemon go"
}
|
tsql command optimization
I have a million rows in my table. If RunId field = 37 for 100K records, then which of these two are faster
update _PECO_Detail set RunId = 37 where Runid <> 37
update _PECO_Detail set RunId = 37
Is 900K records already have RunId of 37, then would the first command be faster
update _PECO_Detail set RunId = 37 where Runid <> 37
update _PECO_Detail set RunId = 37
Index does exist on field RunId
|
The first is faster, because it only updates rows that are not `37` \-- that is 900,000 rows by your description, but that is bettern than 1,000,000. If there are no such rows, then the two would have pretty similar performance.
Updating large numbers of rows is expensive, due to locking and logging overheads. SQL Server updates a row even when there are no changes, so filtering before updating is highly recommended. Sometimes, it is more efficient to just recreate the table.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "sql, sql server, tsql"
}
|
The Rules And Tricks Use To Find The Equivalent Resistance
To find the equivalent resistance we use different tricks and rules to simplify the circuits. But I have confused on the basics of using those techniques.
I breifly searched in google to find the common techniques which can use to simplify a complex circuit but I can't understand how do those techniques not differ the initial circuit.
A Common technique is folding the circuit on a vertical or horizontal line; `
.
Note that the resistors on the axis of symmetry did not change their value.
> What are the requirements for folding the circuit for simplify?
Only that it is symmetrical.
> How is it not differ the initial circuit after folding on that line?
It _is_ different but it _is_ **equivalent**. Internally you have changed the circuit but when looked at from the outside (the left wire and right wire) you can't tell the difference. If you measured the resistance between the two outer terminals it is the same in both cases.
|
stackexchange-electronics
|
{
"answer_score": 1,
"question_score": 0,
"tags": "circuit design, resistance"
}
|
Detecting if an object is following a path
I am attempting to take GPS data and track it on a map and see if it follows a given path. I have the path as a set of points and the GPS data streams in as a similar set of points. I am attempting to track the progression of the current position across the path and I am wondering if there are any well known algorithms for this. I have come up with my own that works ok but it is a complex enough problem that I would like to minimize the amount of re-inventing of the wheel that I do.
What approach or algorithm would you recommend taking for this problem?
|
Just thinking it out, first I would get the formula to calculate the nearest distance from a point to a line. When you say you have the path as a set of points, I assume it's a directional graph and not just a set of points.
Then I would do an algorithm like this: (there are probably logical errors, but the idea is there):
loop through every line in the path
get the line which is closest to your current point
if the nearest distance is greater than some threshold
return not on path
#you could check if the nearest line segment is the next expected one if you want to do checkpoints
for the formula: <
|
stackexchange-gamedev
|
{
"answer_score": 1,
"question_score": 0,
"tags": "path finding"
}
|
Slim API POST in php
I made an API through Slim framework and I was testing it using the Advanced Rest Client. Now I want to implement in my php website the API rest. How Can I do that? Is better use AJAX or PHP for that? Can you give a small code demo?
Thanks in advance, I really appreciate.
I tried this code,is this the best solution: My problem here is that I need to add a header with an authorization key.
$data = array("title" => "otro libro", "isbn" => "998-84-8184-1", "author" => "otro autor :)");
$ch = curl_init("
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));
$response = curl_exec($ch);
curl_close($ch);
if(!$response)
{
return false;
}
else
{
var_dump($response);
}
|
You want to use AJAX. I guess its popular to use a javascript framework like jquery or angular.
You can then just pass your token along as a part of the body. I am most familar with jquery so heres a link to the docs.
<
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, ajax, http, slim"
}
|
wxFileDialog open in MyApp::OnInit() error
I am trying to open a wxFileDialog in MyApp::OnInit(), but I end up with an error message saying **"no matching function for call to ‘wxFileDialog::wxFileDialog(MyApp* const, const char [12], const wxChar* &, const wxChar*&, const char [6], )"**.
MyApp::OnInit()
{
wxFileDialog dialog2(this, _T("open a file"), wxEmptyString, wxEmptyString, _T("*.csv"), wxFD_OPEN);
dialog2.ShowModal();
... open the file and then do something ...
}
The idea is to allow the user to open a config file before the program starts. Can anyone offer some advice to this problem?
Thanks.
|
The problem is your first parameter, the dialog parent, it expects a `wxWindow*` but you are passing a `MyApp*`. Since you don't have a parent just pass `NULL` instead.
wxFileDialog dialog2(NULL, _T("open a file"), wxEmptyString, wxEmptyString, _T("*.csv"), wxFD_OPEN);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c++, user interface, wxwidgets"
}
|
Show reverse ManyToMany entries in Django Admin page
In the classical example of Articles/Publications, when I create a Publication record in Admin page, I would like to be able to add existing Articles to that Publication. How can I do that?
I tried following:
class PublicationAdmin(admin.ModelAdmin):
articles = Article.objects.all()
admin.site.register(Publication, PublicationAdmin)
though I do not see any articles to select at all.
I can do the other way around, when I add a new article, I can select a publication by adding
class ArticleAdmin(admin.ModelAdmin):
fieldsets =[('Publications', {'fields': ['publications']})]
|
You need to define an `InlineModelAdmin` on the `through` model, in your case the `through` model is `Publication.article_set.through`. See the docs.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "django, django admin"
}
|
resizing a subview and having superviews / window resize
My window is structured like so: NSWindow -> NSView -> NSTabView -> NSScrollView -> NSTextView. If I change the size of the NSScrollView with setFrameSize: the superviews / window do not resize to accommodate my larger or smaller NSScrollView. Is it possible to programmatically have the Window, etc. automatically resize when I set the size of a subview or do I need to somehow calculate the size of all the UI components and resize the window itself? Thanks in advance for any assistance or direction.
|
There is no built-in way to do this. You'll have to compute the sizes yourself. Assuming all the views in your hierarchy are set to auto-resize properly, you could just change the window's frame and let auto-resizing do its job.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "cocoa, nsview"
}
|
Replace certain variables with NA, one variable is NA
What is the best function to use if I want to replace certain variables with NA based on a conditional? {
df2$score_2 <- NA
}else{
df2$score_2 <- df$score_2
}
Thanks in advance
|
One option is to find the `NA`s in 'status' and assign the columns that having 'score' as column name to `NA` in `base R`
i1 <- is.na(df2$Status)
df2[i1, grep("^Score_\\d+$", names(df2))] <- NA
* * *
Or an option in `dplyr`
library(dplyr)
df2 %>%
mutate_at(vars(starts_with('Score')), ~ replace(., is.na(Status), NA))
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "r, conditional statements, na"
}
|
How to I get the window handle by giving the process name that is running?
How can I get the window handle by giving the process name or window title in c#.. given the process is in running already
|
You can use the `Process` class.
Process[] processes = Process.GetProcessesByName("someName");
foreach (Process p in processes)
{
IntPtr windowHandle = p.MainWindowHandle;
// do something with windowHandle
}
|
stackexchange-stackoverflow
|
{
"answer_score": 56,
"question_score": 28,
"tags": "c#, process"
}
|
Processing backspace in Java Swing
I have Java Swing code that process user's input as follows:
public class UserEntryPane extends JPanel implements DocumentListener {
…
@Override
public void insertUpdate(DocumentEvent e) {
try {
String c = a.getText(...);
if (c.equals("\n")) {
System.out.println(...);
...
}
else {
...
}
} catch (Exception e) {
e.printStackTrace();
}
}
The issue is that this method is not invoked when `Backspace` is pressed. How can I detect user's `Backspace` to process it correctly?
|
Seems you use `DocumentListener`.
Look at method `removeUpdate`. It called, when you use backspace.
@Override
public void removeUpdate(DocumentEvent arg0) {
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "java, swing, backspace"
}
|
How to git pull project and push new branch
Git has been introduced on a project, after I've been working on it for a bit.
Now there's a local git server, which hosts the base code, I've been working with and modified.
Now I need to create a new branch on the server, which features the modifications I made.
My plan is to pull(?) the current git repository to a new folder, copy over all the content - which I've been managing locally, then create a new branch locally and push(?) it again onto the server.
This would leave me with a new branch, which I can modify locally and push onto the branch on the server, is that correct?
mkdir project_git && cd project_git
git pull <remote>
git checkout -b my_changes
cp project project_git
git add -A
git commit -m "new branch with local changes"
git push origin my_changes
Is this the "correct" way to handle the situation? What commands would I need to use for this?
|
Creating a new branch for git server, you can `clone` the repo in another directory (if you have local repo, you can `pull` directly), and switch to a new branch locally and finally `push` to the git server. Detail steps as below:
# In another directory
git clone /path/for/git/server
cd repo
git checkout -b newBranch
# make changes
git add .
git commit -m "message"
git push origin newBranch
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "git, version control, branch, git branch, pull request"
}
|
How can they prove the superposition of particle states prior to measurement?
If every time a particle's spin or momentum is measured, it gives a discrete answer (collapse of possibility states), how can they ever prove that prior to measurement it was in fact in a super-position of states? Is this solely a logical extrapolation from the wave-like interference patterns seen in the slit experiment?
Clearly I don't understand something fundamental here.
|
There is an approach called weak measurement that can be used to probe the properties of a superposition without destroying it.
There is a reasonable detailed article on it on Wikipedia, or a more accessible article on the Nature web site.
|
stackexchange-physics
|
{
"answer_score": 2,
"question_score": 11,
"tags": "quantum mechanics, quantum spin, observers"
}
|
query of stores that order all types of products
In my db exists relations:
producttype: `type(PK) | description`
product: `id(PK) | title | type(FK) | price`
orderlist: `(productid(FK), orderid(FK))(PK) | quantity `
order: `orderid(PK) | date | shopid(FK)`
shop: `shopid(PK) | shoptitle | address | phone`
How i must create query to know which shops order all types of product.
|
Use `group by` and `having`.
Select s.shopid, s.shoptitle
From shop s join order o on s.shop_id = o.shop_id
Join orderlist ol on ol.order_id = o.order_id
Join product p on p.id = ol.product_id
Group by s.shopid, s.shoptitle
Having count(distinct p.type) = (select count(1) from producttype)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "sql, postgresql"
}
|
c# winform to inspect an object during runtime
I want to display the public Property/Values of an arbitrary object during runtime in a GUI.
Is there a winform which allows the user to view the content of any object like in debug mode? The object will hold many Dictionaries > and it would be nice to be able to expand and view the contents of those lists during runtime.
If not available, is there someway to achieve something similar?
Thanks
|
There's `PropertyGrid`:
var form = new Form();
form.Controls.Add
(
new PropertyGrid()
{
SelectedObject = new { A = "Hi", B = new [] { 32, 40 } }
}
);
form.Show();
It's quite far from how the debugger one works, but it can be quite easily modified to handle any special cases you might have.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "c#, .net, winforms"
}
|
Sum nested lists with recursive function
Hi i have a nested list which i should sum it from recursive function how can i do that? my solution didn't work
def n_l_sum(n):
s=0
for i in n:
if i==list:
s+=i
else:
s+=n_l_s(n)
return s
|
def n_l_s(n):
s=0
for i in n:
if type(i) != type([]):
s+=i
else:
s+=n_l_s(i)
return s
n=[3, -1, [2, -2], [6, -3, [4, -4]]]
print(n_l_s(n))
output:
5
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "python, nested lists"
}
|
Implicits not working as expected
The following code fails due to "could not find implicit value for rs":
import scalikejdbc.WrappedResultSet
object DatabaseSupport {
implicit class WrappedResultSetConverter(columnName: String)(implicit rs: WrappedResultSet) extends AnyRef {
def stringCol: String = rs.string(columnName)
def intCol: Int = rs.int(columnName)
}
def myTest(rsParam: WrappedResultSet) {
val a: String = "name".stringCol
val b: String = WrappedResultSetConverter("name").stringCol
}
}
I had thought that the _rsParam_ parameter to _myTest_ would be visible to the implicits?
|
It is not visible because it is explicit, it should be made implicit via the implicit keyword.
On the other hand, implicit parameters can be passed as explicit ones to methods.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "scala, implicit conversion"
}
|
Name of the encoding format
I was recently dealing with some encoding that was using this type of encoding showed below. Does it have some name?
3006BEIJING
Meaning
30 => ID of the property
06 => length of the data
BEIJING => the data
With the knowledge that Id and length is always represented with 2 characters, it can be easily read.
|
It is a variation of TLV aka "Type Length Value".
See < :
> Within data communication protocols, TLV (type-length-value or tag-length-value) is an encoding scheme used for optional information element in a certain protocol.
>
> The type and length are fixed in size (typically 1-4 bytes), and the value field is of variable size. These fields are used as follows:
>
> **Type** A binary code, often simply alphanumeric, which indicates the kind of field that this part of the message represents;
>
> **Length** The size of the value field (typically in bytes);
>
> **Value** Variable-sized series of bytes which contains data for this part of the message.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "encoding"
}
|
Get the names of the datagridview present in the form
How can I check the number of `DataGridViews` on a form, and then display present their names in `VB.NET`?
I have tried this:
For Each dgv As DataGridView In Me.Controls
MsgBox(dgv.Name)
Next
But my guess is that `Me.Controls` consists of every other form controls except `DataGridView`?
|
For Each _control In Me.Controls
If TypeOf _control Is DataGridView Then
MsgBox(_control.Name)
End If
Next
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "vb.net, datagridview"
}
|
Can iframe detect domain name from which is it loaded on?
Can iframe detect domain name from which is it loaded? I want to see from which domains my widget is loaded?
|
You can try using the document referrer property:
console.log(document.referrer);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "iframe, dns"
}
|
strike out unification ($\sqcup$)
I need to denote that two varibles do not unify. `A \not \sqcup B` produces an unpleasant result:
?
\documentclass{article}
\usepackage{amsmath}
\usepackage{slashed}
\usepackage{centernot}
\begin{document}
\[A \sqcup B\]
\[A \mathbin{\slashed{\sqcup}} B\]
\[A \centernot\sqcup B\]
\end{document}

-- INSERT INTO tblresult
SELECT Type
FROM rcte
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 5,
"tags": "sql, sql server, recursive query"
}
|
.Net c# libraries / assemblies - Crystal Reports
i've developed a .Net C# (Crystal Reports) application in computer 1
dependencies link : <
while running this application in computer 2 , it doesn't work because of the missing dependencies
how can i import all these dependencies with the application to make it running everywhere ?
not by copy & paste all the Needed DLLs in the same path with the executable ? or how ?
thanx a lot
|
You will need to install the **Crystal reports** on the target machine. By this you will have all `dll`s on the same path and application will find them automatically.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, .net, crystal reports"
}
|
Как установить несколько Live CD на флешку?
Есть:
1. Флешка на 8 гб, разбитая на 4 раздела (FAT32 для использования по назначению, NTFS для Alkid live CD и два ext2 раздела для Ubuntu Live DVD и ESET Rescue Disk)
2. Все перечисленные выше образы.
Нужно получить флешку, при загрузке с которой появлялось меню (grub2, или любого другого загрузчика) с выбором нужного live cd.
Пробовал распаковать каждый из образов в нужный раздел и установить grub из-под Ubuntu. Grub устанавливается и даже загружается, но при установке находит только ОСи на жестком диске, соответственно ни один из live cd я загрузить не могу. Исправить grub.cfg вручную не получилось... Может кто-нибудь знает решение?
|
Мультизагрузочная флешка MultiSystem: Ubuntu customized, Clonezilla и Windows 7 на одном USB.
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": 2,
"tags": "usb, grub"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.