INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Correspondence Theorem in Linear Algebra
(Correspondence Theorem) Suppose $ M\subseteq V$ is a subspace. There is an inclusion preserving bijection $$\\{ T : T \text{ is a subspace with} M\subseteq T \subseteq V\\} \leftrightarrow \\{ \text{ subspaces of} V/M\\} $$ given by $T\mapsto P_M(T) $.
I am looking for a proof that the function $ T\mapsto P_M ( T) $ is injective and inclusion preserving, including the inverse function. All proofs I have found have used a group theory approach. Any help is appreciated.
|
Suppose that $p_M(T) = p_M(S)$. Then if $t \in T$, we have $s_t \in S$ such that $[t] = [s_t]$ or equivalently, $t-s_t \in M$. Thus,
$$ t = (t-s_t) + s_t \in S $$
because $t-s_t \in M \subset S$. This proves $T \subset S$, and by symmetry we have $T = S$. As for inclusion preserving, there's no linear algebra here: take $f : A \to B$ to be any function between sets. Then both $f$ and taking preimages of $f$ are inclusion preserving operations. (Careful! Strictly speaking, $p_M$ has no inverse in general).
A group theory approach is "inevitable", in the sense that vector spaces are abelian groups with additional structure. Note that we only use the group structure (i.e. the sum of $V$) for the proof. The extension to the context of vector spaces comes when checking that linear functions send subspaces to subspaces and the same for preimages, etc.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "linear algebra"
}
|
Why can't GC figure it out?
My question is simple, why GC can't figure it out that `timer` object in the `main` should be garbage collected along with the `timer` inside `TestTimer` and associated `EventHandler`?
Why am I continously getting `console.Writeline` output?
class Program
{
public static void Main()
{
TestTimer timer = new TestTimer();
timer = null;
GC.Collect();
GC.WaitForPendingFinalizers();
Console.ReadKey();
}
}
public class TestTimer
{
private Timer timer;
public TestTimer()
{
timer = new Timer(1000);
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
timer.Start();
}
private void timer_Elapsed(Object sender, ElapsedEventArgs args)
{
Console.Write("\n" + DateTime.Now);
}
}
|
Don't depend on the GC, use the Dispose pattern to properly dispose the `TestTimer` (which then should dispose the `Timer`).
However, what happens is that the timer keeps itself alive by getting a GC handle on itself. Read this blog post:
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 6,
"tags": "c#, event handling, garbage collection"
}
|
FullCalendar: refetchEvents call causes to all meetings to blink during re-rendering
I play with fullCalendar and I use refetchEvents:
$('#calendar').fullCalendar('refetchEvents');
It works properly and this command calls `events` method with callback
events: function (start, end, timezone, callback) { /* ... */ }
however it first **remove** all meetings from calendar and after - renders new ones. This approach causes to all table to _blink_ (different from google behaviour).
Is there any other way to render meetings without _clear-add_?
* * *
Seems like I need to add only deltas that makes work too hard, messy and not stable
Thanks,
|
My suggestion is to do the ajax request first (where you initially put `.fullCalendar('refetchEvents')`), and if it succeeds, then call refetchevents. The code will look something like this:
var events = [];
$.get('/events/get', function(result){
events = result;
});
$('#calendar').fullCalendar({
events: function (start, end, timezone, callback) {
callback(events);
}
});
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "javascript, fullcalendar"
}
|
SSH tunnel speed is very slow
I have remote server with Ubuntu Linux and I want to establish SSH tunnel with this server from Windows machine using PuTTY(plink). I have to use this method for getting access to some service on this server, because firewall is blocking all ports on this server except 22 ssh port. But speed of connection over SSH tunnel is VERY SLOW. I have checked speed using iperf tool.
Here is results of using iperf without SSH tunnel:
[ 5] local <remote_server_ip> port 5001 connected with <my_internet_ip> port 11154
[ ID] Interval Transfer Bandwidth
[ 5] 0.0-10.4 sec 5.12 MBytes 4.13 Mbits/sec
And it is results of using iperf over SSH tunnel:
[ 4] local 127.0.0.1 port 5001 connected with 127.0.0.1 port 38231
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-15.2 sec 896 KBytes 484 Kbits/sec
Speed is really different. How is it possible? What should I do to fix it?
|
Probably it's worth a read of this "Why TCP over TCP is a bad idea", it would be better to use a VPN than to rely on SSH for anything more than throw away tunnels.
Admittedly, that's a lot slower than I would have expected, even from an SSH tunnel. Perhaps you need to tune your SSH options.
|
stackexchange-serverfault
|
{
"answer_score": 3,
"question_score": 5,
"tags": "ubuntu, ssh tunnel, putty, iperf, plink"
}
|
Close application through the website
I think I am missing something with the way Electron apps are built but I am using the frame-less option in my `main.js` to hide the exit button for my application and I want to implement my own in code but I can't figure out how to trigger the actual termination of the application. I am using angular2 CLI generator project that I combined with Electron.
Based on my googling, I found I need to use `const remote = require('electron').remote;` but that gives me a `index.js:4Uncaught TypeError: fs.readFileSync is not a function` error that makes no sense to me. I believe its because I'm trying to execute a node-only module on the Angular App. I think I am missing something.
Does anybody know what's going on?
|
The issue was angular CLI uses commonJS and i was trying to use require which doesn't play nicely. To solve this I added the following to my index.html
<script>
const electron = require('electron');
</script>
and then in my typings.d.ts I added `declare var electron: any;` so that it doesn't throw errors when I try to access electron throughout my app.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, ecmascript 6, electron"
}
|
No result returned from ActiveRecord execute_procedure() in Rails
I am trying to execute a stored procedure in my SQLServer database. The procedure does what it is supposed to do, but whenever I try to run it from my Ruby on Rails app, it executes the procedure, but I cannot get a return value. I have also tried modifying the procedure to use an output parameter.
@success = ActiveRecord::Base.connection.execute_procedure("procedure",params[:field1],params[:field2],params[:field3])
render html: @success
The render shows an empty array. It should be a 1 if the procedure succeeds or a 0 if it fails. When I run this in SQL Server Management Studio, I can get the return value. What am I doing wrong?
|
I found the answer from < I need to run the procedure, then get the return from the raw connection as follows.
ActiveRecord::Base.connection.execute_procedure("procedure",params[:field1],params[:field2]
@success = ActiveRecord::Base.connection.raw_connection_return_code
|
stackexchange-stackoverflow
|
{
"answer_score": -1,
"question_score": 1,
"tags": "sql, ruby on rails, sql server, ruby"
}
|
How to remove firebase database
Please tell me, how can I delete the entire database from firebase immediately, documentation or other information could not be found, can anyone come across this before?
it,s easy
db = Database.database().reference()
let usersReference = db
usersReference!.removeValue()
|
db = Database.database().reference()
let usersReference = db
usersReference!.removeValue()
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ios, swift, firebase, firebase realtime database"
}
|
What is the equal sign with 3 lines mean in Wilson's theorem?
I'm reading up on Wilson's Theorem, and see a symbol I don't know... what does an equal sign with three lines mean?
I'm looking at the example table and I still can't infer what they are trying to say about that relationship between equations.
|
$$(n-1)! \equiv -1\pmod n$$ means that $(n-1)!$ and $-1$ differ by a multiple of $n$. Or, if you prefer, that $(n-1)!+1$ is a multiple of $n$.
In general, $$a\equiv b\pmod n$$ means that $a$ and $b$ differ by a multiple of $n$, or that $a-b$ is a multiple of $n$.
It's explained in detail in the Wikipedia article on "modular equivalence". The $\equiv$ symbol itself is pronounced "is equivalent to".
|
stackexchange-math
|
{
"answer_score": 7,
"question_score": 5,
"tags": "notation, self learning"
}
|
Communication betweeh BHO and Explorer Bar
I've a IE Explorer bar (Band object) with lots of UI and communication to server which I would like to implement in C# (.NET). I also have a BHO with all kind of DOM manipulation and events which I would like to implement in C++ (using ATL). What should be the best way to communicate between these two components. Given that a single process can have several of those (Explorer Bar and BHO **_per tab_** ), the pairing has to somehow facilitate IE.
|
You can use IE to facilitate connections, for example you can call IWebBrowser2::PutProperty to store the automation interface of your BHO and retrieve it in your explore bar.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "internet explorer, com, bho"
}
|
Android: Why does the calculated available space differ from Android's displayed available space
I have a question regarding the (free) available space in Android. If I open my Android settings, I can see that my external SD card has about 9GB of free space. But if I do some calculations in an Android application, I only get 1GB out of it. I'm using the following lines:
double freeSpace = stats.getAvailableBlocks() * stats.getBlockSize() / 1024;
and
Environment.getExternalStorageDirectory().getUsableSpace();
What's the reason for this? I just want to get the available space on my SD card that I can use.
|
On most modern Android devices, external storage is the part of the built-in flash that is accessible via a USB cable. While a long time ago external storage tended to be implemented via micro SD cards, that has not been the case in ~4 years and is rather rare today. Hence, `getExternalStorageDirectory()` is probably not what you want.
If your device is running Android 4.4+ -- particularly if it shipped with Android 4.4+ -- then if `getExternalFilesDirs()` returns 2+ entries, the second and subsequent locations are on removable storage. In principle, you could use those with your techniques from your question to try to determine the free space on the card. That being said, I have no idea if this works, as I have never tried it.
On the whole, removable media is mostly there for the benefit of device manufacturers and pre-installed apps, not ordinary SDK apps.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "android"
}
|
How to rename property/attribute of resource with jsonapi-resources ruby gem
I am building json api with rails using jsonapi-resources gem. The library is really great, it does a lot of job.
However some column names in our DB is not really meaninful to be showed in API.
So, my question: is possible to rename property/attribute in resource?
Example:
Let's say I have model User with attribute `login`.
class User < ActiveRecord::Base
attr_accessor :login
end
And I want `login` in API appear as `username`, e.g.:
class UserResource < JSONAPI::Resource
attribute :username, map_to: :login
end
Thanks!
|
Set a `:username` alias for your `:login` attribute:
class User < ActiveRecord::Base
attr_accessor :login
alias_attribute :username, :login
end
Then in `JSONAPI::Resources` (JR) you can specify your `username` attribute like so:
class UserResource < JSONAPI::Resource
attribute :username
end
By setting an alias, you've mapped the `username` attribute to the `login` attribute, so it doesn't matter whether you use `username` or `login`, it will return the same value.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "ruby on rails, ruby, jsonapi resources"
}
|
PDO Problem. Execute arguments not being read?
Here is my function to return the most popular videos. For some reason it don't acknowledge the :limit. If I remove ':limit' and implicitly put in the number 10 it works.
Method:
function getPopularVideos($limit) {
$dbc = connectToDatabase();
$q = $dbc->prepare('SELECT * FROM video ORDER BY views DESC LIMIT 0, :limit');
$q->execute(array(':limit' => $limit));
return $q->fetchAll(PDO::FETCH_ASSOC);
}
Calling code:
$popularVideos = getPopularVideos(10);
Any idea's what I'm doing wrong. Little confused.
|
According to this comment on php.net this happens because the limit is being quoted, which wrecks the SQL syntax. The suggested workaround is using bindParam instead.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "php"
}
|
Capture payment on fulfilment in shopify
How do I make Shopify capture payment once an order is marked as fulfilled?
The only prefedined settings seems to be to capture instantly, or no auto capture at all.
|
When you set your store to authorize a payment but not capture payment, Shopify will then present you with a capture payment button when you examine the order. So if you fulfill the order and you know you want to capture payment, press the button.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "shopify"
}
|
Rails how to fetch data from model specified in form select?
Let's say I have this form select :
<%= form_with(model: task, local: true) do |form| %>
<%= form.select(:person_id, Person.all.collect {|c| [c.person_name, c.id]}, {prompt: "Select a person"}, {class: 'col-md-12'}) %>
In my task controller, in my create def, I'd want to be able to fetch the person_name but it turns out I can't. For example, I can fetch the id by doing @task.person_id, but I can't do @task.person_name. How would I achieve this? I'm thinking about maybe options_for_select or maybe collection_select, but I'm very unsure.
Anyone has an idea? Thank you :)
|
Turns out I fixed it by doing this in my def create of the controller :
name = @task.person_id
@person = Person.find(name)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ruby on rails, ruby"
}
|
Default Starting Conditions for new characters?
> **Possible Duplicate:**
> What's the backstory if you don't import a save?
What are the default starting conditions for new characters (non-imported) in Mass Effect 3? I would assume this question has come up somewhere before, but so far I haven't been able to find a concise answer.
I already read so much that the game assumes you made the dumbest of choices in ME2, so Jack is dead and no romancing Miranda in ME3. But what are the other conditions to look out for?
|
* No DLC, sidequests or Loyalty Missions are counted toward Mass Effect 3. This includes two DLC exclusive characters, Zaeed and Kasumi, who count as never being recruited.
* Tali is exiled from the Migrant Fleet.
* Shepard does not enter into any romantic relationships. Again.
* Grunt is not recruited.
* Legion is not recruited, and no choice is made for the Geth.
* Samara is never recruited. She is killed by Morinth trying to escape from Ilium.
* Suicide Mission Survivors: Mordin, Jacob, Garrus, Tali and Miranda.
* Suicide Mission Survivors (Normandy Crew): Joker and Chakwas. All other crew members are considered killed.
* Suicide Mission Deaths: Jack, and Thane.
* The Collector Base is destroyed.
* Although the DLC is not considered completed by Shepard, the events still occured. The Batarian System is destroyed, and Liara is the Shadow Broker.
|
stackexchange-gaming
|
{
"answer_score": 1,
"question_score": 1,
"tags": "mass effect 3"
}
|
c language+Two dimensional array
I am having one c code. Where i had given an array index as 12.But it is allowing me to initialize the array more to that index instead of giving error for index out of bound. Can any one please explain me y it is happeining.
int vas1[12][12];
vas1[15][15]=0;
int i,j;
for (i = 0; i < 15; i ++)
{
for (j = 0; j < 15; j ++) {
printf("i=%d j=%d vas=%d",i,j,vas1[i][j]);
}
}
printf("Success");
Thanks
|
C doesn't do bounds checking on array accesses. It simply marks illegal accesses as "undefined behavior" so each implementation can do as it please. Since using C means you know what you're doing, C allows you to shoot yourself in the foot.
In practice, sometimes you will get an error, sometimes not. Sometimes you won't get an error but the client will. Worst case scenario: you won't get an error but the program will behave _really_ weird (variables changing values for no reason etc).
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "c, multidimensional array, undefined behavior"
}
|
How can I prove $tr(ST) = tr(TS)$ for two linear operators on a finite dimensional Hilbert space?
I would like to know how to prove that $$tr(ST) = tr(TS)$$ for two linear operators $S$ and $T$ on a finite-dimensional Hilbert space $\mathcal{H}$, given the following definition of the trace operator: $$tr(T)=\sum_{i=1}^n{\langle T e_i, e_i \rangle}$$
for an orthonormal basis $\\{ e_i \\}_{i=1}^n$ in $\mathcal{H}$. Is there a way to prove this without representing the operators as matrices?
|
I am not sure that this is different from writing an operator as a matrix, but you can argue as follows: for any operator $U$ you can write $$U(\cdot) = \sum_j U(e_j) \langle \cdot , e_j \rangle$$ and thus for the trace of $ST$ you can find: $$Tr(ST) = \sum_{i,j} \langle S(e_j), e_i \rangle \langle T(e_i), e_j \rangle $$ Now in the last formula you can commute the terms in the product. Hence the result.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "linear algebra, functional analysis, operator theory, hilbert spaces"
}
|
Why can't I import "white" color from Material UI colors?
I need to convert a Material UI icon to white because background is another color.
I am importing white from their core colors library:
import { white } from '@material-ui/core/colors';
So I can do:
style={{ color: white }}
However, I am getting an error message:
./src/components/footer.js
Attempted import error: 'white' is not exported from '@material-ui/core/colors'.
I cannot see what I am doing wrong based on their docs. I have throughly researched why I am getting this error but couldn't find solution.
|
Check available color palette from MaterialUI here
White is not available.
But you can use `'white'` as string, as CSS has 'white' as value
style={{ color: 'white' }}
A complete list of colors supported by CSS can be found here
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 5,
"tags": "reactjs, material ui"
}
|
selectfield with couple lines sencha touch 2
I'm try to put long option into Sencha Touch 2 `selectfield` It is work only for picker but I need to display whole option text inside `selectfield` too. Let me explain with pictures. I have !enter image description here I want (painted in GIMP) !enter image description here I tried to increase height of `selectfield` and apply `white-space: pre-wrap !important;` but text still truncated...
|
I solved it! I looked through Sencha-2.2 sources and found that `selectfield` extended from the `textfield`. I copied `selectfield` source in my own class `areaselectfield` and changed there only two lines:
extend: 'Ext.field.TextArea',
xtype: 'areaselectfield'
Maybe there is simpler way but it works
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 4,
"tags": "sencha touch"
}
|
HTML table with fixed cells size
I have an HTML table which has equally divided rows and columns. I would like each cell to be of a fixed size, say 40px width and 30px height. When I change the size of the browser window, the cells size changes also. How can I prevent it ? I would expect to see the scroll bars if browser's window become too small. Is that right to set the height and the width of the cell in pixels ? Thanks !
|
You have to specify the size of the table to prevent it from being adjusted to fit the page.
When you specify the size of the cells that is just a minimum size, they will get larger if the table is larger. Also, if you have specified the size for all cells, and the table is smaller than the sum of the cell sizes, the cells will have to get smaller than specified.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "html"
}
|
Yii2: передача конкретного сценария при обновлении данных
Можно ли как-то определить конкретный сценарий валидации данных в модель? В оф.документации есть только при создании новой записи, а для обновления не нашел.
|
Создание новой или обновление существующей модели не играет роли. Сценарий необходимо установить перед загрузкой данных в модель. Сделать это можно подобным образом.
$this->model->setScenario($this->model::SCENARIO_FEEDBACK_TRANSFER);
$model->load(\Yii::$app->request->post());
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "yii2"
}
|
How git "hides" files between branches?
I'm just interested in **_how git "hides" files between branches_**. I was looking for it but didn't find anything. So let me describe what I mean:
I have to branches `master && red`
Switch to the `red` branch and create a new file and also commit it
git checkout red
touch test.js
git add test.js
git commit -m "Added new file for test"
ls
And i got list of files in my repo on the `red` branch
> README.md app.js index.html new-red.js new-test.js red.js test.js
Now let switch to the `master` branch and tyle `ls`
git checkout master
ls
files on a master branch
> README.md app.js index.html new-red.js new-test.js red.js
So how git "hides" the test.js files between branches?
Thanks
|
What you intended to ask is "Where does Git store all the data that is not currently in the working directory tree?".
The short answer is "In the `.git` directory."
For the long answer, see the documentation.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 4,
"tags": "git"
}
|
MATCH & paste in Excel
Googling this wasn't productive, hence posting here.
I have data available in columns D and E. When adding numbers into column A, I need Excel to check if it exists in column D. I'm able to do that with MATCH function (no match for A1, however match exists between A2 and D3).
What I'm missing is that if there is a match between columns A and D, I would also need to paste data in column E into column B. I.e. as a match is found for cell A2 in cell D3, cell B2 should be filled with data in cell E3 (text "Yellow").
I have left column C for the formula, but that's not important. How to tackle such a thing? Not essential to definitely use MATCH.
A B C D E
13 #N/A 25 Blue
11 5 Red
11 Yellow
9 White
33 Yellow
|
The forumla you are looking for is VLOOKUP.
=VLOOKUP(A2,D:E,2,FALSE)
This will find the value in A2 in column D and return the value in column E, which it finds an exact match.
Put this formula in B2 and copy it down as needed.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "excel"
}
|
find_elements_by_partial_link_text won't locate the elements
In the website i visit there are 7 links of the following structure:
<tr>
<td>
<a href="some link i will need to visit" title="some title"> some text... Episode ....
</a>
</td>
<td> some date </td>
</tr>
Now i use the following code to fetch the episodes and put them in a list
chromedriver = "C:/.../chromedriver.exe"
driver = webdriver.Chrome(chromedriver)
driver.get("link containing the content")
episodes = driver.find_elements_by_partial_link_text('Episode')
print "episodes found: ", len(episodes)
This always prints `episodes found: 0`. I've tried using a piece from the beginning of the hyperlink text, but it still doesn't work. Any help would be appreciated.
The link is this
|
Aside from what @nullpointer null-pointed out, notice the delay in the webpage load - _the elements you are looking for are not immediately available and you need towait for them to be present_:
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//a[contains(@title,'Episode')]")))
episodes = driver.find_elements_by_xpath("//a[contains(@title,'Episode')]")
print(len(episodes))
driver.close()
Prints `8`.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "python, selenium, selenium chromedriver"
}
|
card reader не читается
Кто-нибудь сталкивался с тем, что в линукс не читаются карты памяти SD? Само устройство определяется, но при вставке карты в лоток ничего не происходит, даже после перезапуска системы. Может кто подскажет что можно сделать?
|
Файловая система на SD карте быть может та которая не распознается.. какой дистр, ФС и пр. инфу в студию
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "linux"
}
|
Need help understanding proving a multivariable limit exists
I understood the reasoning up until equality 3. I cant understand it. Can anyone guide me through the reasoning to get to that inequality?"` and the method sits right there in page body. Full content is here: < but most interesting piece is at the end:
var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0');
printWindow.document.write(printContentWrapper.html());
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
I added debugger breakpoint at the first line with "close" and clicked the link. Then I got a small window in bottom left corner of the screen with content I wanted to access.
It took more time than copying content to text editor and formatting it manually, but what I learned was worthwhile (-:
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 2,
"tags": "firefox, google chrome, printing"
}
|
Concatenate multiple SQL scripts using CodeSmith template
I'm trying to create simple tool for concatenating SQL scripts using CodeSmith.
I have template which is generally just:
* header (check whether tables exists, begin transaction)
* body (concatenated scripts should be placed here)
* footer (commit or rollback transaction)
Scripts are stored in separate .sql files. I need to pick these files through CodeSmith Explorer during template generation, but I don't know which `UITypeEditor` to choose.
I've tried FileNameEditor, but it allows to choose only one file.
Is there any existing `UITypeEditor` for this purpose? Or do I need to create such by myself?
|
If you wish to pick a fie then the FileNameEditor is your best choice. If you wish to choose multiple files I'd create my own. If you have to parse the sql files then I'd recommend just selecting a base folder using a UITypeEditor and then using DirectoryInfo to get a list of files matching a pattern in that directory.
If you are looking to concat the output of various templates this can be done via a Generator Project File (See project options -> Single File) out of the box or you could update your master template to accomplish this.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "concatenation, sql scripts, codesmith"
}
|
Posting Instagram Photos Automatically
I'd like to post my Instagram photos to my WordPress blog.
I cannot use one of the many existing Instagram plugins, though, because those plugins simply post the images on my blog but they are still hosted by Instagram. I'd like this to be a batch process that will actually upload the Instagram photo to my WordPress media library and then post it.
In summary: How do I automatically _upload and post_ Instagram photos to my WordPress blog ( _not_ via a sidebar widget)?
|
You'll probably have to do your own integration, but here's how I would approach it:
1. Grab an Instagram PHP wrapper: < OR < OR <
2. Authenticate via an admin option page
3. Iterate through your user images using the `/users/self/feed` method
4. Use the media_sideload_image() function found in wp-admin/includes/media.php to download the images
5. Keep a running cache of downloaded Instagram image IDs in an option to check before downloading an image.
If you want this to work as a WordPress gallery, you could assign a specific post ID to `media_sideload_image` and then include a gallery on that post.
It seems pretty straightforward. Check out the API documentation for self/feed: <
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 1,
"tags": "plugin recommendation, automation"
}
|
Does C have to calculate out a number in scientific notation?
The max value of a float is 3.40282347E+38. This is equivalent to 3.40282347 * 10^38. I am wondering if I set a float equal to this, does it have to actually perform the power and multiplication to get the value to store, or is scientific notation simply the actual value?
I am writing a school project in which we are optimizing as best we can, so this is relevant to me, especially since it is within a nested loop structure.
|
When you use literals in your source code, those literals (and mostly expression containing all literals for constant folding) are evaluated at compile time and converted to instructions like `move immediate`, `add immediate`, `move special_constant_register` etc.
For ex:
int a = 10, b = 0xA;
Here both `10` and `0xA` literals are evaluated to same value at compile time. In your case also, `double` literal or `float` literal would be evaluated at compile time and most appropriate value would be assigned to the variable.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "c, floating point, scientific notation"
}
|
Relationship between solubility and enthalpy of solution
I'm reading my lab manual and there is a part where it goes through Van't Hoff's isochore. That's fine but then it states
> The variation of the solubility of a substance with temperature may thus be given by the relation
>
> $$\dfrac{d \ln Sol}{dT}=\dfrac{\Delta H}{RT^2}$$
where do they derive this from. Is it from chemical potentials and mole fractions. I can't really find a good derivation and explanation online.
|
For equilibria such as $\ce{[C6H5COOH]_{(s)} <=> [C6H5COOH]_{(aq)} }$. The equilibrium constant $K_{eq}$ can be written in the very simple form:
$$K_{eq}\equiv \ce{[C6H5COOH]_{(aq)}} \equiv \text{solubility}\, (sol)$$
That's more than likely where the equation comes from. Then you get
$$\dfrac{d \ln Sol}{dT}=\dfrac{\Delta H}{RT^2}$$
when you separate the variables and integrate with respect to both sides you get:
$$\int_{\ln sol_1}^{\ln sol_2}d(\ln sol) = \int_{T_1}^{T_{2}}\dfrac{\Delta H}{RT^2}\, dT$$
$$\ln sol_2 - \ln sol_1 = \dfrac{\Delta H}{R}\Bigg{(}\dfrac{1}{T_1}- \dfrac{1}{T_2}\Bigg{)}$$
Which gives the useful result
$$\ln \dfrac{sol_2}{sol_1}= \dfrac{\Delta H}{R}\Bigg{(}\dfrac{1}{T_1}- \dfrac{1}{T_2}\Bigg{)}$$
|
stackexchange-chemistry
|
{
"answer_score": 5,
"question_score": 4,
"tags": "physical chemistry"
}
|
Retrieve random row from a Table from ids in a string
I am trying to select a random row from my table with ids in my array.
The string $data has all the list of ids that i want separated by commas.
$statement = $conn->prepare("SELECT * FROM clients ORDER BY rand() WHERE find_in_set(id,'$data') LIMIT 1");
this is my query,
id is the field of my table.
Here is the error
An error has occurred exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE find_in_set(id,'0,1') LIMIT 1' at line 1' in
|
Your query is wrong. You need to rewrite it first. See below one
$statement = $conn->prepare("SELECT * FROM clients WHERE find_in_set(id,'$data') ORDER BY rand() LIMIT 1");
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, mysql"
}
|
Modal Popup from CEWP
I need some help. I'm very new to SharePoint development so please go easy on me.
Here is what I'm trying to do:
* I need a Modal window to popup during page load of home.aspx to display a disclaimer with an "I Agree" button.
* What I have so far is that while editing the CEWP it will popup everytime and close properly with the button but only while in edit mode.
* Once I click OK and go back to the public shared view, it throws an error referencing SP.UI.ModalDialog.
* SP.UI.ModalDialog is not a file on our SP2010 server.
Here is the code I'm using in the CEWP:
<script type="text/javascript">
function codeAddress() {
var options = {
url: " };
SP.UI.ModalDialog.showModalDialog(options);
}
_spBodyOnLoadFunctionNames.push("codeAddress");</script>
This is the line it errors on: SP.UI.ModalDialog.showModalDialog(options);
Any help would be greatly appreciated!
Thanks,
Bg
|
SharePoint 2010: JavaScript error when creating Modal Dialog?
Use ExecuteOrDelayUntilScriptLoaded.aspx), to make sure it executes after sp.js is loaded!
<script type="text/javascript">
function codeAddress() {
ExecuteOrDelayUntilScriptLoaded(function () {
var options = {
url: " };
SP.UI.ModalDialog.showModalDialog(options);
}, 'sp.js');
}
_spBodyOnLoadFunctionNames.push("codeAddress");</script>
|
stackexchange-sharepoint
|
{
"answer_score": 1,
"question_score": 1,
"tags": "error, popup"
}
|
Do I need a swap space to use Hybrid-sleep?
Battery levels setting is now handled by UPower on latest Ubuntu and other systems. Instead of using gsettings, one should now edit the file `/etc/UPower/UPower.conf`.
As specified by that file:
# The action to take when "TimeAction" or "PercentageAction" above has been
# reached for the batteries (UPS or laptop batteries) supplying the computer
#
# Possible values are:
# PowerOff
# Hibernate
# HybridSleep
#
# If HybridSleep isn't available, Hibernate will be used
# If Hibernate isn't available, PowerOff will be used
That is, normal Suspend is not possible at critical battery level, but only HybridSleep. (That was posted as a bug here.)
But Hybrid Sleep doesn't seem to be available on my system.
Could it be because I don't have a swap space? (That's what I think the bug reporter says: "PowerOff is the only option for machines lacking a swap partition".)
|
The answer is 'Yes'.
After creating a swap partition both hibernation and hybrid sleep are available.
Hybrid Sleep is **both** hibernation and sleep/suspend, but to the user it looks more like suspend. Like hibernation, it 'swaps' RAM data to the hard disk and can restore it even in case of power failure. It acts like sleep/suspend in that it refreshes RAM constantly and therefore (if the battery is not fully depleted) can wake up as quickly as normal suspend.
|
stackexchange-unix
|
{
"answer_score": 2,
"question_score": 2,
"tags": "swap, power management, suspend"
}
|
Execute PHP code on every call
I need to execute some PHP code on every admin view/action. E.g
file_put_contents('somelogfile.log', 'I just executed admin action');
Where should I put this code so that it wont be swept away when I should upgrade my Joomla?
Joomla version is 3.8.6.
|
You can create a plugin. See <
Joomla automatically calls enabled Plugins on each trigger event.
Depending on the state the application has to be in for your code to be executed, you can choose the appropriate trigger event. See <
There are also existing plugins that allow you to just place your code in the configuration interface in the backend. I haven't tried those though and I don't know if they work on every event.
|
stackexchange-joomla
|
{
"answer_score": 3,
"question_score": 2,
"tags": "joomla3.8"
}
|
Beep by PhoneGap- Android
I tried to use the PhoneGap notification and beeping when a function is called (Android)
According to **this** document
All I have to do is put this line:
navigator.notification.beep(2);
And add in app/res/xml/plugins.xml this line:
<plugin name="Notification" value="org.apache.cordova.Notification"/>
and in app/AndroidManifest.xml this line:
<uses-permission android:name="android.permission.VIBRATE" />
It did not work for me.
My function:
function BeepNow() {
navigator.notification.beep(2);
}
Am I missing something?
|
Problem solved, I was missing the **JS of cordova** in head
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, android, html, cordova, notifications"
}
|
Using Query datatype in C#
I have a piece of code which returns a Sales Order from AX. In that record im using the querySalesLine method but I'm not sure where I go from there to get all the lines attached to the order below is my code:
AxaptaRecord OrderRecord = (AxaptaRecord)ax.CallStaticClassMethod("OnlineOrder", "getSalesOrder", salesRef);
if(OrderRecord.Found)
{
AxaptaObject Lines = (AxaptaObject)OrderRecord.Call("querySalesLine");
}
How would I then use this Lines object to retrieve all of the items attached to this order? I know that the querySalesLine returns a Query object but not sure what to do next.
|
You should create a `QueryRun` object, then use that object to read the lines.
var qLines = (AxaptaObject)OrderRecord.Call("querySalesLine");
var qrLines = ax.CreateAxaptaObject("QueryRun", qLines);
To read the lines use this answer.
The Query is a static description of the query.
The QueryRun uses the query to find the records.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "c#, axapta, ax"
}
|
What does $w(t) ∈ \mathcal{L}^1$ mean?
I am reading a paper where it is mentioned the following:
> The function $w(t) ∈ \mathcal{L}^1$, where $w(t) ≥ 0$
so what does $\mathcal{L}^1$ mean here?
|
In most contexts in math, the set $\mathcal{L}_1$ is the set of all such functions from a space $X$ to either $\mathbb{R}$ or $\mathbb{C}$ that are absolutely integrable:
$$ \mathcal{L}_1 = \left\\{ f:X \to \mathbb{C} : \int_X |f| dx < \infty \right\\} $$
In measure theory, the functions are measurable and the integral is $\int_X |f| d\mu$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "functions, notation"
}
|
What is a good way to pass authentication info to API methods in PHP NuSoap?
I am using NuSoap to implement an api server. The public SOAP API may have a method such as:
function createComment(articleID, content);
This would ideally create a comment on the given article and attribute it to the user who was authenticated.
Authentication is being handled via http auth. So, the nusoap_server object has the user information.
How can createComment have access this information? It knows nothing about the server. I wanted to avoid putting the user info in the global space, but I am starting to think there's no other easy way.
Is there a technique that allows the public signature for the method to remain as stated above, while the implementation method has additional arguments (user info)?
|
SoapServer is meant to provide a means to call a function w/ parameters remotely. The function being called doesn't have any information about the SoapServer handling the communication to make this happen--all it sees is the parameter's being passed to it. So unless you want to add the user credentials as actual parameters to the function call then you'll need to do something like registering the credentials globaly. This doesn't have to be in the global scope explicitly. It could be registered in some value Registry pattern instance.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, nusoap"
}
|
Target class [AuthController] does not exist Laravel 8
I get this error after usual installation that works for me for years... Dont really know what have changed now.. Can any one help?
|
Very simple... The issue is from Http\Provider\RouteServiceProvider.php. To make it work exactly the way your installation have been working, include the namespace variable
public const HOME = '/home';
......
protected $namespace = 'App\Http\Controllers';
........
Happy coding:-)
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 1,
"tags": "laravel, laravel 8"
}
|
Remove last comma from a string in JavaScript
I have a JavaScript method to return an array of database objects. The following Kendo UI template allows the items to be returned as a comma-separated string.
The problem is, a comma is always returned at the end of each string. Here's the code by the way:
#for(var i = 0; i < Categories.length; i++){#
#:Categories[i].CategoryName#,
#}#
Any suggestions?
|
You can use this template:
#for(var i = 0; i < Categories.length; i++){#
#if(i+1 === Categories.length){#
#:Categories[i].replace(/,/g,'')#
#} else{#
#:Categories[i].CategoryName#
#}#
#}#
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, kendo ui"
}
|
jQuery fade in and out on timeout
This is a pretty common problem, but I am looking to fade out some text, change it then fade it back in.
My code so far is:
setTimeout(function(){
$("#ilovequote").fadeOut( 500, function(){
var ilovequotes = ["CSS3", "Photoshop", "AJAX", "jQuery", "Social Media API's"];
var rand = ilovequotes[Math.floor(Math.random() * ilovequotes.length)];
$('#ilovequote').html(rand);
$("#ilovequote").fadeIn( 500);
});
}, 500);
});
But this for some reason does not work. I am looking for help on this, basically I would like a smooth animation with just long enough to read the word.
JS FIDDLE
<
|
Do you want something like this?
var cnt = 0;
setInterval(function(){
cnt ==4 ? cnt=0:cnt++
$("#ilovequote").fadeOut( 500, function(){
var ilovequotes = ["CSS3", "Photoshop", "AJAX", "jQuery", "Social Media API's"];
var rand = ilovequotes[cnt];
$('#ilovequote').html(rand);
$("#ilovequote").fadeIn( 500);
});
},1000);
jsFiddle demo here <
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "jquery, timeout"
}
|
I went to bed with a headache vs I slept with a headache
Is it idiomatic to say **" I slept with a headache"** as opposed to **" I went to sleep with a headache**"? I'm not sure why but **" sleeping with a headache"** doesn't sound right to me. Can anyone help? I can't understand why it sounds wrong.
|
The issue here is the meaning, not grammar.
When you are asleep, you feel nothing. You can't have a headache while you are sleeping (unless you have a headache in your dream). When you are asleep, you are not conscious of pain or anything else.
This is why "sleeping with a headache" seems wrong.
It is fine to say "I went to sleep with a headache". And I suppose you might say "I slept with a headache" to mean "I went to sleep with a headache, and I still had a headache when I woke up". But that still seems a little strange.
There's no grammar rule to learn here, just that the meaning has to make sense too.
|
stackexchange-ell
|
{
"answer_score": 4,
"question_score": -1,
"tags": "phrase usage"
}
|
Existe lista de de objetos no envio de requests no html?
Estou desenvolvendo um pequeno projeto web em python(flask) para aprendizado próprio e me deparei com algo que nunca havia encarado antes.
Tenho um formulário de cadastro onde os campos de uma informação são dinâmicos, ou seja, via jquery eu posso criar e excluir campos pois não sei quantos links o usuário enviará. Minha dúvida é a seguinte, como eu recebo o request desse form no meu código python se não sei quantos campos serão enviados? Existe alguma espécie de lista no request onde eu possa criar 'objetos' para enviar tudo junto?
|
Como diz documentação aqui, o `request.form` é um `ImmutableMultiDict` que se comporta como um dicionário.
Você pode usar métodos de dicionário nele normalmente, como `request.form.keys()`, `request.form.items()` ou até mesmo iterar diretamente nele para ver todos os nomes usados:
for chave in request.form:
print(chave, request.form[chave])
Vai imprimir no console tudo que chegou do formulário.
Se a sua página enviar multiplos campos com o mesmo nome, mesmo assim você pode pegar usando `getlist`:
request.form.getlist(chave)
Vai retornar uma lista com todos os valores com aquele nome.
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "html, python, aplicação web, flask"
}
|
hibernate SQLquery extract variable
How can I extract variables total, min, max from hibernate SQL queries and assign them to java variables?
(select count(*) as total, min(price) as min, max(price) as max from product).addScalar("total", Hibernate.INTEGER).addScalar("min", Hibernate.INTEGER).addScalar("max", Hibernate.INTEGER);
|
This post should help you.
**Later edit:**
String sQuery = "select min(myEntity.x), max(myEntity.y) from MyEntity myEntity";
Query hQuery = session.createQuery(sQuery);
List result = hQuery.list();
Iterator iterator = result.iterator();
while (iterator.hasNext()) {
Object[] row = (Object[])iterator.next();
for (int col = 0; col < row.length; col++) {
System.out.println(row[col]);
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 2,
"tags": "java, hibernate, orm"
}
|
XCTestCase - how to assert on a NSTextView containing String?
I have a macOS project that I'm creating UI tests for.
While it's relatively easy to find `staticText`, `buttons`, etc. by their text value. Using a subscript lookup on `.textViews` doesn't (seem to) work.
I've managed to get a reference to the `NSTextView` I want to inspect using `.textViews.firstMatch` but I can't figure out how to assert on it's string value.
I'm looking for something that works like this.
XCTAssertEqual(prefs.textViews.firstMatch.stringValue, "Enter text below")
|
Simply `value` should do.
It's available on `XCUIElementAttributes` and is of type `Any?` that varies based on the type of the element.
XCTAssertEqual(prefs.textViews.firstMatch.value as! String,
"Enter text below")
* * *
Ref:
* <
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "swift, macos, nstextview, xctestcase, xcuitest"
}
|
How to view source of a broken page in IE instead of "Cannot display the webpage" message
I'm stuck in an Internet Explorer only environment, and one of my users is experiencing an error on one of my pages. It's a Cold Fusion page, and I'm sure it's not crashing at the beginning. Does anyone know of any way to view the actual source of the error page rather than the generic error message that IE redirects the user to?
I know from previous experience that if I could navigate to the page in Firefox or any other browser, it would just show the HTML that was able to render and I could go from there to view source, but if I view source in IE it shows me the source of the error message, not the source of the page causing the error.
|
Un-check “Show friendly HTTP error messages” in the Internet Options:
!“Show friendly HTTP error messages” in Internet Explorer's Internet Options
That setting causes generic error messages to be displayed if the response was smaller than 500-ish bytes for HTTP errors. Beyond that threshold the actual response is always displayed. So you could also pad your error responses appropriately—that's not uncommon to do :-)
|
stackexchange-superuser
|
{
"answer_score": 3,
"question_score": 2,
"tags": "browser, internet explorer"
}
|
Emacs freezes when minimizing frame on OSX
I have had the issue that emacs will lock up (and need to be force quit) on occasion when I minimize it. I am almost always in org-mode, but otherwise I can see any pattern, except that it happens while it is minimized.
I have scoured the world for a fix to this. Does anyone know how to fix this, or at least how to figure out why it is happening?
I'm on OSX 10.11 with Emacs 24.5
|
I have been using the ``not yet stable'' 25-rc2 build of Emacs for a month without any lockup issues. So it seems @lawless is correct, and this did fix the issue.
|
stackexchange-emacs
|
{
"answer_score": 2,
"question_score": 2,
"tags": "osx"
}
|
Finding the roots of a different Quadratic equation from the roots of a Given Quadratic equation
**The Question:**
> If $\alpha$ and $\beta$ are the roots of the equation $ax^2+bx+c=0$...
>
> _Then find the roots of the equation $ax^2-bx(x-1)+c(x-1)^2=0$_
* * *
**My Attempt:**
The new equation can be made into a quadratic as:
$$(a-b+c)x^2+(b-2c)x+c=0$$
Now $$\text{Sum of roots}=\dfrac{-b}{a} = \dfrac{2c-b}{a-b+c}$$
And $$\text{Product of roots}=\dfrac{c}{a}=\dfrac{c}{a-b+c}$$
* * *
_But I don't seem to be going anywhere with the way I'm proceeding_
_**Please Help! Thanks!**_
|
**hint** : $\dfrac{2c-b}{a-b+c} = \dfrac{2\dfrac{c}{a}-\dfrac{b}{a}}{1-\dfrac{b}{a}+\dfrac{c}{a}}=\dfrac{2\alpha\cdot \beta+(\alpha+\beta)}{1+\alpha+\beta+\alpha\cdot \beta}$, can you continue?
|
stackexchange-math
|
{
"answer_score": 5,
"question_score": 2,
"tags": "algebra precalculus, roots, quadratics"
}
|
Resize UIBarButtonItem in code
How do I resize a UIBarButtonItem in the code?
|
You can't resize a UIBarButtonItem as you would a UIView. What you can do is change its **width** property.
UIBarButtonItem *b;
// Initialize and such ...
b.width = 150.0;
This should work for a Fixed Space Bar Button Item.
|
stackexchange-stackoverflow
|
{
"answer_score": 18,
"question_score": 10,
"tags": "ios, cocoa touch, uibarbuttonitem"
}
|
Limit jQuery toggle to only affect one accordion
So there's a page I'm working on which contains several accordions. You can check it out right here:
<
If you click on one of the accordions, you can notice all chevron arrows are animated at the same time. ¿How can I limit my toggleClass to only affect the accordion I clicked on?
Here's my code:
$('.panel-heading').click( function() {
$(".fa-chevron-right.rotate").toggleClass("down");
} );
Thanks a lot for your help!
|
Its because you have selected all the `.fa-chevron-right.rotate` instead of the one which you clicked.
the below code should do the trick.
$('.panel-heading').click( function() {
$(this).find(".fa-chevron-right.rotate").toggleClass("down");
});
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "jquery, twitter bootstrap, accordion"
}
|
getting value of array from certain index in php
I want to get the value of an array type given a certain index. The array's values are
> $status = [1,2];
And I used these code to get the value:
> $task_state = $status[1];
But it actually thought $status is a string and returns
> '['
I know that this is actually quite simple, but I just can't seem to find the answer to my problem. Thank you
|
If `$status` defined as a string, you can return php value of it with `eval` function like below:
$status = '[1,2]';
$status_array = eval('return ' . $status . ';');
$task_state = $status_array[0];
> **Caution** The eval() language construct is very dangerous because it allows execution of arbitrary PHP code. Its use thus is discouraged. If you have carefully verified that there is no other option than to use this construct, pay special attention not to pass any user provided data into it without properly validating it beforehand.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "php, arrays"
}
|
Advantage of pure maths courses in transcript for physics grad school
Are there an advantages of doing courses in pure maths (master level) courses, if you want to apply to physics grad school for a phd in areas such as string theory, or high energy physics? Apart from the obvious advantage, that you get better at math, which is used a lot in this areas, I am asking about the direct advantage for grad school applications on the transcript? Does the selection committee like to see more grad level physics courses in maybe slightly irrelevant areas, or pure maths courses which have use in these areas?
|
I think the real answer is that it depends on what it is that you're planning to do. The more closely your courses align with your proposed field of study, the easier it is for the committee to evaluate. So, taking pure mathematics courses makes more sense if you're going into a theory-based field than if you're doing something more experimental in focus.
However, you should also keep in mind that a strong grade in an upper-level mathematics course will at best be "neutral," and it might be possible to explain away a bad grade; a bad grade in any physics course will not go over so well. So you should factor your interest level and ability to handle the courses in your selection process. You should also consider if the course in physics is considered a "standard" course for undergraduates pursuing graduate admissions. If so, then it makes more sense to take that class than an elective mathematics course. (Otherwise, the question will of course be "Why didn't you take course X?")
|
stackexchange-academia
|
{
"answer_score": 1,
"question_score": 3,
"tags": "phd, graduate admissions"
}
|
a parameter is missing. parameter ordinal = 1 dataAdapter
This is my code:
String client = textbox.text;
try {
connexion.da = new SqlCeDataAdapter("Select NOM_PRENOM ,NUM_FAC_CLI ,SOLDE_RESTANT ,DATE_FACT ,MODE_PAIEMENT from EXP WHERE NOM_PRENOM_CLI=@client ", connexion.objConn);
connexion.da.Fill(ds, "EXPORT");
}
I can't find a property `da.Parameters.add("@client", client)`.
Any suggestions?
|
you can add parameters like this
da.SelectCommand.CommandType = CommandType.Text; da.SelectCommand.Parameters.Add("@client", client);
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -1,
"tags": "c#, windows mobile 6, sql server ce 3.5"
}
|
Is there a 'Restore session' command-line argument for Firefox?
I would like to make a batch script for Firefox that restores my last session _upon_ launching the script. I found that I could do this rather easily in Chrome with the `--restore-last-session` argument. I made this script and placed it along-side `chrome.exe`:
chrome.exe --restore-last-session
Can the same be done with Firefox? ~~I am aware of the built-in options within the Firefox menu, but~~ I would like to make this script so that Firefox restores _instantly_ when I open it.
|
Your question is oddly framed. Why do you specifically want to be able to do this from a script? Do you just want to be able to start Firefox and restore your previous session, or do you specifically want to do this **_only part of the time**?_
Firefox has an option to restore the previous session all the time. In “Options” / “General”, set “When Firefox starts” to “Show your windows and tabs from last time”:
 with a two column table (with the headers) to fill the three columns. The table is fairly long and I need it to wrap/continue from the first column on the page to the second column and on to the third and then continue to the next page in the same fashion. Right now I can only get the table to show in one column on the page and it continues on the next page. The final output is a printed PDF page.
