INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Custom ordering in sqlite Is there a way to have a custom order by query in sqlite? For example, I have essentially an enum _id|Name|Key ------------ 1 | One | Named 2 | Two | Contributing 3 | Three | Named 4 | Four | Key 5 | Five | Key 6 | Six | Contributing 7 | Seven | Named And the 'key' columns have ordering. Say Key > Named > Contributing. Is there a way to make `SELECT * FROM table ORDER BY Key` return something to the effect of _id|Name|Key ------------ 4 | Four | Key 5 | Five | Key 1 | One | Named 3 | Three | Named 7 | Seven | Named 2 | Two | Contributing 6 | Six | Contributing this?
SELECT _id, Name, Key FROM my_table t ORDER BY CASE WHEN key = 'Key' THEN 0 WHEN key = 'Named' THEN 1 WHEN key = 'Contributing' THEN 2 END, id;
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 4, "tags": "sql, sqlite, select, sql order by" }
Tem como usar display block e flex juntos? Recentemente vi um Indiano fazer um menu de navegação usando HTML,CSS,JS mas oque me intrigou foi ele usar `display: block` e `display: flex` no mesmo elemento. Talvez ele errou porque até então eu sei que o último a ser declarado é oque recebe a aplicação. Eu até fiz testes mas o último sempre é aplicado! Então fica a pergunta: é possível usar esses 2 display no mesmo elemento?
## Antes de saber se é possível ou não devemos saber o que faz cada um, seja **Block** ou **Flex** > ### O que faz o `display: block`? > > Faz com que o elemento HTML seja renderizado como **bloco** tal com os parágrafos e os cabeçalhos são. Exemplo de aplicação na página abaixo: ![]( Demonstração de como é exibido o estilo bloco na página. > ### O que faz o `display: flex`? > > É um recurso do CSS3 que serve para "moldar" e/ou organizar elementos em _containers_ de forma flexível conforme a sua necessidade. Exemplo de aplicação na página abaixo: ![]( * * * ## Afinal da para usar ambas propriedades juntas? **Não é possível utiliza-los no mesmo elemento juntamente**. Atributos repetidos seguem a regra da especificidade para dizer qual será utilizado. Como o usuário @Rafael Tavares mencionou, podes visualizar claramente pelo _DevTools_ (ou Inspencionador de Elementos do Navegador)
stackexchange-pt_stackoverflow
{ "answer_score": -2, "question_score": 0, "tags": "css" }
How to remove a blank array from option input in php Hi I´m trying to put an array into option input. But the problem is I get one blank option. I want to remove it. Here is what I'm trying to do: <select name "x"> $myarray=array('black','blue','brown'); for ($i=0;$i<=count($myarray);$i++){ if ( $row['colur']==$myarray[$i]) {//if value in database = array$i echo"<option value='$myarray[$i]' selected>$myarray[$i]</option>"; } else { echo"<option value='$myarray[$i]'>$myarray[$i]</option>"; } }
You should loop one item less: for ($i=0;$i < count($myarray);$i++) { The last `$i` your loop "sees" is `count($myarray)` which is 3 in your case. However, because arrays are zero-indexed, item `$myarray[3]` doesn't exist (it goes from 0 to 2). The `if` fails and `$myarray[3]` is shown, which doesn't exist: you also get an error of level "notice" in your server logs (which should be the trigger to find this all out yourself). To prevent all this, use `foreach`: foreach ($myarray as $color) { // use $color instead of $myarray[$i] }
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "php" }
Trying to Run RT(Request Tracker) on a mail Server (Zimbra), problems with web server? I have installed `zimbra` and I am using it as my mail server. However I wanted to also install `request tracker`, so that the server could be used for admin and my other server purely as a web server. Zimbra is working 100%, however when I install `httpd` the `zimbra` front end disappears and is replaced by the default `apache httpd` page. I am using `centOS 6 64 bit`
Don't do this. Zimbra is a complicated beast with lot of components and it should run on a dedicated server or VM. For the specific problem: Obviously, you noticed that there is a conflict between Zimbras own web server and the one you installed. If you insist to continue with this, you would have to change ports for the Zimbra web server installation and then configure a reverse proxy in Apache to forward requests, e.g. to ` to the altered port of the Zimbra web server. Again: Don't do this. There is also no need if you have another server as a web server. RT plays nicely with most web servers and it's easy to get the mail into it from another server - there is no need to put it on the same host as the mail server.
stackexchange-serverfault
{ "answer_score": 2, "question_score": 0, "tags": "centos, zimbra, request tracker" }
How to get rounded corners on an Electron app? I am currently trying to get rounded corners on an Electron application I'm making. I have tried nearly every solution available on-line at the moment, but none of them make any difference. How can I round the corners of my Electron app?
Make a frameless transparent window const myWindow = new BrowserWindow({ transparent: true, frame: false }) And have something like this in the renderer, or apply the style directly to the body tag <div style="width: 500px; height: 500px; border-radius: 5px">My window content</div> Just make sure to also add a custom window titlebar that has `-webkit-app-region: drag`in order to make the window dragable from this element. Check out the Electron Docs for further informations ;) <
stackexchange-stackoverflow
{ "answer_score": 18, "question_score": 12, "tags": "node.js, electron, atom editor" }
"Cannot read property" [JS] There are, again, many problems and solutions but I cannot seem to find a answer to my question. 1. Goal: this is a lexer for my custom, garbage programming language. 2. Expected: advance function will change values Actual: it doesn't. 3. Error: cannot read property length of 'undefined'. What I've tried: bugfixing, changing the function code, looking it up. ! Edit: the error is on line 87. Code (a small snippet): class Lexer { constructor(text) { this.text = text; this.pos = -1; this.current_char = 'None'; } advance() { this.pos += 1; if (this.pos < this.text.length) { //this is line 87 this.current_char = this.text[this.pos]; } else { this.currenct_char = 'None'; } } Ask me if you need more code.
When you instantiate your object, constructor param `text` is undefined, so `this.text` is undefined too. You probably forgot param `text` or the variable send to constructor is undefined. So when you call method `advance()`, it can't access property length on `this.text.length` because `this.text` is undefined.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "javascript" }
Cycle counter on ARM Cortex M4 (or M3)? I'm trying to profile a C function (which is called from an interrupt, but I can extract it and profile it elsewhere) on a Cortex M4. What are the possibilities to count the number of cycles typically used in this function ? Function shall run in ~4000 cycles top, so RTC isn't an option I guess, and manually counting cycles from disassembly can be painful - and only useful if averaged because I'd like to profile on a typical stream with typical flash / memory usage pattern. I have heard about cycle counter registers and MRC instructions, but they seem to be available for A8/11. I haven't seen such instructions in cortex-Mx micros.
Take a look at the DWT_CYCCNT register defined here. Note that this register is implementation-dependent. Who is the chip vendor? I know the STM32 implementation offers this set of registers. This post provides instructions for using the DWT Cycle Counter Register for timing. (See the post form 11 December 2009 - 06:29 PM) This Stack overflow post is an example on how to DWT_CYCCNT as well.
stackexchange-stackoverflow
{ "answer_score": 23, "question_score": 16, "tags": "embedded, arm, cortex m3" }
What is the lowest broker fee possible? What is the lowest possible broker fee that you can get to, and what do you need to do to get there? Are there skills or standings requirements that modify the broker fee?
Also from the UniWiki on Trading: Standings Faction and corporation standings relevant to the station the orders are placed in will have an effect on the broker fee. Faction standings contribute significantly more than corp standings. The exact formula is: BrokerFee % = (1% – 0.05% × BrokerRelationsSkillLevel) / e ^ (0.1 × FactionStanding + 0.04 × CorporationStanding) (A picture is also available, but it is a tad confusing) With 10 faction and corp standing, the broker fee is reduced to 0.185%, saving you more than 1% through the buy and sell process.
stackexchange-gaming
{ "answer_score": 2, "question_score": 2, "tags": "eve online" }
change font size in flex4 datagrid dynamically how do i change the datagrid's font size on the click of a button. size will be an input from a text box.
datagrid.setStyle("fontSize", int(textBox.text));
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "actionscript 3, apache flex" }
Singleton Class With Protected Constructor Class was designed with Protected Constructor as a SingleTon Class. It is shipped to Customer. Now need to submit a patch such that this Protected constructor can be made as a Private. is it possible?
I am guessing by your user name that your language is java... A singleton _must_ have a private constructor to be safe - otherwise it's not guaranteed to be a singleton! You should just make it private. If your customer has subclassed your singleton and used the protected constructor, too bad. You shouldn't break your application design just to provide support for poisoned legacy code.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "constructor, protected" }
the homotopy type of the pointed loop space of a countable cw complex I apologize in advance if this is too elementary for this forum. I have received some help but am still unsure about how to proceed. I am interested in a proof of the following result due to John Milnor: If X is a countable CW complex then the pointed loop space of X (with the compact open topology) has the homotopy type of a CW complex. I have consulted Milnor's "on spaces having the homotopy type of a CW complex" but it references articles I was unable to find after determined searches on google scholar. Does anyone know of a self-contained exposition of this result?
There is a very fine book ``Cellular structures in topology'', by R. Fritsch and R.A. Piccinini that gives a detailed and self-contained treatment of Milnor's results. It has a wealth of other well-presented material, some of which is little known nowadays.
stackexchange-mathoverflow_net_7z
{ "answer_score": 14, "question_score": 9, "tags": "at.algebraic topology, cw complexes" }
If in mysql JOIN PHP Codeigniter im trying to do this : in the controller i did: foreach($troublesome_pupil as $u) array_push($bad_pupils,$u->id) i send $bad_pupils to my model and before the query i do : $bad_pupils = implode(',', $bad_pupils); Select user.name from user IF (user.id NOT IN '$bad_pupils') JOIN `marksheet` ON marksheet.id = user.id JOIN `holiday` ON holiday.id = user.id ENDIF basically $bad_pupils is an array , so i check for user id in that array (i have already taken care of the array using implode) if found then only join the two tables , else go ahead Also if in my select statement say example : i have select (user.name , marksheet.marks) .. if the row gets skipped in the IF statement what will be the value of the marks column for that row ? How can i achieve this ?
Can you use this? SELECT user.name, marksheet.marks, holiday.holiday FROM user LEFT JOIN marksheet ON marksheet.id = user.id AND user.id NOT IN ($bad_pupils) LEFT JOIN holiday ON holiday.id = user.id AND user.id NOT IN ($bad_pupils)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "php, mysql, codeigniter, if statement" }
dll copied to output path from wrong folder all of the projects in my solution have an output path of "..\Release" for Release builds and "..\Debug" for Debug builds. All of the projects works fine except for one. Whenever I build the problematic project in Release the dll that gets copied to "..\Release" comes from "obj\Debug" instead of "obj\Release". This happens both in VS and by manually running MSBuild build, but doesn't happen if I clean the "obj\Debug" folder first. this is a part of the build log that I think is relevant: 17>Target CopyFilesToOutputDirectory: 17> Task "Copy" 17> Copying file from "obj\Release\XXXXX.dll" to "..\Release\XXXXX.dll". 17> Command: 17> copy /y "obj\Release\XXXXX.dll" "..\Release\XXXXX.dll" 17> Done executing task "Copy". 17> Task "Message" 17> XXXXX -> C:\Dev\Service\Release\XXXXX.dll 17> Done executing task "Message". Any ideas on why would this happen?
You might want to check the paths against the reference; it might be that you've somehow referenced it against the obj folder. This may be easier to see in the csproj than the IDE ("hint path" or something).
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": ".net, visual studio, dll, msbuild" }
Accessing sub-objects in a "for in" loop? Here is some sample code of what I am trying to achieve: pingpong = { paddleA: { speed: 5, }, paddleB: { speed: 6, }, paddleAI: { AI1: "paddleA", AI2: "paddleB" } } paddleAI = pingpong.paddleAI; paddleA = pingpong.paddleA; paddleB = pingpong.paddleB; for (paddle in paddleAI) { document.write(paddleAI[paddle].speed); } When I run this code, it returns "undefined" I am trying to use the text values in `paddleAI` as which paddle's speed I want to access. How would I get that code to return the speed values of `paddleA` and `paddleB`? **Note:** This is only demonstration resembling my actual code, therefore I don't have much room to dramatically restructure how I am storing and accessing my values.
This is probably what you are after... Using the contents of `pingpong.paddleAI` to tell you what paddles are available... Your problem is that you were using `paddle` in the loop expecting the paddle name, when in fact you were getting the property name ( ex... `AI1`) < for (paddle in paddleAI) { document.write(pingpong[paddleAI[paddle]].speed); } Although this seems like **really bad** way to do it... Also, your trailing commas will make IE throw fits... remove the last comma in a object/array literal declaration
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "javascript, html5 canvas" }
How to group by with a rule with MS Access Microsoft Office is not my favourite platform, but at the moment I have a problem, that I need to solve in MS Access. I have a table `example` that, for example, contains: |not_unique_id|qty|val | 1 | 1 | 10 | 2 | 1 | 5 | 2 | 10| 10 | 3 | 1 | 3 | 3 | 10| 2 From this table I need to extract unique_id with lowest `qty` and representing `val`: |unique_id|qty|val | 1 | 1 | 10 | 2 | 1 | 5 | 3 | 1 | 3 At the moment I have: SELECT not_unique_id as unique_id,MIN(qty),MIN(val) FROM example GROUP BY not_unique_id that will yield incorrect results for the third entry. How can I get the correct results?
Try: SELECT e.not_unique_id AS unique_id, e.qty, e.val FROM (SELECT not_unique_id, MIN(qty) AS MinOfqty FROM example GROUP BY not_unique_id) q INNER JOIN example e ON q.not_unique_id = e.not_unique_id AND q.MinOfqty = e.qty ORDER BY e.not_unique_id;
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, ms access" }
do I use "rescale=1. / 255" or not? Building VGG-like CNN I am building a CNN with a similar architecture as VGG16. I know in VGG16 u do rescale u also center around 0. Now I train mine from scratch, does it make a difference and should I do it or no? Anyone who can help? `datagen = ImageDataGenerator(rescale=1. / 255)` Thanks a lot guys! <3
Rescaling to 0-1 in general is always a good choice when training neural networks, so yes go for it. The reason behind this is that neural networks tend to yield better results when the inputs are normalised. You could run the same exact experiment with pixel rescaling and without pixel rescaling and see for yourself the results!
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python, tensorflow, keras, conv neural network, image classification" }
Force a user to HTTPS So I recently got my webserver to support HTTPS using the EFF's certbot Currently, if you navigate to `DotNetRussell.com` or `www.DotNetRussell.com`, the browser will use HTTP by default. How do you force a user to use HTTPS? My server is a Raspberry Pi running the latest distro, and a LAMP stack that has been recently updated. The LAMP stack is running an updated wordpress site.
Most websites force HTTPS by redirecting all HTTP connections to their corresponding HTTPS equivalent using an HTTP 301 "Moved Permanently" response. This both redirects the current connection to HTTPS and all future connections as your browser will remember the 301 response and act accordingly. If you're using a LAMP stack you can do this redirect using Apache's redirect rules. If you're looking for how to do this redirect, check out this answer on StackOverflow.
stackexchange-security
{ "answer_score": 2, "question_score": 3, "tags": "tls, http" }
What harm could malicious PHP code cause? What harm can virus sites that contain malicious PHP code cause? What is an example of a piece of PHP code that could potentially harm your computer or steal information? I know that most if not all client-side code cannot cause any harm, but how about the server-side code, what harm could it cause? I was always curious as to how a website could harm your computer ...
It all comes down to the credentials that that PHP code is running with on the server. If the `apache2` process running that PHP code is running as `www-root`, the damage that this script can do goes to the extent of what `www-root` can access, which would typically mean all of the `/var/www/` folder. To fully understand this question, one needs to understand how linux works, if the web server is running under linux, to fully understand the extent of the possible damage. If it's running under Windows, it would be the same thing, only the damage would be to the extent of what the owner of the process is able to use the machine's resources for. Things that typically PHP viruses do are: 1. Use your server to send spam 2. Use your server to brute force other servers 3. Use your server's resources to join their own rig and mine crypto-currencies Those are just a few. They can pretty much use your server to run any software.
stackexchange-security
{ "answer_score": 5, "question_score": 3, "tags": "php, virus" }
ADO.NET EF Composite primary key - can not update foreign key I have following entities: !alt text In my code I need to update the `FKCategoryID` in entity `BudgetPost` but I'm getting the following error: > FKCategoryID is part of the object's key information Is it any way to update the key in this case or it's not possible? Thanks in advance
Why is it a part of the composite key? As long as FKBudgetID is a part of the composite primary key you won't be able to modify it. If you want to enforce uniqueness in the combination of FKCategoryID and FKBudgetID, use a UNIQUE constraint instead.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "c#, asp.net, .net, entity framework, ado.net" }
how to use c# struct from f# what's the syntax for using a c# struct in f#? how do i assign it's fields values? thanks! update: looks like i can declare the variable itself mutable and then set it's fields using the <\- operator...is there another way?
> looks like i can declare the variable itself mutable and then set it's fields using the <\- operator...is there another way? This is the correct thing to do. let mutable someStruct = CallSomething() someStruct.Field1 <- 42 // etc.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "f#, c# to f#" }
Class not loaded I have an CSS style in an external file and the element refers to a the style using the 'class' attribute. However, I can't seem to get the styling.
Email is notorious for being difficult to style in multiple clients. For this reason, inline styles and tables are the norm for email templates. As for loading an external asset, a lot of email clients won't do this for privacy reasons, to prevent the sender from determining if the email has been read by attaching a unique identifier to the URL. ### Example The system then checks the nonce against who it maps to, and can tell who is receiving/reading the email. This is very useful for spammers.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "html, css, email" }
Interact with non standard control via codebehind I'm using a CMS plugin with Microsoft Dynamics which features its own controls etc. I have the following control within a listview, that I need to detect and then potentially update from the CodeBehind file. I know how to do this with a standard control such as a Panel, Div, TextBox etc but dont know how to do it with a control like this. <crm:Property DataSourceID="Event" PropertyName="Adx_Summary" EditType="html" runat="server"/> I'm also sure that this is something I NEED to know long term for other similar scenarios.
You can just give it an ID and then work with it like any other control: <crm:Property DataSourceID="Event" PropertyName="Adx_Summary" EditType="html" runat="server" id="myCustomControl" /> In code: myCustomControl.WhatEverItSupports(); Of course, this is if this tag is not part of another control and is nested within some sort of template. I can't deduce that from your question
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, asp.net, dynamics crm 2011, dynamics crm" }
Looking for faster loops for big dataframes I have a very simple loop that just takes too long to iterate over my big dataframe. value = df.at[n,'column_A'] for y in range(0,len(df)): index=df[column_B.ge(value_needed)].index[y] if index_high > n: break With this, I'm trying to find the first index that has a value greater than value_needed. The problem is that this loop is just too inneficent to run when len(df)>200000 Any ideas on how to solve this issue?
In general you should try to avoid loops with pandas, here is a vectorized way to get what you want: df.loc[(df['column_B'].ge(value_needed)) & (df.index > n)].index[0]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "python, pandas, loops" }
Is this relation anti symmetric Was asked to `Work out transitive closure of: R = {(1, 1),(1, 3),(2, 2),(2, 1),(3, 3),(4, 4),(4, 3),(4, 2)}` I did using Warshall's, getting: R*={(1,1)(1,3)(2,1)(2,2)(2,3)(3,3)(4,1)(4,2)(4,3)(4,4)} Is R* antisymmetric? I understand antisymmetric means if (a,b) exists and (b,a) exists then a=b. But I am confused here, since there are symmetric elements here too: (1,2)(2,1) Does the exclusion of (1,2)(3,1)(3,2)(1,4) etc make R* antisymmetric or symmetric or neither?
Checking element by element you see it's antisymmetric. If (2,1) and (1,2) exist, there would be a problem, but it's not the case.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "relations" }
Distribution function, applied to itself? Consider random variable $X$ with continuous, increasing CDF $F_X (x)$. Let $W=F_X (X)$. Characterize the distribution of $W$. I get $F_W (w)=\mathrm{Pr}(F_X (X) \leq w)=\mathrm{Pr}(X\leq F_X^{-1}(w))=F_X(F_X^{-1}(w))=w$ Can I just impose that $w=1$ and say this is a degenerate distribution? That seems off to me because the question doesn't actually specify a domain for $x$. Did I miss something?
$W$ follows the uniform distribution on $[0,1]$ because the image of $F_{X}(X)$ is the closed interval $[0,1]$ (which is in turn the domain of $F_{W}$).
stackexchange-stats
{ "answer_score": 7, "question_score": 4, "tags": "probability, distributions, self study" }
why my texture is not appearing? I made pikachu in Blender and pack everything in but after packing it . Now, suddenly my texture is not appearing of certain areas and appearing as purple , I am adding a image for your reference. Kindly help. Thank you![enter image description here](
You are apparently using Photoshop PSD files directly as image textures. While this this may work to a certain extent, packing is not supported. PSD files may be packed for transport while "in transit", but they can't be used directly, or read from memory inside the blend as stated in the bug report. Possible workarounds are to unpack first, or pack as layered tiff files.
stackexchange-blender
{ "answer_score": 1, "question_score": 0, "tags": "rendering" }
JQuery Scroll Listener To handle parallax scrolling and dynamic elements appearing on the page depending on how far the user has scrolled, I am using the JQuery scroll listener method. `$(window).scroll(function(){});` The one problem I am having is that this method is only triggered when the user reaches the bottom of the page or the top of the page: there is no "live" scroll tracking. Is there anyway to accomplish tracking the "live" scroll and not when the user reaches the bottom of the page? My code is as follows. $(document).ready(function() { $(window).scroll(function() { $("#article").append("<div>Did scroll</div>"); }); }); The did scroll will only appear when the user reaches the top or bottom. EDIT: And I have tired to place the code outside the `$(document).ready();`. Same result presented itself.
It works correctly, probable you are just missing some css here's an example < $(document).ready(function() { $(window).scroll(function() { $("#article").append("<div>Did scroll</div>"); }); });
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "javascript, jquery, html, css" }
NSwag.MSBuild TypeScript version issues In NSwag Studio there's a flag to use a specific TypeScript version for the generated TypeScript typings/code. Inside my `.csproj` file I'm trying to accomplish the same things but it doesn't seem to have any effect. Here's my MSBuild command: `<Exec Command="$(NSwagExe_Core20) swagger2tsclient /input:$(OutDir)api.json /output:..\api.ts /generateClientClasses:false /typeScriptVersion:2.4 /dateTimeType:Date /nullValue:Undefined /generateDtoTypes:true /markOptionalProperties:true /generateCloneMethod:true /typeStyle:Class /generateDefaultValues:true /generateConstructorInterface:true" /> ` I'm assuming that isn't the correct way of sending the TS version as a parameter to the command line. Does anybody know which is the correct parameter name?
Closing. Behind the scenes the generated typing had a bug but not related to the TypeScript version.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "typescript, msbuild, nswag" }
Click button, resize view Im new to programming and obviously not that good. But I'm trying to search my way to success! But unfortunately I'm bad at it too. Im doing an Mac OS X app with a webview and a few buttons. When I'm clicking one button I want the webview to change size. One thing I could to is to add lots of web views and show and hide them, but I think it most be easier to change the webview on a button click. - (IBAction)changeButton:(id)sender { self.webview.HowToChangeTheSize = unKnown; NSLog(@"Button works"); }
To change a webview size could be used frame property. - (IBAction)changeButton:(id)sender { self.webview.frame = CGRectMake(self.webview.frame.origin.x, self.webview.frame.origin.y, 200, 200); NSLog(@"Button works"); } This will change your webview's height and width to 200.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "macos, webview, width" }
Access: count how many time an item is used I have two tables: The table `Consent Archiving` is a list of unique items. The table `Table1` is the association of n rows to 1 item of `Consent Archiving`. I would like that in the column `Count` of `Consent Archiving` there would be the number of time that that certain item is repeated into `Table1`. ![enter image description here]( ![enter image description here](
Isn't a query, build to look like mentioned table, a better option? If so build it on Table1 and just add group by clause for "Consent Archiving" with a count(*) function.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ms access, ms access 2010" }
SOAP envelope response xml validate I have a soap envelope <?xml version='1.0' encoding='UTF-8'?> <soapenv:Envelope xmlns:soapenv=" xmlns:xsi=" xsi:noNamespaceSchemaLocation="file:///Users/michael/Downloads/soap.xsd"> <soapenv:Body> </soapenv:Body> </soapenv:Envelope> soap.xsd is just a local version of < saved to soap.xsd when i try to validate this, it says the schema target is incorrect per the targetAction All trial and error point to the xmlns:xsi tag as giving the error I wonder if it has to do with SOAP 1.0 vs 1.1 (i have been able to validate the xml inside the soap with the exact same method) im pretty sure this can be done in one element, but for the sake of sanity, im trying to get this to work
ok the answer to validating a soap is the following format, using trial and error <?xml version='1.0' encoding='UTF-8'?> <soapenv:Envelope xmlns:soapenv=" xmlns:xsi=\" xsi:schemaLocation=\" <soapenv:Body> </soapenv:Body> </soapenv:Envelope> You can then validate that this is a valid SOAP, but sadly, if there is xml inside the body, and you also properly point to the xsd file, they both cannot be validated. When I say validated, I mean not using lib2xml or any other external tool. Only using the xml file itself to validate
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "xml, xslt, xpath, soap, xsd" }
purpose of feed_token in GitLab for atom feeds Shall i simply add feed_token directly( **explicitly** ) in the URL to view atom feeds of my GitLab project through Python script? Is it the correct method to get feeds for GitLab? Will it be useful for automation? How shall I check for any unauthorized access of feeds with my feed_token?
Yes, it is the correct and easiest method to get feeds from GitLab. The _**'feed_token'**_ is just like the private access token provided by your GitLab account, exclusively used to get the feeds. **P.S.** For Security, instead of explicitly mentioning the _**" feed_token"**_ directly in the script, it will be better to let user input their Feed token (Their own Feed token shall be accessible from their respective GitLab account)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, automation, gitlab, feed, atom feed" }
how to update fields created dynamically using meteor i have created a collection as below and want to update field lets say i want to update "field1" with type "checkbox" here is my mongo collection data "dynamicfields" : { "field1" : { "type" : "textarea" }, "field2" : { "type" : "text" } } is it possible? how? Thanks,
You are look for the $rename operator Check syntaxis. {$rename: { <field1>: <newName1>, <field2>: <newName2>, ... } } Try with this. Collection.update({_id:this._id},{$rename{'dynamicFields.field1':'dynamicFields.field111'}}) or Collection.update({_id:this._id},{$rename{'dynamicFields:{'field1.type':'input'}}}) not tested code, but the `$rename` its what are you looking here, since you want to update the `field`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "meteor" }
How to specify a dummy column in outer queries using MySQL? I need to perform the following query: SELECT ID FROM tbl_a WHERE (fld_merchID, 'something') IN (SELECT MerchID, MAX(Priority) FROM tbl_b WHERE Name LIKE 'AAA.com') as you can image, there's no 'Priority' field in tbl_a. (I need to select the MerchID with the higher Priority value). That query is returning empty and it shouldn't. I'm not sure how to do it. Thanks!
If you want the one with the max priority, then you need to change your subquery pretty significantly to choose the MerchID with the highest priority: SELECT ID FROM tbl_a WHERE fld_merchID IN ( SELECT DISTINCT MerchID FROM tbl_b INNER JOIN ( SELECT Name, MAX(Priority) as Priority FROM tbl_b WHERE Name LIKE 'AAA.com' GROUP BY Name ) mx ON mx.Name = tbl_b.Name AND mx.Priority = tbl_b.Priority )
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "mysql, dummy data, inner query" }
Add two statements underneath min function I'm trying to get two statements underneath the `min` function. I have already got one statement, using the following code: \min_{\textbf{C}, \textbf{C}' \in \mathcal{C}} I need to add one more statement below this. I already tried: \min_{\textbf{C}, \textbf{C}' \in \mathcal{C}}_{\textbf{C} \neq \textbf{C}'} but with no luck. Please excuse my ignorance if this is a silly question. I'm new to Latex. How do I get two statements under the min function?
Use `\substack`: \[ \min_{\substack{\mathbf{C}, \mathbf{C}' \in \mathcal{C}\\ \mathbf{C} \neq \mathbf{C}'}} \]%[![enter image description here][1]][1]
stackexchange-tex
{ "answer_score": 4, "question_score": 2, "tags": "pdftex" }
How to populate a table from data in JSON array I am trying to populate an HTML table from data that is in a two-dimensional array. The data is coming to an $.ajax script from a php/MySQL query. I'm successfully parsing the data in the success function and I can read out the array element contents to the console, but I can't figure out why the values won't populate the HTML table. See this jsFiddle for my work. In the console I can populate the input in any of the table cells with this jQuery notation: $('#tblApTdms tr:nth-child(4) td:nth-child(3) input').val('q34rfewa') but it won't populate in the jsFiddle, in the Web application I'm building, nor in an isolated test page. I must be missing something here!
Try putting parenthesis around the addition equations: $('#tblApTdms tr:nth-child(' + (r + 1) + ') td:nth-child(' + (c + 1) + ') input').val(note);
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "javascript, jquery, ajax, json" }
Angular ui-bootstrap: Modal not dismissed on backdrop click When using ui-bootstrap version 0.13, the modal is not dismissed in the event of a click to the backdrop. (even if backdrop is not set to 'static') $modal.open({ ... backdrop: true, ... }); The problem is illustrated in this plunker. The second version of the plunker shows that the same code works on version 0.6 of ui-bootstrap. Does anyone know how to fix this?
The last version of ui-bootstrap that was compatible with Bootstrap CSS 2.3.x was ui-bootstrap 0.8.0. So you need to either update Bootstrap CSS to 3.x or stick with ui-bootstrap 0.8.0. > This version of the library (0.13.0) works only with Bootstrap CSS in version 3.x. 0.8.0 is the last version of this library that supports Bootstrap CSS in version 2.3.x. <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "angularjs, twitter bootstrap, angular ui, angular ui bootstrap" }
Symfony Nelmio Solarium Bundle FilterQuery When I execute this code in solr API ....fq=title:(bionformatics OR scince)... It works fine and return data that fit to Filter Query. But when I try the same query in Solarium bundle $client = $this->solr->getClient(); $query = $client->createSelect(); $query->setFilterQueries('title:("bionformatics" OR "scince")'); I get this error > Catchable Fatal Error: Argument 1 passed to Solarium\QueryType\Select\Query\Query::addFilterQueries() must be of the type array, string given, called in /var/www/html/conference/vendor/solarium/solarium/library/Solarium/QueryType/Select/Query/Query.php on line 737 and defined I must notice that Solarium bundle works well with **`$query->setQuery('title:"bionformatics" OR title:"scince"');`**
The error message is telling you exactly what the problem is. try: $query->setFilterQueries(array('titleFilter' => 'title:("bioinformatics" OR "science")')); Or since you only want to add a single Filterquery use the documented way from the solarium docs (< // get a select query instance $query = $client->createSelect(); // create a filterquery $query->createFilterQuery('maxprice')->setQuery('price:[1 TO 300]'); // this executes the query and returns the result $resultset = $client->select($query); When you look at this example it is also clear why setFilterQueries uses the array syntax, since every filterquery needs its unique identifier.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "php, symfony, solr, solarium" }
"Gafas" vs "anteojos" vs "lentes" vs "espejuelos" in Mexican Spanish Four different words, same meaning. Both according to Wiktionary as well as Google Images. Which one's preferred in regular speech in Mexico? I don't want to know what official dictionaries or RAE say. I want to know what people say.
In North México we say "lentes" for glasses, and "lentes de sol / lentes oscuros" for sunglasses.
stackexchange-spanish
{ "answer_score": 9, "question_score": 10, "tags": "vocabulario, diferencias regionales, méxico" }
Locked out Sitecore users cannot reset their password: Sitecore Password Recovery I did implement a basic Sitecore password recovery functionality following Enable Sitecore Password Recovery functionality Which works fine. However, if the Sitecore user is locked and the user clicks "Forget your password?" link on the Sitecore login page, the page throws an error. How can we fix this issue? ![enter image description here](
Sitecore did send me a patch and it solved the issue. If the user is locked out and the user clicks the "Forget your Password?" link, the site does not throw an error message anymore. It displays the login page with a message.However, the system does not send a new password for locked out users. Sitecore admins need to unlock the user. ![enter image description here](
stackexchange-sitecore
{ "answer_score": 0, "question_score": 3, "tags": "login" }
fd.seek() IOError: [Errno 22] Invalid argument My Python Interpreter (v2.6.5) raises the above error in the following codepart: fd = open("some_filename", "r") fd.seek(-2, os.SEEK_END) #same happens if you exchange the second arg. w/ 2 data=fd.read(2); last call is fd.seek() Traceback (most recent call last): File "bot.py", line 250, in <module> fd.seek(iterator, os.SEEK_END); IOError: [Errno 22] Invalid argument The strange thing with this is that the exception occurs just when executing my entire code, not if only the specific part with the file opening. At the runtime of this part of code, the opened file definitely exists, disk is not full, the variable "iterator" contains a correct value like in the first codeblock. What could be my mistake? Thanks in advance
From `lseek(2)`: > EINVAL > > whence is not one of SEEK_SET, SEEK_CUR, SEEK_END; or the resulting file offset would be negative, or beyond the end of a seekable device. So double-check the value of `iterator`.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 7, "tags": "python, python 2.6" }
How to approach, substitution - definite integral So I have this problem $${\int^{\pi/2}_0} {{\cos\theta \sin\theta}\over \sqrt{\cos^{2}\theta +8}}d\theta $$ and I'm not sure if this is the right direction to begin. If I have $u = \cos\theta$ then, $du = -\sin\theta$ can I then do this: $$-du=\sin\theta$$ $$-\cos\theta du = \cos\theta \sin\theta dx$$ and then: $$-\cos\theta {{\int^{0}_1}} {1\over \sqrt{u}}du$$ $$=\cos\theta {{\int^{1}_0}} {1\over \sqrt{u}}du$$ And then do the rest from there? Also, what other way could I do this?
Another way is to note that the numerator is a constant times the derivative of expression within the square root in the denominator, i.e. $$\frac{d}{d\theta}(\cos^2\theta+8)=-2\cos\theta\sin\theta$$ so that the indefinite integral is simply $$-(\cos^2\theta+8)^{\frac{1}{2}}$$ You can verify this by differentiating the above, using the chain rule.
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "calculus, integration" }
Dont get the output out of char palindrom[] i trying to make a palindrom out of the user input. Im saving the user input as array in char eingabe[] with int i im counting the index of the used arrays. Then i want to copy the reversed value of eingabe in palindrom and then printf both of them to get the palindrom. My i and j are counting correctly, but i dont get the output for palindrom. I hope you can help me. #include <stdio.h> int main(){ char eingabe[20]; char palindrom[20]; int i = 0; int j = 0; char c; do{ c = getchar(); if (c != EOF){ eingabe[i] = c; i++; } } while (c != EOF); eingabe[i] = '\0'; do{ palindrom[j] = eingabe[i]; j++; --i; } while (i != 0); palindrom[j] = '\0'; printf("\n\n%s",eingabe); printf("%s\n\n",palindrom); return 0; }
It is sometimes very helpful to add printf's to see what is going on. For example, if I add: do { printf("palindrom[%d] = eingabe[%d]\n", j, i); palindrom[j] = eingabe[i]; then the output is: abcde palindrom[0] = eingabe[5] palindrom[1] = eingabe[4] palindrom[2] = eingabe[3] palindrom[3] = eingabe[2] palindrom[4] = eingabe[1] eingabe: "abcde" palindrom: "" The problem is immediately obvious: the array index is off by 1. Since the first character of palindrom ([0]) gets set to the last character of eingabe ([5]) which is "\0", then C sees it as an empty string. This is easily corrected by moving the --i to the top of the loop: do { --i; palindrom[j] = eingabe[i]; j++; } while (i != 0);
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "c, palindrome" }
Test if a function name includes string, if the function returns an observable I would like to decide which function of a subset of functions to use on the base of its name. For Example: methodArray = [method1() {}, secondMethod() {}, thirdMethod() {}] getTheRightMethod(i: string){ for (const method of methodArray) { if (method.name.includes(i)) { return method; } } } getTheRightMethod('second'); The result should be the `secondMethod()` in this case. **Extra Question** My next Problem is here that my functions return Observables. What I want is an array of pointers to the functions. Is this possible?
You have to declare named functions for this to work: const methodArray = [function one() { return 1; }, function two() { return 2; }, function three() { return 3; }]; function getRightMethod(str) { for (const method of methodArray) { if (method.name.includes(str)) { return method; } } return null; } console.log(getRightMethod('two')());
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "javascript, typescript" }
Name and derivation of the approximation $\frac{1+x}{1+y} - 1 \approx x-y$? I am wondering if there is a name and way to derive the following approximation: $$\frac{1+x}{1+y} - 1 \approx x-y$$ I'm essentially interested in how to refer to this.
I would call this a Taylor approximation. When $|y|\lt1$, $$ \begin{align} \frac{1+x}{1+y}-1 &=-1+(1+x)\left(1-y+y^2-y^3+\dots\right)\\\ &=x-y-xy+y^2+xy^2-y^3-xy^3+\dots\\\\[6pt] &=x-y+O\\!\left(\max(|x|,|y|)^2\right) \end{align} $$
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "approximation" }
How to execute command every 10 seconds (without cron)? When I execute `cron` I get this fault > cron: can't open or create /var/run/crond.pid: Permission denied So, how to do it without `cron`? P.S. I want to check if file in svn has changed and I have a special script for it.
To access your personal `cron` configuration you should use the command `crontab -e` (to edit your cron table). Alternative is the `watch` command: watch -n10 command args Finally, to monitor filesystem events more effectively, you could use `inotifywait`, from `inotify-tools` package.
stackexchange-askubuntu
{ "answer_score": 66, "question_score": 39, "tags": "bash, cron" }
Singularities of $3$-folds Let $X,Y,Z$ be projective $3$-folds. Assume that $Y$ is smooth and $Z$ is smooth and Fano. Moreover, assume that there is a generically finite morphism $f:Y\rightarrow Z$ admitting a factorization $f=h\circ g$ where $g:Y\rightarrow X$, $h:X\rightarrow Z$ are two generically finite morphism. Can we say something about the singularities of $X$ or could it have arbitrarily bad singularities ? For instance, does the assumptions imply that $X$ has at worst canonical singularities ?
It can have bad singularities and dimension doesn't matter. Take an arbitrarily singular $X$ of dimension $d$. There is always a finite generic projection $X \to Z = {\mathbb{P}}^d$ (and $Z$ is smooth and Fano). On the other hand let $Y \to X$ be a resolution of singularities. Then $Y \to X \to Z$ is generically finite (birational followed by finite). In particular, such a factorization exists for any $X$.
stackexchange-mathoverflow_net_7z
{ "answer_score": 5, "question_score": 2, "tags": "ag.algebraic geometry, projective geometry, singularity theory, birational geometry, resolution of singularities" }
Instead of .resize? I have this jQuery code: $(window).resize(function() { if ($(window).width() <= 1250) { $('#topbar').css('position', 'static'); } else { $('#topbar').css('position', 'fixed'); } }); Problem is, when you have zoomed in lesser than 1250 and then reload the page this jQuery doesn't work. So how do i fix this?
Try to trigger resize handler maybe: $(window).resize(function () { if ($(this).width() <= 1250) { $('#topbar').css('position', 'static'); } else { $('#topbar').css('position', 'fixed'); } }).triggerHandler('resize');
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "jquery, html, css" }
How to say “otherwise” in everyday conversations Looking for the German translation of _otherwise_ , I can see there are a lot of possibilities: _ansonsten, anderenfalls, sonst, anderweitig, im Übrigen_ and so on. Here’s a little example of the English usage I’m referring to. > I hope the weather improves, _otherwise_ I’ll have to stay at home > [I’m just providing a sample context, no translation needed] Which German word/expression is better to use? I’m referring to the most commonly used — and informal — ones.
The three best possibilities to form your sentence are: 1. [Hauptsatz] …, **ansonsten** _Verb_ … 2. [Hauptsatz] …, **anderenfalls** _Verb_ … 3. [Hauptsatz] …, **sonst** _Verb_ … Example: > [I hoffe, dass sie mir helfen kann], **sonst/anderenfalls/ansonsten** schreibe ich dir. > [I hope she can help me], otherwise I’ll write you. The other two expressions don’t fulfill your requirements.
stackexchange-german
{ "answer_score": 5, "question_score": 6, "tags": "word usage, single word request" }
Find the min and max of each nested list in a list I am trying to find the min and max of each list in a nested list, and the index of when the min or max occurred: So that, for example: l=[[5,6,7][6,10,9,6][2,3,1]] Becomes: maxl=[7,10,3] indexl=[2,1,2] I've tried this and it seems to get me the max list (no indexes yet) but not for min- does anyone know how best to do this? maxHap=[] for subL in happiness1: maxHap.append(max(subL)) print(maxHap) minHap=[] for subL in happiness1: minHap.append(min(subL)) print(minHap) Thank you from a newbie
You can use the method `index` to get the index of a value of a list: < maxl = [] indexl = [] for inner_list in l: max_value = max(inner_list) maxl.append(max(max_value)) indexl.append(inner_list.index(max_value)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python" }
How do I solve $3(2^{x+2}-2^x) = 4a_1a_2a_3$ I encountered this problem but I'm not sure how to solve it since it has 4 unknowns. $$3(2^{x+2}-2^x) = 4a_1a_2a_3$$ What is known is that $x\in\mathbb{Z}$ and $a_1, a_2$ and $a_3$ are digits in a 4-digit-number. I'm not even sure if a solution exist. If I divide by three I get: $$(2^{x+2}-2^x) = \frac{1}{3}4a_1a_2a_3$$ So that's not working...
I assume you want integer solutions. You have that $3\cdot3\cdot2^x$ must be an integer between $4000$ and $4999$. So: $$4000\leq9\cdot2^x\leq 4999$$ $$\log_2\tfrac{4000}{9}\leq x\leq \log_2\tfrac{4999}{9}$$ which gives approximately $$8.795\leq x\leq 9.117$$ The only integer in this range is $$\boxed{x=9}$$ so that $$9\cdot2^x=9\cdot2^9=4608$$ and you have $$\boxed{a_1=6, a_2=0, a_3=8}$$
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "diophantine equations" }
How can I build a JSON object-key from string In a AngularJS environment I've got two JSON objects like the following: var rowData = { fields: { Id: 1234, Code: xyz } }; var access = { 0: "fields['Id']" } now I want to access the value of rowData.fields['Id'] generic by evaluating the value of access[0]. I tried: var result = rowData.access[0] which of course does not work. Problem seems to be that the value of `access[0]` is a string. How do I convert this to being usable in this given scenario?
Since you want this in the context of Angular, you can utilize the `$parse` service (ref): var getter = $parse(access[0]); var result = getter(rowData);
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "javascript, json, angularjs" }
how to use an alias name for a calculated expression in SQL I have something like this `CASE WHEN (1-(DayDiff([END_DATE],[START_DATE])*0.01)) >= 1.5 THEN 1.5 WHEN (1-(DayDiff([END_DATE],[START_DATE])*0.01)) <=0 THEN 0 ELSE (1-(DayDiff([END_DATE],[START_DATE])*0.01)) END` Can I use alias for the formula `(1-(DayDiff([END_DATE],[START_DATE])*0.01))` instead of using it multiple times? Also I want to make the value 0 when the formula returns `null`.
You can give an alias for the calculated field and use that alias in your outer query. For example; select CASE WHEN calc_field >= 1.5 THEN 1.5 WHEN calc_field <=0 THEN 0 ELSE calc_field END result from ( select (1-(DayDiff([END_DATE],[START_DATE])*0.01)) calc_field from table ) K
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql" }
Do not store password in .net membership I use the built in membership system in a MVC 3 .net application. Later in the developement I will use an external web service for authentication. Hence I would only have to store the (unique) username in the membership system. All other user info can be retrieved through the webservice. Therefore I wonder how to _not_ store a password?
Don't worry about the storing of the password, just randomly generate and store a password when you create the user. Have your account controller validate the password against the external webservice in the logon method, if its correct, then simply call `FormsAuthentication.SetAuthCookie(userName, false /*persistantCookie*/`), which will "login" the user :) side note: Have you though about how you will migrate the existing user's to the new external webservice if you only have their password hash/salts?
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "asp.net mvc 3, asp.net membership" }
Combining array of arrays based on first element I have an array of arrays, the inner array containing an item number and a quantity: array = [[a, 4], [b, 6], [d, 4], [a, 6], [b, 8]] I want to combine them so that each item is listed only once, with the sum of its quantities: [[a, 10], [b, 14], [d, 4] What is the easiest way for me to do this?
Possible solution: array = [[:a, 4], [:b, 6], [:d, 4], [:a, 6], [:b, 8]] array.each_with_object(Hash.new(0)) { |(k, v), memo| memo[k] += v } #=> {:a=>10, :b=>14, :d=>4} You can convert the result into an array (by simply calling `to_a`), but as for me, a hash is more suitable here.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "ruby" }
Поиск максимума во вложенных словарях Есть словарь с вложенными словарями вида: { 'Иван': {'рост': '176', 'вес': '120', 'прибавилВвесе': '14'}, 'Вася': {'рост': '176', 'вес': '120', 'прибавилВвесе': '-5'} } И мне нужно узнать, у кого значение `'прибавилВвесе'` максимальное. Kакую функцию применить, или придется через цикл искать?
Найти максимальное значение можно с помощью функции max: data = {'Иван': {'рост': '176', 'вес': '120', 'прибавилВвесе': '14'}, 'Вася': {'рост': '176', 'вес': '120', 'прибавилВвесе': '-5'}} print(max(data, key = lambda k: data[k]['прибавилВвесе']))
stackexchange-ru_stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python 3.x, словари" }
Right align a youtube video I'm trying to right align (class="alignright") a YouTube video AND allow my client to edit the surrounding text in the future using the visual editor. I simply added class="alignright" to the tag containing the embed using the HTML editor however when any changes are made to the text using the visual editor WordPress strips the extra code. I think it might be impossible to get the result that I want but could anyone confirm my suspicions or give me a workaround.
Use an id and CSS selector for the element and align it in your stylesheet.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "posts, css, html, visual editor, youtube" }
How to properly structure relationship from pre-established choices (or new if not exists) in rails? This is a quick and simple question of thinking the database. I have a User model and a Hotel model. Each user has a hotel and can select one of those from the hotels table OR add hotel name and address if his hotel is not found on the table. What is the best way to do that? I don't want users to be able to create hotels. So what I thought was: 1- Users table \-- User.hotel-name \-- User.hotel-address 2- Hotels table \-- Hotel.name \-- Hotel.address If the user selects an existing hotel, it would "copy" the info from this hotel. But that does not seem correct. Any help? Thanks
The best way to do that and normalizing de database is create another table HotelUsers including the hotels created by Users. 1. You check if hotel exist in HOTEL table. 2. Next check if hotel exists in HOTELUSERS with de id of user. 3. create new HOTELUSER copy of Hotel or new by User HOTELUSERS userId name address ANOTHER WAY You also can have a relationship many to many in USERS <-> HOTEL and store one parameter on HOTEL table for knowing when hotel is create by user.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ruby on rails, activerecord" }
Homology computation for $T^2$ Set $X=T^2$. Denote $E$ as the square and $\partial E$ as the boundary of disk. Set $Z$ the image of $\partial E$ under quotient of $X$. I am going to abuse notation for $H_\star$ to denote both homology and reduced homology. The book has shown $(E,\partial E)\to (X,Z)$ induces homology level isomorphism. It suffices to compute $H_\star(E,\partial E)$. I am looking for the mistake in my thought process. Consider long exact sequence $H_\star(\partial E)\to H_\star(E)\to H_\star(E,\partial E)$. Since $E$ is a square/contractible, then $H_\star(E)=0$. So $H_{\star+1}(\partial E)\cong H_\star(E,\partial E)$. This computation is clearly wrong as $H_1(X)$ should have 2 generators. $\textbf{Q:}$ What is my mistake?
The relative homology group $H_\star(E, \partial E)$ should be giving the homology of the quotient space formed by collapsing $\partial E$ to a point. But this quotient is actually homeomorphic to the sphere $S^2$ rather than a torus. To get a torus you must instead identify opposite sides. The homology isomorphism is giving the first homology group of $X/Z$, which is not a torus but rather a torus with two circles collapsed to a point.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "general topology, algebraic topology" }
Adding subviews with time delay on UISlider? I have a `UISlider` and I am trying to add subviews **dynamically** on the track of the `UISlider` with animation. I need 1 second time delay before adding each subview. How can I achieve this?
This is a basic setup of how you can go about achieving it: @interface ViewController () { NSTimer *_timer; CGRect sliderFrame; } @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.slider.minimumValue = 0.0f; self.slider.maximumValue = 100.0f; sliderFrame = self.slider.frame; _timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(addLabel:) userInfo:nil repeats:YES]; [_timer fire]; } - (void) addLabel:(NSTimer*) timer { UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(sliderFrame.origin.x + self.slider.value/100 * self.slider.frame.size.width, sliderFrame.origin.y - 10, 20, 20)]; label.text = @"1"; [self.view addSubview:label]; } @end
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ios, nstimer, uiviewanimation, uislider" }
Signed sum over labeled connected graphs Let $\binom{n}{2}$ be the set of all subsets of $\\{1,2,3, \ldots, n\\}$ of size $2$ and let $C_n$ be the set of $E \subseteq C_n$ so that the graph $G$ with vertex set $\\{1,2, 3, \ldots, n\\}$ and edge set $E$ is connected. Using generating function methods one can show that $$\sum_{E \in C_n} (-1)^{|E|} = (-1)^{n-1}(n-1)!.$$ For example, if $n=3$ then $$C_n = \\{\\{12,23\\}, \\{12, 13\\}, \\{13, 23\\}, \\{12, 13, 23\\} \\}$$ and then $$(-1)^2 + (-1)^2 + (-1)^2 + (-1)^3 = 2!.$$ Is there a more direct proof? For example, a sign-reversing involution argument.
The claim holds for $n=1$. Assume that it holds for $n-1$. Then the graphs in which $n$ has exactly one edge and the rest of the graph is connected yield the result. The graphs in which $n$ has at least two edges, say to $u$ and $v$, come in groups of $2$, with or without the edge $uv$, and thus cancel.
stackexchange-math
{ "answer_score": 1, "question_score": 5, "tags": "combinatorics, graph theory" }
Which function is correct for cloud masking I was writing a function to mask cloudy pixels of the Sentinel-2 data. Function 1: function cloudMask(image) { var qa = image.select('QA60'); var cloudBitMask = 1 << 10; ### var cirrusBitMask = 1 << 11; ### var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and( qa.bitwiseAnd(cirrusBitMask).eq(0)); return image.updateMask(mask).divide(10000); } Function 2: function cloudMask(image) { var qa = image.select('QA60'); var cloudBitMask = Math.pow(2, 10); ### var cirrusBitMask = Math.pow(2, 11); ### var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and( qa.bitwiseAnd(cirrusBitMask).eq(0)); return image.updateMask(mask).divide(10000); } Which function is correct? The difference between two functions is that how `cloudBitMask` and `cirrusBitMask` are defined.
Both functions are correct as they are doing exactly the same thing. Either `1 << 10` or `Math.pow(2, 10)` will result in a number with a value of `1024`. As we usually use both opaque cloud and cirrus cloud for cloud masking, I suggest keeping the code short and clear as below: function cloudMask(image) { var qa = image.select('QA60'); var allCloudBitMask = (1 << 10) + (1 << 11); var mask = qa.bitwiseAnd(allCloudBitMask).eq(0); return image.updateMask(mask); }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 3, "tags": "mask, google earth engine" }
Give counterexample for $\forall x (P(x) \rightarrow Q(x)), \exists x(P(x)) \vdash \forall xQ(x)$ I know this should be quite easy but I can't figure out how I have to write down a model as a counterexample for this: $\forall x (P(x) \rightarrow Q(x)), \exists x(P(x)) \vdash \forall xQ(x)$ Let's say $ P = \\{ \text{students who attended exam E.123} \\}$ and $ Q = \\{ \text{students who passed exam E.123} \\}$ How do I define my universe of values and how do I give the definitions of the functions and predicates? How to show a model $\mathcal{M}$ as counterexample? * * * Is it sufficient to define $\mathcal{A}_\mathcal{M} = \\{ a, b\\}$ and say $ \begin{align} P_\mathcal{M}(a) &= T \\\ P_\mathcal{M}(b) &= T \\\ Q_\mathcal{M}(a) &= F \\\ Q_\mathcal{M}(b) &= F \end{align} $ ?
1) $\forall x ((x > 0) \rightarrow (x > 0))$ --- is the _generalization_ of a tautology; thus, it is _valid_ 2) $\exists x (x > 0)$ --- it is true in $\mathbb N$ 3) $\forall x(x > 0)$ --- it is _false_ in $\mathbb N$, because **not** $0 > 0$. * * * Of course, we can "shrinck" it to a model $\mathcal M$ with $|\mathcal M |= \\{ 0,1 \\}$.
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "predicate logic" }
What is the difference between conda 'base' and 'root' enviroments? I have recently been pulling my hair out trying to organize my conda environments. I ended up reinstalling miniconda and I'm in a good spot. My question is this, when I run `conda env list` I get: # conda environments: # base * /Users/rheft/miniconda3 sonny36 /Users/rheft/miniconda3/envs/sonny36 I would expect "root" to be included here. Further more when I look at my conda environments from inside jupyter notebooks there are 3 environments listed. root -- /Users/rheft/miniconda3 miniconda3 -- /Users/rheft/miniconda3 sonny36 -- /Users/rheft/miniconda3/envs/sonny36 My question is why is it that `root` doesn't show when I run `conda env list`? Although everything works correctly, I would like to remove the duplicated environment if possible, any suggestions? Many thanks!
`root` is the old (pre-conda 4.4) name for the main environment; after conda 4.4, it was renamed to be `base`. Most likely the reason you have a Jupyter environment named `root` is because you have a kernel installed with that name in it.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 2, "tags": "python, jupyter notebook, conda" }
SQL wont let me replace a quote in SELECT statement I am trying to remove double quotes `"` from a column in my SQL export and I get an error, after researching the proper way... this is one of the ways I have tried.... SELECT '293453' as custnum, REPLACE(Orders.Order_Comments, '"', '') as FULFILL1, OrderDetails.OrderID as OrderID2, etc. The resulting error is: > Your SQL is invalid: Argument data type text is invalid for argument 1 of replace function.
Take a look at this answer: SQL Server find and replace in TEXT field The `text` data type is not valid for use with `replace`, so you need to cast it as VARCHAR(MAX) REPLACE(CAST(Orders.Order_Comments AS VARCHAR(MAX)), '"', '')
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "sql" }
Value not captured for SELECT in IONIC4 After the value is selected the value shows always empty. Working code in previous version as below. And latest version is also added below. Am i doing wrong some where ? IONIC previous version <div> <ion-select> <ion-option *ngFor="let city of citys.options" [value]="city"> {{city}} </ion-option> </ion-select> </div> IONIC 4 <div> <ion-select ngDefaultControl> <ion-select-option *ngFor="let city of citys.options" [value]="city"> {{city}} </ion-select-option> </ion-select> </div> Working code if using plain html controls <div> <select ngDefaultControl> <option *ngFor="let city of citys.options" [value]="city"> {{city}} </option> </select> </div>
This importing IonicModule in my components.module.ts made it to work import { IonicModule } from '@ionic/angular';
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ionic framework, ionic4" }
Qt three ComboBoxes for a date I have been looking around Google and Stackoverflow, but I have yet to find out if there is any simple solution to auto-filling three comboboxes to represent a correct date (like YYYY-MM-DD). I would presume it would be related to QCalendarWidget. Any ideas? I want to be able to scroll through current time to dates from X years ago, it shouldn't have non-existant dates like February 29, 2011. Not sure if this is asking for too much.
Now i get what's your idea. The answer is simple. Make three combo boxes: Day (1 - 31), Month (1 - 12) and Year (i.e. 1999 - 2012). Create "OK" button. No ultra-logic is needed. After button being pressed just validate the date by creating QDate object with three numbers given by user and calling QDate::isValid(). If it isn't, create some warning prompt and ask user to change something in input. The best way to validate the data entered by user is to override QDialog::done() method. void Dialog::done(int r) { if(r == QDialog::Accepted) { QDate date; //Create QDate from comboboxes' values ... if(!date.isValid()) { //Some warning to user. return; } } QDialog::done(r); }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "qt, date, combobox" }
okhttp and facebook crashed I am using picasso framework for displaying images. I have used facebook and dropbox as social network to download images. If i hit dropbox and show images and and within displaying images i hit facebook it crashed with single logcat issue **fatal signal 11 (sigsegv) at 0x00000000 (code=1), thread 15224 (asynctask #1)** I have read and got to conclusion 1\. there is no out of memory. 2\. some this is causing to using some space which is unavailable On seaching for okHTTp it hits services in secured soket in Trasport layer. If the same time some one use trasport layer out side this socket this crashed with fatal signal 11 see link here My appication uses images and I want to use Piccaso.because UIL through OOMs so much Any help to solve **What to solve: OKhttp or picasso with facebook or dropboxapi** Thanks.
I was able to solve my issues with crashing facebook interaction by following official workaround : > URL.setURLStreamHandlerFactory(new OkHttpClient());
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "android, picasso, okhttp" }
From where did the symbols *args and **kwargs in Python originate? I know that `*args` and `**kwargs` are ways to feed more arguments into a function in Python. I am wondering where these terms stem from. Why have all the asterisks in the beginning? What does the kw in kwargs stand for?
The "kw" stands for Key Word because the dictionary that you pass in is expanded to a sequence of key-word pair arguments. As to "Why have all the asterisks in the beginning?" I ask you, why not have them? My hypothesis as to why the * characters were chosen is that they frequently have a wildcard meaning (e.g., in regular expressions or globing). This is just guess-work though and I have nothing to document that.
stackexchange-softwareengineering
{ "answer_score": 8, "question_score": 7, "tags": "python" }
The game of 1036 Mahmoud and Zomhan play a game where they alternatively write numbers on a board. In each turn, a player takes the old number $N$ written on the board and replaces it either by the number $T$ of divisors of $n$ or by the difference $N-T$. For example if $N=22$ is written on the blackboard then $T=4$ with the divisors 1, 2, 11, 22 of $N=22$, and the next player may write $T=4$ or $N-T=18$ on the blackboard. Mahmoud is the first player to play, and whichever player is the first player to write the number $0$ is the winner of the game. Given that the initial number on the board is $1036$, determine which player has a winning strategy.
A player has a winning strategy if and only if * They can write $0$, or * They can write a number where their opponent does not have a winning strategy. > If $N$ is $1$ or $2$, the player can write $0$, so they win. > If $N$ is $3$, the player must write $1$ or $2$, and then the opponent wins. > If $N$ is $4$ or $9$ (3 divisors for each), the player can write $3$ and win. > If $N$ is $6$ (4 divisors), the player must write $2$ or $4$, but the opponent wins from both. > If $N$ is $11$ (2 divisors), the player must write $2$ or $9$, but the opponent wins from both. > If $N$ is $12$ (6 divisors), the player writes $6$ and wins. > If $N$ is $1024$ (11 divisors), the player can write $11$ and win. If $N$ is $1036$ (12 divisors), > the only options are to write $12$ or $1024$. Both of these let the opponent win. So Mahmoud does not have a winning strategy, and Zomhan does.
stackexchange-puzzling
{ "answer_score": 17, "question_score": 12, "tags": "mathematics, game" }
C# Grid-like interface (similar to a file explorer) to delete files from a Form I am currently looking for a grid-like interface, that you can insert into a C# form. From the grid interface you are able to delete files, although not execute them. I'm fairly new to C# and have not seen such as `Control` which can do this yet.
Can you try this ? < . You can add path as a parameter on Delete buttton. Also check this <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "c#, .net, winforms" }
ASP.NET MVC3 Cache object I have an Util class that goes through multiple xml files. Since there may be many of them I want to cache their data. So, how (and is it even possible) can I get to the application's Cache object? I know I can use it in my controllers through HttpContext.Cache, but in other classes? Ah, when I try to construct Cache object in my Util class I get NullReferenceException...
Try using System.Web; and then use HttpContext.Current.Cache in your Util class. That's what I see working.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "asp.net mvc 3, caching" }
Set initramfs to prompt for luks passowrd on startup on Mint 18? After updating to Mint 18.1, I can't get initramfs to prompt for a password to unlock the volume with the root file system on it. I have to wait until initramfs times out to a prompt then run `cryptsetup luksOpen` manually. I've tried running `update-initramfs` while the system is mounted and running (as well as from the live CD in chroot) and I have an entry in `/etc/cryptab`. This was working for me before the Mint 18 upgrade, but for some reason I'm still not getting a password prompt now no matter what I try. What should I check?
The UUID in `/etc/crypttab` has to be the UUID of the device that the crypt container sits on top of, not the UUID of the container. Or in other words, if you have `/dev/sda1` with `/dev/mapper/sda1_crypt` on top of it, the `/etc/crypttab` file should contain the name of the mapper device, `sda1_crypt` with the UUID of `/dev/sda1` **not** the UUID of `/dev/mapper/sda1_crypt`. An `/etc/crypttab` entry should look like this (all four fields are required): mappedname UUID=12345678-9abc-def012345-6789abcdef01 none luks You can get the UUID's from the `blkid` command. After this, `update-initramfs -u -k all`.
stackexchange-unix
{ "answer_score": 10, "question_score": 3, "tags": "linux mint, boot, grub, initramfs" }
Inverse Laplace Transform of $s^n$ I want to calculate Inverse Laplace Transform of $s^n$. I have an idea, but I do not know if it works? We have a formula to compute inverse laplace transforms of functions as below, $$\mathcal{L}^{-1} [ F(s) ] = -\frac{\mathcal{L}^{-1} [ F^{\prime}(s) ]}{t}.$$ So from the given formula, we can obtain $$\mathcal{L}^{-1} [ s ]= -\frac{\mathcal{L}^{-1} [ 1 ]}{t}= -\frac{\delta (t)}{t}.$$ and as a result, $$\mathcal{L}^{-1} [ s^n ] = (-1)^n\frac{n!\delta (t)}{t^n}$$ Is it right? In fact, I want to know the necessary conditions to use the given formula.
Intuitively, the derivative of the Dirac delta function $\delta'$ has Laplace transform $s$. The derivative of the Dirac delta is a generalized function that pulls out the derivative of the function with a change of sign: for any interval $[a,b]$ where $a < 0 < b$, $$\int_a^b \delta'(t)f(t) \ dt = \left[ \delta(t) f(t) \right]_a^b - \int_a^b \delta(t) f'(t) \ dt = -f'(0)$$ Applying that procedure inductively, $$L^{-1}\\{s^n\\}(t) = \delta^{(n)}(t)$$
stackexchange-math
{ "answer_score": 7, "question_score": 5, "tags": "ordinary differential equations, laplace transform" }
Find the values of $ t$ so that the tangent line to the given curve contains the given point ![enter image description here]( I'm doing exercise 27. I know that the tangent vector is $ r'(t)$. I think that the tangent line should be $ <-8,2,-1> \+ \frac{r'(t)}{ ||{r'(t)||}}$. I'm not sure how to find all values of $ t$ . I suppose that $t \in \mathbb{R}$. I'm not sure what this question is asking. I'm looking to verify my solution and correct if necessary.
Note that an equation for a line through point $\mathbf p$ with direction $\mathbf v$ is $\mathbf s=\mathbf p+\mathbf v t$. Also note that this $t$ is independent of the $t$ in the given function. Further, the magnitude of your direction vector $\mathbf v$ doesn't matter. So, you're looking for the values of $t$ such that $\langle -8,2,-1\rangle=\mathbf r(t)+c\mathbf r'(t)$ for some scalar $c$.
stackexchange-math
{ "answer_score": 0, "question_score": 1, "tags": "vectors, curves, tangent line" }
Firefox extension: Secret Agent - User Agent String Randomizer - Application testing Extension Link: < This plugin is great. It has one problem though, on pages that use AJAX to make http requests, it switches the user agent for each request and confuses many ajax applications. What I want to do is figure out where the preferences for this plugin are saved. Particularly, where all the User-Agent Strings that are currently being used are located. I would like to do this so that I could edit these settings outside of firefox before I open the browser so as to "hot swap" one user agent string for each browsing session at a time. I have looked through all kinds of .sqlite databases in my firefox profile but still haven't found the information. I am using Watir-Webdriver with ruby to application test.
As Mr Palant said... simply changing general.useragent.override would achieve what you want. Type about:config in the address bar, accept the warning, and filter on useragent and you'll see the setting. I gather (but haven't tested) this preference may not affect the user agent presented to client side Javascript code. So if your Ajax code references navigator.useragent you might find the real user agent is returned despite your override setting. Pete (author of SecretAgent). www.secretagent.org.uk PS See also <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby, firefox, firefox addon, user agent, watir webdriver" }
jquery - how to make a dialog box when user clicks a link? I am new to JQuery. I want to know that how to make a dialog box that popsup when user clicks a link like if i click send then a dialog box popsup to tell that your information has been sent! Any help would be appreciated!
Have a look at Twitter Bootstrap modal... <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery" }
Override longer mappings Is there a way to trigger a certain short mapping i.e. `\c` without waiting to see if there is a longer one that starts with the same characters (effectively disabling all other overlapping mappings)?
Yes, you can use the `<nowait>` modifier. See here, copied from the documentation: *:map-<nowait>* *:map-nowait* When defining a buffer-local mapping for "," there may be a global mapping that starts with ",". Then you need to type another character for Vim to know whether to use the "," mapping or the longer one. To avoid this add the <nowait> argument. Then the mapping will be used when it matches, Vim does not wait for more characters to be typed. However, if the characters were already typed they are used. Note: this is not limited to buffer-local mappings, but it might effectively disable all the longer mappings, so use with care.
stackexchange-vi
{ "answer_score": 4, "question_score": 0, "tags": "key bindings" }
Expand a string which has '\t' to a specific length I have a string which have 3 '\t's and when I use the proper methods like: string.padright(totalWidth); Or string.format("{0,width}",myText); Or even a function from scratch, I get a problem with that '\t' escape in the string which counts one but depend on a string, it's between 0 to 8. At the end, if I have this string "blah\tblah\tblah" and I apply those methods to have a 20 length string I get this "blah blah blah " which has a length of 30. How can I count the spaces that '\t' fills after the string is displayed?
Tabs are a bit strange because they're a single character, but the effective width is variable. It depends on how many characters are on screen currently, and the tab width. It's possible to write a function that expands the tab characters to spaces. string ExpandTabs(string input, int tabWidth = 8) { if (string.IsNullOrEmpty(input)) return input; var result = new System.Text.StringBuilder(input.Length); foreach (var ch in input) { if (ch == '\t') { result.Append(' '); while (result.Length % tabWidth != 0) result.Append(' '); } else result.Append(ch); } return result.ToString(); } Note that this is a fairly naive function. It won't work properly if there are embedded `\r` or `\n` characters, and other characters could also cause problems.
stackexchange-stackoverflow
{ "answer_score": -1, "question_score": -3, "tags": "c#, string, escaping" }
MySQL order by two values In short, I have a game of sorts, and the score board for it shows the score of the player at the end + how long they took to achieve it. I need to order my MySQL results so that the highest score in the fastest time is first and the lowest score with the slowest time is last, and everything in between is ranked in the same way. But I have no idea how I'd do that, here's my sql as it stands: $sql1 = "SELECT * FROM boobmatch_highscores ORDER BY t_score DESC, time ASC"; Any help would be greatly appreciated! The data in the table: Score Time 23 00:04:32 23 00:04:31 25 00:02:32 16 00:06:32 35 00:04:32 2 00:01:17 -13 00:19:32 -3 00:07:27
You query is supposed to work perfectly. If you have any issues just enclose the field names in quotes like so: $sql1 = "SELECT * FROM boobmatch_highscores ORDER BY `t_score` DESC, `time` ASC"; Guessing it's MySQL, else the quotes won't be necessary
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 5, "tags": "php, mysql, sql order by" }
How to put my app in a iPhone 3G? I am using Xcode 4.2 to develop my apps. My current ongoing project is set to run on ios4.2, but i only have a iPhone 3G (not 'S') to test my app. The problem is that when i try to run my app in my device, xcode says it was compiled and running on device but the app doenst even install in my iPhone. I have read on other posts that i have to change the armvX configuration, so how do I do that in order for my app to run in a iPhone 3G? Thanks.
This is a hardware issue rather than an iOS version issue. In the Architectures section of your build configuration it probably just says armv7. You need it so have two entries, armv6 and armv7. Select Other from the architectures menu then delete the default then add two new entries, one that just says armv6, on that just says armv7. This creates a fat binary (essentially two binaries) which will contain the v6 code the 3G needs.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "iphone, ios, xcode, debugging" }
Why is a virtual MAC address needed in FHRP protocols? Imagine the following topology ![enter image description here]( I understand why both R1 and R2 need to share a virtual IP, but why is it necessary for them to also share a virtual MAC? Couldn't they simply use their own MAC address? And if the Active router went down, R2 could just send a graituitous ARP, announcing that the VIP will now use R2's MAC address, so the end hosts can update their ARP cache and switches their MAC address table. Thank you in advance.
The reason for using a virtual MAC address instead of each router's own MAC address, is that in case of a failover, you don't want to have to learn the new MAC address for the virtual IP address on each node using this virtual address. A virtual MAC address ensures hosts are always sending traffic to the correct ethernet address, without having to update their ARP table if a failover occurs.
stackexchange-networkengineering
{ "answer_score": 8, "question_score": 5, "tags": "fhrp" }
Detect the gray level of a surface I'm looking just for an idea/conception to resolve my problem. I need to **CHECK** if the color of a surface does not exceed a certain gray level. So I thought to calculate its luminance. Problem is that colors like this one `#BCB0F5` will give me an acceptable gray level, however the color of the surface must not look that blue for the human eyes. It must look (for human eyes) just as a certain gray level (black and white). How can I resolve this problem ? Thank you for any hints.
In a perceptual model of colour, we can talk of a particular colour's luminance and chromaticity (it's "brightness" and it's "quality"). By converting the samples you have from RGB to CIELAB (via ColorPy say), you can filter out colours which are brighter than your desired grey (`L_sample` > `L_grey`) and whose distance from the white point are greater than a JND (e.g. `sqrt(a_sample**2 + b_sample**2) > 2.3`)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "python, python 2.7, opencv, colors, grayscale" }
What is the smallest possible SQL injection attack character sequence? Simple, a SQL injection attack in as few characters as possible. Note, I'm not trying to prevent SQL injection attacks by limiting inputs to a certain size, but rather am genuinely curious how many characters is needed to execute even the simplest attack. For posterity sake, let's say the smallest table name is 4 characters, e.g., "user". Please factor that in.
1 Character is the smallest unit that you have control over. The question depends heavily on what you're doing. For instance, if you're dealing with an interface to delete your profile from a site, and you send '%' instead of your name: "Delete from Users where name like '"+username+"'" then setting your username to `%` will delete all the users.
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 6, "tags": "sql, code injection" }
How to give Emacs-started-by-icon-click the same environment as Emacs-started-from-Unix-shell? On my Mac laptop, I can start Emacs in several ways, including (1) clicking on an icon on the dock, or (2) running % emacs from the Terminal app. These two ways of launching Emacs produce instances of Emacs that run differently, because they have different settings for their environment variables. How can I give the instance of Emacs that I start by clicking on an icon the "same"1 environment as that of an instance of Emacs started from the Unix shell command-line (as described above) right after the parent shell is initialized? * * * 1 Well, the two environments cannot be _exactly_ the same, because there are some environment settings, such as the value of the `$$` parameter, that are specific to the respective processes. So, when I say that two environments are "the same", I mean that they agree on all the settings for which such agreement is possible in principle.
There's a package called **exec-path-from-shell** that was made to solve this problem. By default, it'll try to figure out `PATH` and `MANPATH` from your shell setup, but you can customize the variable `exec-path-from-shell-variables` to pull in more environment variables. You'll need to figure out for yourself which environment variables matter to you. ;; note env vars of interest (dolist (var '("SSH_AUTH_SOCK" "SSH_AGENT_PID" "GPG_AGENT_INFO" "LANG" "LC_CTYPE" "NIX_SSL_CERT_FILE" "NIX_PATH")) (add-to-list 'exec-path-from-shell-variables var)) ;; set env vars in emacs (when (memq window-system '(mac ns x)) (exec-path-from-shell-initialize))
stackexchange-emacs
{ "answer_score": 2, "question_score": 2, "tags": "osx, environment, system environment" }
DBPedia SPARQL <LONG::IRI_RANK> I could run SRARQL queries with LONG::IRI_RANK from this URL: < but I can't run it in my local OpenRDF Sesame repository loaded with 'person_en.nt' DBPedia dataset file(SPARQL parser error). Is it possible to use LONG::IRI_RANK (or something similar) for the local Sesame repository(not Virtuoso)? May be I should load another(which one?) DBPedia dataset file into my local Sesame repository? Thanks!
`IRI_RANK` is a proprietary extension in OpenLink Virtuoso. To the best of my knowledge, nothing comparable is available in Sesame.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 4, "tags": "sparql, dbpedia, pagerank, sesame" }
Get capital characters as string using Java Stream API I am trying to get capital letters by: "My Name Is".chars() .filter(c-> c > 64 && c < 97 ) .collect(<??>); I am not sure what I should pass to collect() method to get list of characters or a string. My object is to parse string and get another string which has only capital letters This works fine : StringBuilder abbr=new StringBuilder(); "My Name Is".chars() .filter(c -> c > 64 && c < 97) .forEach(c->abbr.append(Character.toChars(c))); Is is possible to use collect() construct of even a better /shorter way ?
You can use `Collectors.joining("")`. String upper = "My Name Is".chars() .filter(Character::isUpperCase) .mapToObj(c -> Character.toString((char)c)) .collect(Collectors.joining()); Note that I also use `Character.isUpperCase`.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "java, java stream" }
Having trouble installing Paddle Module I'm receiving an error when i try to install a .whl file: $ pip install paddlepaddle-1.8.5-cp27-cp27m-win_10_6_intel.whl `ERROR: paddlepaddle-1.8.5-cp27-cp27m-win_10_6_intel.whl is not a supported wheel on this platform.` I am running windows 10, the latest version of pip, and python 3.9.1 I'm in the correct directory when I run it but I am not sure why it is doing this. the main goal is to install paddle, and $ pip install paddle didn't work.
look like you are trying to install cp27 compatible version which is Cpython 2.7 and you have 3.9.1 in your system, that's why you are getting that error. try this: > pip install paddlepaddle-1.8.5-cp27-cp27m-win_amd64.whl It should work, because AMD supports Intel architecture. but in case if this doesn't work try to create venv and install python2.7 and do your work.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python" }
CakePHP Cookies getting scrambled - Suhosin related For some reason I am unable to read any cookies from my CakePHP app on any page after they have been set, the only thing that is returned is garbled text. My code is as simple as this: $this->Cookie->write('Region', 'test'); $reg = $this->Cookie->read('Region'); pr($reg); I uncomment the $this->Cookie->write() line and all I get back is a bunch of random control characters. I also recently upgraded to CakePHP 1.3 but AFAIK this should not effect cookie like this... This was working fine until I **changed server** , this must be the root of my problem. **Update** After probing around further I have discovered this is a known issue with the Suhosin security patch for PHP effecting the rand() and srand() methods, I had configured Suhosin to allow the rand() functions but still it is happening, is there a more effective work around out there?
Try this code which will disable cookie encryption: $this->Cookie->write('Region', 'test', false); $reg = $this->Cookie->read('Region'); pr($reg); The write method has the following params: `write(mixed $key, mixed $value, boolean $encrypt, mixed $expires)` By default all values in the cookie are encrypted by CakePHP. However for security reasons you may wish to look into working with the encryption.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 7, "tags": "php, cakephp, suhosin" }
Lifting of a morphism in a hom-functor when hom-sets are empty I'm having trouble in unserstanding a hom-functor. Suppose we have a hom-functor $\mathrm{Hom}(X,$_$)$ for some Category $\mathcal{C}$. Suppose further that the hom-sets $\mathrm{Hom}_{\mathbf{Set}}(X,A)$ and $\mathrm{Hom}_{\mathbf{Set}}(X,B)$ are empty and there exists an arrow $f$ going from $A$ to $B$. What would be the lifted function $\mathcal{C}(X,f)$ in category $\mathbf{Set}$? Isn't this a function going from the empty set to the empty set? How does this work?
First, note that the notation for the hom-set is $\mathrm{Hom}_{\mathcal C}(X, A)$, rather than $\mathrm{Hom}_{\mathbf{Set}}(X, A)$ (the $\mathbf{Set}$ is implicit). Yes, $\mathrm{Hom}_{\mathcal C}(X, f)$ will be a function $\emptyset \to \emptyset$ if $\mathrm{Hom}_{\mathcal C}(X, A)$ and $\mathrm{Hom}_{\mathcal C}(X, B)$ are empty. But that's okay! There is exactly one function from the empty set to the empty set, which is the identity function. (In fact, for each set $Y$, there's exactly one function from the empty set to $Y$. We just have to provide an assignment of each element in the domain to an element of the codomain: when the domain is empty, this is trivial, as there aren't any elements to provide assingments for.)
stackexchange-math
{ "answer_score": 7, "question_score": 4, "tags": "category theory, functors, hom functor" }
Let $a,b \in \mathbb{Q^{+}}$ then $\sqrt{a} + \sqrt{b} \in \mathbb{Q} $ iff $\sqrt{a} \in \mathbb{Q}$ and $\sqrt{b} \in \mathbb{Q}$ I need to prove this equivalence Let $a,b \in \mathbb{Q^{+}}$ then $\sqrt{a} + \sqrt{b} \in \mathbb{Q} $ if and only if $\sqrt{a} \in \mathbb{Q}$ and $\sqrt{b} \in \mathbb{Q}$ I have already proved the reciprocal (the obvious part) but I am having difficulties with the other part Please any hint will be appreciated. Thanks in advance.
Let $x = \sqrt{a} + \sqrt{b}$ and suppose $x \in \Bbb Q$. If $a = b$, then $x = 2\sqrt{a}$, so $\sqrt{b} = \sqrt{a} = \frac{x}{2} \in \Bbb Q$. Now suppose $a \neq b$. Then $\frac{1}{x} = \frac{\sqrt{a} - \sqrt{b}}{a - b} \in \Bbb Q$. So $y:= \sqrt{a} - \sqrt{b} = \frac{a - b}{x}\in \Bbb Q$. Now prove the result by considering $x + y$ and $x - y$.
stackexchange-math
{ "answer_score": 9, "question_score": 3, "tags": "real analysis" }
Weather transition matrix Based on observation, I've gathered some data: Day 1 2 3 4 5 6 7 8 9 10 S R S F S R F F R S (S) = Sunny (R) = Rainy (F) = Foggy How do I construct this into a transition matrix, for markov chain ? S R F S[? ? ?] R[? ? ?] F[? ? ?] Thanks
There are $9$ transitions. To fill in the appropriate entries, count the number of relevant transitions. So for the entry in row S, column S, count the number of two consecutive days where you have S,S. For row S, column R, coin the number of two consecutive days where you have S then R. For row S, column F, coin the number of two consecutive days where you have S then F. Once you have evaluated the number of transitions for all $9$ entries, divide each row by the total number of entries in that row. I have filled in part of the matrix below:- S R F S[0 2/3 1/3] R[2/3 0 1/3] F[1/3 1/3 1/3] Can you complete the transition matrix?
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "matrices, markov chains, transition matrix" }
How to find all "orphaned" user stories in Rally tool I want to find all `"orphaned"` user stories in `Rally`, where a `user story` does not belong to any `feature`. I know I need to set filter to((PortfolioItem = null) AND (Parent = null)) but where do I do that? Where do I start? Forgive my ignorance, I am new to Rally
You have a bunch of options: the Work Views page or a custom list app are both decent places to start. Both of those apps have filters where you should be able to select a filter for Parent = -- No Entry --
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "rally" }
(X)HTML Markup for Book Titles Should book titles be contained in an <em> tag? If not <em> is there more appropriate markup?
<em> is definitely wrong. In addition to the other suggestions given before me such as RDFa or a semantic class name, consider using <cite> From the HTML 5 draft: > The cite element represents the title of a work (e.g. a book, a paper, an essay, a poem, a score, a song, a script, a film, a TV show, a game, a sculpture, a painting, a theatre production, a play, an opera, a musical, an exhibition, etc). This can be a work that is being quoted or referenced in detail (i.e. a citation), or it can just be a work that is mentioned in passing.
stackexchange-stackoverflow
{ "answer_score": 27, "question_score": 13, "tags": "html, markup, web standards, semantic markup" }
Bounded in expectated absolute value implies bounded in probability ($O_p(1)$) Suppose $X_n$ is a sequence of real value random variable and $E(\|X_n\|)<\infty$. Then $X_n=O_p(1)$. My thinking is to use Markov inequality. $$ P(\|X\|\geq a)\leq \frac{E\|X\|}{a} $$ Now choose $a = \frac{E\|X\|}{\epsilon}$. Then $$ (\forall \epsilon>0)(\exists a<\infty)(P(\|X\|<a)>1-\frac{E\|X\|}{E\|X\|/\epsilon}=1-\epsilon $$ as required. Is this correct? Any alternative proof? Definition: A sequence of random variables $\\{X_n\\}_{n\geq 1}$ is said to be $O_p(1)$ if and only if $$ (\forall \epsilon>0)(\exists K<\infty )(P(\|X_n\|<K)>1-\epsilon\ \ \forall n \in N) $$
With your assumption the claim is false and $X_n=n$ is a counter-example. If you assume that $\sup_n E\|X_n\|<\infty$ then you can prove it as follows: Let $C=\sup_n E\|X_n\|$. Then $P(\|X_n\|\geq M)\leq \frac {E\|X_n\|} M\leq \frac C M <\epsilon$ for $M >\frac C {\epsilon}$. Hence, $P(\|X_n\|<M)>1-\epsilon$ if $M >\frac C {\epsilon}$.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "real analysis, probability theory, expected value, probability limit theorems" }
Rails: InsufficientPrivilege: ERROR: permission denied for relation schema_migrations In my rails app, I am using `postgresql` as my adapter in `database.yml` file. I want to rename the database and reassigned them to a different owner. So i went ahead and changed my postgres database by running: ALTER DATABASE old_name RENAME TO new_name; CREATE ROLE new_role WITH PASSWORD 'pw123'; ALTER USER new_role CREATEDB; ALTER USER new_role LOGIN; Then I also modified my `database.yml` file accordingly After all that, when i run the app again, the error: `InsufficientPrivilege: ERROR: permission denied for relation schema_migrations` This new role has the exact same privilege of the previous owner, but I don't know why it is yelling at the new owner. I believe I am missing a tiny thing here, but i would not figure out what. So what should i do to let my app accept the new postgresql changes?
The database has changed ownership, but the objects in it have not. So the schema still belongs to the old user, and the new user has no permissions on it. When it comes to permissions and ownership, databasea are objects like all other objects. To use an analogy, you don't own everything _in_ a house just because you own the house. The `REASSIGN OWNED` SQL command can change ownership of all objects in a database.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby on rails, postgresql" }
Why letsencrypt SSL certificate display warning messages? I'm new to letsencrypt SSL certificate. I have followed the article here, but received the following warning messages upon loading the website : Warning: stream_socket_client(): Peer certificate CN=`abc.com' did not match expected CN=`1.2.3.4' in /usr/share/nginx/html/wp-includes/class-wp-http-streams.php on line 150 Warning: stream_socket_client(): Failed to enable crypto in /usr/share/nginx/html/wp-includes/class-wp-http-streams.php on line 150 Warning: stream_socket_client(): unable to connect to ssl://1.2.3.4:443 (Unknown error) in /usr/share/nginx/html/wp-includes/class-wp-http-streams.php on line 150 Any clue on what's going on?
I finally found the answer. I modified my DNS control panel to use 2 nameservers, where previously there were 4 nameservers, from 2 different web hosting providers. Then I tried : sudo certbot --nginx -d abc.com -d www.abc.com --force-renewal Refreshed the browser and voila, it works now. Hopefully this will be useful to whom encounter the same problem.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "lets encrypt" }
Can't set automatically TimeZone in TimePicker Using TimePiker I want to set timezone: $('#timeStart').timepicker({ showTimezone: true, timeFormat: "hh:mm TT", timezoneList: [ { 'value': '-720', 'label': '(GMT-12:00) International Date Line West' }, { 'value': '-660', 'label': '(GMT-11:00) Midway Island, Samoa' } .... { 'value': '+840', 'label': '(GMT+14:00) Time in Samoa' } ] }); timepiker is initialized and zones is added in selector but selected value is the first from list is not detected if I set manually option timezone: '+840' it work why timezone is not detect automatically?
I found solution,instead of { 'value': '-720', 'label': '(GMT-12:00) International Date Line West' } Is need to use { value: -720, label: '(GMT-12:00) International Date Line West' }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "jquery, datetime, timepicker" }
Visual C# 2008 Control to set a path Greetings, What control in Visual C# 2008 would allow me to set a path and get the value of that path. For example: I want the user to click a button then select a path where he/she would do the operation such as save a file in selected path.
You want to use a FolderBrowserDiaglog var folderBrowserDiaglog = new FolderBrowserDiaglog(); if ( folderBrowserDiaglog.ShowDialog() == DialogResult.OK ) { string path = folderBrowserDiaglog.SelectedPath; }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "c#, visual studio" }
Is it possible to do reverse debugging with qemu? I read on this page that they were going to add revese execution support to existing simulators such as qemu. Since this page has been last edited since 2012, I would like to know if the current version of qemu supports this functionnality. If so, how to use it?
There are some patches, but AFAIK not yet merged: < In the mean-time (shameless plug), if it's a user-mode Linux application you're looking to debug, you could always try <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "debugging, gdb, reverse, qemu" }