INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
If I run my own push notification server do I still need FCM? I've just read alot about push notification servers, self-hosted ones as well as cloud. and I am pretty much confused about one aspect. I need push notifications for my Android/iOS app for more than a million devices using the same app. now there is no free service for that scale and paid services will result in too much monthly fees, so I thought about running my own server with an open source solution. I've checked Many but parse seems to be the best fit. but they say that it uses FCM and I know from google pricing that it is free only for a limited number of registered devices. I thought that hosting my own push server would spare me those fees; but it seems like not; what good is it then ? wouldnt it be better to just use FCM directly ?
Delivering push notifications to Android (with Google Play Services) and iOS will always use FCM or APNS respectively. The reason is that those services are built into the operating system, or built closer to the operating system than regular application can function and get reliability and battery life advantages from that. Both FCM and APNS are completely free and unlimited, although both have quota to protect the services against abuse. There are many services (such as Parse Push, Airship, OneSignal, etc) that build on top of FCM and APNS to provide higher level messaging operations. But at a lower level these will be using APNS and FCM for the actual delivery of the messages. That's also what you have to think of when you considering building your own server: what will that server actually do to deliver the messages to the devices? If you're not using FCM/APNS, how do you get the message to the device, especially when the user is not actively using the app?
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 2, "tags": "server, push notification, firebase cloud messaging, apple push notifications, android notifications" }
Please, how do I calculate this integrals? Which substitution(s) is/are suitable? > $$\int_0^{1} \frac{1}{1+\tan^2{x}}\,\mathrm{d}x$$ > > $$\int_0^{1} \frac{1}{1+a^2\tan^2{x}}\,\mathrm{d}x $$ How can I evaluate these integrals? I don't know which substitution to use to solve them. I wanted to use the solution of the second integral to evaluate this integral: $$I (1)=\int_0^{1} \frac{x}{tan{x}}\,\mathrm{d}x $$ by converting it to the integral with the parameter as I obtain: $$I'(a)=\int_0^{1} \frac{1}{1+a^2\tan^2{x}}\,\mathrm{d}x $$
**HINT:** For the first one, you don't even need to use substitution. Use the trigonometric identity $$1+\tan^2 \theta=\sec^2 \theta$$ and the integral will become _much_ easier. Now for the second one. Start off with $$\int \frac{dx}{1+a^2\tan^2 x}$$ and make the substitution $x \to \arctan u$. You will end up with $$\int \frac{du}{(1+u^2)(1+a^2u^2)}$$ Now, using partial fractions, this is equal to $$\frac{1}{a^2-1}\int \bigg(\frac{a^2}{1+a^2u^2}-\frac{1}{1+u^2}\bigg)du$$ Now, using the fact that $$\frac{d}{d\phi} \arctan\phi=\frac{1}{1+\phi^2}$$ You should be able to easily finish this integral.
stackexchange-math
{ "answer_score": 2, "question_score": -4, "tags": "integration, definite integrals, substitution" }
OSL Struct SyntaxError I'm trying to create a way to calculate imaginary numbers in **OSL** using the `struct` constructor. Here is the beginning of my code: #include "stdosl.h" struct complex { color r; color i; }; complex test; According to the documentation, that should create a `complex` datatype, then initialize a variable named `test`. Instead, I get these errors: ERROR: <path-to-file>.osl:8: error: Unknown shader type: complex ERROR: <path-to-file>.osl:8: error: Syntax error: syntax error Error: OSL script compilation failed, see console for errors This seems to indicate a syntax error on line 8, but I can't figure out what is wrong.
You should declare the variable inside a shader struct complex { color r; color i; }; shader node_complex(output float result=0.0) { complex test; } This will resolve the compilation error. The issue is that Global variables in OSL are predefined and it is not possible to create custom global variables. You can use these structs inside shaders and pass it around.
stackexchange-blender
{ "answer_score": 2, "question_score": 1, "tags": "shaders, osl" }
How to extract patches from a .tiff file to feed as input to Alexnet implemented in Keras? I am trying to use transfer learning to extract features. My dataset has images in .tiff format.How do I feed patches of this format to the Alexnet implemented in Keras ?
Are you able to feed any other format of data to ALextNet or do you need complete guide to feed images into a neural network in Keras. If you are able to feed a numpy array containing the pixel values of images then you can follow the following steps to read a tiff image and convert a numpy array out of it. Or if you want a complete tutorial then you should mention it in the question. **Using PIL library** from PIL import Image im = Image.open('a_image.tif') **Using matplotlib** import matplotlib.pyplot as plt I = plt.imread(tiff_file) Let us know if you need any help with it.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, python 3.x, deep learning, keras" }
What are the advantages and differences of using github desktop and using git? I learned a bit about Git and Github. Can you tell the advantages of using git compared to Github Desktop?
**GitHub Desktop** is a **graphical client** for the GitHub software development platform, which **uses Git** version control. The desktop client offers essential functions and a tidy display. **Git** is a free and **open source distributed version control system** designed to handle everything from small to very large projects with speed and efficiency. So GitHub Desktop **based on git** and shows the results graphical. Git is a technology for version control system and can be used differently. Here are all GUI Client where you can use for git (also github).
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "git, github desktop" }
A-Frame: Default value 'true' does not match type 'boolean' in browser.js I've been fighting with this for a while. The console seems to populate with incorrect match types, when it's actually getting the right type. Default value `true` does not match type `boolean` in component `nav-panel` Default value `false` does not match type `boolean` in component `nav-panel` Default value `0` does not match type `number` in component `nav-button` It does get annoying to see this happening.
The problem here is that those defaults are string values, and they are not defined in their types per se. When defined in the schema, if you have a number or a Boolean they cannot be wrapped in quotes `""` (If you do so, you're telling A-Frame that those are strings!) This means: Change "true" to true, and '0' to 0: AFRAME.registerComponent('nav-panel', { schema : { active: {type: "boolean", default: "true"}, textOffset: {type: 'number', default: '0'}, }, } Correct: AFRAME.registerComponent('nav-panel', { schema : { active: {type: "boolean", default: true}, textOffset: {type: 'number', default: 0}, } }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "three.js, components, aframe" }
Application layer scaling while depending on a single DB How can running multiple instances of my backend improve performance if they are all backed with a single Database (served with the same database instance) Because I think that most of the latency of the request is caused by the database, shouldn't I focus first on database performance/scalability rather running multiple instances of the application and hope for the best?
Consider that many times servers do cache some of the data they get from DB. Also take note that server can perform some operations before sending data to DB so you may or may not benefit from having multiple instances. In order to figure out how to scale your application with success you need to measure it, identify bottlenecks and address them. Just thinking this or that is often misleading.
stackexchange-softwareengineering
{ "answer_score": 0, "question_score": 0, "tags": "architecture, scaling" }
After notitlepage my abstract lost formatting I've added `notitlepage` option to not get my page counter reset ( according to suggestion : < ) but my abstract lost formatting ! Now it has line spacing and margins like rest of document. _How to achieve default look of abstract when`notitlepage` option is used?_ \documentclass[pdftex,a4paper,12pt,twoside,openany]{report} %\documentclass[pdftex,a4paper,12pt,twoside,openany,notitlepage]{report} % <--- switch to this to see difference \usepackage{lipsum} \begin{document} \linespread{1.6} % interline 2.0 \begin{abstract} \lipsum[1-3] \end{abstract} \chapter{CH} \lipsum[1-8] \end{document} How to achieve same look of abstract with `notitlepage` as without that option, wile preserving same formatting of rest of document ?
\renewenvironment{abstract} {\newpage\thispagestyle{plain} \null\vfil \begin{center}% \bfseries \abstractname \end{center}} {\par\vfil\null\cleardoublepage}
stackexchange-tex
{ "answer_score": 2, "question_score": 3, "tags": "formatting, titles, abstract" }
Umbraco - SQL Server or SQLCE4? Performance and upgrade considerations I am creating a customer site with the Umbraco CMS. the cheapest database option is to go with SQLCE4, as the latest version supports this. What concerns me about using SQLCE4 is the performance.... how many concurrent users before it starts to top out? if i did need to upgrade to full SQL Server in the future would i be able to port all of my data over? is the schema exactly the same for the sql server version and SQLCE4 version? because SQLCE does not support stored procedures or views.
If you are worried about having an upgrade path, you could consider SQL Server Express (which is also free), and the upgrade (if you ever need it) would be as painless as shelling out some bucks. I am using SQL Express 2008 on one of my Umbraco installs, and the performance is more than fine. (Though this is not a high traffic site). CE I beleive uses a SDF file format that is not compatible, the MDF file that expressSQL uses is the same one that the bigger versions of SQL server use. The upgrade would be a nobrainer. I'd say the schema is the same - umbraco has no views or stored procedures by default.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "sql server, sql server ce, umbraco" }
Finding generalized eigenbasis 1. For a complex square matrix $M$, a maximal set of linearly independent eigenvectors for an eigenvalue $\lambda$ is determined by solving $$ (M - \lambda I) x = 0. $$ for a basis in the solution subspace directly as a homogeneous linear system. 2. For a complex square matrix $M$, a generalized eigenvector for an eigenvalue $\lambda$ with algebraic multiplicity $c$ is defined as a vector $u$ s.t. $$ (M - \lambda I)^c u = 0. $$ I wonder if a generalized eigenbasis in Jordan decomposition is also determined by finding a basis in the solution subspace of $(M - \lambda I)^c u = 0$ directly in the same way as for an eigenbasis? Or it is more difficult to solve directly as a homogeneous linear system, and some tricks are helpful? Thanks!
Look at the matrix $$M=\pmatrix{1&1\cr0&1\cr}$$ Taking $\lambda=1$, $c=2$, Then $(M-\lambda I)^c$ is the zero matrix, so any two linearly independent vectors will do as a basis for the solution space of $(M-\lambda I)^cu=0$. But that's not what you want: first, you want as many linearly independent eigenvectors as you can find, then you can go hunting for generalized eigenvectors.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "matrices" }
How to broadcast a non standard transaction? How can i broadcast a non standard transaction? I tried using the core client, coinb, blockchain.info, luke-jr's test release as well as pushing it to eligius but it doesn't work.
You generally don't - there are likely to few nodes on the network that will forward it far enough to reach a miner. What you can do is find a miner yourself, contact them, and see what mechanism they offer to include your transaction (perhaps for a fee). In this case, the transaction will not propagate through the network directly; only as part of the block after mining.
stackexchange-bitcoin
{ "answer_score": 2, "question_score": 1, "tags": "transactions" }
Regular Expression, bash I need to read an ASCII file `coordinates.ascii` that have one line only: -I0.00130000258937/0.000899999864241 inside a bash script, and attribute `0.00130000258937` to the variable `x_inc` and `0.000899999864241` to `y_inc`. guess that the regexp for `x_inc` is: (\d.\d+)(?=/) but I do not know the regexp for y_inc and also the sed or grep commands/syntax to implement the regexp inside the bash .. x_inc=$(sed -n '(\d.\d+)(?=/)' coordinates.ascii ) # does not work!!!
Just with bash: $ IFS="I/" read _ x_inc y_inc < coordinates.ascii $ echo $x_inc 0.00130000258937 $ echo $y_inc 0.000899999864241
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "regex, bash, sed" }
Passing map name as argument in nested each loop Is it possible to pass map names as argument in nested each loop? For example, we have the following: $colorsets: () !default; $colorsets: map-merge( ( "greys": "get-gray", "reds": "get-red" ), $colorsets ); @each $colorset, $value in $colorsets { /* #{$colorset} #{$value} */ @each $color, $value in $colorset { /* #{$color} #{$value} */ // do some stuff } } and where `greys` and `reds` are also maps with some colors. My goal here is to collect the map name from the first loop and pass it as argument to the second loop. The problem is that compiler takes the variable as text, not as a map!
Problem solved. The solution was to put map varables as values in main `$colorsets` map, think like an array of maps: $colorsets: () !default; $colorsets: map-merge( ( 0: $greys, 1: $reds // and so on ), $colorsets ); Obviously, this should come after all defined color maps. And, the nested loops come like this: @each $index, $colorset in $colorsets { /* #{$index} */ @each $color-name, $color in $colorset { /* #{$color-name} #{$color} */ // do stuff here } } Hope someone will find this useful.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "sass" }
I get an error, if i want to publish my app to the apple store i get this error: Note that the Bundle ID cannot be changed if the first version of your app has been approved or if you have enabled Game Center or the iAd Network. Can someone help me?
You can not change the Bundle ID once the app is already approved. Meaning if you are trying to submit an update to an app that's Bundle ID is foo.foo.com you can not submit the new update with a different Bundle ID (ex:foo2.foo.com). They must be identical in order to establish that it is the same application. Bundle ID's are also case sensitive so make sure they match 100%.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ios, app store" }
Variable accessible to all instances of a class Let's say I have a lookup table which I'd like to make accessible to all instances of `Foo`. Should I make the table `private static`? If not, what should I do? Basically I want a way to save just one copy of the table (so it doesn't consume extra memory for each instance of `Foo`) and have it available privately to all instances of `Foo`.
That sounds like private static to me.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c++, class" }
Use implicit differentiation to find all points on the curve with a given slope Consider the curve $R^2$ given by the equation: $x^2 - y^2 = 1$ a/ Use the method of implicit differentiation to find all points on the curve at which that tangent has a slope of $\frac53$ b/ Explain why there are no points on the curve at which the tangent is horizontal. So far, I have found the implicit differentiation, which is $\frac{dy}{dx} = \frac{x}y$. Can you guys help me what should I do next. Any help is appreaciate
HINT: 1. Solve $\frac{dy}{dx} =\frac{x}{y}=\pm \frac{x}{\sqrt{x^2-1}}= \frac {5}{3}$ 2. If slope is 0, then $y^2=-1$, is it possible?
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "calculus" }
Android UX - how to show the user that a list item is clickable? I have a list of things in an Android activity. Do I need to add something to let the user know that they will get more detail by clicking an item? (It opens a new activity.) I could add a button to every item, but it looks ugly.
1) Showcaseview will be the best way 2) or use Card view , this way the user will know for sure that the item is clickable and also in some cases, expandable. (Similar to Call logs in Google Phones)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "android, user experience" }
How can i find the closest image using input type hidden in jquery? How can i find the closest image using input type hidden. i want to find `<div class="wrap_col td4 participantstatus">` and change the image how can i find it using the closest input type hidden? this is my code: $("input[value='closest_img']").find(".participantstatus img").attr("src","/pc/images/mute.png"); this is my code: <div class="wrap participantlist wrap_body"> <div class="wrap_col td1"> <input type="hidden" name="hiddenuid" value="closest_img"> <div class="wrap_col td2">1</div> <div class="wrap_col td3">2</div> <div class="wrap_col td4 participantstatus"><img style="vertical-align: middle" src="/pc/images/dissable.png"></div> </div>
`.participantstatus` is not a descendants of `input` element, find it using `.sibling()` and after that using `.find()` as `img` is a child of `.participantstatus` element: $("input[value='closest_img']").siblings(".participantstatus").find('img').attr("src","/pc/images/mute.png"); If `.participantstatus` located next to input element, you can find it using `.nextAll()` after all like so: $("input[value='closest_img']").nextAll(".participantstatus").find('img').attr("src","/pc/images/mute.png"); **DEMO**
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "javascript, jquery, html" }
Matrix differential of $AA^T $ I need to find the first and second partial derivative of $\dfrac{\partial \|AA^T\|_{F}^2}{\partial A_i}$ where $A$ is a $n$ by $n$ matrix and $A_i$ denote the $\textit{i}^{th}$ row of matrix $A$.$\|A\|_{F}$ means the F norm of matirx A. I am always confused about how to transform the expression into elements sum and back to matrix form.
Let $f:A\rightarrow \|AA^T\|_{F}^2=tr((AA^T)^2)=\sum_{j,k}((AA^T)_{j,k})^2=\sum_{j,k}(A_jA_k^T)^2$. Thus $\dfrac{\partial f}{\partial A_i}= \dfrac{\partial g}{\partial A_i}$ where $g=(A_i{A_i}^T)^2+2\sum_{j\not= i}(A_i{A_j}^T)^2$. The derivative is $\dfrac{\partial f}{\partial A_i}:h\in M_{1,n}\rightarrow 2(A_iA_i^T)(2hA_i^T)+2\sum_{j\not= i}2(A_iA_j^T)(hA_j^T)=4\sum_j (A_iA_j^T)(hA_j^T)$ and the gradient is $\nabla_{A_i} (f)=4\sum_j (A_iA_j^T)A_j$. The second derivative (Hessian) is: $\dfrac{\partial^2 f}{\partial A_i^2}:(h,k)\in (M_{1,n})^2\rightarrow 4(2(kA_i^T)(hA_i^T)+(A_iA_i^T)(hk^T)+\sum_{j\not= i}(kA_j^T)(hA_j^T)$. The associated symmetric matrix $\nabla^2_{A_i}(f)$ is defined by $h\nabla^2_{A_i}(f)k^T=\dfrac{\partial^2 f}{\partial A_i^2}(h,k)$; then $\nabla^2_{A_i}(f)=4(2A_i^TA_i+(A_iA_i^T)I+\sum_{j\not= i}A_j^TA_j)$ that is $\nabla^2_{A_i}(f)=4(\sum_jA_j^TA_j+A_i^TA_i+||A_i||^2I)$.
stackexchange-math
{ "answer_score": 0, "question_score": 1, "tags": "matrices, derivatives" }
Is it possible to partition 2D data into bins such that each bin contains the same number of samples? I am trying to sort data following a bivariate distribution into a numpy histogramdd, where each bin should contain the same number of data points (to the nearest whole sample). I expect that some kind of quantile-approach is required, and have tried `scipy.stats.mstats.mquantiles`, which according to the documentation takes up to 2D data. However, it seems to take the dimensions independently, splitting each dimension into to equal marginal probabilities, which doesn't achieve the desired result of equal-probability bins in 2D. Is there a built-in way in scipy/numpy or another package to achieve this (in 2D or higher)? If not, are there algorithms designed to achieve this which I can implement myself directly?
You obviously can't do this if you want the bins to be separated at the same $x_i$ and $y_i$ values. This is easy to see if you want to have, say, 4 bins and have 10 data points at $(0,0)$ and 10 points at $(1,1)$. But you can use a $kd$ tree data structure in which you recursively subdivide each bin so that it contains the same number of points.
stackexchange-scicomp
{ "answer_score": 1, "question_score": 0, "tags": "python, scipy, numpy" }
Complete renormalization in $\phi^4$-theory? In the one-loop renormalization of $\phi^4$-theory, only 1PI vertex functions $\Gamma^{(2)}$ and $\Gamma^{(4)}$ are regularized and renormalized. But they do not exhaust all the irreducible connected diagrams at one loop. One can have a diagram, for example, with one-loop, 3 vertices and 6 external lines, or with one-loop, 4 vertices and 8 external lines and so on. What about these diagrams? They respectively correspond to $\Gamma^{(6)}$ and $\Gamma^{(8)}$. What about these 1PI diagrams with one-loop? Shouldn't they require renormalization as well? In fact these diagrams contribute to the effective potential. **EDIT :** arxiv.org/abs/hep-ph/9901312 This might be an useful reference. Please look at the one-loop diagrams in the calculation of the effective potential in $ϕ^4$-theory.
The naive power counting approach for a $d$-dimensional theory with coupling constant $\lambda$ tells us that the amplitude of diagrams with $E$ external lines and $V$ vertices behaves with the cutoff $\Lambda$ as $\propto\Lambda^D$ with $$ D = d - [\lambda]V - \frac{d-2}{2}E$$ where $[\dot{}]$ is the mass dimension. Since $\phi^4$ in four dimension has a dimensionless coupling, $$ D = 4-E $$ and since only diagrams with $D \geq 0$ need renormalization, the only diagrams needing it in 4D $\phi^4$ are those with $E \leq 4$. All diagrams with an odd number of external lines vanish due to the $\phi\mapsto-\phi$ symmetry, so what's left to renormalize is $E=0,2,4$, which are the vacuum energy, the propagator, and the 4-vertex, respectively. The diagrams you ask about exist, but have $D < 0$, and do not need to be renormalized, since they are not diverging when we take the cutoff to infinity.
stackexchange-physics
{ "answer_score": 6, "question_score": 3, "tags": "quantum field theory, renormalization" }
Forwarding a entire Outlook inbox to a different account? We have a senior employee who is leaving. My boss showed me what our previous IT employee set up for him, it looked like folders on his Outlook, and underneath was the full inbox/draft/spam etc of that person's outlook. Now they want the same thing for this employee who is leaving. We are setup with an active directory if that matters. How can I achieve this for leaving employees email to forward everything to my bosses email (inside of a folder or folder like object)? I'm wondering and thinking too perhaps my boss was just granted full permissions to view these mailboxes - if that's the case and the easy way to do things, how can I set that up?
You could create a shared mailbox with the same address, and add it to your boss' Outlook client. This will allow you to deactivate the (soon to be) former employee's account after they leave, but not give your boss access to historical contents of their mailbox. Or, you could add delegate permissions for your boss to the user's mailbox, and then add it to your boss' Outlook client. This will give your box access to the historical contents of the mailbox, but you will need to keep the account active to keep receiving emails at that address.
stackexchange-superuser
{ "answer_score": 0, "question_score": 0, "tags": "email, microsoft outlook, microsoft outlook 2019" }
To remove focuse on editText I need a help that to remove focuses on edit text in android. i used this android:focusable="false" but it disables the edit text. Please help me, and if possible post the code
then use this code it works `android:focusable="true" android:focusableInTouchMode="true"`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "android, android edittext, autofocus" }
Flutter Bloc, what is the "..add" create: (_) { return NewCarBloc(newCarRepository: NewCarRepository()) ..add(NewCarFormLoaded()); } Why it has 2 dots here? Why not like below? I tried in various ways, but nothing else works. create: (_) { return NewCarBloc(newCarRepository: NewCarRepository()) .add(NewCarFormLoaded()); }
The double dot operator let you call multiple functions on the same object in one instruction. It's named cascade operator. For more about cascade operator: < Here your first function is to create the object and the second is "add" function. If you don't want to use cascade operator you can do this like so: create: (_) { NewCarBloc newCarBloc = NewCarBloc(newCarRepository: NewCarRepository()); return newCarBlock.add(NewCarFormLoaded()); }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "flutter, bloc" }
Is collectionview the new way instead of listview? I need to ask a general question. I read that `CollectionView` is more flexible and has better performance than `ListiView`. So is `CollectionView` the new way to go? Should I replace all my `ListiView` to `CollectionView`?
Yes. From the docs > CollectionView is a view for presenting lists of data using different layout specifications. It aims to provide a more flexible, and performant alternative to ListView. you do not necessarily need to replace existing `ListView`, but you should generally choose `CollectionView` for any new development
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "xamarin, xamarin.forms" }
RxJava Completable.andThen never triggers the second Completable I'm trying to chain two reactive calls which return `Completable` using retrofit on android: val userRequest = ... val languageRequest = ... return userService.updateUser(userRequest) .andThen { userService.updateMessagingUserLanguages(user.id, languageRequest) } .doOnComplete { userRepository.updateUser(user) } which are defined as follow: @PUT("$BASE_USER_URL") fun updateUser(@Body user: UserRequest): Completable @PUT("$BASE_URL/{userId}/languages") fun updateMessagingUserLanguages(@Path("userId") userId: Long, @Body request: MessagingLanguageDTO): Completable The first `Completable` succeed and returns a response with a 200 status. However, the second call is never triggered (it never appears in my log and does not pass my breakpoint). What am I missing here?
Try: andThen(userService.updateMessagingUserLanguages(user.id, languageRequest)) IOW, replace the lambda expression as a parameter with the actual `Completable` that you want to add to the chain.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "android, kotlin, retrofit, rx java, rx java completable" }
Request to https://bower.herokuapp.com/packages/angular-messages failed with 410 I am getting this error suddenly today. > Request to < failed with 410 What is the problem?
I also got this error just today. < may shed some light on this.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "bower" }
Gmpy sqrt precision I want to know why does this code in Python print gmpy.sqrt(2009) give the result 44, and not 44.82186966... like i want it to do? How can i set the function to show me the decimal numbers. Thank you in advance.
Bluntly put, because it was defined that way. There is no way to set that option. Edit: @casevh is correct: `gmpy2.sqrt()` returns what you want.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "python, sqrt" }
How do we know whether certain mathematical theorems are circular? There are countless mathematical theorems and lemmata, some of which, obviously, depend on others. My question is: how do we know that, say, Theorem $A_1$- which uses a result proved in Theorem $A_2$ which uses a result proved in ... which uses a result proved in Theorem $A_n$ which, in fact, relies on the fact that Theorem $A_1$ is true - doesn't make the proof of Theorem $A_1$ circular? Essentially, what I'm saying is that, since there's no comprehensive list of all mathematical theorems, lemmata and corollaries (and what statements they rely on), how can we assume that no two theorems will be circular (not directly- but down a long chain of theorems)? If I'm not articulating myself properly, please ask me to elaborate. Thanks
The shortest answer is this: because theorem $A$ can only be proven using theorem $B$ if theorem $B$ is already proven. This way, your circular chain can never happen, since $B$ can only be proven using already proven theorems, meaning $A$ cannot be used to prove neither $B$ nor any theorems used in the proof of $B$ (or any theorem used in the proof of a theorem used in the proof of a theorem used in the.... .... used in the proof of $B$)
stackexchange-math
{ "answer_score": 16, "question_score": 14, "tags": "soft question, proof writing" }
how to send value to javascript from input field i need to send the input fields "data-validation" to javascript function. form is <input type="text" name="fname" id="fname" data-validation="length" onchange="validate(this);" required /> Javascript is function validate(value) { var value=value.value; var validation=value.data-validation; alert(value +" "+ validation); return false; } i can't get the value of data-validation in javascript.
please review this code `getAttribute()` is used to get attribute of element function validate(ele) { var value=ele.value; var validation=ele.getAttribute("data-validation") alert(value +" "+ validation); return false; } Demo here <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "javascript, html, validation" }
Finding big cacti between Phoenix, Las Vegas, and Los Angeles I was wondering if there are any huge cacti like these: ![enter image description here]( (I believe they're called Saguaro or something, but I guess similar cacti are fine too) that one can see (in the winter) somewhere along the following route? San Diego - Palm Springs - Phoenix - Sedona - Tusayan - Page - Panguitch - Springdale - Las Vegas - Badwater - Los Angeles I'm aware about Saguaro National Park, but it's too far from Phoenix.
Saguaro cactus are native specifically to the Sonoran desert. This photo outlines where the Sonoran desert is located. ![enter image description here]( According to this TripAdvisor thread, you will not see them 20 minutes north of Phoenix. They seem to stop growing above 3,000 feet above sea level. You should be able to see them south of Sedona, along I-17 interstate highway.
stackexchange-travel
{ "answer_score": 34, "question_score": 35, "tags": "where on earth, california, utah, arizona, nevada" }
Array of class objects inside another class I want to make var1 the array of instances of Class1. This array must be defined in Class2. How to do this correctly? class Class1 { public $values = array(); } class Class2 { public $var1 = array(); public $var1_ptr; public function setPtr(Class1 $var1) { $this->var1_ptr = $var1; } } $cl2 = new Class2(); $cl2->sePtr($cl2->$var1[0]); // Here I want to access the first array's object of Class1.
You can store objects as array elements, and access them no differently as if they were their own variables. The same applies to storing them as a property of an object. class Class1 { public $values = array(); } class Class2 { public $var1=array(); } $cl2=new Class2(); $cl2->var1[]=new Class1; //Do this as many times as you want to store Class1 objects To retrieve the $j-th value of the $i-th object stored in the array: $retrieved_object=$cl2->var1[$i]->values[$j];
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "php, class" }
Does the last layer of a classifier neural network use both sigmoid and softmax? Hidden layers of a classifier network use sigmoid or another activation function to introduce non-linearity and normalize the data, but does the last layer use sigmoid in conjunction with softmax? I have a feeling it doesn't matter and the network will train either way -- but should a softmax layer alone be used? or should the sigmoid function be applied first?
In general, there's no point in additional sigmoid activation just before the softmax output layer. Since the sigmoid function is a partial case of softmax, it will just squash the values into `[0, 1]` interval two times in a row, which would give be a nearly uniform output distribution. Of course, you can propagate through this, but it'll be much less efficient. By the way, if you chose not to use ReLu, tanh is by all means a better activation function than sigmoid.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 4, "tags": "neural network, classification, softmax, sigmoid" }
using file config message in javascript I would use a message file to various warnings that are given to the user, use a file msg.js var mensaje = { DATOS_VACIOS : "Verifique los campos ...." } call alert(mensaje.DATOS_VACIOS); I wonder if anyone knows a way to do better, or that involves having this object in memory, if it can degrade performance. Thank you.
Of course, it depends on the client, but unless you have a huge list of messages (1MB or more), loading msg.js into memory won't affect performance. It is better to do it the way you already are because the messages will be available to the user virtually instantly. If you want to hold less in memory, you could split up msg.js into smaller files and load them asynchronously, destroying the old object each time. Doing so would make the browser store less, but it would translate into much slower response time. Not worth it unless your msg.js is huge.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "javascript" }
Is it possible to optimize internet connection for video streaming > **Possible Duplicate:** > How can I throttle the bandwidth consumed by Windows Automatic Updates? I'm always watching anime online. I want to know if it is possible to allot more bandwidth on online streaming than in downloading. Because I've notice in ubuntu that it prioritize the downloads. And XP prioritize the browsing. Because I get higher download rates in ubuntu than in xp. Is there any software that I can use in order to modify what the os prioritizes.
**Traffic Shaper XP** is a free bandwidth limiter for Windows 2000, XP and 2003 Server. It combines high performance traffic shaping with the ease of use and flexibility to keep your network free of congestion.
stackexchange-superuser
{ "answer_score": 0, "question_score": 2, "tags": "windows xp, ubuntu, download, speed" }
How Are Databases Managed With Docker? I understand what Docker is and how you can package your application to run instantly anywhere. What I don't understand is: what do you do about the Database? Do you make another Docker image/container just for the DB? This seems wrong because if that container disappears, so does your data, I guess forever. Or do you package your DB in the same container as your application? In this case, scalability is gone. So how is it done? Thank you
Volumes are the solution. Adding a volume to your database will make the data persistent as long as that volume exists, though there are situations where this doesn't quite work out of the box, so remember to do your backups. Your database will, in most scenarios, be separated from your application as far as the non development deployments go, so it will have its own scalability and backup policy, so your application scalability should not be tied to your database.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "database, docker, docker compose, dockerfile" }
Equicontinuity-like property of a convex compact set Let $X$ be a Tychonoff topological space and let $x\in X$. Let $B\subset C(X)$ be convex and compact in the topology of pointwise convergence, and such that $f(x)=1$, for every $f\in B$. > Is there an open neighborhood $U$ of $x$ such that $f(y)\ne 0$, for every $f\in B$ and $y\in U$?
Since $C(X)$ is not complete one cannot take the closed convex hull of the example in the comment. But what about this: Let $g_n=1-f_n$ with $f_n$ as in my comment. Since the $g_n$ are bounded by one, the linear map $T:\ell^1\to C(X)$, $\lambda\mapsto \sum\limits_{n=1}^\infty \lambda_ng_n$ is well defined. We would like to have $T$ continuous as a map $(\ell^1,\sigma(\ell^1,c_0)) \to (C(X),pw)$ (where $c_0$ is the space of all null sequences so that $\ell^1$ is its dual). This follows from the pointwise convergence to $0$ of all sequences $(g_n(x))_{n\in\mathbb N}$. The unit ball $K$ of $\ell^1$ is weak$^*$ compact à la Alaoglu and hence $T(K)$ is compact and convex in $(C(X),pw)$. Then $B=\\{1-g: g\in T(K)\\}$ is convex and compact in the pointwise topology, it satisfies $f(0)=1$ for all $f\in B$ (because $g_n(0)=0$ for all $n$), and it contains all $f_n=1-g_n=1-T(e_n)$ with the standard unit vectors $e_n$ of $\ell^1$.
stackexchange-mathoverflow_net_7z
{ "answer_score": 1, "question_score": 2, "tags": "fa.functional analysis, gn.general topology, banach spaces, topological vector spaces" }
Trying to find count of missed targets between 2 sheets I am trying to work through this problem where I have 2 sheets (seen here as 2 sections for simplicity) and I am trying to count how many shipments from sheet 1 were below the SLA target in sheet 2. The formula I tried was `IF(A21=INDEX(A2:A11,MATCH(A21,A2:A11,0),COUNTIF(C2:C11, ">="&C21))` I have tried multiple iterations of these parameters and have it returning some very inconsistent and totally wrong results. The output I am expecting is 0,0,1,3,0,0 I know this is going to probably be some kind of boolean algebra but I honestly do not understand how that system works. I have tried looking it up but I dont think i am doing it right. Sample Data
You could use a simple boolean multiplier like this: =SUM((A21=$A$2:$A$11)*($C$2:$C$11<C21)) This checks if the ID matches A21 and then multiplies these TRUE/FALSE results times a second boolean array that checks if the shipped amounts (C2:C11) are less than the SLA standard C21. _NB: If it is really less than or equal, then use`=SUM((A21=$A$2:$A$11)*($C$2:$C$11<=C21))`._ This generates a series of 1's for each value that matches the conditions and then SUM adds those one's up. Using your example for ID Key 4/Item Name D, you would get: SUM({FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE,FALSE,FALSE} * {TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE}) This gets coerced into: SUM({0,0,0,0,0,1,1,1,0,0})
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "excel, boolean, algebra" }
how to sort data based on two different (text and number) conditions in sql server? I have an `Emp` table, which has following data. Eno Ename Location Deptid ------------------------------- 1 Alex Delhi 10 2 John Mumbai 10 ............................. Like this I have 1000 records, I need to sort them by `Deptid` column and `Location`. The result after sort should be like this (If I sort by `deptid` and `location=Mumbai`): If a deptid=10 has 300 records (of which 150-Delhi, 100-Mumbai, 50-chennai), then I should get all the records of mumbai (only with deptid=10) first, then other locations of same deptid and then records from other deptid.
SELECT Eno, Ename, Location, Deptid FROM employee WHERE Deptid = 10 AND Location = 'Mumbai' UNION ALL SELECT Eno, Ename, Location, Deptid FROM employee WHERE Deptid = 10 AND Location <> 'Mumbai' UNION ALL SELECT Eno, Ename, Location, Deptid FROM employee WHERE Deptid <> 10 An Order by will probably screw it up, unless you add another column like SELECT Eno, Ename, Location, Deptid FROM ( SELECT Eno, Ename, Location, Deptid, 1 OrderBy FROM employee WHERE Deptid = 10 AND Location = 'Mumbai' UNION ALL SELECT Eno, Ename, Location, Deptid, 2 OrderBy FROM employee WHERE Deptid = 10 AND Location <> 'Mumbai' UNION ALL SELECT Eno, Ename, Location, Deptid, 3 OrderBy FROM employee WHERE Deptid <> 10) a ORDER BY OrderBy, Deptid, Location
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "sql, sql server, sorting, select, sql order by" }
Axios asynchronous get requests come back in the wrong order I'm currently trying to use a .each and then making my request inside of it but then when I console.log it, it's not in order. I'm super new to Axios and cheerio and coding in general so I was wondering how I could make the call output come back in order. const axios = require('axios') const cheerio = require('cheerio') axios.get(' .then((response) => { const $ = cheerio.load(response.data) //console.log($('option')) $('option').each((index, element) => { console.log(index) axios.get(' => { const z = cheerio.load(response.data) var x = z('img#img')[0].attribs.src console.log(x, index) }) }); })
The point of asynchronous functions is that they are done when they are done. If you need to preserve order, then wrap the promises return by axios in an array and pass it to `Promise.all`. const promises = [ axios(...), axios(...), axios(...), ]; Promise.all(promises).then(ordered_array => { ordered_array.forEach( result => { ... } ); });
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "javascript" }
Set JsonSerializerSettings Per Response? I have an MVC 4 Web API. Usually I want responses to return all properties, but there is one place I only want to return only non-null values. I can setup either behavior by setting the JsonSerializerSettings of the `Formatters.JsonFormatter.SerializerSettings.NullValueHandling` of the `GlobalConfiguration.Configuration` instance in the global file but I want to use both depending on the response. Is there an easy way to configure the request scope from within an API controller action?
By changing your controller action to return HttpResponseMessage you can get more control over how your content is returned for a particular action. e.g. public HttpResponseMessage Get() { var foo = new Foo(); var objectContent = new ObjectContent<Foo>(foo, new JsonFormatter() {SerializerSettings.NullValueHandling = ???}) return new HttpResponseMessage() {Content = objectContent}; }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "asp.net mvc, json, asp.net web api" }
Have aggregate function group results in one row I have a table that has the following columns: * debit * credit * payment_method * class Now I will perform this query: select sum(debit - credit), payment_method, class from my_table group by payment_method, class And since I have various payment methods and various classes, I will have several rows of the result set. Now I want to be able to aggregate this result and have the output grouped by class only, for example for a certain class `001` I want to have: `payment_method1, sumofpayment_method1, payment_method2, sumofpayment_method2, payment_method3, sumofpayment_method3` in one row. Is it possible in Postgres 9.1? Update: The table definition is as follows:- * debit numeric(10,2) * credit numeric(10,2) * payment_method varchar(20) * class varchar(25)
You are looking for the `crosstab()` function provided by the additional module tablefunc. Then your function could look like this: SELECT * FROM crosstab( 'SELECT class, payment_method, sum(debit - credit) AS saldo FROM tbl GROUP BY 1,2 ORDER BY 1,2' ,$$VALUES ('payment_method1'::text), ('sumofpayment_method1') , ('payment_method2'), ('sumofpayment_method2') , ('payment_method3'), ('sumofpayment_method3')$$ ) AS ct (class text , payment_method1 numeric, sumofpayment_method1 numeric , payment_method2 numeric, sumofpayment_method2 numeric , payment_method3 numeric, sumofpayment_method3 numeric); I am using all 6 "types" you mentioned. Well, I see that only half of them are actually intended as type. Either way, substitute your actual types. More details, links and explanations in this related answer on SO.
stackexchange-dba
{ "answer_score": 5, "question_score": 1, "tags": "postgresql, postgresql 9.1" }
How to display relational tables At the moment I am creating a Membership Site. When a member login to the site: Account Number: Password: Automatically the account of the member will display. I am currently on this but I have a problem. I am trying to connect to 2 tables on the same instance of MySQL from 1 PHP script. This table is relational in one database. Any other ideas?
If the tables are in one and the same database then simply use JOIN operator. If the tables are in different databases then you can do: SELECT t1.fieldname1, t2.fieldname2 FROM `database1`.`table1` t1 JOIN `database2`.`table2` t2 on (...) WHERE ... Of course you have to had corresponding access rights, for the databases and the tables.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "php, mysql" }
How to get an id for the dates Table1 id dates 01 23/02/2011 02 24/04/2011 03 26/08/2011 ... I want to select the id from table1, if dates is exceeded 6 month. Expected Output from tabl1 id dates 01 23/02/2011 'Dates is older than 6 month 02 24/04/2011 'Dates is older than 6 month How to make a query Need query Help
select id, dates from Table1 where dates < dateadd(month, -6, getdate())
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 4, "tags": "sql, sql server, sql server 2000" }
How to align text to center with custom font-family applied to Textbox in winRT XAML app I am working on winRT C# app. I have Textbox with custom font-family. Due to custom font-family my text in Textbox is aligned to top of Textbox. I tried to set VerticalContentAlignment to "center" but it still not working.
I'm not so sure it's because of your font, and more likely expected behavior of the `TextBox`. I would take a look at the control template for your `TextBox` and check your `Setter`'s and `ContentPresenter` to see if there isn't a property set to make it that way. Otherwise I think you can touch it via something like; <TextBox> <TextBox.Resources> <Style TargetType="TextBlock"> <Setter Property="VerticalAlignment" Value="Center"/> </Style> </TextBox.Resources> </TextBox>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, xaml, winrt xaml" }
How can I stop drag slider I have a draggable slider, and he moves ok, but he incorrectly stops, at the beginning and at the end of the bar. function drag (handle, event) { var diffX = event.clientX - handle.offsetLeft; document.addEventListener('mousemove', startDrag, false); document.addEventListener('mouseup', stopDrag, false); // START function startDrag (e) { if (handle.offsetLeft >= 0 && handle.offsetLeft <= 280) { handle.style.left = (e.clientX - diffX) + "px"; } e.preventDefault(); } // STOP function stopDrag() { document.removeEventListener('mousemove', startDrag, false); document.removeEventListener('mouseup', stopDrag, false); } } Here is the link to full code – <
the handle is at -2px when fully scrolled left. Your code states `if (>=0)`. Try if (handle.offsetLeft < 0) { handle.style.left = (0) + "px"; }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, slider, draggable" }
Reddit image retrieval from url An url was postet at reddit: < But reddit was not able to retrieve an image from the website and is showing a default image. How do you tell websites like reddit which image to show there? And how can you set this image in a nuxt vue file?
Reddit (and most of the other major sites that do this, like Facebook and Twitter) uses the `og:url` Open Graph tag, if present. Full details of Open Graph can be found at < but fundamentally: <meta property="og:image" content=" /> If an `og:image` is not present, most sites will try to guess which image on the page is the right one. They'll often get it wrong.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "vue.js, nuxt.js, reddit" }
print something else below the renderDataTable in shiny, R I've tried to print some other strings below or above the table in a tab page (via tabPanel, renderDataTable and dataTableOutput) in shiny, R. How to implement it? Thank you.
Suppose you have: tabPanel("Table", dataTableOutput("show_data")) Change to: tabPanel("Table", dataTableOutput("show_data"), HTML("My exta text")) Or is you need more control you could use: tabPanel("Table", dataTableOutput("show_data"), verbatimTextOutput("extra_text")) where extra_text is a renderText function
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "r, shiny" }
scrollView not scrolling swift I have a scroll view which is not scrolling. Googling seems to indicate that it may be to do with my constraints? My constraints are as follows: Trailing space to superview = -16 Leading space to superview = -16 Top space to top layout guide = 0 Bottom space to bottom layout guide = -13 I am printing out the scrollview contentSize in the viewDidLayoutSubViews and it is printing out the same value each time i.e: scrollview is (375.0, 356.5) Any idea what the issue may be
Check the bottom constraints of the content view (container inside `ScrollView`) in your case it's the `UILabel` Apple Technical Note TN2154: UIScrollView And Autolayout > To size the scroll view’s frame with Auto Layout, constraints must either be explicit regarding the width and height of the scroll view, or the edges of the scroll view must be tied to views outside of its subtree. Useful article : Using UIScrollView with Auto Layout in iOS
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "ios, swift, uiscrollview, contentsize" }
CHMOD To Prevent Deletion Of File Directory I have some hosting on a Linux server and I have a few folders that I don't ever want to delete. There are sub folders within these that I do want to delete. How do I set the CHMOD permissions on the folders I don't want to delete? Of course, when I say "I don't ever want to delete" - what I mean is that the end customer shouldn't delete them by accident, via FTP or in a PHP script etc. As an example of directory structure... MainFolder/SubFolder MainFolder/Another I don't want "MainFolder" to be accidentally deleted, but I'm happy for "SubFolder" and "Another" to be removed!
Deleting a file/directory changes the contents of the parent directory, hence, if you don't want `MainFolder` to be deleted, you want to ensure that the intended user does not have write access to the parent dir of `MainFolder`. Assuming this structure: `/some/dir/ParentDir/MainFolder/SubFolder` You'll want to run something like this to prevent deletion (for all users): `chmod a-w /some/dir/ParentDir` Of course, this is not an ideal situation as making it non-writeable means than users cannot add additional files/directories to `/some/dir/ParentDir` Would a sticky bit fit your purpose better? setting the sticky bit on the parent directory will only allow deletion by the directory owner. `chmod +t /some/dir/ParentDir` Look at the usage section on < for more information about Sticky bits.
stackexchange-serverfault
{ "answer_score": 11, "question_score": 4, "tags": "linux, permissions, hosting, chmod" }
Installing Heroku's Taps gem I'm trying to use Heroku's Taps gem to get my database from their server. When I run $heroku db:pull it says I need to install the Taps gem using the command: sudo gem install taps I run this command, and as expected, Taps says it has installed ("1 gem installed"). I'm able to run the Gem update taps command without an error after installing. However, > $gem list does not show Taps as installed, and I cannot see it in the gem folder at /Users/username/.rvm/gems/ree-1.8.7-2010.02@timeline Needless to say, I cannot run the Heroku db:pull command because of this. I am running bundlr and RVM, I don't know if these are relevant. I'm sure I'm doing something simple wrong...
Using `sudo gem install taps` probably installs the gem with root permissions, and thus you can't see it as your normal user when you try to `gem list`. Have you tried installing the gem without sudo? or if you really want to find it, try `sudo gem list`. I would suggest not installing gems with sudo though, the point of using rvm is to always have your gems bundled in a place you can access (without root) and separated conveniently with rubies/gemsets.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 4, "tags": "ruby on rails, rubygems, heroku" }
String.getBytes() returns different values for multiple execution? public static void main(String[] args) { try { String name = "i love my country"; byte[] sigToVerify = name.getBytes(); System.out.println("file data:" + sigToVerify); String name1 = "data"; byte[] sigToVerify1 = name1.getBytes(); System.out.println("file data1:" + sigToVerify1); } } I am trying to execute the above program but `getBytes()` gives me different values for the same `String`. Is there any way to get the same byte while executing multiple times for a given string?
System.out.println("file data:" + sigToVerify); Here you are not printing the value of a `String`. As owlstead pointed out correctly in the comments, the Object.toString()) method will be invoked on the byte array `sigToVerify`. Leading to an output of this format: getClass().getName() + '@' + Integer.toHexString(hashCode()) If you want to print each element in the array you have to loop through it. byte[] bytes = "i love my country".getBytes(); for(byte b : bytes) { System.out.println("byte = " + b); } Or even simpler, use the `Arrays.toString()`) method: System.out.println(Arrays.toString(bytes));
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 2, "tags": "java, string" }
How to truncate a SHA1 hashed string into a 32 bit string I want to create a 32 bit string that I can use as encryption key. This string/key should be derived from a plain text string, e.g.: 'I am a string' My approach would first be to hash it: hashed_string = Digest::SHA1.hexdigest('I am a string') # => 'bd82fb0e81ee9f15f5929e0564093bc9f8015f1d' And then to use just the first 32 characters: hashed_string[0..31] # => 'bd82fb0e81ee9f15f5929e0564093bc9' However, I feel there must be a better approach, and I'm not sure if I risk the possibility of 2 input strings yielding similar keys. What would be a better approach? I have seen this post that touches on truncation, but can't find an answer that appeals to me there.
If you want a string with 32 bits out of your (weak) password : Digest::SHA1.digest('I am a string').unpack('B32').first #=> "10111101100000101111101100001110" The same amount of information can also be displayed with 8 hexadecimal digits : Digest::SHA1.hexdigest('I am a string')[0,8] #=> "bd82fb0e" or 4 ascii chars : Digest::SHA1.digest('I am a string')[0,4] #=> "\xBD\x82\xFB\x0E"
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "ruby, encryption, sha1, truncate, truncation" }
get selected items from select_tag I have this line in my rails app: <%= select_tag :questionnaire_id, options_for_select(@questionnaires_types, @questionnaires_ids), :multiple => true, :size => 7 %> which works fine. but when I try to use the multiple values that were selected I get this: questionnaire_id"=>["1687,1688,1689,1690,1691,1724"] instead of this: questionnaire_id"=>["1687", "1688", "1689" ,"1690", "1691", "1724"] i.e. I get 1 item instead of 6 items. any suggestions?
Well, just in case that someone will come to this issue, I found the problem. It seems to be a bug in rails. I was using **remote_form_for** , and that gave me the strange behaviour. I tried to change the form to **form_for** instead, and I got an array with 6 items. Rails, Rails, when will you be like .Net? :-(
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ruby on rails" }
About convexity of a set in $\mathbb{R}^n$ Can we say that a set $E\subset \mathbb{R}^n$ is convex iff $E\cap L$ is contractible for every real affine line $L$ in $\mathbb{R}^n$? I know that $E\subset \mathbb{R}^n$ is convex iff $E\cap L$ is convex for every real affine line $L$ in $\mathbb{R}^n$. And a convex set is contractible. Also if we consider $E\subset \mathbb{R}^n\subset \mathbb{C}^n$ , then is $E$ convex if and only if $E\cap L$ is contractible for every complex affine line $L$ in $\mathbb{C}^n$?
Strictly speaking this is not true since $\emptyset$ is not contractible. So let us interpret the condition in the sense that for every real affine line $L$ in $\mathbb{R}^n$, the set $E\cap L$ is either empty or contractible. You know that $E$ is convex iff $E\cap L$ is convex for every real affine line $L$ in $\mathbb{R}^n$. Thus your first question is equivalent to showing that a subset $A \subset \mathbb R$ is convex iff it is contractible. Clearly nonempty convex sets are contractible. Now assume that $A$ is not convex. This means that there exist $x,y \in A$ such that $z_t = tx + (1-t)y \notin A$ for some $t \in [0,1]$. W.l.o.g. we may assume that $x \le y$. It is impossible that $x = y$ because then $z_t = x$ for all $t \in [0,1]$. Thus $x < y$. Hence $A$ is not connected because $A \cap (-\infty, z_t)$ and $A \cap (z_t,\infty)$ form a partition of $A$ in disjoint nonempty open sets. But a non-connected set is not contractible.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "algebraic topology, convex analysis, homotopy theory" }
How to get an "mouse over" event in kivy I am looking for an easy solution, to detect if the mouse(or finger) is an spezific region of a kivy app. The code for that could look like this: BoxLayout: Label: text: 'box 1' Label: text: 'box 2' Label: text: 'box 3' I would like to detect if the cursor or the finger is in box 1, 2 or 3. If the user clicks on the contorl it is easy to handle the "on_touch_xxx" event. But if he is not doing anything I found no good solution. I have read that it is possible to listen to the "mouse_pos" property. But may be there is another good way.
> I have read that it is possible to listen to the "mouse_pos" property Yes, do this.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "python 3.x, mouseover, kivy" }
Why some applications host the API in a different domain? I have seen a trend of applications moving their APIs to other domains (from api.application.com to api.applicationapi.com). Two examples: 3.basecampapi.com and api.dropboxapi.com Is there a security benefit to host the API in a different domain than the dashboard or marketing website? Why does a subdomain is not enough?
> Is there a security benefit to host the API in a different domain than the dashboard or marketing website? In a word, **resilience**. One benefit is that any security blocks which are put in place due to content on the dashboard or marketing website will not impact the API, if the API is on a completely different domain. (If "marketing" means Wordpress or Drupal, for example, such blocks can be a very real threat!) I've had direct experience with blocks triggered by the Google Blacklist, and they can impact the domain name _and_ subdomains thereof. If example.com ends up with malware on it, then api.example.com (and api.api.example.com) will get blocked as well. Moving to api.exampleapi.com cleanly segregates the API so it won't be impacted if example.com is blacklisted. > Why does a subdomain is not enough? Again, with Google at least, blocks may extend into subdomains as well. Also, DNS-based filters like OpenDNS wildcards will block all subdomains as well.
stackexchange-security
{ "answer_score": 7, "question_score": 8, "tags": "web application, api, dns domain" }
How to make my localhost-server accessible for others on my WiFi I am currently on a mac using the pre-installed Apache server. Now I need to cross-browser test some websites, and therefore I need to access my pages on some other computers. How can I make my localhost-sites accessible for other computers on my WiFi (without uploading to another server)? Thanks in advance.
Apache server's default configuration should allow other computers (even ones not on your local network) to access whatever it's serving up. You can access your server from another machine by using the IP address of your server. You can find the IP address of your server by finding a console (this works in Windows and Mac machines) and typing in "ipconfig". (For linux machines, it's "ifconfig".)
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "apache, localhost, sharing" }
Existence of groups of a given order For groups of order 21 i have found Z21 and Z3×Z7. Also they are isomorphic. I would like to know if there are other groups of order 21 which is not isomorphic to these groups. How many different groups are possible for order 21.
It is known that a group of order $ps$ ($p<q$ primes) is cyclic if $q\not\equiv 1\mod p$. If $q\equiv 1\mod p$, either it is a cyclic group, if it is abelian, or it is a semi-direct product $$\mathbf Z/q\mathbf Z\rtimes_\varphi\mathbf Z/p\mathbf Z,$$ where $\;\varphi\colon \mathbf Z/p\mathbf Z\to \operatorname{Aut}(\mathbf Z/q\mathbf Z)$ is a homomorphism such that $\varphi(\overline 1)$ has order $p$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "abstract algebra" }
SQLServerCE DefaultConnectionFactory I am using Entity Framework 4.1 and try to connect to a new SQLServerCE 4.0 database inside an MVC Web application. I am using this code Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0", "|DataDirectory|", "test.sdf"); And it raises this exception : > Format of the initialization string does not conform to specification starting at index 86. What's wrong with this code? If I use Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0") It works and creates a database with a very long name matching my assembly name.
A little late, but this should help: new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0", "", @"Data Source=|DataDirectory|\test.sdf");
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "sql server ce, connection string" }
How do they shoot binocular scenes? How do they shoot binocular scenes? Do they put two cameras in binoculars? See this binocular vision from Ronin (1998): ![enter image description here](
As has been mentioned, the binocular "look" is just a mask. It's also worth noting that if you're looking through binoculars properly you will only see _one_ circle.
stackexchange-movies
{ "answer_score": 117, "question_score": 44, "tags": "film techniques, cinematography" }
Is it illegal directly putting in unicode in character-literal instead of using universal-character-name? According to ISO/IEC 14882:2011(§2.14.3), _character-literal_ , which is also called constants, is illustrated as below. character-literal: ’ c-char-sequence ’ u’ c-char-sequence ’ U’ c-char-sequence ’ L’ c-char-sequence ’ ... c-char: any member of the source character set except the single-quote ’, backslash \, or new-line character escape-sequence universal-character-name At a glance, it seems **directly putting in unicode instead of using _universal-character-name_ in _character-literal_** is illegal. However most compilers, such as g++ and visual studio c++, do not bother at all with it, which is somewhat confusing. Does each implementation automatically convert these unicodes to _universal-character-name_ before compile begins regardless of the standard?
I think the first "phase of translation" handles that (C++11 2.2/1:1.): > Any source file character not in the basic source character set (2.3) is replaced by the universal-character-name that designates that character. So your input files are encoded in the source character set, which includes the basic source character set, but in the program text all non-basic characters are replaced by their universal-character-name.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 7, "tags": "c++, c++11, unicode" }
Value of submit button clicked This should be really straight forward. I'm checking if a form is being submitted using jquery. The form has multiple submit buttons with various values: <button type="submit" value="foo">Foo</button> <button type="submit" value="bar">Bar</button> I would like to find the value of the button that just submitted the form: $(form).live('submit', function() { // Get value of submit button } Thanks
Bind the event to submit buttons instead of the form and then $(this) would have the reference to the buttons... $(":submit").live('click', function() { alert($(this).val()); }) **EDIT** As of jQuery 1.7 live is deprecated. Use on instead. $(document).on("click", ":submit", function(e){ alert($(this).val()); });
stackexchange-stackoverflow
{ "answer_score": 25, "question_score": 16, "tags": "jquery" }
Should I run Windows Virtual Machines on a Windows or Linux host? I have currently have a PC with 16GB of RAM. I will be running multiple virtual machines using VirtualBox. Would I get the best performance from running the VMs on a Linux host, or a Windows host? If Linux is best can anyone recommend a distribution to use?
Well, as long as the OS is 64-bit I don't think it really matters. It's down to personal preference. I've ran VirtualBox on Windows 7 and Ubuntu 10.04 and have not seen much of a performance difference. One question is what processor do you have, and is it enough to run enough Virtual Machines to take advantage of 16GB of RAM?
stackexchange-superuser
{ "answer_score": 3, "question_score": 4, "tags": "windows, linux, virtualbox, virtual machine" }
What's the difference between <?php ?> and <? ?> I can't find the answer anywhere. Thanks!
Basically, `<? ?>` are short tags. However, not every php installation has short tags enabled. Therefore, even though is faster to type than the normal tags (`<?php ?>`), it may not work if you move your code to another server. Are PHP short tags acceptable to use? EDIT: Also, if you're using xml in your web page, you might run into conflicts, as writing `<?xml version="1.0"?>` will make you run into a PHP error, as xml version="1.0" isn't PHP! If you're using XML and PHP you may need to `<?php echo "<?xml version=\"1.0\""; ?>`
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 1, "tags": "php, syntax, tags" }
How do websites post to Twitter, on my behalf? Is this OAuth? i'm wanting to allow my website to post (an authorised user) to twitter (eg. update status). How do websites do this? eg. TwitPic, etc? I know i had to authenticate at one point with the source website -> twitter -> my twitter account. It's just like how I log into SO -> using OpenId. Is this OAuth / the twitter's OAuth API? If it it, i'm assuming that Twitter ends up sending me back some secret token or something which I'll then store in the database against the current user (which is actually an OpenId auth'd user .. no passwords in my DB!) I've used twitter's API using Basic Authentication perfectly fine. Lastly, if this is OAuth, are there any .NET tutorials (or .NET MVC tutes) with this and Twitter? Thanks folks!
Yup, it's OAuth. Here's their documentation
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "twitter, oauth" }
how do I get emacs to treat a file with the wrong extension correctly? So (let us not concern ourselves with why) I have a **.emacs** file which is called **dotemacs** , and a **.bashrc** file which is called **dotbashrc**. When I load up **dotemacs** , I get no syntax highlighing (amongst other things). If I do **M-x lisp-mode** then all is well. Without changing the name of the file, how do I get emacs to recognise automatically that **dotemacs** is a lisp file and go into **lisp-mode**? Similarly for bash scripts, and indeed any other type of file with the wrong (or no) extension.
You can put this at the top of the dotemacs file: ; -*- mode: lisp -*- causing it to start elisp-mode when you load the file. For shell scripts, putting a #!/bin/bash (for whichever shell you are using) is enough to turn on the correct mode. Or otherwise put this at the top of the file: # -*- mode: sh -*-
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 2, "tags": "emacs, file type" }
What happens when a Ditto battles against his second opponent after transformed to first one in GYM? What is happening after a Ditto transformed to his first opponent in a gym battle and defeat it? What is happening if I withdraw my Ditto after it transformed to his opponent and choose it against another opponent in the same gym battle period? Will Ditto transform to his new opponent or will fight as his first transformed form?
Here is the relevant portion of Niantic's Ditto announcement: > Ditto is also a unique Pokémon when you interact with Gyms. When training or battling at a Gym, Ditto will copy the appearance, types, and moves of the first Pokémon it sees, and it will stay that way through the remainder of those Gym battles.
stackexchange-gaming
{ "answer_score": 11, "question_score": 7, "tags": "pokemon go" }
Prove that $f(x)=x^2$ is a contraction on each interval in $[0,0.5]$ I need to formally prove that $f(x)=x^2$ is a contraction on each interval on $[0,a],0<a<0.5$. From intuition, we know that its derivative is in the range $(-1,1)$ implies that the distance between $f(x)$ and $f(y)$ is less then the distance between $x$ and $y$. But now I need an explicit $\lambda$ such that $0\le \lambda<1$ and $d(f(x),f(y))\le \lambda d(x,y)$, where $d$ is the standard metric on $\Bbb R$. Thanks a lot!
Remark that $$ |f(x)-f(y)| = |(x+y)(x-y)| \leq (|x|+|y|)|x-y| < 2a |x-y| $$ if $x$, $y \in [0,a]$. Now $2a<1$ by assumption.
stackexchange-math
{ "answer_score": 5, "question_score": 3, "tags": "metric spaces, contraction operator" }
Advanced Installer error on running MySQL script at Program Setup I have this Visual Studio program that I am packaging into an .exe setup using Advanced Installer v10.7. I have added all the prerequisites into the installer with no issues. My problem comes in when I am trying to run a MySQL script I included in the installer. I created the script using SQLyog Backup DataBase As SQL Dump. I have made sure that the correct version of MySQL is installed on the target computer. During the install process, I get the error !enter image description here This is the part of the script that is throwing the error from the Advanced Installer - SQL Scripts page !enter image description here What I don't understand is that when I try to restore my database directly form SQLyog using the same script, it works. How do I fix this?
Most likely the problem is that there is no statement separator specified. Try setting that field (visible below the inline script field) to ';'.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "mysql, advanced installer" }
Degree of the extension $k(x)/k(q(x))$ for a rational function $q\in k(x)$ Let $k$ be an algebraically closed field, and $q\in k(x)$ a nonzero rational function, expressible as $q(x)=r(x)/s(x)$ for $r$ and $s$ coprime, and $d=\deg r\ge\deg s$. Then will $[k(x):k(q(x))]=d$? It is easy to see that $d$ is an upper bound, by using the polynomial $$ r(T)-q(x)s(T)\in k(x)[T] $$ which vanishes for $T=x$, but I don't see why this polynomial must be irreducible. Presumably, the proof of this will at some point involve Gauss's lemma, applied, say, to $$ s(x) r(T)-r(x)s(T)\in k[x,T], $$ but I can't see how to make the details of the argument work.
Set $L:=k(x)$, and its subfield $K:=k(q)$, where $q=r/s$ for coprime polynomials $r,s\in k[x]$. The claim is that $L\cong K[t]/(r(t)-qs(t))$, and it is enough to show that $m:=r(t)-qs(t)$ is an irreducible polynomial in $K[t]$. (This is where you are making a mistake: we don't want to ask about this polynomial in $L[t]$.) Now, $m$ is an irreducible element of $k(t)[q]$ (it is linear in $q$), and is primitive in $k[t][q]$, so by Gauss's Lemma it is irreducible in $k[q,t]$. Then Gauss's Lemma once more implies that it is irreducible in $k(q)[t]=K[t]$. Thus $L\cong K[t]/(m)$, and so $L/K$ has degree $\max\\{\deg(r),\deg(s)\\}$.
stackexchange-math
{ "answer_score": 3, "question_score": 1, "tags": "abstract algebra, algebraic geometry, field theory, algebraic curves" }
Yii + PDO_DBLIB + SQL Server My website based on yii framework and I work with SQL Server (on Windows) under linux using pdo_dblib + freetds. **My FreeTDS config:** [egServer70] host = my server ip address port = 1433 tds version = 8.0 client charset = UTF-8 Connection is fine. Website uses UTF-8, and SQL Servercolumns used `nvarchar, ntext` etc. types. When I insert some cyrillic text into database, it inserts like this "????????????????????". With english text inserts well. When I select data where cyrillic text already have, it displays normal. So problem only when I try `INSERT` cyrillic text. Anyone know how resolve this issue?
Try the following INSERT INTO Sentences (LangText) VALUES (N'Поиск') (Note the "N" qualifier on the constant) for additional info, read Here
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, sql server, sql server 2008, yii, freetds" }
Left join with a predicate on the inner table in the ON clause I have a query like this: Query 1) select A.col1, B.col2 from A left join B on A.id= B.id and B.col3 = 'Hello'; I want to rewrite it to use a temp table for performance issue (I need the result the be exactly the same): Query 2.1 and 2.2 Select B.id, B.col2 into #temp from B where B.col3 ='Hello'; select A.col1, t.col2 from A left join #temp AS t on A.id= t.id; But my result is not the same (the temp table version has some `null`s in `B.col2` where the first version does not have).
for me, both queries have the same result ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, sql server, tsql" }
Writing udev rules I have added the rule $ cat /etc/udev/rules.d/00-my.rules ACTION=="add", KERNEL=="sd[a-z]", SUBSYSTEM=="block", PROGRAM="/usr/sbin/mytool add %r/%k" on my `RHEL 5.8` to check the disk's partition table on disk appearance event. After I connect the disk `mytool` is called by `udev` subsystem and `udev` is pass something like `/dev/sdb` to `mytool`. But `mytool` unable to `fopen` the `/dev/sdb` because there are no `/dev/sdb` file at the time of `mytool` executing by `udev` on `RHEL`. How can I `fopen` the file `/dev/sdb/` in mine `mytool`?
You should be using `RUN`, not `PROGRAM`.
stackexchange-superuser
{ "answer_score": 2, "question_score": 0, "tags": "linux, rhel 5, udev, redhat enterprise linux" }
Is it possible to install Ubuntu without a CD or USB drive? So basically as it stands I have a laptop which has no cd/dvd drive, and I don't have a usb drive. The laptop has windows 7 installed with ubuntu 11.04 installed through wubi. What I want to do is remove windows completely, and make ubuntu the only OS installed on the system. Is there a way to do this without re-installing ubuntu? (i.e. can I take my wubi install away from windows?) or is there a way to from inside ubuntu have it run the ubuntu iso somehow so I can just wipe the system and install it fresh? (even if it means I need to have an e.g. 2gb partition just for the image to reside in).
1. Use Windows 7 to shrink one of your partitions (you can shrink a mounted partition while running Windows). If you already have 4 primary partitions you'll need to remove one of them first. 2. Boot wubi and install GParted and create an extended partition in the free space you created, and then 2 logical partitions, one an ext4 partition large enough to contain your Wubi install, and optionally 1 swap partition (> size of RAM). 3. Migrate wubi to the partition, installing the grub bootloader at the same time 4. Boot the migrated Ubuntu and format the Windows partition, which you can then reuse as a separate /home or you can use the same migration script to move the migrated Ubuntu to it. This solution doesn't require a live CD/USB (although it's always a good idea to have one.
stackexchange-askubuntu
{ "answer_score": 9, "question_score": 14, "tags": "system installation" }
MySQL LENGTH() > 0 and NOT NULL not getting expected results Viewing my result set, I see a blank field despite my conditions. I tried selecting: SELECT column FROM table WHERE LENGTH(column) > 0 AND column IS NOT NULL i also tried: WHERE LENGTH(column) <> 0 AND column IS NOT NULL but, I'm still seeing a blank field. In my SELECT, I tried checking the contents of the field: SELECT column, LENGTH(column), HEX(column) etc... But, they both come up as 0 and seemingly empty, respectively. What did I miss here?
SELECT .... FROM contacts as co JOIN clients as cl ON co.contact_client = cl.client_oldid -- this starts a where clause WHERE cl.client_status = 2 -- ORDER BY ends a WHERE clause, and goes only for ordering: order by cl.client_name AND LENGTH(co.contact_email) > 0 -- so, order by result of this 0 or 1 AND co.contact_email is not null -- then, order by result of this 0 or 1 AND TRIM(co.contact_EMAIL) <> ' -- then, order by result of this 0 or 1
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "mysql, select, string length, notnull" }
Scrapy Missing one Positional Argument Response I want to Store All the links inside a **my_links** variable. But one i tried to store they gives me error. Missing one Positional Argument **response**. I am new to scrapy... Help Please... Here is the My Code import scrapy from scrapy.crawler import CrawlerProcess class Udemy_Scraper(scrapy.Spider): name = "udemy_scraper" start_urls = [' def parse(self, response): for links in response.xpath('//div[@class="rh-post-wrapper"]'): yield { 'name': links.xpath('.//a/text()').extract(), } my_links = parse() Thanks in Advance
You don't need to call `parse` method as it is the callback method and gets called for all the URLs in the `start_urls` list. You can make a list at spider level. This will work. import scrapy from scrapy.crawler import CrawlerProcess class Udemy_Scraper(scrapy.Spider): name = "udemy_scraper" my_links = [] start_urls = [' def parse(self, response): for links in response.xpath('//div[@class="rh-post-wrapper"]'): self.my_links + =[{'name': links.xpath('.//a/text()').extract()}] yield self.my_links
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "python, python 3.x, web scraping, scrapy" }
How can I transfer all content of two drives between each other automatically? I have two, nearly full, external hard drives of equal size. I want to transfer all content from one drive to the other, and vice-versa. Is there a way to do this automatically, without having to manually and successively transfer files between the two drives until all of the content has been switched? I.e., is there a program, or command, that I can leave running by itself until drive 1 contains all of drive 2's content, and drive 2 contains all of drive 1's content? I have access to both Windows and Linux, but not to an intermediary to temporarily store the data of one drive.
Since this is a duplicate question, this little script by bytebuster may be of help. It simply moves files back and forth between drives X: and Y: into Y:\fromX and X:\fromY until it runs out of free space on current destination drive, then switches source/dest over until there are no dirs except Y:\fromX and X:\fromY. Of course, it will only work if none of the drives contain files bigger than the sum of free spaces on both drives, and it may not work even then (due to file order and it being a really simple script). To work safely, it needs each drive to have free space bigger than the largest file being transferred. It's really simple and if you prefer Linux, you could easily rewrite it using bash / rsync with `rsync --remove-source-files --exclude=dir` instead of `robocopy /MOVE /XD dir`.
stackexchange-superuser
{ "answer_score": 0, "question_score": 2, "tags": "linux, windows, hard drive, file transfer" }
Handheld oscilloscope for saving waveform in memory I am looking for an handheld oscilloscope which can save some single frozen waveforms on memory and transfer it later to a computer. The saved waveform should have a lot of points so that I can process it on the computer with FFT for spectrum. I want it to be a handheld oscilloscope instead of a USB oscilloscope are numerous: More lightweight, less boot time,... I wonder why I have found none with this capability, some difficulties with this approach?
Like DKNguyen said in comments, your looking at equipment that is too cheap and/or low end. All the big names make one or more handheld scopes. Almost all of them use 8bit ADCs, and can capture 3K to 30K samples. The cheapest starts around $250(100Msps/20Mhz) and they skyrocket from there. On the other hand, the cheapy(less than $100) scopes are most likely using a STM32, PSOC3/5 or some Arduino core that is being pushed to it's limit and just could not do it. Not enough RAM, not enough CPU and lack of a storage device are all possible problems at this level. If a real time display is not needed, maybe a data logger might work? I've done that in the past when I was doing RFI reports. The logger grabbed 5 different bands at about 100Msps for up to 2 mins and wrote them to a USB dongle. Then we would take the dongles back to the lab, and let the PC software do the hard work. Don't know the cost, and that was the only time I've used something like that.
stackexchange-electronics
{ "answer_score": 0, "question_score": 0, "tags": "oscilloscope, fft" }
How to mass-delete inline styles in Wordpress custom post type automatically? I'm looking for a pragmatic way to delete about 100+ individual pages worth of inline styles. I had entered in content for a client by copying and pasting from Word, which took all that data with it and wrapped it in inline styles. It doesn't make sense to go through each post individually. Has anyone done this before? I would be fine with any solution that 'works.' Myself and my employer thank you for any input immensely.
I would use the Search Regex plugin. It will allow you to use a regular expression to find and replace (in your case _delete_ ) inline styles. Make sure you backup your database before you begin! A simple regular expression that should work for you would be (style=").*" It will look for a string starting with `style="` and containing any number of characters until it hits another double quote `"`. (That would be an inline style applied to an HTML element). You'll "replace" it with an empty value (to delete it). You can also test your content / regular expression with Regexr to ensure the one I gave you will work. **Backup your database** before you begin. If something goes wrong you can restore it. It looks like this plugin will allow you to Search (as a test) before you run a Replace & Save.
stackexchange-wordpress
{ "answer_score": 4, "question_score": 1, "tags": "functions, customization" }
Remove [NOT FOR REPLICATION] from all Identity columns of Database tables I have a Database which is containing lot of tables with Identity columns set to [NOT FOR REPLICATION]. in SQL Server 2008 R2 Is there any way that I can remove this constraint from all tables from Management Studio or any Query thanks. Create Table mytbl ( [EmpId] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL, I tried this but it is removing one by one. ALTER TABLE dbo.tblAttendance ALTER COLUMN Id DROP NOT FOR REPLICATION;
Microsoft provides a system stored procedure to turn on and off the NOT FOR REPLICATION setting. The stored procedure is **_sys.sp_identitycolumnforreplication_**. We can use this system stored procedure along with sp_msforeachtable to remove the NOT FOR REPLICATION setting from all tables: EXEC sp_msforeachtable @command1 = ' declare @int int set @int =object_id("?") EXEC sys.sp_identitycolumnforreplication @int, 0'
stackexchange-stackoverflow
{ "answer_score": 13, "question_score": 5, "tags": "sql, sql server, sql server 2008 r2, replication, identity column" }
How to enable English mode as default for OS X login I cannot input user account in English without changing input mode when to type user account at login dialog box. I have to change input mode to US every time when I boot mac. Settings: 1. Region is english 2. Top priority input mode is English(US). Next one is Japanese. 3. I setup for the login dialog box to type use account name and password for when its login. !Keyboard !Language Region Environment: Input modes: hiragana(Kotoeri) Input source: US, Kotoeri Keyboard: Japanese Do you know how to enable English mode as default without changing input the mode?
Check "Romaji" option for Kotoeri and remove "US" completely as it becomes useless with Kotoeri. This way you will have roman letters input just like with "US" keyboard. If you have Japanese keyboard, use key to switch to Romaji input and key to switch to Kana input. If you have non-Japanese keyboard, it is possible whether to change input sources using hotkeys as displayed in Kotoeri preferences or to map Caps Lock key to switch input sources as many people do.
stackexchange-apple
{ "answer_score": 1, "question_score": 2, "tags": "macos" }
SFTP/SCP command re-prompts for passphrase I'm logged into remote unix server and want to transfer file to sFTP. Issue is that entered passphrase is not accepted and constantly re-prompted. This is my setting of folder and RSA file permissions .ssh directory permissions: drwx------ 2 USER USER 131 Aug 29 11:17 .ssh .ssh files permission: -rw------- 1 USER USER 1.5K Aug 29 11:17 user_priv.ppk Code is executed from different folder on the same machine scp -i /home/user/.ssh/user_priv.ppk file.csv [email protected]:~/folder/folder Once entered passphrase I get a notification: 'Enter passphrase for Key /home/user/.ssh/user_priv.ppk'
`...user_priv.ppk` ".ppk" is the extension used by the PuTTY key generator. I presume you used PuTTY's key generator to create the key. The OpenSSH utilities (`ssh`, `scp`, and `sftp`) don't read the PuTTY key file format. If you want to use that key, then use the PuTTY key tool to export the key file in a format which `ssh` can use. Alternately, use the OpenSSH key generation tool `ssh-keygen` to generate a new key and use that. Note that the OpenSSH key file format actually uses two files. One file will have a name without an extension (like "id_rsa"), containing the private key. The other file will have a .pub extension (like "id_rsa.pub") and contains the public key. The contents of the .pub file have to be stored on the server that you want to connect to. You will normally add the contents of the .pub file to the `.ssh/authorized_keys` file on the server.
stackexchange-superuser
{ "answer_score": 1, "question_score": 0, "tags": "unix, file transfer, sftp, scp, rsa" }
Rails4; scope returns ActiveRecord_AssociationRelation not single object I just wonder how I can return one object instead of `ActiveRecord_AssociationRelation` within models with `scope`. For example, scope :primary, -> { where(is_active: true).last } which returns `ActiveRecord_AssociationRelation`. So I always have to something like `Account.last.credit_cards.primary.last`. How can I achieve this more efficiently?
Your code already returns a single object. It's a good practice to return `ActiveRecord_Relation` instead: in this case, you can write like YourObject.scope_1(params).scope_2.where(...) Using `limit` instead of `last` returns `ActiveRecord_Relation`: scope :primary, -> { where(is_active: true).limit(1) }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "ruby on rails" }
Check if a String Starts with a Number in PHP > **Possible Duplicate:** > Check if a String Ends with a Number in PHP I'm trying to implement the function below. Would it be best to use some type of regex here? I need to capture the number too. function startsWithNumber($string) { $startsWithNumber = false; // Logic return $startsWithNumber; }
Something like to this may work to you: function str2int($string) { $length = strlen($string); for ($i = 0, $int = ''; $i < $length; $i++) { if (is_numeric($string[$i])) $int .= $string[$i]; else break; } return (int) $int; }
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 11, "tags": "php, string, numbers" }
What is the maximum value of unsigned DECIMAL(M, D) column? I found a `DECIMAL(5, 2)` column supports a range of `-999.99` to `999.99` in 12.22.2 DECIMAL Data Type Characteristics. When the column is defined as _UNSIGNED_ , what is the maximum value that the column supports? Is it still `999.99`?
This probably took less time than your typing the question. Like P.Salmon said, there really should be something more deep behind this. create table td (d decimal(5,2) unsigned); insert td values(999.99); -- Query OK, 1 row affected (0.00 sec) insert td values(1000); -- ERROR 1264 (22003): Out of range value for column 'd' at row 1
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "mysql, decimal, unsigned" }
Getting a Function Expected error while using array.includes in a if statement i am not sure why i get the Function Expected error and not yielding in useful info while searching the web. Thanks for your time! oCollectedValue =new Array(); var i = 0 for (i; i < CollectedValue.length; i++) { if (Attribute.includes(CollectedValue[i])) { oCollectedValue.push(CollectedValue[i]) } }
If you can rely on IE9+, you can use `indexOf` instead of `includes`: const CollectedValue = ["YES", "NO", "TEST", "YES", "NO"]; const Attribute = ["YES", "NO"]; oCollectedValue =new Array(); var i = 0 for (i; i < CollectedValue.length; i++) { if (Attribute.indexOf(CollectedValue[i]) > -1) { oCollectedValue.push(CollectedValue[i]) } } console.log(oCollectedValue);
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript" }
Conditional probability - Basketball player A basketball player has a chance of 80% on his free throw shoots and 30% on his three-point shoots. If he makes free throw shoots N times and then makes three-point shoots as many times as the successful shoots he made in his free throw shoots, find a)the probability mass function of the successful three-point shoots b)If N=3 , what the probability he scores 1 three-point shoot Any help? I can see this is a conditional probability and the two variables are binomial , X= the number of the free throw shoots ~ Bin(N,0.8) and let m be the successful free throw shoots and Y=the number of the three-point shoots ~ Bin(m,0.3). I don't know how two get the conditional probability when the two variables are binomial. Thank you!
Let $X$ denote the number of successful $2$-point shots. Let $Y$ denote the number of successful $3$-point shots. * * * $P(Y=m)=$ $\sum\limits_{k=m}^{N}P(Y=m|X=k)=$ $\sum\limits_{k=m}^{N}\binom{N}{k}\cdot(0.8)^k\cdot(1-0.8)^{N-k}\cdot\binom{k}{m}\cdot(0.3)^m\cdot(1-0.3)^{k-m}$ * * * Using this with $N=3$ and $m=1$ gives a probability of $0.415872$.
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "probability" }
Can a Sun rack be converted to a normal rack? The Sun rack with PN 595-5953-01 does not use the normal rails like HP and IBM uses. Does there exist Sun rails so standard servers can be put in it? Or perhaps those L-shelves, where you lay the servers on the the L-shelves? **Update** The reason I am asking is because since the rack was put in place, a cooling pipe have been mounted on the wall, which prevents the rack from being pulled out. If I should remove it, then it would have to be sawed in two. Right now I have left the old Sun servers in the rack powered off, just to separate the hot and cold room. So either I can let it stay as it is, and not be able to use the rack, or saw it over, and then have to find something to cover the hole where the rack was. I would prefer to be able to put normal servers in it.
Just don't use the Sun rack!! It really can't be converted. Starting a new project with a round-hole non-standard rack today is irresponsible. * Racks are not expensive new. * Racks can be purchased used or refurbished, if cost is a concern. * If you're going through the steps to rack mount equipment, you may want to future-proof it a bit. A more comprehensive description of rack types and features is available at: What to look for in a server rack? You can't go wrong with APC's NetShelter rack offerings.
stackexchange-serverfault
{ "answer_score": 6, "question_score": 2, "tags": "hp, ibm, rack, sun" }
How to align subfigures in this specific grid? I am trying to place the bottom right figure in the same way as the bottom left figure but I find it really really difficult. Any ideas? \begin{figure} \begin{tabular}{cccc} \includegraphics[width=35mm]{./Figures/10026cropped.jpg} & \includegraphics[width=35mm]{./Figures/10026cropped.jpg} & \includegraphics[width=35mm]{./Figures/10026cropped.jpg} & \\ \multicolumn{2}{c}{\includegraphics[width=35mm]{./Figures/10026cropped.jpg} } & \multicolumn{2}{c}{\includegraphics[width=35mm]{./Figures/10026cropped.jpg}} \end{tabular} \caption{caption} \end{figure} ![The figure](
You don't need `tabular` for this: \documentclass{article} \usepackage{graphicx} \begin{document} \begin{figure} \centering \includegraphics[width=35mm]{example-image}\quad \includegraphics[width=35mm]{example-image}\quad \includegraphics[width=35mm]{example-image}\\[2ex] \includegraphics[width=35mm]{example-image}\quad \includegraphics[width=35mm]{example-image} \caption{caption} \end{figure} \end{document} ![enter image description here](
stackexchange-tex
{ "answer_score": 1, "question_score": 3, "tags": "horizontal alignment" }
Data mining vs Pattern recognition What is the difference between Data mining and Pattern recognition? Thanks.
First, I'm going to directly quote the two tags you put on this question: The _data-mining_ tag says: > Data mining is the process of analyzing large amounts of data in order to find patterns and commonalities. The _pattern-recognition_ tag says: > Pattern recognition is the term given to the science of automating the classification of input into pre-determined categories, or on the other hand, of being able to recognise particular categories of input by their characteristics. Now, irony aside, the way I've always seen it is that in data mining you don't necessarily know the patterns. You have to look for them, which can often involve a lot of hunch-following and guess-work combined with a bit of solid testing. In pattern-matching, you tend to know the patterns already and you search for them based on their features.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -3, "tags": "artificial intelligence, data mining, pattern recognition" }
How do I use Python with a database? I wrote a Python program that handles very large data. As it processes the data, it puts the processed data into an array, which easily grows to hundreds of megabytes or even over a gigabyte. The reason I set it like that is because Python needs to continuously access the data in the array. Because the array gets larger and larger, the process is easily prone to error and very slow. Is there a way to have the array-like database stored on a different file or database module and access it on a as-needed basis? Perhaps this is a very basic task, but I have no clue.
1. You can use sqlite3 if you want. it is part of the python packages, it is simpler for basic usage. 2. MySQL for python 3. Postgres for python
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 5, "tags": "python, database" }
union of two queries to get the result in mysql I'm confused about this: SELECT request_id, SUM( cc_amount ) AS amt, DATE_FORMAT( transaction_datetime, '%b %y' ) AS tdate FROM ee_request_cc GROUP BY DATE_FORMAT( transaction_datetime, '%b %y' ) UNION SELECT request_id, SUM( request_amount ) AS amt, DATE_FORMAT( transaction_date, '%b %y' ) AS tdate FROM ee_request_paypal GROUP BY DATE_FORMAT( transaction_date, '%b %y' ) I'm getting: id amt tdate 20 86.00 Mar 12 80 5.00 Apr 12 23 55.00 Mar 12 Whereas I want to add all amounts for March and April like: id amt tdate 20 141.00 Mar 12 80 5.00 Apr 12 Please suggest me the change in my query.
You need to get all the results, and then perform the aggregation: SELECT table_both.request_id, table_both.tdate, SUM(table_both.amount) AS amt FROM (SELECT request_id, cc_amount AS amt, DATE_FORMAT(transaction_datetime,'%b %y') AS tdate FROM table1 UNION ALL --Don't remove the duplicates SELECT request_id, request_amount, DATE_FORMAT(transaction_date,'%b %y') FROM table2) table_both GROUP BY table_both.request_id, table_both.tdate --You don't need to add the format function in the group by
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "mysql" }
how can use string function to solve this problem in java the link of the problem : < and what is the problem of my code My Code : import java.util.Scanner; import java.lang.String; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); String s=in.nextLine(); int d=0; int a=0; for(int i=0;i<n;i++) { if(s.charAt(i)=='A') a++; else d++; } if(a>d) System.out.println("Anton"); else if(a<d) System.out.println("Danik"); else System.out.println("Friendship"); } }
The `Scanner.nextInt()` method does not read the newline character in your input created by hitting Enter, So change your code like below instead of using `nextInt()`; Scanner in = new Scanner(System.in); int n = Integer.parseInt(in.nextLine()); String s = in.nextLine(); This will fix the issue
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -6, "tags": "java" }
Using an other command in alias When this command is run, it is not the time to submit the command, But print the `source ~/.zshrc` time. ~/.zshrc: alias gitCommitAll="git add . && git commit -m \"`date +\"%T\"`\"" eg. `source ~/.zshrc` at 10:00 `gitCommitAll` at 10:10 ==> `git commit -m "10:00"` not 10:10
Try this: alias gitCommitAll='git add . && git commit -m "`date +%T`"' Backquote (``) inside double quotes (`""`) will be executed prematurely. Try using single quotes (`''`) instead.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "shell, alias, zsh" }
Como conecto mi aplicación android a una Base de Datos MySQL en android studio? Me podrían explicar como me puedo conectar a una base de datos en `android` studio, en `java` es tan fácil como descargar una librería y poner public Connection getConexion(){ Connection con = null; try { Class.forName("com.mysql.jdbc.Driver"); con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/baseDeDatos","root","clave"); return con; } catch (Exception e) { //JOptionPane.showMessageDialog(null, "Error al conectarse con la BD: "+e.getMessage()); } return con; } pero veo que en android es muy diferente. ¿Me pueden decir paso por paso que debo hacer?, Ya tengo descargado `Xamp`. ¿Qué librería necesito? ¿Cómo es la clase? en caso de utilizar librería, ¿Cómo la coloco en el proyecto?
Por lo que vea necesitas conectar tu base de datos MySQL con Android. Pero lamentablemente esto no es posible. Android no soporta a MySQL como motor de base de datos para instalarlo. La única solución que tienes es hacer un web service que debes consumir en tu aplicacion Android y desde este web service consultar a tu base de datos MySQL. Otro punto importante es que para hacer persistencia (mantener los valores de tu base de datos MySQL en tu aplicación Android para manejar, mantener, etc) es que hagas una Base de datos SQLite. Te dejo un completo Tutorial SQLite Android
stackexchange-es_stackoverflow
{ "answer_score": 7, "question_score": 2, "tags": "java, android, mysql" }
Django + New Relic performance benchmarking I've got a Django web app with a complicated data model that's experiencing performance issues. Using New Relic, I was pretty much instantaneously able to isolate what the problem is. But there are a number of different solutions I can try. What I'd like to do is be able to benchmark the efficacy of different solutions in various combinations. In my mind, one way of doing this by hand would be to make a Django model that stores configuration flags outside of my settings file, so I could change them through the admin instead of redeploying. Then I could monitor New Relic and record the metrics into a spreadsheet. But I feel like that would be a poor reinvention of something people probably do all the time. Is there a good methodology for doing this without a whole bunch of manual labor?
I'm not sure about the overall methodology, but another option to check out that I was really happy with was Tracelytics. Also, another thing to help with your question would be the project django-waffle which I've never used, but seems like it'd be nice for changing flags/settings from admin!
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "django, performance, automation, newrelic" }
Is there a way to generate PAT in Azure B2C I have a api's which are exposed to users, and i have added B2C authentication in Middleware. asking customers to login everytime & ask to get token is not looking a great idea, Gone through documents about refresh token, but refresh tokens max lifetime is 3 months. Just like Azure Functions can we generate a PAT for B2C app.
When refresh token expires you will fall back to cookie based authentication at AAD B2C. You can create a persistent cookie with length of many years using “keep me signed in”. <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, node.js, asp.net core, azure ad b2c, msal" }
Can I retrieve an Email Alert via the Ant Migration Tool? I wanted to retrieve an Email Alert via the Ant Migration Tool. However, I could not find it in a Metadata Types Reference. I suppose it's hidden under some other name like many other SF Metadata Types - I just don't know which. To make things more precise - pic related: ![enter image description here](
You can retrieve it with "workflowAlert" metadatatype. You can find more info at this URL here Workflow Metadata Ref, you might want to scroll through to the section "WorkflowAlert" to see field references associated to it. ![WorkflowAlert](
stackexchange-salesforce
{ "answer_score": 3, "question_score": 3, "tags": "deployment, metadata api, ant, migration tool, mdapi" }
Wrap lines only after a space So, I like that (n)vim has line wrapping support, but what I dislike about it is that it does things like this: 1 | Instead of wrapping text--| 2 | like this, Vim does it lik| 3 | e this. | How could I make (n)vim wrap text after whitespaces, and not deliberately after any character it finds? Also, I am talking about the screen wrapping, not the auto-wrapping it can do by inserting a newline.
Maybe the following question answer yours How can I soft-wrap a word to a new line? The author proposes you to use option `linebreak`: set linebreak
stackexchange-vi
{ "answer_score": 1, "question_score": 0, "tags": "neovim" }