|
Using span="all" is the way to cause some in flow content to span all the columns of a multi-column document. For brevity in answering, I am posting a picture of the XSL FO for something like this.!Sample XSL FO three column with spanning table
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "css, xslt, pdf"
}
|
sort linked list in C++ by using std::sort
I have already used std::sort for array, now I want to use it for linked list Can I use std::sort for linked list. If it's able, how can I use it.
|
You can't, because `std::sort` requires random access iterators, and `std::list` provides only bidirectional iterators. Use `std::list::sort` instead.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 0,
"tags": "c++, sorting"
}
|
Location of Google Logo on Map in iOS Application
Is there an approval process that I must follow in order to move the "Google" that is in the left-hand corner to another area of the map? I have an application where my UI will cover these words and would like to display them in another location on the Google map. I know how to do this in iOS, just don't know if there are legal concerns with Google in doing so.
!enter image description here
|
You can't.. That violates a Google Maps term:
> (f) delete, obscure, or in any manner alter any warning, notice (including but not limited to any copyright or other proprietary rights notice), or link that appears in the Products or the Content;
and the App Store Review Guidelines:
> 8.6 Google Maps and Google Earth images obtained via the Google Maps API can be used within an application if all brand features of the original content remain unaltered and fully visible. Apps that cover up or modify the Google logo or copyright holders identification will be rejected
|
stackexchange-stackoverflow
|
{
"answer_score": -1,
"question_score": 5,
"tags": "ios, google maps"
}
|
Unable to import python requests library into AWS Lambda function
I have a lambda function that where I cannot the requests library to import.
So far I have tried the following imports:
import requests
from botocore.vendored import requests
Neither of these has worked. Other libraries are importing fine such as import json.
What do I need to do to get the requests library to import to AWS Lambda
|
requests library doesn't come by default in lambda. Comment out the first line and just go with the second line:
from botocore.vendored import requests
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "python, amazon web services, lambda"
}
|
Is the question I am trying to answer a conditional probability or an intersection of events?
I am trying to understand the difference between conditional probability and an intersection of events better. The type of event I am studying is a gambling problem. Let's say that I have an hour at the casino to play a game N times in a row. And I have a bankroll S that can tolerate L losses. I am using a martingale strategy where I can only bet S times in a row before losing all my money. I want to win at least W times.
So I want to understand what are my chances of winning at least W times within those N times, while not losing L times in a row.
Is this a conditional probability?
i.e. am I asking given that I do not lose L in a row out of N times, what are my chances of winning at least W times out of N times?
Or is this is an intersection of events?
e.g. What are the chances that I win at least W times out of N times and I do not lose L times in a row out of N times?
|
It's an intersection. You want the probability that you win at least $W$ times **and** you don't lose $L$ times in a row. Conditional probability would arise if you asked for the probability of winning at least $W$ times **if** you don't lose at least $L$ times in a row.
One thing that's not clear to me from your description is what happens if you win $W$ times before you have played $N$ times. Do you quit at that point, or keep playing?
The game can be analyzed as a Markov chain with states $(w,l)$ where $w$ is the number of wins so far, and $l$ is the length of the current losing streak. You would have an absorbing state when you've played $N$ games, and another when you've lost $L$ in a row, and perhaps another when you've won $W$ games, if indeed you quit at that point.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "probability, conditional probability, martingales"
}
|
Minor JavaScript array error
var add = [];
add[0].url = data.url;
add[0].photo = data.thumb;
console.log(add);
This'll be an instant know for most JS people. The code above is failing, anyone able to tell me where I'm going wrong
|
`add[0]` doesn't exist... `.push` something first.
add.push({ url:data.url, photo:data.thumb })
or
add[0] = {};
add[0].url = 'blah';
add[0].photo = 'foo'
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 1,
"tags": "javascript, arrays"
}
|
How to change font size in JQuery knob
I have a problem in jQuery Knob plugin.I want to change the font size inside the circle and change the content of the input text.
|
The only way I can seem to do this tidily is to hook on the `draw` function, and use the `i` property to set the style of the input. For example, here is one applying a CSS property to rotate the input element and set the font size.
$(".dial").knob({
'min':-50,
'max':50,
'draw': function() {
$(this.i).css('transform', 'rotate(180deg)').css('font-size', '10pt');
}
});
<script src="
<script src="
<input type="text" class="dial" data-min="-50" data-max="50" />
|
stackexchange-stackoverflow
|
{
"answer_score": 9,
"question_score": 6,
"tags": "jquery, canvas, input, font size, jquery knob"
}
|
reusing common sections in a webpage
Ok, I have searched on web and stackoverflow too, but no success.
I just want the code of header, nav-bars, footers etc. to be reused. I just want them to sit at their own respective files and then I want all other file to link these files.
How will we do these in html5 way.
Can someone please help me?
Thanks Raja
|
This isn't really possible with plain HTML. For reusing HTML chunks in your web page you basically have two options: 1\. Server side templates via PHP, Twig, Smarty or the likes. 2\. Or you can do client side templates with MustacheJS, Jade or Handlebars.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "html, layout"
}
|
How can a 51% attack be successful?
In the paper by Nakamoto, miner can accept the mined block only if all transaction are valid.
Assume that there are 5 miners in the world. 4 of 5 are honest that have 10% of 100% hash power and 1 of 5 is malicious that has 90% of all hash power.
Let's say group A consists of honest nodes (4 of 5). Let's say group B consists of malicious node (1 of 5).
Group B wants to create a block which has a fraud transaction (e.g. Alice wants to spend 1000 BTC but she actually does not have it). Group B is successively creating and propagating some blocks with huge hash power, but Group A does not accept these blocks because transactions in blocks are invalid. Yes, 51% attack is not accepted with only hash power. So, length of chain of group A is short but group B is long. But group A does not accept chain of group B.
So my conclusion is that 51% attack makes a mess in the network, not coin control.
I'm confused. Please help me understand where I am wrong.
|
A 51% attack does not allow the attacker to spend coins they do not own; the usual rules of validity still apply for transactions and blocks. If those rules are broken, the block/transaction will be ignored by the rest of the network, no matter how much hashpower the miner making invalid blocks has.
This question has a more complete explanation of what a 51% attacker can, and can not do.
|
stackexchange-bitcoin
|
{
"answer_score": 2,
"question_score": 2,
"tags": "blockchain"
}
|
How to get a cookie by a part of its name using php?
Lets say I have multiple cookies like so:
add_listing_123=1
add_listing_456=1
add_listing_789=1
How can I retrieve all cookies starting with "add_listing_" ?
And when retrieved how would I go about parsing out the numbers from the cookies using php, so that my end result is an array of 123, 456, 789?
|
$listings = array ();
foreach ($_COOKIE as $name => $content) {
if (strpos($name, 'add_listing_') === 0 && $content == 1) {
$listings[] = substr($name, strlen('add_listing_'));
}
}
var_dump($listings);
This iterates through all the cookies to find those that start with `add_listing_` (if the position of `add_listing_` in the name is `0`). If so, it adds to the `$listings` array the part after `add_listing_`.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 2,
"tags": "php, cookies"
}
|
Группировка временного ряда с определение Начала и Окончания по группам
Есть временной ряд:
import pandas as pd
myIndex = pd.date_range('2019-01-01', '2019-01-13')
myData ={'A':[1,1,1,2,2,3,3,3,3,3,4,4,4]}
df = pd.DataFrame(myData, index = myIndex)
A
2019-01-01 1
2019-01-02 1
2019-01-03 1
2019-01-04 2
2019-01-05 2
2019-01-06 3
2019-01-07 3
2019-01-08 3
2019-01-09 3
2019-01-10 3
2019-01-11 4
2019-01-12 4
2019-01-13 4
Нужно сгруппировать по столбцу 'A' определить дату начала и дату окончания каждой группы. Вот желательный результат:
A Start End
0 1 2019-01-01 2019-01-03
1 2 2019-01-04 2019-01-05
2 3 2019-01-06 2019-01-10
3 4 2019-01-11 2019-01-13
|
Начиная с Pandas 0.25.0 в функции агрегирования можно задавать имена результирующим столбцам.
Исходный DF:
In [6]: df
Out[6]:
A
2019-01-01 1
2019-01-02 1
2019-01-03 1
2019-01-04 2
2019-01-05 2
2019-01-06 3
2019-01-07 3
2019-01-08 3
2019-01-09 3
2019-01-10 3
2019-01-11 4
2019-01-12 4
2019-01-13 4
решение:
res = (df.reset_index()
.groupby("A")
.agg(Start=("index", "min"), End=("index", "max"))
.reset_index())
результат:
In [8]: res
Out[8]:
A Start End
0 1 2019-01-01 2019-01-03
1 2 2019-01-04 2019-01-05
2 3 2019-01-06 2019-01-10
3 4 2019-01-11 2019-01-13
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python, pandas, dataframe, group by"
}
|
Multipath Inheritance and
In the following code the `Multi Path Inheritance` was resolved by using `Virtual Class` How did the constructor work? A Constructor cannot be inherited or virtual or static.
/*Multi Path Inheritance*/
class A{
public:
int a;
A(){
a=50;
}
};
class B:virtual public A{
public:
/*B(){
a = 40;
}*/
};
class C:virtual public A{
public:
/*C(){
a = 30;
}*/
};
class E:virtual public A{
public:
E(){
a = 40;
}
};
class D : public B, public C, public E{
public:
D(){
cout<<"The value of a is : "<<a<<endl;
}
};
int main(int argc, char *argv[]){
D d;
return 0;
}
|
You can find a lot of informations and examples about virtual inheritance here (yes, it's actually on msdn, how strange :) )
As for the constructors, constructors get called as you specify them. If you don't specify a call for a virtua-base class constructor,
> constructors for virtual base classes anywhere in your class's inheritance hierarchy are called by the "most derived" class's constructor.
(read it here).
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c++, visual c++"
}
|
What is the meaning of バカにはええじゃないか?
. But it's obvious that the boy is dejected, so my translation can't be right.
|
I think it might be "", where "" is a twisted pronunciation of "". And the sentence means "(You came back) very early, didn't you"
|
stackexchange-japanese
|
{
"answer_score": 7,
"question_score": 2,
"tags": "grammar, translation, colloquial language, spoken language"
}
|
Syntax Error: Multiline bash command in dockerfile RUN statement
I have this Dockerfile, to which I am echoing the following line:
echo $"RUN cat file | while read pkg \
do\
sudo apt-get install -qy $pkg \
done" >> Dockerfile
Now, when docker executes this line, I get the following error:
`/bin/sh: -c: line 1: syntax error: unexpected end of file The command '/bin/sh -c cat autobuild/buildenv_packages | while read pkg do sudo apt-get install -qy done' returned a non-zero code: 1`
I know there is something small and syntactical I am missing, but I am unable to figure it out. Notice that the `$pkg` variable in the `apt-get install` statement isn't in the error.
Any assistance would be appreciated!
|
The backslashes in your code only prevent the string from containing literal newlines; they are not written to the `Dockerfile`. Without a newline (or a semicolon) before `do`, the `while` condition never ends; you just have a giant list of arguments for the command `read`.
echo 'RUN while read pkg; do sudo apt-get install -qy "$pkg"; done < file' >> Dockerfile
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "linux, bash, docker"
}
|
Properties of distinct graphs with given nodes degree
Suppose $N$ nodes with degree $v_1,v_2,...,v_n$ are given. How many distinct graphs can be built?
Have all these graphs the same property? I mean they all have the same shortest TSP, They are all planner or non-planner, They all have the same diagonal and any other property of a graph.
> In the aggregate I would like to know, When there is a list of nodes degree, Is there any difference in terms of graph properties among all the graphs that can be generated using the nodes degree?
To be not too broad, what _properties_ are the same among the graphs?
Thanks in advance.
|
Very different graphs can have the same degree sequence; here is a simple example.
Consider graphs with $12$ vertices, each of degree $2$. Such graphs are unions of cycles. It can have $1,2,3$, or $4$ components. Its clique number can be $2$ or $3$. The independence number can be $6$ (e.g., if the graph is $C_{12}$), $5$ (if the graph is $2$ copies of $C_3$ and one of $C_6$), or $4$ (if the graph is $4$ copies of $C_3$). Its chromatic number can be $2$ (e.g., for $C_{12}$) or $3$ (if it has an odd component). It can be bipartite (if all of its components are even) or not (if it has an odd component).
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "combinatorics, graph theory"
}
|
How to switch off / restart Mobile using Java ME Code
I want to know is there any API in Java ME, using which I can Switch Off or Restart the Mobile Phone ?
|
No there is no specific API for this. However several handsets have undocumented J2ME bugs which will cause the phone to reboot, that you could utilise for this purpose!
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "java me"
}
|
GetOpenFileName open at default directory 'Computer' possible?
I'm using `GetOpenFileName` to open files in C++, is it possible to set the initial dir at "Computer" virtual location with `lpstrInitialDir`?
Thanks, Lee.
|
This is not possible with `GetOpenFileName` because the location you wish to use is not part of the file system. Rather it is part of the wider shell namespace.
If you look at the documentation for `GetOpenFileName` you will see that it has been superseded (over 10 years ago in fact) by the Common Item Dialogs. Those dialogs do allow you to specify the initial folder as a shell item.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "c++, winapi, getopenfilename"
}
|
Getting error - utocreateviewport set into true but no component is designed as the initial view
I get this error, may i know what i am missing ?
this application has autocreateviewport set into true but no component is designed as the initial view
|
The solution is to R-Click on the View you want to display as the initial view and select `Mark as initial view`.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "extjs4, extjs4.1, sencha architect"
}
|
Checking if an attribute exists in a shortcode
I've written a small plugin that spits out html for a button. It works great, except for one thing: If the user doesn't specify an image, the image appears broken. Is there a way for me to check and see if the user has specified an image, and only print the image code if that's the case?
Here's my plugin code:
function button_shortcode($args) {
return "<a class=\"button\" href=\"" . $args["url"] . "\"><img alt=\"" . $args["bigtext"] . "\" class=\"alignleft\" src=\"" . $args["img"] . "\" /><small>" . $args["smalltext"] . "</small>" . $args["bigtext"] . "</a>";
}
add_shortcode("button", "button_shortcode");
Here's the shortcode:
`[button url=" img="/path/to/image.png" smalltext="Smaller Text" bigtext="Bigger Text"]`
|
Borek pointed in the right direction, here's my fine code*:
function button_shortcode($attributes, $content) {
if ($attributes["image"] != "") {
$img = "<img alt=\"" . $content . "\" class=\"alignleft\" src=\"" . $attributes["image"] . "\" />";
} else {
$img = "";
}
if ($attributes["intro"] != "") {
$intro = "<small>" . $attributes["intro"] . "</small>";
}
return "<a class=\"button\" href=\"" . $attributes["link"] . "\">" . $img . $intro . $content . "</a>";
}
add_shortcode("button", "button_shortcode");
*Note: I did change some of the attribute names and stuff as well, but that wasn't necessary.
|
stackexchange-wordpress
|
{
"answer_score": 2,
"question_score": 6,
"tags": "plugins, plugin development, shortcode, customization"
}
|
Android Studio guest hasn't come online in 7 seconds
When I first start the emulator in Android Studio I get an information message,
> guest hasn't come online in 7 seconds retrying
I am curious as to how to stop this because while it is on my screen for about 40 seconds I cannot do anything in the emulator.
|
I had the same problem. Selecting Cold Boot Now in AVD manager solves the problem.
But I have to open AVD manager each time when I want to launch Emulator and I just want to click on Run app button and select device, without opening AVD manager.
To solve this: open AVD manager -> Edit device -> Show Advanced Settings -> Boot option -> select Cold Boot instead of Quick boot.
|
stackexchange-stackoverflow
|
{
"answer_score": 79,
"question_score": 89,
"tags": "android studio"
}
|
How can I make the browser read "%0A" as a just string, not encoded character
I'm facing a problem with URI in my web service.
One of my webpage has a link to another page like "< using get method.
When the browser(Chrome) opens the page "< it reads "%0a" as LF(The browser thinks "%0a" is encoded) even though "%0abcd" is itself a string.
Is there any solution to solve it?
|
I think this answers your question: URI encode, Percent-encoding the percent character.
Basically, when you put your string into your URL, just encode the `%` sign as `%25`, it should be properly converted.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "html, url, uri, encode"
}
|
How to use vars in lm in an own function?
I want to write a function, which calculates a linear regression based on the input.
I can build the function, but when I call it (e.g. `myregression(i1,i2)` it will result in an error)
myregression <- function(input1, input2) {
model <- lm(data = trainData, example ~ input1 + input2)
}
How can I use the input in the function `lm`?
|
Inside the function, we can use `paste` to create the formula
myregression <- function(input1, input2) {
model <- lm(data = trainData, paste0("example ~", input1, " + ", input2))
}
* * *
Or another option is `reformulate`
myregression <- function(input1, input2) {
model <- lm(data = trainData, reformulate(c(input1, input2), "example"))
}
and call the function as
myregression("i1", "i2")
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "r"
}
|
Postfix + Cloudflare configuration for FQDN mail server
My configuration is Ubuntu 16.04 LTS + postfix for basic Internet mail server. We are using Cloudflare as our DDOS protector for websites. Here is the problem:
The website record A **example.com** working with CF and resolves as 104.28.19.27 not our real IP 164.251.x.x
We have another VPS instance with Mail server and IP of 121.14.x.x. As CF declare it will not work with other ports than 443/80 so the real IP exposes to the world.
Records for mail server: A > mail > 121.14.x.x
MX example.com > **mail**.example.com > Priority 1. And it works great. We get the emails to:
[email protected] but not **[email protected]** If we specify MX record to example.com it will resolves as CF IP and forward that mail to website. I hope you get the idea. Here is the tutorial from CF:
<
How to achieve the mail server to work with to: [email protected] ?
Any help appreciated.
|
The problem was found. CF has nothing to do with resolving. The root cause was wrong postfix configuration. Make sure hostname matches to example.com
|
stackexchange-serverfault
|
{
"answer_score": 0,
"question_score": 0,
"tags": "postfix, cloudflare"
}
|
GSON getAsString() method does not strip double quotes from JSON element?
I am parsing this JSON using GSON, but when I try to get the deserialized string, I still end up with quotes around the element. So, for example, for the code below:
val ret = gson.toJson(tempObject.getAsJsonObject("medias")
.getAsJsonObject("media").getAsJsonObject("media_sources")
.getAsJsonArray("media_source").get(0).asJsonObject.get("source").asString)
Log.d(JOURNAL_FETCHR_TAG, "Value of ret is: $ret")
The value of ret is:
D/JournalFetchr: Value of ret is: "
I can just get the substring to solve my problem, but I am curious as to why asString is not giving me the string without the quotes around it? Thank you.
|
What you do now is encode the string again:
val tempObject = JsonObject().apply {
addProperty("a", "b")
}
val r0 = tempObject.get("a").asString // b
val r1 = Gson().toJson(tempObject.get("a")) // "b"
val r2 = Gson().toJson(tempObject.get("a").asString) // "b"
val r3 = Gson().toJson(tempObject.get("a").toString()) // "\"b\""
`asString` returns the string value just fine. Calling on it `toJson()` adds the quotes.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "android, json, kotlin, gson"
}
|
Loading data from external API in Vega
When I try to change < like,
- "url": "data/cars.json"
+ "url": "
I get an error,
> loader.js:166 Mixed Content: The page at '< was loaded over HTTPS, but requested an insecure resource '< This request has been blocked; the content must be served over HTTPS.
How do I fetch data from an external API?
|
Pretty simple. I just needed to use the same protocol HTTPS --> HTTPS
{
"$schema": "
"description": "A scatterplot showing horsepower and miles per gallons for various cars.",
"data": {"url": "
"mark": "point",
"encoding": {
"x": {"field": "userId","type": "quantitative"},
"y": {"field": "id","type": "quantitative"}
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "vega"
}
|
auto scroll to bottom when overflow auto
does anyone know how to automatically jump to the bottom of a scrollable area by event in jquery ( or even javascript if no easy jquery solution)?
regards
|
<div id="myDiv" style="height:300px;overflow:auto;">
<p>my content here</p>
</div>
var myDiv = $("#myDiv");
myDiv.animate({ scrollTop: myDiv.attr("scrollHeight") - myDiv.height() }, 3000);
**Edit:**
jQuery 1.6 introduced `.prop` and changed the meaning of `.attr` thus `$("#someDiv").attr("scrollHeight")` won't work anymore.
Need to be changed to: `$("#someDiv").prop("scrollHeight")`
Reference.
|
stackexchange-stackoverflow
|
{
"answer_score": 35,
"question_score": 23,
"tags": "jquery, scroll"
}
|
django how to see sql query when running tests?
One of my django application unit test fails with
DatabaseError: ORA-00942: table or view does not exist
I would like to see actual SQL query that caused this error. Do you know how to achieve that?
|
The best solution I found so far is debugsqlshell custom django management command provided by django-debugtoolbar.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 23,
"tags": "sql, django, oracle, unit testing, django testing"
}
|
How to specify template argument for a function in a child?
So I try:
class data_ppp {
public:
template <class T>
virtual boost::shared_ptr<T> getData()
{
return boost::shared_ptr<T>(new T());
}
};
class data_child : public data_ppp {
public:
template<>
getData<std::vector<int>>();
};
but cant get desired effect - I want to have in class data_child getData function that would only return `boost::shared_ptr<std::vector<int>>`. How to do such thing?
|
The only solution to your problem that I see now is:
class data_ppp
{
public:
template<class T>
std::shared_ptr<T> getData()
{ return std::shared_ptr<T>(new T()); }
};
class data_child : public data_ppp
{
public:
std::shared_ptr<int> getData()
{ return data_ppp::getData<int>(); }
};
Usage:
data_child dc;
dc.getData();
//dc.getData<float>(); // compilation error
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c++, templates, inheritance, virtual functions, function templates"
}
|
How should a climbing rope be cleaned?
What products and process should be used to clean a climbing rope when it gets sufficiently dirty? How would I remove as much dirt and grime as possible without negatively affecting the strength or lifespan of the rope?
|
All the major climbing sites agree on the two options for cleaning, and the subsequent drying:
* ukclimbing.com
* basicrockclimbing.com
* etc
Wash in cool water (less than 30°C) and use a mild detergent, either in a bath, or in the shower. Some people place it in the shower while they wash. Gentle brushing can help remove grit or sand, but be wary of abrading the strands.
To machine wash, pop the rope in a pillowcase and use a ‘delicate wash’. Some recommend daisy-chaining the rope first to hero keep it tangle free.
Generally treating a rope like a delicate wool article is a handy rule of thumb.
Once washed, hang it indoors, in a dark, cool area, and allow it to dry naturally.
|
stackexchange-outdoors
|
{
"answer_score": 19,
"question_score": 21,
"tags": "rock climbing, climbing, ropes"
}
|
Cancelled Sends
I send an email through a guided send and arrived this morning to find out that it has been cancelled under tracking. Does someone have to do this manually or can this occur because of a system failure?
|
This can automatically happen if there is an error in the email. For example if you have ampscript that only runs at send time and the syntax is incorrect.
You have a couple ways to debug this:
1. Easiest way is to talk to support as they will have the error log - but this also can take at least a couple hours to get the log.
2. Remove all Send Time only conditionals and do a send preview - to see where the error is occurring
3. Check for any exclusion scripts or outside scripting that can be affecting this send and verify that it is correctly syntaxed and does not throw errors.
|
stackexchange-salesforce
|
{
"answer_score": 3,
"question_score": 0,
"tags": "marketing cloud, email"
}
|
How do I call a secured Google Apps Script web app endpoint?
I want to make a POST request to my Google Apps Script Web App, but I don't know what format google wants me to send my credentials in. I have restricted access to the API to anyone in my gmail domain. The script that is making the POST request is written in Python and running automatically on a server, no user input.
Even a link to a page of documentation that addresses this issue would be great. I searched but couldn't find anything.
|
Up until a few months ago there was no authenticated way to do server to webapp calls. The webapp had to run as the author with anonymous access. Recently a new service was released called the Execution API. Which allows someone to execute a script using a simple REST call.
Overview of the service:
> <
Python quickstart:
> <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python, google apps script"
}
|
What does "the private comes well" mean in the following context?
> Sharing the cycle with Elisabeth Leonskaja and Khatia Buniatishvili, among others, to Douglas has fallen the massive Hammerklavier and the Waldstein sonatas, as well as gems such as Op 90 and 101. The private comes well to Douglas, who in person proves to be as reticent in manner offstage as he appears confident onstage.
Full article <
|
Here, "private" is used to mean
> small
>
> intimate
>
> internal
>
> delicate
>
> introspective
It's that simple.
The writer is pointing out that Douglas is good with that sort of music. "comes well" is like saying "comes easily" or, simply, "is good at".
|
stackexchange-english
|
{
"answer_score": 0,
"question_score": 2,
"tags": "meaning in context"
}
|
Is it true that 7-Zip can fail to extract an successfully created archive?
I remember seeing a highly upvoted answer here stating that sometimes the server log files "fail to decompress" when using the highest compression level in 7-Zip.
Can this happen if 7-Zip doesn't give any errors during the compression phase?
|
I could find nothing on the web related to 7-Zip's ultra compression being buggy.
If a 7-Zip archive cannot be extracted, it would most likely be due to file corruption _after_ the archive was created.
However, if an archived data is important, you should always test decompression before deleting the originals.
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 0,
"tags": "7 zip"
}
|
Mysql: what situation(s) will cause index failure
Let's suppose you have a table called `user_card_tbl` which contains fields `userid`,`cardno` etc. And you have created index as seen below:
CREATE INDEX cardno_idx ON user_card_tbl(cardno);
I just want to know, what situation(s) will cause `cardno_idx` failure when you execute query.
|
* If some other index is better.
* If more than something like 20% of the rows have the particular value for `cardno`
* If you are using certain types of `WHERE`: `REGEXP`, `LIKE` with a leading wildcard, etc.
* If you are using `OR` (in some cases).
* If `cardno` is `VARCHAR`, but you are testing against a number that is not quoted.
* And probably many more.
If you provide a particular case, we can discuss the details.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "mysql, indexing"
}
|
How Do I Integrate Birst Single Sign on with Salesforce?
I am trying to have this Birst web tab accessible to all Salesforce users, not just users who have Birst licenses. To do this I am trying to set up a Single Sign on between Birst and Salesforce.See: Single Sign on for Birst
I have followed the steps here to create a web tab in Salesforce: Adding a tab for Birst in Salesforce
The user guide makes mention of using birst.SSOToken, birst.username, and birst.ssopassword: <
Birst gives me the following Apex control code (I assumed I need to create a new Visualforce page and use this code somehow?):
<apex:page standardController="<object>" showHeader="false" sidebar="false">
<apex:iframe height="<height>" width="<width>" src="
</apex:page>
What is the best way to get Birst integrated into SFDC for users who do not have Birst licenses? How do I best call the SSO Token Generator through a post?
|
It is necessary to write a custom controller with a POST specifying the parameters, which include the space id, the sso password, and the user name of the account that will be used as the access user.
You can then make a Visualforce page with an action to send the request. Then you can make a link on the home page or tab for this Visualforce page. The parameters should pass correctly and open Birst in a new window. The request to the Token Generator will look something like:
req.setEndpoint('< // Server Url
The parameter passing will look something like:
req.setBody('[email protected]&birst.ssopassword=fakepassword&birst.spaceId=fake-space-id'); // Request Parameters
The sso password and space ID is obtained in the Birst application.
|
stackexchange-salesforce
|
{
"answer_score": 1,
"question_score": 3,
"tags": "visualforce, integration, birst"
}
|
I want to send mail to my gmail but failed
my send.php code is
<?php
mail('mn###[email protected]', 'Mail Subject', 'From: md###[email protected]');
?>
and php.ini file is
](
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "php, xampp"
}
|
How to define impl on standard types in Rust?
How can we define a wrapper type around an existing type and define functions over it?
I have tried the below code and I am getting this error
struct Deploy(u8);
impl Deploy {
fn values_yaml(self) -> u8 {
self+1
}
fn chart(self) -> u8 {
self+1
}
}
fn main() {
let a = Deploy(1);
println!("Hello, world! {:?}", a.chart());
}
error:
error[E0369]: cannot add `{integer}` to `Deploy`
--> src/main.rs:5:11
|
5 | self+1
| ----^- {integer}
| |
| Deploy
|
note: an implementation of `Add<_>` might be missing for `Deploy`
Any suggestion is most welcome.
|
You're dealing with a tuple struct, with tuple size 1. The elements of tuples are accessed via the usual syntax for tuples in Rust:
self.0
Alternatively, you can also match the fields similarly to regular tuples.
let Deploy(resource_type) = self;
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "rust"
}
|
Buying button sending to an empty cart page instead of product page
When I have all the caches active the buying product button at the home page sends the client to an empty cart page, and when I disable all the caches the buttons start to behave normally. Any help is much appreciated, magento CE 1.9.0.1 All the best,
|
What is the URL of your website and also what is the setting in admin-> system -> configuration-> sales -> Checkout-> Shopping Basket -> After Adding a Product Redirect to Shopping Cart (Yes or no)?
Cheers S
|
stackexchange-magento
|
{
"answer_score": 2,
"question_score": 1,
"tags": "magento 1.9"
}
|
find the limit of the first one
(\lim_{n\to\infty} 1/n^p)$ and when the absolute value of $a$ is less than or equal to one, $(\lim_{n\to\infty} a^n)=0$ so the limit of the whole sequence is $0$?
|
Almost. Your argument works for $|a|<1$, but if $a=\pm 1$ we don't have $\lim_{n\to\infty} a^n=0$. Because $p>0$, however, $\lim_{n\to\infty} 1/n^p=0$. That's because $\lim_{n\to\infty} n^p=\infty$ ($p$ fixed of course). That gives us $\lim_{n\to\infty} |a^n/n^p|=0$ when $a=\pm 1$, and $\lim_{n\to\infty} a^n/n^p=0$ follows. Not sure what your Exercise 9.12 says.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "numerical methods"
}
|
How to hide or disable in-function printed message
Suppose I have a function such as:
ff <- function(x) {
cat(x, "\n")
x^2}
And run it by:
y <- ff(5)
# 5
y
# [1] 25
My question is how to disable or hide the `5` printed from `cat(x, "\n")` such as:
y <- ff(5)
y
# [1] 25
|
You can use `capture.output` with `invisible`
> invisible(capture.output(y <- ff(2)))
> y
[1] 4
or `sink`
> sink("file")
> y <- ff(2)
> sink()
> y
[1] 4
|
stackexchange-stackoverflow
|
{
"answer_score": 63,
"question_score": 37,
"tags": "r, printing"
}
|
Yahoo Messenger API For PHP
I've asked the same question before for Flex, but due to some restrictions, I'm gonna have to do all the communication from the back end.
I googled all day, I just can't find anything that works.
Thanks,
|
You are looking for libpurple. It has PHP bindings.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "php, yahoo, yahoo messenger"
}
|
Dice game, how to maximize winnings
Here is a question I've been struggling to solve. We're playing a game with $1$ die. If I roll a $1$, $2$, $3$, or $4$, I get a dollar and can roll again. If I roll a $5$ or $6$, the game ends and I lose all my winnings so far. I can select to stop playing and keep my winnings whenever. What's the expected value of money I'll make if I play with a strategy that maximizes my expected winnings?
Isn't this just $2/3$? I have a $2/3$ chance of winning a dollar and $1/3$ chance of ending the game and losing everything on each turn, so shouldn't it just be $2/3$?
|
If you play once you get $2/3$ of a dollar. If you play twice you either get two dollars or nothing, so the expected winnings are $(2/3)^2\times2=\$8/9$. If you play three times the expected winnings are $(2/3)^3\times 3=\$8/9$. If you play four times you get $(2/3)^4\times 4=\$64/81<\$8/9=\$72/81$. So the best strategy seems to be to play twice or three times.
Let $$f(x)=x(2/3)^x=x \exp(\log(2/3)x)$$ then $${df\over dx}=(1+x\log(2/3))\exp(\log(2/3)x)$$ which has a critical point when $x=-1/\log(2/3)\approx2.5$, which turns out to be a maximum from graphing.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 0,
"tags": "combinatorics, dice, gambling"
}
|
Dirtytalk's \say for quoting doesn't work in captions
The quotation command `\say` from the dirtytalk package doesn't seem to work in figure captions. Does anyone know why this is the case and how to fix it?
\documentclass{article}
\usepackage{dirtytalk}
\begin{document}
Say is working \say{fine} here.
\begin{figure}
\caption{But it \say{doesn't} work here.}
\end{figure}
\end{document}
Manually inserting the correct quotation marks `“` and `”` works fine though. But shouldn't `\say` produce the same result? .
|
stackexchange-tex
|
{
"answer_score": 0,
"question_score": 0,
"tags": "captions, quoting"
}
|
Django path error while trying install skin for Admin
I'm trying to install the following skin for my Django admin. I followed all the instructions till the part where I have to update my urls.py
from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url
from django.conf.urls import handler404, handler500
from django.conf import settings
from django.conf.urls.static import static
`url(r'^admin/', include('djadmin.urls')),`
I've changed the code and tried entering
`path('admin/', djadmin.urls),`
also tried `path('admin/', include(djadmin.urls)),`
But its still giving me an error in this line of code. I've added djadmin to my installed files and also updated the middleware.
Could anyone help me out?
|
Add **quote symbols** ( ** _" and "_** ) to the `djadmin.urls` as
path('admin/', include("djadmin.urls")),
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, django"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.