INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Toshiba Satellite Touch Pad controls arrow keys
On my account on my wife's laptop, the touch pad has started to control the cursor keys instead of the mouse pointer.
It works fine on my wife's account or on the main user selection screen. On my account it controls the mouse pointer at first, but when Windows has fully loaded it starts to control the arrow keys instead.
I have not found anyone else with this problem during my research, and I have also tried setting the options for the touch pad to default in mouse settings and rebooting to no avail.
I've also tried disabling all Start-up programs - no difference:
!Start=up
I've checked the F5 function key too and this just disables the touch pad totally. Plugging in a USB mouse works fine. Anyone seen such an odd problem like this before? | I found the following article that pointed me in the right direction for solving this: Touchpad mouse cursor not moving only scrolling
To solve I uninstalled the Synaptics Pointing Device Driver:
!Windows Programs
The Touch Pad now works on all accounts. | stackexchange-superuser | {
"answer_score": 0,
"question_score": 0,
"tags": "windows 8.1, mouse, touchpad, toshiba laptop"
} |
How do I stop my PC from autoplaying media files present on my SD card on my Android Phone?
How do I stop my PC from autoplaying media files present on my SD card on my Android Phone? Whenever my USB linkage cord between my PC and my phone is wobbled just a little bit my Ubuntu 12.10 tries to play all the files on my SD card (like audio and picture files) how do I stop this? | Open up System Settings and click "Details". Under removable media set the drop down menus under music player and photos to "Do nothing." | stackexchange-askubuntu | {
"answer_score": 2,
"question_score": 5,
"tags": "12.10, android, sd card, autoplay"
} |
Double Validation (Re-typing) in Visual Flow
I have been asked to create a validation rule in a visual flow that requires a user to type a value twice. Then the validation rule will compare the two values typed (ignoring case) then if they are not equal the validation rule will fire and they will need to re-enter. This will be similar to how you check a password or email address on many web forms. The second value won't need to be saved, so I don't really want to create a new field that is never saved (it seems like a bad practice). Has anyone done this or have an idea of how to do this? | You do not need a validation rule or a field. You can build this logic in the Flow directly. That design will look like the following:
 and upload them to another host instead of deploy to Cloudbee itself?
When I create a build, the only host service I can select is Cloudbee Run@Cloud service. I want to know can I deploy my php application to another host service?
Thanks. | From CloudBees you can also deploy through some plugins to other PaaS providers. If you want to deploy to other providers you will need to develop your own Jenkins plugin or maybe to use some of the Jenkins plugins available to upload your artifact to the provider you want through SFTP for example. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, jenkins, cloudbees"
} |
Advice on writing generic function to encode variables in R
I have a data.frame:
mydata = data.frame(v1 = c("A", "A", "A", "B", "B", "C", "D"),
v2 = c("XY", "XY", "ZZ", "BB", "ZZ", NA, "ZZ"),
v3 = 5)
And I would like to encode each of the characters in the data frame to integers corresponding to each of the levels. I also want to "ignore" NA values. The expected output would be equal to:
output = data.frame(v1 = c(1, 1, 1, 2, 2, 3, 4),
v2 = c(1, 1, 2, 3, 2, NA, 2),
v3 = 5)
My hope is to write a function that accepts a data.frame object AND a list specifying the columns on which I want to perform the operation, something like:
my_function = function(df, vars){
...
}
EDIT: in the example above, "vars" would be = c("v1", "v2")
Any suggestions for how to approach this? I'm open to using packages such as dplyr to help.
Thanks, D | We can convert to `factor` and then coerce to `numeric`
mydata[1:2] <- lapply(mydata[1:2], function(x)
as.numeric(factor(x, levels=unique(x))))
This can be converted to a function
myfunction <- function(df, vars) {
df[vars] <- lapply(df[vars], function(x)
as.numeric(factor(x, levels=unique(x))))
df
}
myfunction(mydata, c('v1', 'v2'))
# v1 v2 v3
#1 1 1 5
#2 1 1 5
#3 1 2 5
#4 2 3 5
#5 2 2 5
#6 3 NA 5
#7 4 2 5
If we need it to be further generalized, we may need to check the column classes i.e. whether it is a `numeric` column and if not, then change to `factor` with `levels` specified and coerce to `numeric`.
mydata[] <- lapply(mydata, function(x)
if(!is.numeric(x)) as.numeric(factor(x, levels=unique(x)))
else x) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "r"
} |
QT quick layout segmentation by percentage
How to have two columns in a gridLayout where the first column occupies 20% of the space and the second column automatically fills the rest of the space, like what happens in css? I try this but now work:
GridLayout{
id:root
anchor.fill:parent
columns:5
rows:1
Column{
id: col1
Layout.column:0
Layout.columnSpan:1
}
Column{
id: col2
Layout.column:1
Layout.columnSpan:4
}
}
Finally, please show me an article that is well-trained in working with layout. | You are building this on the assumption that the columns are equal but they are not. You have to set the column size explicitly.
GridLayout {
anchors.fill: parent
columns: 2
columnSpacing: 0
Rectangle {
Layout.preferredWidth: parent.width * 0.2;
Layout.preferredHeight: 50
color: "orange"
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 50
color: "green"
}
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "qt, qml, qt quick, qtquickcontrols2"
} |
AS3 Custom Object to ByteArray then to Custom Object
Having problem reading bytearray of custom objects. Any help is appreciated
public class CustomObject extends Object {
public function CustomObject() {
public var _x:Number = 100
public var _y:Number = 10
public var _z:Number = 60
}
}
var cObj:CustomObject = new CustomObject()
var bytes:ByteArray = new ByteArray()
bytes.writeObject(cObj)
bytes.compress()
//read
try { bytes.uncompress() } catch (e:Error) { }
var obj:CustomObject = bytes.readObject() as CustomObject
trace(obj) // null why?!
trace(obj._z) // Obviously - TypeError: Error #1009: Cannot access a property or method of a null object reference. | What you want to do is use the registerClassAlias method to register type information along with the data. That way Flash will know how to serialize/deserialize your object. Here's some sample code from Adobe's documentation):
registerClassAlias("com.example.eg", ExampleClass);
var eg1:ExampleClass = new ExampleClass();
var ba:ByteArray = new ByteArray();
ba.writeObject(eg1);
ba.position = 0;
var eg2:* = ba.readObject();
trace(eg2 is ExampleClass); // true
It should be noted that _all_ types that should be serialized must be registered for the type information to be saved. So if you have another type that is referenced by your type, it too must be registered. | stackexchange-stackoverflow | {
"answer_score": 12,
"question_score": 6,
"tags": "actionscript 3, object, arrays"
} |
debug message printed on jupyter notebook... How to disable it
When I am trying to use quandl to download some data within a function in jupiter notebook:
I got some debug messages like,
> 03-Jan-18 10:43:40 DEBUG Starting new HTTPS connection (1): www.quandl.com 03-Jan-18 10:43:40 DEBUG < "GET /api/v3/datasets/SCF/CBOE_VX2_ON/data?order=asc&end_date=2100-11-17&start_date=2017-11-28 HTTP/1.1" 200 None
There are too much of them and i do not want to see them... what shall i do? Thank you. | Try this inside your notebook:
#Supress default INFO logging
import logging
logger = logging.getLogger()
logger.setLevel(logging.CRITICAL) | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 1,
"tags": "jupyter notebook"
} |
Signed Macros Are Disabled In Excel
I have two Excel files:
1. A newly created, empty Excel file with 1 macro in it
2. A large Excel Model containing macros, custom formats, range names, tables, custom ribbon UI, etc.
I have digitally signed the macros in each file and set Excel Macro Settings to "Disable all macros except digitally signed macros".
When opening the freshly created file the macros run fine. When I open the large file the macros are disabled.
I have ensured that they are both signed with the same certificate and saved correctly. | After a lot of process of elimination we narrowed the issue down to a single range name with RefersTo: `TRANSPOSE(GET.WORKBOOK(1))&T(NOW())`
If the above range reference exists inside a XLSM file with digitally signed macros, then Excel will silently disable the macros even though it was signed by a trusted certificate. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "excel, vba, certificate"
} |
How to get a string from a dictionary and use it as a named parameter in any function?
I have a dictionary in python,
mapper = {'my_func': ['a', 'b', 'c', 'd']}
I want to call a function which takes a, b, c, d and e parameters -
functn(a, b, c, d, e=None)
The parameters a, b, c, d is what I want to use while calling the function, and not e, and those parameter names are defined in that dictionary.
How can I parse the dictionary values and use them as named parameters in the function, while passing some values to each one of them?
Eg:
I can get named parameter a, by doing this -
mapper['my_func'][0]
But how to use that value as a named parameter in the above function?
Any help? | You can do this in a couple of steps:
mapper = {'my_func': [1, 2, 3, 4]}
def functn(v, w, x, y, z):
return v + w + x + y + z
# create dictionary of arguments to values
d = {**dict(zip(list('vwxy'), mapper['my_func'])), **{'z': 5}}
# unpack dictionary for use in function
res = functn(**d) # 15 | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "python, dictionary, functional programming, named parameters"
} |
getting path of "self" using powershell
I know this has to be incredibly simple but everything I'm finding is how to recover the path of another file. What I need to get is the path of the powershell file that is running. That way it can be moved and still function properly. | Try:
$MyInvocation.MyCommand.Path | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 2,
"tags": "powershell"
} |
Determining the derivative of $e^{5x}\tan(2x)$
> Determine the derivative of $e^{5x}\tan(2x)$
I have no idea, what is this question mean- but what I can do is
$$\begin{align*}y&=e^{5x}\\\ \frac{dy}{dx}&=e^{5x}(5)\\\ \frac{dy}{dx}&=5e^{5x} \end{align*}$$
what can I do to the $\tan(2x)$. can you please help me out? | Is that $e^{5x}\cdot\tan2x$? In that case, we want to use the product rule. Recall that the product rule says that $(fg)'(x)=f'(x)g(x)+g'(x)f(x).$ | stackexchange-math | {
"answer_score": 4,
"question_score": 1,
"tags": "calculus, derivatives"
} |
Polynomial interpolation
I need to find the polynomial of degree $3$ with respect to these conditions:
$$\begin{cases} p(0) = 1\\\ p(1) = -1\\\ p'(0) = 1\\\ p''(0) = 0 \end{cases}$$
How do I deal with the condition on the second derivative? | More generally speaking, consider the cubic polynomial as $$p(x)=a x^3+bx^2+cx+d$$ for which the first and second derivatives are given by $$p'(x)=3a x^2+2bx+c$$ $$p''(x)=6ax+2b $$and now apply the conditions in the order they are given in the post. So,$$p(0)=d=1$$ $$p(1)=a+b+c+d=-1$$ $$p'(0)=c=1$$ $$p''(0)=2b=0$$ So, you have four simple equations to solve for $a,b,c,d$ from which $b=0$, $c=1$, $d=1$, $a=-3$.
Just to make the problem more general, suppose that instead you were given the conditions $p(0)=\alpha$, $p(1)=\beta$, $p'(0)=\gamma$, $p''(0)=\delta$, the same procedure would lead to $a=-\alpha +\beta -\gamma -\frac{\delta }{2}$, $b=\frac{\delta }{2}$, $c=\gamma$, $d=\alpha$. | stackexchange-math | {
"answer_score": 4,
"question_score": 2,
"tags": "polynomials, interpolation"
} |
handle words with accents
I'm trying to access a field by the display name that is a link, something like this:
`<a class="node" href="javascript: MCMenu(7);">MÓVEL</a>`
and trying to access the item by doing this:
`t= $browser.link(:text => "MÓVEL").exists?`
`t.click`
the error is:
unable to locate element, using {:text=>"M\303\223VEL", :tag_name=>"a"} (Watir::Exception::UnknownObjectException) | Try it with a regex like this:
t = $browser.link(:text => /M.VEL/).exists? | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "watir, watir webdriver"
} |
What sort of progress should I be expecting with burpee sets?
So, between 40 and 50 years old, mountain biker weighing about 90kg. No problems doing 100km on an MTB on or off terrain in reasonably quick time frames. Recently (couple of weeks ago) started doing burpees daily. Proper form, full press-up and jump, and initially felt like I was dying doing more than 5 or 6 of them in a set. Am now able to do about 25 in a set before literally feeling unable to jump or breathe properly. I will then go on to finish 30 after a minute pause.
Is this acceptable progress? I am a little discouraged to note that many people on the internet talk of doing 100 burpees in a single set as though it was not a problem, and apparently with no previous experience of doing burpees. Is that level of progress too low, that I should be looking at some possible problem, eg: diet etc? | In general this seems like good progress for burpees. I generally take everything people say about their results on the internet with a grain of salt. Burpees are a particularly problematic one because people have different definitions of what good form is.
I doubt anyone other than the highest level of athletes could easily do 100 burpees without significant preparation. The idea behind an exercise like burpees is that they work out the whole body including core, legs, and shoulders as well as good cardio without too great an impact on joints. As a result they tend to be difficult for any athlete regardless of fitness level. All bodyweight exercises are going to continue to be difficult because as you gain muscle you will weigh more.
With burpees, like any other exercise, you will have large initial gains and then gains will slowly increase. All I can say is keep working on it and make sure you have sufficient protein intake and calorie intake. | stackexchange-fitness | {
"answer_score": 1,
"question_score": 2,
"tags": "stamina"
} |
jQuery isotope initialize with filtered results
Hi I'm using jQuery Isotope and I have a filter like this:
<ul class="filter option-set " data-filter-group="date">
<li><a class="selected" href="#filter-date-January" data-filter-value=".January">January</a></li>
<li><a href="#filter-date-April" data-filter-value=".April" class="">April</a></li>
<li><a href="#filter-date-any" data-filter-value="" class="">ALL</a></li>
</ul>
Even though I use the "selected" class for the first item, the items are not filtered by that criteria, it shows all instead. Is there anything else I should do to make it work?
Thanks in advance. Lu | You could split initialization and filtering. I'd prefer to handle filtering in a separate function, i.e:
$(function() {
// isotope init
$(container).isotope({
itemSelector: '.item',
animationOptions: {
duration: 750,
easing: 'linear',
queue: false
}
});
filterItems(); // filter onload
});
var selectedDate = '.January'; // update this var with your UI
var filterItems = function() {
$('ul.option-set li a').each(function(i, a) {
if($(a).data('filter-value') == selectedDate) {
$(a).addClass('selected');
}
else {
$(a).removeClass('selected');
}
});
$container.isotope({
filter: '.selected',
isAnimate: true
});
}; | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 3,
"tags": "jquery, jquery isotope"
} |
To write java method in PL/SQL
Is it possible to write a java method within a PL/SQL block?
Please eloborate this using an example...
Thanks in advance. | No its not, but you can write JSP (Java Stored Procedure). For that, you can find a tutorial over here, Developing Java Stored Procedures. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "java, plsql"
} |
How to manally lookup "@string/..." style references in custom android XML
I have something like the following custom XML in `res/xml/widgets.xml`:
<?xml version="1.0" encoding="utf-8"?>
<root>
<widget name="car" color="mauve">Car Name: @string/car_name</widget>
</root>
and `res/values/strings.xml`:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="car_name">Ford Model-T</string>
</resources>
Since I am using `getResources().getXml()` to parse the XML manually, the embedded string `@string/car_name` is not dereferenced automatically by Android. How do I do it myself (without a lot of annoying reflection code)? This is to say, I would like a method that gives me back the string `Car Name: Ford Model-T`, assuming I have already parsed `Car Name: @string/car_name` using the XMLPullParser. Surely the methods Android itself uses are visible. | Search through your XML String, find every @string/str_name , and then find related string to `str_name` by this:
`String relatedString = getString(getResources().getIdentifier("str_name", "string", getPackageName()));`
then replace `@string/str_name` with `relatedString`
Done! | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "android, xml parsing"
} |
backup file to NAS device
I have a WD Sharespace storage device at home. link
I currently backup my live servers files to a PC of mine at home.
I do this once daily using RoboCopy and a scheduled task.
I use this robocopy command so only new files are copied daily:
robocopy \\serverip\share\backupfolder c:\backups /E
I want to take this one step further and also back this up daily from my PC to my WD Sharespace storage device.
The problem i'm having is this won't copy only the new files.
Everytime I run this it copies every file again as if its changed.
I assumed the NAS device may be changing the modified time but it seems to remain the same.
I have tried to use XCOPY which does the exact same thing.
What is causing this and how can i set this up to only copy new files?
Note: These are pretty much daily document and database backups. This files will actually never be changed but only new files will be added daily. | If you are having problems, you may want to take a look at Microsoft Synctoy
If you want to stick with Robocopy, try adding the `/XO` option which is (from the help file) `/XO :: eXclude Older files.` | stackexchange-superuser | {
"answer_score": 4,
"question_score": 1,
"tags": "backup, automation, robocopy"
} |
Is it safe to substitute a 10-gauge wire for ground strap on dryer?
I am backfitting a dryer with a 3-prong plug. The manual says to connect the body to the neutral terminal using a copper ground strap.
I don't have a ground strap and none of the stores around carry them.
Is it safe to use a 10-gauge solid copper wire in place of the ground strap?
Model #: GE DCVH515EF0WW
The negative terminal is about 2 inches away from the grounding screw on the dryer body. I folded a 4-inch, bare, 10-gauge, solid copper wire into a long U. I fitted the U around the grounding screw and put the tips of the U under the screw at the negative terminal. This results in two 10-gauge segments that can carry current from the body to ground.
)
Thanks! | You should use UIColor init method:
view.backgroundColor = UIColor(patternImage: UIImage(named:imageName)) | stackexchange-stackoverflow | {
"answer_score": 14,
"question_score": 6,
"tags": "swift, xcode6"
} |
Adding text on product page is more that 0 in Opencart
I would like to add a line of text below the stock status on the Opencart product page. I thought a simple PHP If Then would do the trick but sadly I must be doing it wrong. Could someone help me out?
Thanks!
<?php
if ($text_stock > 0)
echo "If ordered before 5pm this product ships same day";
?> | Try using
if ($product_info['quantity'] > 0) {
Instead. That is the data pulled directly from the database | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, opencart"
} |
Is there any other store like appstore to upload iphone apps?
I tried to upload the apps in appstore but it needs 5000 rs/ year for creating an account. Can anyone please tell me whether do we have any other iphone appstore other than appstore.
Thanks in advance | Search for **alternative stores for iOS**. But if you target legal ios(iPhone/iPad) devices, you have to use AppStore of Apple
**EDIT** I tried to share a link of lmgtfu.com but it didnd't let me share that content, so in my answer there is somtehing like "here are some alternative stores" sorry for sharing that without fixing. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "iphone, ios, app store"
} |
How to convert an IEnumerable<Task<T>> to IObservable<T>
Is there a built in way to convert an IEnumerable<Task<T>> to an IObservable<T>. Order doesn't matter, just that I get things, though preferably as they're completed.
If it doesn't exist yet, what might be a good way to accomplish it? | I believe this will work
tasks.Select(t => Observable.FromAsync(() => t))
.Merge();
Each task will send its results to the observable sequence in whatever order they complete. You can subscribe to the sequence and do whatever you want with the results that way. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 9,
"tags": "c#, .net, linq, .net 4.0, system.reactive"
} |
Do I need to explicitly use `_r` suffix when using `-D_REENTRANT`?
I'm writing an multithreaded application and I'm wondering about following: When using `-D_REENTRANT` macro, do I need to explicitly use `_r` suffixed functions?
e.g. Shall I use `strtok_r` everywhere in the code or can I use `strtok` and make sure I pass `-D_REENTRANT` macro to the compiler?
Thanks a lot | Defining `_REENTRANT` won't change the semantics of `strtok()`. You'll need to use `strtok_r()`. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "c, multithreading, reentrancy"
} |
Perl6 Regex Match Num
I would like to match any Num from part of a text string. So far, this (stolen from from < does the job...
my token sign { <[+-]> }
my token decimal { \d+ }
my token exponent { 'e' <sign>? <decimal> }
my regex float {
<sign>?
<decimal>?
'.'
<decimal>
<exponent>?
}
my regex int {
<sign>?
<decimal>
}
my regex num {
<float>?
<int>?
}
$str ~~ s/( <num>? \s*) ( .* )/$1/;
This seems like a lot of (error prone) reinvention of the wheel. Is there a perl6 trick to match built in types (Num, Real, etc.) in a grammar? | If you can make reasonable assumptions about the number, like that it's delimited by word boundaries, you can do something like this:
regex number {
« # left word boundary
\S+ # actual "number"
» # right word boundary
<?{ defined +"$/" }>
}
The final line in this regex stringifies the Match (`"$/"`), and then tries to convert it to a number (`+`). If it works, it returns a defined value, otherwise a `Failure`. This string-to-number conversion recognizes the same syntax as the Perl 6 grammar. The `<?{ ... }>` construct is an assertion, so it makes the match fail if the expression on the inside returns a false value. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 6,
"tags": "raku"
} |
Как добавить QLineEdit на QGraphicsScene c возможностью редактировать текст
Не столько вопрос, сколько совет нужен
1) Я могу добавить на QGraphicsScene QLineEdit просто через scene->addWidget Но тогда при нажатии на QLineEdit не появляется курсор. Надо добавить какие-то eventCliced или что-то такое, да? Они у меня не переопределены. 2) Я могу создать виджет, на котором уже создать QLineEdit, и только после этого добавить виджет с лайнэдитом на сцену. Но тогда вокруг него появляется уродская рамочка, которая мне не нужна абсолютно. Её можно наверно как-то ужать через size?
_И вообще, мне просто нужны поля для ввода текста на QGraphicsScene с чёрным контуром, потому что это для штампа чертежа..._
Или можно ещё что-то сделать с этим безобразием?( | Если задача просто редактировать текстовые поля на сцене, то проще так:
QGraphicsScene * scene = // ...
QGraphicsTextItem * field = scene->addText("text");
field->setTextInteractionFlags(Qt::TextEditorInteraction);
Можно установить и другие флаги редактирования. | stackexchange-ru_stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "c++, qt"
} |
Does every complex polynomial of degree not equal to 1 have a fixed point?
Suppose $P$ is a complex polynomial of degree not equal to 1. Is it the case that $P$ has a fixed point? | Consider $f=P(x)-x$ and use the fundamental theorem of algebra, the degree being greater than one by condition $f=P(x)-x$ not constant. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "algebra precalculus"
} |
How Can I Revise a List Node Property Using Cypher?
I have nodes in my graph that contain properties that are of type double[]. How can I do something like this in cypher?
for (int i=0; i < theArray.length(); i++)
theArray[i] *= .8;
This obviously doesn't work, but here is the general idea:
start a = node(0)
a.theArray = a.theArray*.8
return a; | You can use `extract` for that which is like `map` and creates a new collection.
start n=node(0)
set n.foo=extract(x in [1,2,3] : x*0.8)
return n
set n.foo = extract(x in n.foo : x*0.8) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "neo4j, cypher"
} |
Theory of groups
Can someone help me with this question,
"Is the subset of symmetries of a square consisting rotation is subgroup?"
My idea is that this is a subgroup but i have problem on how to explain it with words. Thank you | You want to apply a subgroup test. The most straightforward one is the following:
* Is the subset closed under composition? (Is the composition of two rotations also a rotation?)
* Is the subset closed under inversion? (Is the inverse of a rotation also a rotation?)
In general, any subset that is closed under composition and inversion is a subgroup.
e: Ethan Bolker has reminded me that if you're being careful, you need to check that the subset is nonempty, too. | stackexchange-math | {
"answer_score": 2,
"question_score": -1,
"tags": "discrete mathematics"
} |
Easiest way to convert number stored as text to number in Excel VBA
I trying to convert this text into numbers:

For Each WS In Sheets
On Error Resume Next
For Each r In WS.UsedRange.SpecialCells(xlCellTypeConstants)
If IsNumeric(r) Then r.Value = Val(r.Value)
Next r
Next WS
End Sub
The result looks like this
, ",", "." ) )
Or this one if your decimal character is a colon [,]
=SUM( SUBSTITUTE( B2, " ", "" ) )
, array('2012-12-14', 'df'),array('2012-12-10', 'vvv'),array('2012-12-11', 'vvv'));
Array
(
[0] => Array
(
[0] => 2012-12-12
[1] => vvv
)
[1] => Array
(
[0] => 2012-12-14
[1] => df
)
[2] => Array
(
[0] => 2012-12-10
[1] => vvv
)
[3] => Array
(
[0] => 2012-12-11
[1] => vvv
)
)
<
is possible to sort this with dates DESC? For this example should be:
$array[1] //2012-12-14
$array[0] //2012-12-12
$array[3] //2012-12-11
$array[2] //2012-12-10
For me the best way is use embedded functions for PHP, but how? :) | You can use `array_multisort()` :
foreach ($array as $key => $row) {
$dates[$key] = $row[0];
}
array_multisort($dates, SORT_DESC, $array);
First, you put out all dates in a new array. Then, `array_multisort()` will sort the second array (`$array`) in the same order than the first (`$dates`) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "php, arrays"
} |
How to solve "Collection query aborted after accumulating over 5000 elements"?
I am trying to sample image and to get scatter plot of its' two bands- NDVI and db from senttinel 1. For some reason, probably because of the size of the shapefile, I get the error:
> Error generating chart: Collection query aborted after accumulating over 5000 elements.
>
> Collection query aborted after accumulating over 5000 elements
That's happens after I try to sample my image using this:
// Generate a sample of points within the region
var sample = pairedImage.sampleRegions(geometry, null,3);
I have playes with the last number in the funnction , I started with 50 but then went down to 30,10,5 ,1 and 3, but non of them worked and in all I have gotten the same error. is it possible that it happens because of the size of the image and there is nothing I can do?
Here is a link to my code:
<
My end goal: to be able to sample this image and create the chart | The collection you pass to `ui.Chart.feature.byFeature()` cannot contain more than 5000 features. In your case, your `sample` collection contains way more than 5000.
pairedImage.sampleRegions(geometry, null,3);
This samples your image at a scale of 3 meters. Since your image comes from Sentinel 2, it’s pointless to sampling at a scale smaller than 10 meters. Sampling your geometry at 10 meters gives you more than 600,000 features. That leaves you with two options: Sample at a larger scale or sample a smaller area. The below script samples at 100 meters:
< | stackexchange-gis | {
"answer_score": 3,
"question_score": 0,
"tags": "google earth engine, sentinel 2, sentinel 1, sampling, radar"
} |
App Icon not loading in Slingshot
I've set some custom icons (via editing .desktop files) for some apps using png files stored in my home directory. In the Slingshot menu they are showing the generic grey square with gear icon. Yet when launching the app the proper icon appears on Plank. Any thoughts? | Try "AppEditor" from Appstore - it saves you the chore of editing the *.desktop files manually, but includes that option if you still want to. When editing files manually there is always greater chance for an error. This app minimizes it. Ofcourse it can also set icons of menu entries. Very useful. | stackexchange-elementaryos | {
"answer_score": 1,
"question_score": 0,
"tags": "plank, slingshot"
} |
How to save a string to a .txt file in java
Ive finished an application and have tested all the functions and they are working. However one part of inputted data is supposed to be saved to a .txt file. Ive placed this inside a string but Im a bit out of my depth in this area and have no idea how to save this to a drive on my PC. Any help is appreciated. The code is on this link: < | Try This:
public static void main(String args[])throws IOException {
File file = new File("Hello1.txt");
// creates the file
file.createNewFile();
// creates a FileWriter Object
FileWriter writer = new FileWriter(file);
// Writes the content to the file
writer.write("This\n is\n an\n example\n");
writer.flush();
writer.close();
}
Read more abut here | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -2,
"tags": "java, save"
} |
How do I parse this data in a Django template?
{u'4th-of-July': {'name': 4th of July', 'slug': u'4th-of-July'}}
I would like to have access to `'name'` and `'slug'` in a django HTML template. How do I go about doing this? | You can access a dict in template with dot notation:
Let's call your dictionary `data`:
{{ data.4th-of-July.name }}
And
{{ data.4th-of-July.slug }} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "python, django"
} |
How to remove element with no attributes and child element?
I've got a list of elements and I want to remove div elements with no attributes and child element.
Sample code:
<div class="wrapper">
<div class="xx-1"></div>
<div id="yy-1"></div>
<div></div>
<div><h1>Hello World!</h1></div>
<div></div>
<div></div>
</div>
How can i remove `<div></div>` inside the wrapper class? | If the conditions for removal are:
1. DIV tags
2. which have no attributes
3. and have no child elements
Then you'll probably want a filter:
$(".wrapper div").filter(function() {
return this.attributes.length == 0
&& this.childNodes.length == 0;
}).remove();
The `div:empty` selector in jQuery will remove all DIV tags with no child nodes, including DIV tags that have attributes and no child nodes. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "jquery"
} |
Prove that $\lim_{z\rightarrow \infty}f(z) = \lim_{z\rightarrow 0}f(\frac{1}{z})$ by definition
I tried this:
Suppose $\lim_{z\rightarrow \infty}f(z) = L_1$.
This means $\forall \epsilon_1 \ \ \exists N>0$ such that $z>N \implies |f(z) - L_1| < \epsilon_1$.
Then suppose $\lim_{z\rightarrow 0}f(\frac{1}{z}) = L_2$.
This means $\forall \epsilon_{2}\ \ \exists \delta>0$ such that $0<|z|<\delta \implies |f(\frac{1}{z}) - L_2| < \epsilon_2$.
I'm not sure what to do now. Maybe I could have just done a mapping $z\mapsto \frac{1}{z}$ but I'm not sure... | Note that:
$$\forall \epsilon >0 \exists N>0 :\text{ if } |z|>N \text{ then } |f(z)-L|<\epsilon$$
is equivalent to
$$\forall \epsilon >0 \exists N>0 :\text{ if } |z|<1/N \text{ then } |f(1/z)-L|<\epsilon$$
Call $\delta := 1/N$ and you are done. | stackexchange-math | {
"answer_score": 3,
"question_score": 0,
"tags": "complex analysis, limits"
} |
Ways to allow other users to upload images and text
I've decided to make a website for my friend as sort of picture diary and I having trouble figuring out how I can make it so he is able to upload images and some text without having to go into the html for the website and doing it that way i'm looking for simple text editor like when you are typing up a question on here and basically a photo blog.
Thanks for taking the time to read this sorry for the rambling i'm having trouble describing it | **Since you have not yet tried anything i will give you** link try
## Must Read This | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -4,
"tags": "html, image, blogs"
} |
How to set up environment variable for all tests in Eclipse?
Setting up environment variables for hundreds of tests get old very quick. Is there a way to declare an environmental variable globally in Eclipse?
Can this be done in Eclipse? Can this be done outside of Eclipse?
!enter image description here | It seems that the only way to do it is to enable "`Run all tests in the selected project ..`" and set `Environment` variables once there.
If you want to run a single test, and that test requires an environment variable set, it looks like you need to set that environment variable as part of that tests's settings.
!enter image description here | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 12,
"tags": "eclipse, junit"
} |
View Controller loading from storyboard taking too much time
In my application, I am having 5 viewControllers. In which I have 4 web services call. While going from 4th controller to 5th controller, there is no web service, Still taking so much time to load.
What could be the possible possible reasons?
My observation :
1. View controller is coming to viewDidLoad very late.
2. Storyboard should the issue.
3. Once I am removing custom fonts from some labels, it is working fine. | In my case, the **font** assigned to control(s) was wrong.
`ProximaNovaSoft-Semibold` font was assigned to controls, but this font did not exist. The real font was `Proxima Nova Semibold`.
Because `ProximaNovaSoft-Semibold` did not exist, **the system took time to search for this font** causing a delay.
After I corrected the font for some of my controls, it loads fast. | stackexchange-stackoverflow | {
"answer_score": 12,
"question_score": 10,
"tags": "ios, objective c, iphone, ios8"
} |
Replace html text when it changes month to month
I have a calendar that changes month names , and its using an abbreviated Month name , aka Dec , Jan , Feb . I want to change that to full names. Is there a way to combine these functions into one ?
jQuery('#calendar .month_header th').html(function () {
return $(this).html().replace('Oct', 'OCTOBER');
});
jQuery('#calendar .month_header th').html(function () {
return $(this).html().replace('Nov', 'NOVEMBER');
});
jQuery('#calendar .month_header th').html(function () {
return $(this).html().replace('Dec', 'DECEMBER');
}); | You can chain multiple `replace()` together
jQuery('#calendar .month_header th').html(function(i, currHtml) {
return currHtml
.replace('Oct', 'OCTOBER')
.replace('Nov', 'NOVEMBER')
.replace('Dec', 'DECEMBER');
});
For all months, you can use an array with a replace loop:
const months = [
/* add prior months */
{short:'Oct', full:'OCTOBER'},
{short:'Nov', full:'NOVEMBER'},
{short:'Dec', full:'DECEMBER'}
];
jQuery('#calendar .month_header th').html(function(i, currHtml) {
months.forEach(function(e) {
currHtml = currHtml.replace(e.short, e.full);
});
return currHtml;
}); | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "jquery"
} |
When container width is defined in em unit in responsive friendly design?
I am learning about Relative Unit of measurement for responsive design. But i am little bit confused seeing many designers are using em unit in defining their container width. I have also seen while defining media queries,the breaking point is defined in em. what is benefit of using em in layout. I will be thankful to you who can show me real life benefit of em in using in layout. I used em in layout of my design. i was expecting that em will behave like percentage while squeezing browser window but it behaved like pixel. so, why does designers prefer em instead of px ? | This has been already raised in stack overflow.
Go here for it. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "css"
} |
Difference between Travel and Commute
So I am taking some english lessons on grammar and vocabulary and the teacher said that there was a difference between the meaning of travelling and commuting. He did explain it but I can't seem to remember it now and even when I did hear it, couldnt understand it properly. Could someone kindly help me out with this. | **Commuting** is a special kind of traveling. You do it regularly in order to get back and forth to school, to your job, or to your family.
Think of a _commuter train_. Such a train picks passengers up in the morning in the outskirts of the city, has no runs between approximately 10 am and 3 pm, and then starts delivering passengers back to the outskirts again starting around 4 pm.
This is related to the _commutative law of addition_ \-- _a + b = b + a_. _a_ and _b_ trade places! When you commute to work, you just go back and forth between points A and B, over and over again. This is a boring kind of traveling.
When someone says, "I like to travel," they are imagining going to A, B, C, D, E -- and this is not boring! | stackexchange-english | {
"answer_score": 7,
"question_score": 1,
"tags": "vocabulary"
} |
Number of integer solutions of $\frac{1}{x} + \frac{1}{y} = \frac{1}{1000}$
What is the number of integer solutions of: $$\frac{1}{x} + \frac{1}{y} = \frac{1}{1000}$$ How to solve these type of problems if am comfortable of solving $x+y=z$. But how to do if multiplicative inverses are involved? | Assuming you mean integer solutions, you will be able to rewrite your equation as:
$1000(x+y) = xy$
Then rearranging you will be able to write as:
$(x - 1000)(y - 1000) = 1000^2$
So that your solutions for $x-1000$ and $y-1000$ correspond to divisors of $1000^2$. | stackexchange-math | {
"answer_score": 13,
"question_score": 2,
"tags": "algebra precalculus, diophantine equations"
} |
Allure report marking tests and test steps as passed but also indicating result is unknown?
My allure report is marking my test and all steps as passed but the arrow to expand the test steps in the report is marked purple which I understand indicates an unknown result (css classes indicate this).
This only occurs for a few tests (most others have a green arrow for expand) but I can't really see a pattern as they use different types of assertions. Additionally I can't find good information when allure marks a test result as unknown.
Any ideas?
I am using WDIO and the latest allure (7.16.14)
{
get-childitem C:\Docs\* | where {$_.name -eq $line.OldFileName} | Rename-Item -NewName $line.NewFileName | Move-Item -Destination C:\Renamed
} | assuming your csv file looks similar to mine, this worked for me. you can remove my $fileinfo section and un-comment the first line.
#$fileinfo = Import-Csv $extractFile
$fileinfo = @'
oldfilename,newfilename
test1.txt,newtest1.txt
test2.txt,newtest2.txt
'@ | convertfrom-csv
$source = 'c:\docs'
$dest = 'c:\renamed'
foreach($line in $fileinfo) {
Get-ChildItem $source -Filter $line.OldFileName | % {
Move-Item $_.FullName -Destination $(Join-Path $dest $line.NewFileName)
}
}
not tested this part, but you may be able to shorten the main line like so:
Get-ChildItem $source -Filter $line.OldFileName | Move-Item -Destination $(Join-Path $dest $line.NewFileName) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "csv, powershell, foreach"
} |
Dynamically change the top margin of a div based height of another div
Trying to use the code learned here
to update the top-margin of a fixed position div like so:
jQuery(document).ready(function ($) {
var sw = $(".snw-button-outer-wrapper");
var hw = $(".header-wrapper");
sw.css("margin-top", hw.outerHeight());
});
but the top margin does not update upon change in the outerheight of the header-wrapper div, only once upon initialization. Obviously, I'm very new to javascript/jQuery; where should I go from here? Any insight at all would be greatly appreciated. | If this code needs to run more than once (initial load) then you'd be better off placing this code to run when you click your search button.
For example, something like:
$(function(){
$('#searchButton').on('click', function(){
var sw = $(".snw-button-outer-wrapper");
var hw = $(".header-wrapper");
sw.css("margin-top", hw.outerHeight());
});
});
**EDIT:**
$('a.searchBtn').on('click', function () {
$('#searchAccordion .accordion-navigation [data-external-trigger]').trigger('click.fndtn.accordion');
var sw = $(".snw-button-outer-wrapper");
var hw = $(".header-wrapper");
sw.css("margin-top", hw.outerHeight());
}); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "jquery, css"
} |
preprocessor,ifdef
When debuging gen_server module, I want to record more details status.
init()->
put(?COMPLETED_COMMANDS,[]),
-ifdef(DEBUG).
put(?DETAIL_STATUS,[]),
-endif.
ok.
The compiler give the following error.
src/benvolio_command_cache.erl:34: syntax error before: ','
src/benvolio_command_cache.erl:36: syntax error before: '.'
src/benvolio_command_cache.erl:33: variable 'DEBUG' is unbound
src/benvolio_command_cache.erl:33: function ifdef/1 undefined
How to add debuging code lines in the `*.erl` file's function? | Macro directives cannot be used inside functions. see 8.5 Flow Control in Macros. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "erlang"
} |
How do I fill in missing values based on the values in other rows?
country <- c("USA","UK","Egypt","Brazil","USA", "UK")
continent <- c("North America","Europe","Africa","South America", NA, NA)
data.frame(country, continent)
How do I automatically impute those last two NAs based on the previous rows since we know that "USA" goes with "North America" and "UK" goes with "Europe"?
I have a large dataset so it would be super helpful if I could find a quick way to do this in dplyr when there are many NAs.
Thank you in advance! | We can do a group by `fill`
library(dplyr)
library(tidyr)
d1 %>%
group_by(country) %>%
fill(continent) %>%
ungroup
-output
# A tibble: 6 x 2
country continent
<chr> <chr>
1 USA North America
2 UK Europe
3 Egypt Africa
4 Brazil South America
5 USA North America
6 UK Europe | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 3,
"tags": "r, dplyr, data wrangling"
} |
TeX logo with LuaTeX and Linux Biolinum O/G
Something is wrong with TeX and LaTeX logos with the font Linux Biolinum O under LuaTeX. I am using MiKTeX 2.9 on Windows. Here is a minimal working example:
\documentclass{minimal}
\usepackage{fontspec}
\newfontfamily\LinBioO{Linux Biolinum O}
\newfontfamily\LinBioG{Linux Biolinum G}
\begin{document}
{\LinBioO\LaTeX}\quad{\LinBioG\LaTeX}
\end{document}
With LuaTeX, I get
!this,
while with XɘTeX you get the correct result:
!result
I did not really try other fonts, except Linux Libertine O and G, which both give a correct alignment of the ‘E’. Is the problem specific to the Linux Biolinum O font? | Though it is a bug in the font, with LuaTeX we can “patch” fonts on the fly, and here is a possible fix:
\directlua {
local function fix_biolinum_xheight(fontdata)
if fontdata.fullname:find("Linux Biolinum") then
if fontdata.characters[string.byte("x")] then
fontdata.parameters.x_height = fontdata.characters[string.byte("x")].height
end
end
end
luatexbase.add_to_callback("luaotfload.patch_font", fix_biolinum_xheight, "mypatch.fix_biolinum_xheight")
}
Adding those lines just after loading `fontspec` should do the trick. | stackexchange-tex | {
"answer_score": 3,
"question_score": 8,
"tags": "fonts, luatex"
} |
How do I defined undefined in JavaScript?
There's this IIFE trick to get around people that have defined `undefined` to something. It goes something like this:
(function (undefined) {
// ...
})();
How do I become this person? Is it even possible to define `undefined` anymore?
If I open my console (FF or Chrome), it will look something like this:
undefined = 5 // => 5
undefined // => undefined | Well I agree - there is no way to define it. And I will try to explain why:
console.log(Object.getOwnPropertyDescriptor(window,"undefined"))
which, of course, prints the following:
Object {value: undefined, writable: false, enumerable: false, configurable: false}
According to MDN if the property `writable` is `false` then you cannot change it. Quite obvious, isn't it?
If you try to change your scope (do it inside of the function), you will be the owner of the scope and perhaps you can define the name as you like. But as far as you are on `window` scope - no way. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript"
} |
Why does my uploaded image not display?
I am using PHP to upload a file. The upload seems to be successful. The $_FILES array is:
Array ( [image] => Array ( [name] => mount.jpg [type] => image/jpeg [tmp_name] => /tmp/php61qYZj [error] => 0 [size] => 28947 ) )
Everything seems to be in order. However, when I do
echo '<img src="' . $_FILES['image']['tmp_name'] . '" />';
it gives me a broken image.
This is so basic, how can it possibly be failing? | `$_FILES['image']['tmp_name']` is a temporary storage and works for only one request. It is not available from web as long as it usually located at OS directory for temporary files `/tmp`. You need to move the file to some permanent storage which is available form web. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "php, image, file upload"
} |
How to know the central time in .NET
I have a console app on the server that I need to run between 8 am to 5pm central time on weekdays. I have a batch file that invokes the console app and scheduled it to run every hour from Mon-Fri for a period of 12 hours. This means that the app would be running 12 hours instead of 10. To overcome this problem...I want to do a simple check in .NET code that checks if the time is between 8 am to 5 pm central time..
How do I know if the time is between 8 am to 5 pm central time in .NET.
Any ideas and suggestions are much appreciated! | var CSTNow = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow,
TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"));
if(CSTNow.TimeOfDay >= new TimeSpan(8,0,0) && CSTNow.TimeOfDay < new TimeSpan(17,0,0))
{
/* Do something */
} | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 1,
"tags": "c# 4.0"
} |
How do we revive an unprotected li ion 18650 battery
How can we confidently revive and recondition an unprotected li ion 18650 battery by aid of common electronic tools and kits | You can't.
When a LiPo batteries voltage drops below a certain point, the lithium begins to precipitate and creates tiny sharp needles of metal. These needles don't dissolve upon recharging. Instead, they remain, and eventually may poke through the plastic separator causing an internal short. Then you get to watch the fireworks.
Plenty people talk about reconditioning or recharging over discharged LiPo. Yes it usually works. It is not safe. You asked how to do it "confidently". A cell that you can not know is safe you cannot be 'confident' in. | stackexchange-electronics | {
"answer_score": 3,
"question_score": 0,
"tags": "batteries, lithium ion, repair"
} |
jQuery UI Slider Steps
I have a jquery UI slider and I have noticed that if the difference between max and min value is not an exact multiple of step option the slider doesn't works correctly.
For example: min: 6900 max: 79900 step: 1500
When I move the max cursor, the maximum reachable value is 78900 ((78900-6900)/15=48), the next would be 80400.
How can I achieve the max value (79900)?
Thanks | You could set your max value to a multiple of step:
var range = Math.floor((max - min) / step) + 1;
var max_calc = min + range * step;
then in slide handler limit the values to original max value:
slide: function(event, ui) {
var v1 = Math.min(ui.values[0], max);
var v2 = Math.min(ui.values[1], max);
$("#slider-price").slider("values", 0, v1);
$("#slider-price").slider("values", 1, v2);
$("#amount").val("$" + v1 + " - $" + v2);
}
Your fiddle adapted accordingly: < | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "jquery, jquery ui, jquery ui slider"
} |
Why is $Spec \ k$ final in category of $k$ schemes?
I am working on an exercise trying to show that $Spec \ k$ is final in category of $k$ schemes. I am stuck and I would appreciate any assistance. Thank you!
PS The definition I have for $k$ scheme is that it is a morphism of the form $X \rightarrow Spec \ k$. And then I know from the exercise I did that $X \rightarrow Spec \ A$ are in natural bijection with ring morphisms $A \rightarrow \Gamma (X, O_X)$.
So I figured if I have a $k$ scheme, then it follows that there exists a corresponding ring morphism $k \rightarrow \Gamma (X, O_X)$. I guess I was wondering how this is unique. | A $k$-scheme is a scheme $X$ together with a morphism $X \to \operatorname{Spec} k$. A _morphism_ of $k$-schemes is a morphism $\varphi : X \to Y$ of schemes such that the diagram $$\begin{array}{c} X & \xrightarrow{\varphi} & Y \\\ \downarrow & & \downarrow \\\ \operatorname{Spec} k & = & \operatorname{Spec} k \end{array}$$ commutes. In particular, not every morphism $\varphi : X \to Y$ of schemes is a morphism of $k$-schemes. This appears to be the sticking point for you.
(This is just an unpacking of what Qiaochu Yuan mentioned in the comments.) | stackexchange-math | {
"answer_score": 3,
"question_score": 4,
"tags": "algebraic geometry"
} |
Firefox snap instead of default deb or flatpak
Decided to install the freshly minted eOS 7 today, super impressed by it all till I tried to install firefox as the Gnome Web simply does not cut it as a daily driver for my browser needs.
I was quite surprised to see it installs the snap version, Did I miss something? I though eOS is a flatpak based distro?
Is this correct? | I believe it has to do with Ubuntu's repo for Firefox forcing snap and not with ElementaryOS. Here's how to add a Firefox repo and install it using apt:
< | stackexchange-elementaryos | {
"answer_score": 2,
"question_score": 0,
"tags": "firefox, camera"
} |
Realworld example of when struct can be used
Can anyone provide a realworld example of when a struct can be used? | A struct can be used when you have a complex return type for a method. i.e. you have to return several values, and they don't really warrant a full class's overhead. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -2,
"tags": "struct"
} |
How to validate the length of nested items in a serializer?
I am using Django Rest Framework 2.4. In an API where I am expecting a dictionary containing two keys:
{
"category" : <category-id>,
"items" : [{"title": <title>}, {"title": <title>}, {"title": <title>}, ....]
}
I have a `ItemListSerializer` that accepts this dictionary. category is a foreign key to the Category model hence we get that data. category has a limit property which
I have a list of items which is handled by a nested ItemSerializer with many set to True
However, I want to check if the total number of items don't cross the limit which is based upon the category ? | Use validate() method on the serializer to check the length and raise `ValidationError` if it doesn't pass:
class YourSerializer(serializers.Serializer):
items = ItemSerializer(many=True)
def validate(self, attrs):
if len(attrs['items']) > YOUR_MAX:
raise serializers.ValidationError("Invalid number of items") | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "python, django, django rest framework"
} |
Java Iterate Bits in Byte Array
How can i iterate bits in a byte array? | You'd have to write your own implementation of `Iterable<Boolean>` which took an array of bytes, and then created `Iterator<Boolean>` values which remembered the current index into the byte array _and_ the current index within the current byte. Then a utility method like this would come in handy:
private static Boolean isBitSet(byte b, int bit)
{
return (b & (1 << bit)) != 0;
}
(where `bit` ranges from 0 to 7). Each time `next()` was called you'd have to increment your bit index within the current byte, and increment the byte index within byte array if you reached "the 9th bit".
It's not really _hard_ \- but a bit of a pain. Let me know if you'd like a sample implementation... | stackexchange-stackoverflow | {
"answer_score": 43,
"question_score": 35,
"tags": "java, arrays, byte, bit, loops"
} |
R shortcut to getting last n entries in a vector
This may be redundant but I could not find a similar question on SO.
Is there a shortcut to getting the last _n_ elements/entries in a vector or array _without using the length_ of the vector in the calculation?
`foo <- 1:23`
> foo
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Let say one wants the last 7 entities, I want to avoid this cumbersome syntax:
> foo[(length(foo)-6):length(foo)]
[1] 17 18 19 20 21 22 23
Python has `foo[-7:]`. Is there something similar in R? Thanks! | You want the `tail` function
foo <- 1:23
tail(foo, 5)
#[1] 19 20 21 22 23
tail(foo, 7)
#[1] 17 18 19 20 21 22 23
x <- 1:3
# If you ask for more than is currently in the vector it just
# returns the vector itself.
tail(x, 5)
#[1] 1 2 3
Along with `head` there are easy ways to grab everything _except_ the last/first n elements of a vector as well.
x <- 1:10
# Grab everything except the first element
tail(x, -1)
#[1] 2 3 4 5 6 7 8 9 10
# Grab everything except the last element
head(x, -1)
#[1] 1 2 3 4 5 6 7 8 9 | stackexchange-stackoverflow | {
"answer_score": 15,
"question_score": 8,
"tags": "arrays, r, vector, indexing"
} |
Where can I get untrusted certificates?
Where can I find certificates signed by a CA which are invalid? I need them to test a program I'm writing - I want to check if it will correctly mark invalid certificates.
I found this site: < but I can't find any way to download the invalid site certificate.
I'm interested mainly in expired and revoked certificates. And (I'm not sure if it is important) I'm looking for certificates for signing things, not for web certificates (but AFAIK they're same). | BadSSL is open-source. You can find some of the certificates in their GitHub repository.
* * *
On Chrome, you can also export the certificate used for a tab.
* Click on "Not Secure", then click on "invalid" under "Certificate".
* See the details tab, then click "export" to save the certificate. | stackexchange-security | {
"answer_score": 5,
"question_score": 4,
"tags": "certificates, certificate authority"
} |
map function python3 to get message length
I was learning the map function, I was trying to get the message length by using map(). my code is
messages['length'] = messages['message'].map(lambda text: len(text))
But I am not sure since I read the map ducument map(functions, list) The code above, should I include the list?
Thanks guys | `map()` is a function, and not a method. That means `some_object.map(some_function)` isn't valid syntax.
The proper call would be:
messages['length'] = map(len, messages['message']) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "python 3.x"
} |
Function that maps the set of all angles in 360 rotation to the set of all 2D directions?
I am trying to think about a function that maps a 360 rotation to every direction in 2D space.
$0^{\circ} \to (0,1) \\\ \vdots \\\ 90^{\circ} \to (1,0) \\\ \vdots$
Thank you in advance. | $$ \theta \mapsto (\cos{\theta},\sin{\theta}) $$ | stackexchange-math | {
"answer_score": 3,
"question_score": 0,
"tags": "functions"
} |
Recent change in userid on stackoverflow
I clearly remember my user ID was **1310070** few days back and my profile link was
> <
But recently I observed this link gives me 404 and my profile link has been transferred to
> <
This means my userId has also been changed. Few questions in my mind:
1. Why did the user IDs change? They were supposed to be unique.
2. Is there any way I can see which user IDs changed or did it happen to all users?
I built a chrome extension StackEye - which allows to follow other users/questions. It works on userIds and data is stored in localStorage. Now all the extension users might have followed some users on StackExchange sites and now they won't be getting notification of questions/answers because user IDs have changed or they might be getting wrong data.
What should I do in this case? | You did end up with two profiles that were merged on April 7. There's not much more to say about that except that I'm very certain that they were both yours.
Our login/signup system is a bit convoluted, and it's not uncommon for folks to end up with two profiles once in a while, if they forget what they signed in with once upon a time.
There's nothing else for you to do - just relax, enjoy your profile with the lower userid, and remember to sign in with the same credentials going forward just in case. | stackexchange-meta | {
"answer_score": 4,
"question_score": 6,
"tags": "support, profile page, data explorer, user accounts"
} |
Finding records that overlap a range in Rails
So, I have an `Event` model that has a `starts_at` and a `ends_at` column and I want to find events that take place in a range of dates.
I've come up with this `named_scope` (`range` is typically a month):
named_scope :in_range, lambda { |range|
{:conditions => [
'starts_at BETWEEN ? AND ? OR ends_at BETWEEN ? AND ?',
range.first, range.last, range.first, range.last]} }
Which works as expected.
**But** if an event starts the month before **and** ends the month after the range it won't show. Is there any way to find those events in a proper way? | There are four cases:
Start End
1. |-----|
2. |------|
3. |-------------|
4. |------|
Your named_scope only gets cases 1,2 and 4. So you just need need to add:
named_scope :in_range, lambda { |range|
{:conditions => [
'(starts_at BETWEEN ? AND ? OR ends_at BETWEEN ? AND ?) OR (starts_at <= ? AND ends_at >= ?)',
range.first, range.last, range.first, range.last, range.first, range.last
]}
} | stackexchange-stackoverflow | {
"answer_score": 23,
"question_score": 14,
"tags": "ruby on rails, ruby, activerecord"
} |
How to style target="_blank" anchors?
I have been looking for a way to change the css of links all over my site that have a target:_blank; Please note that I can only do this in css and not js. Thank you.
Example:
<style>
a{ color : blue }
a:[target=_blank]{ color : green}
</style>
<a href="someplace.html">link1</a>
<a href="someplace.html" target="_blank">link2</a>
Link1 would be blue and Link2 would be green. | Try fiddle
a[target=_blank]{ color : green}
a{ color : blue }
a[target=_blank]{ color : green}
<a href="someplace.html">link1</a>
<a href="someplace.html" target="_blank">link2</a> | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "css"
} |
Is "sound approach" an accepted phrase?
English is not my first language, and in my language (Bosnian) we write just as we speak ; so from time to time, I encounter phrases which I know I have heard before, but am not sure if I am writing them correctly.
Do you say _sound approach_ to describe an approach to a problem which is logical, makes sense, and is practical?
The reason I ask is that I could not find it in a reliable online reference, and I have a feeling that I am spelling it wrong. | Used as adjective, _sound_ can per the OED mean:
> In full accordance with fact, reason, or good sense; founded on true or well-established grounds; free from error, fallacy, or logical defect; good, strong, valid.
And it is this sense that is operative here. They give four citations that appear especially relevant, albeit not especially recent:
> * C. 1440 Capgrave _Life St. Kath._ ᴠ. 1183 ― Youre counseyll in this is neyther saue ne sounde.
> * 1576 Gascoigne _Steele Gl._ (Arb.) 52 ― And sound advice might ease hir wearie thoughtes.
> * 1596 _Edw. III_ , ɪ. i. 101 ― The soundest counsell I can giue his grace, Is to surrender ere he be constraynd.
> * 1697 Dryden _Æneid_ xɪɪ. 42 ― Sound Advice, proceeding from a heart Sincerely yours.
>
In summary, I should say that your approach is therefore sound. | stackexchange-english | {
"answer_score": 7,
"question_score": 5,
"tags": "meaning, adjectives, word usage, orthography, collocation"
} |
In Highcharts, any way we can get the plotWidth and plotHeight before rendering the chart?
I know that we may find the `plotWidth` and `plotHight` after chart rendering. After rendering a chart:
var someChart = $("someContainer").Highcharts(someChartOptions);
We may find `someChart.plotWidth` and `someChart.plotHeight`.
But seems they are only calculated after the chart is rendered. Are there any way we can find out or predict the plotting area width and height before rendering. | `plotWidth` and `plotHeight` values are calculated dynamically when rendering. If you set `margin`, then those calculations are not done and set values are used instead. Knowing size of a chart and margins you can predict plotWidth and plotHeight before creating the chart.
For chart with set `margin` as `[50, 20, 80, 70]` and chart's container size being 600px x 400px you will get (in pixels):
* `plotHeight` = 270 = 400 - (50 + 80)
* `plotWidth` = 510 = 600 - (20 + 70)
Example: < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript, highcharts, data visualization"
} |
How to resolve conflicts when using git?
I'm trying to rebase...you can read all about my trials here. I'm working on an XCode project and after I've performed a `get rebase master my_branch`, I get messages about conflicts. I'm trying to resolve them. The text files are easy. There are also some XCode config files, that I basically want to keep and don't need any manual resolution.
So...after I've resolved the conflicts in my source files what do I do? Is there a way to mark the files as resolved? Do I commit them to the local repo? Or do I just do a `git rebase --continue`? | You can mark a file as "resolved" by `git add`ing that file. After that, you can do a `git rebase --continue`. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "xcode, git, git rebase"
} |
Best way to find max serial num in MySQL database
I have a MySQL database with a column named ID(VARCHAR 60)
The data of ID is linked by id_num + serial num.
For example, a group data is below
* 367618648+0001
* 367618648+0002
* 51687687+0001
* 51687687+0002
* 51687687+0003
* 51687687+0004
I want to know the best way to find the max "serial num" for an "id_num"? | Use `substring_index()`. The following gets the max for all `id_num`s:
select substring_index(id, '+', 1) as id_num,
max(substring_index(id, '+', -1) + 0) as serial_num
from t
group by id_num; | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "mysql, sql"
} |
WP Plugin Running before jQuery
I'm having problems with jQuery and a plugin, the console error says jQuery is not defined. What I don't understand is it only fails when I load it to the production server, on my local dev installation it worked perfectly.
> ReferenceError: jQuery is not defined.
The plugin code:
add_filter( 'wp_footer', 'enqueue_footer_scripts', 9);
add_filter( 'wp', 'enqueue_styles', 11);
function enqueue_footer_scripts() {
wp_register_script( 'sjs', plugins_url('/js/sjs.js', __FILE__), array('jquery'));
wp_enqueue_script( 'sjs' );
echo "<script>jQuery(document).ready(function ($) { $('p').sJS();});</script>";
}
function enqueue_styles() {
wp_register_style('sjcss', plugins_url('/css/sjs.css', __FILE__), false, '2.1');
wp_enqueue_style('sjcss');
} | Your code doesn't work because of a fundamental ordering problem.
You're hooking into wp_footer. Then you're registering a script and enqueueing it. Finally, you echo some code.
Here's the problem, the act of enqueueing a script does not cause an echo of the script code immediately. Enqueueing does just what it says, it sets the script up to be added to the page output at a later time. So your echo of the script code here is too early.
Specifically, the enqueued scripts for the footer happen in the wp_print_footer_scripts call, which is connected to the wp_footer action with priority 20. So you need to enqueue before then, but print your custom script code after then.
So make a new function. Hook it to the wp_print_footer_scripts action. Then move your echo code into that, but leave the enqueue code where it is. | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "plugin development, theme development, jquery, wp enqueue script"
} |
Unable to rebase git svn repo through cron job
I tried to update git svn repo (git svn rebase) with cron job, but I get this error.
usage: git-cat-file [-t|-s|-e|-p|<type>] <sha1>
error closing pipe: Broken pipe at /usr/local/libexec/git-core//git-svn line 4290
cat-file --batch: command returned error: 129
I've added git path in cron script, seems not helping.
export PATH=$PATH:/usr/local/libexec/git-core/
git svn rebase is working properly when I login with bash. What else should I do to make it run as cron job? | Seems it is still a PATH problem. After I copied exact PATH from bash env, problem solved.
export PATH=$HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/libexec/git-core/ | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "cron, git svn"
} |
Finding the Length of the shortest Accepting path of a NDTM
Let $M$ be a NDTM (non deterministic Turing machine) which decides a certain NP-complete language, say SAT.
$M$ computes any instance $I$ of the NP-complete problem in at most $p(n)$ non deterministic steps ($p$ in a polynomial function, $n$ is the input size). The length of a computation path can be measured as the "rank" of the non deterministic step where $M$ halts. Let call $rank_M(I)$ the rank of the shortest accepting path ($rank_M(I)$ is $p(n)+1$ if $M$ rejects $I$).
Is this problem NP-complete : Given a boolean expression $I$, is it true that $rank_M(I)=k$ ? ($k$ is polynomially bounded in $n$)
Edit --- $rank_M(I)$ has been modified : it defines now the shortest accepting path (instead of just the rank of the step where $M$ halts).
Thank you. | Your problem is $\mathsf{NP}$-complete, and you can find a proof for instance here (I gave a sketch in comments).
A remark: If you consider $\\{\langle M,x,t\rangle : M$ halts on $x$ in $t$ steps $\\}$, then you can only show it is $\mathsf{NP}$-hard. But as you mention that you consider $t$ polynomially bounded (in the sizes of $M$ and $x$, I guess), then your problem belongs to $\mathsf{NP}$. | stackexchange-cstheory | {
"answer_score": 7,
"question_score": 2,
"tags": "cc.complexity theory, complexity classes, sat, counting complexity, turing machines"
} |
Oracle Client for Console screen
I want to install an Oracle Client like SQLDeveloper differing in that it works on Linux shell console, there will not be GUI.
Do you to recommend most usefull one? | SQL*Plus is basically the SQLDeveloper without the GUI.
> SQL*Plus is the most basic Oracle Database utility, with a basic command-line interface, commonly used by users, administrators, and programmers.
Source
Check also here and here for more information. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "linux, oracle"
} |
Recent CS graduate with no social media profiles. Am I suspicious?
I'm a recent university graduate looking for work.
For privacy reasons, I have never registered in any of the social media sites under my _real_ name. I cannot easily be found on Facebook/Twitter/LinkedIn, there are no pictures of me on the Internet. **I really want it to stay this way.**
Now almost everyone I know has profiles in the above networks and a personal site with a link to their GitHub account.
I know prospective employers tend look you up on the Internet and find it strange if you aren't there.
Is my absence in the public space seriously detrimental for my job search (in Canada)? | American by the way here.
No, you are fine. And I don't think most employers look you up on social media; you aren't that interesting. Most companies run a background check to ensure you are suitable to work there. Background checks cover things like criminal background and debt (things you can't hide readily), but could be more in-depth depending on the employer (FBI for example is much more thorough than McDonald's).
If an employer asks for your social media information, it is not a place you want to work as it shows they don't understand personal boundaries and are unprofessional. The could be in the right to ask if you know how to use Facebook or Twitter if it is relevant to the position, but to ask to see your account would be a privacy invasion. | stackexchange-workplace | {
"answer_score": 67,
"question_score": 44,
"tags": "recruitment, human resources, social media"
} |
Firefox WebExtensions vs Add-on SDK
I've been trying to figure out the difference for hours and have drawn no conclusions.
Are both methods used to develop add-ons? Are they independent or connected development methods?
Thank you for any clarification. | Moved to solution:
This page is just a draft, so just use it as a pointer -
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "firefox, firefox addon, firefox addon sdk, firefox addon webextensions"
} |
Speeding up temp table joins in SQL Server
I have 2 temp tables #temp1 and #temp. Both have a key and date columns. Both have around 25k rows. And I'm left joining them on the basis of the key and date which are unique on all rows. It's taking around 4 minutes for this join to complete. Is there any way to speed it up or any alternative methods? | I believe you can create indexes on temporary tables as on any other tables. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 4,
"tags": "sql, sql server, sql server 2005, join, temp tables"
} |
Difference between SurfaceView and GLSurfaceView in Android
Can anyone tell me what the basic difference is between SurfaceView and GLSurfaceView? When should I use SurfaceView, and when should I use GLSurfaceView?
I read some already answered questions on Stack Overflow, but they did not satisfy my queries.
Any help would be appreciated. | A `GLSurfaceView` is a `SurfaceView` that you can render into with OpenGL. Choosing between them is simple:
* If you're familiar with OpenGL and need what it provides, use a `GLSurfaceView`.
* Otherwise, use a `SurfaceView`.
OpenGL is low-level. If you're not already familiar with it, it's an undertaking to learn. If you only need 2D drawing, `SurfaceView` uses the high-level, reasonably high-performance Canvas. It's very easy to work with.
Unless you have a strong reason to use a `GLSurfaceView`, you should use a regular `SurfaceView`. I would suggest that if you don't already know that you need GL, then you probably don't. | stackexchange-stackoverflow | {
"answer_score": 36,
"question_score": 20,
"tags": "android, opengl es, surfaceview"
} |
R getting columns that follow specific pattern
I want to select specific columns from R dataframe and I am using below line and it works fine:
maindata <- rbind(maindata, dat[c('Segment','hWave')])
But then I want to select columns that are names such as `Q2_1`, `Q2_2` up to `Q2_18`. How could I do that effectively? I can type individual column name but that won't be efficient.
The line below gives me an error.
maindata <- rbind(maindata, dat[c('Segment','hWave','Q2_1':'Q2_18')]) | Try:
maindata <- rbind(maindata, dat[c("Segment","hWave",paste("Q2",1:18,sep="_"))]) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "r, dataframe"
} |
Delay with remapped q
I've remapped q to :bp, but to get an instant response, I have to press it twice. Otherwise there's a two second delay. What could be causing this and how can I fix it?
function! NetrwMapping()
noremap <buffer> q :bp<CR>
endfunction | This happens because Vim waits to see if you want to do `q<letter>` to start recording a macro (there are a couple other things too like `q:`). You can use the `tm` option to change the amount it waits(will apply to all maps), or remap it to another unused letter. | stackexchange-vi | {
"answer_score": 4,
"question_score": 1,
"tags": "key bindings, error"
} |
Evaluating the limit of a gamma function
I have the following to start:
$$F(x)=x^{b-a}\frac{\Gamma(x+a+1)}{\Gamma(x+b+1)}$$
And I'm trying to evaluate:
$$\lim_{x\rightarrow\infty}F(x)$$
I have simplified this to yield the same outcome as
$$e^{b-a} \lim_{x\rightarrow\infty}x^{b-a}\frac{(x+a)^{x+a}}{(x+b)^{x+b}}$$
But I am totally stuck from here.
Any input on how to evaluate the initial limit or how to evaluate the limit I have simplified to would be excellent. I know that using Stirling's approximation is useful in finding the limit of the initial problem and that is in fact how I reached my simplification.
Thanks in advance. | We have $$e^{b-a}\lim_{x\rightarrow\infty}x^{b-a}\frac{\left(x+a\right)^{x+a}}{\left(x+b\right)^{x+b}}=e^{b-a}\lim_{x\rightarrow\infty}\frac{\left(x+a\right)^{a}}{x^{a}}\frac{x^{b}}{\left(x+b\right)^{b}}\frac{\left(x+a\right)^{x}}{\left(x+b\right)^{x}}=e^{b-a}\lim_{x\rightarrow\infty}\frac{\left(1+\frac{a}{x}\right)}{\left(1+\frac{b}{x}\right)^{b}}^{a}\left(\frac{x+a}{x+b}\right)^{x}=e^{b-a}\lim_{x\rightarrow\infty}\left(1+\frac{a-b}{x+b}\right)^{x}=e^{b-a}e^{a-b}=1.$$ | stackexchange-math | {
"answer_score": 4,
"question_score": 0,
"tags": "limits, gamma function"
} |
Java Reading a file using readAllLines and saving it into a list
For my studies I have to write a huge program with some other folks and right now I'm trying to read a specific file and save it's content into a list. After this we need to access the list, move it's content around, change stuff, compare it and so on.
Here's what I tried so far, but it gives me the error:
> The method readAllLines(Path, Charset) in the type file is not applicable for the arguments(Path).
public static Collection<Order> readFromFile(String filePath) throws IOException {
Map<String, Order> orderMap = new LinkedHashMap<>();
List<String> lines = Files.readAllLines(Paths.get(filePath));
Thing is, we never really did Java before and I'm real noobish and don't even know what I'm doing there. | The exception you're receiving is because that method you're calling takes two parameters, not one. You're calling it with a path, but the method is expecting a `Path` parameter and a `Charset` (see this for more info). Remember, Google is your best friend when it comes to exceptions like these! Good luck with your project. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "java, file, filepath"
} |
Geometrically reduced algebraic extension of a field
Let $k$ be a field. Let $A$ be a commutative algebra over $k$. We say $A$ is geometrically reduced over $k$ if $A\otimes_k k'$ is reduced for every extension $k'$ of $k$.
Let $K$ be an algebraic extension of $k$. It is well-known that $K$ is geometrically reduced over $k$ if $K$ is separable over $k$. Conversely suppose $K$ is geometrically reduced over $k$. $K$ is separable over $k$? | Let $K_0$ be the separable closure of $k$ in $K$. Let $L$ be any extension of $K_0$. Then $$(K\otimes_{K_0} L) \hookrightarrow (K\otimes_{K_0} L)\otimes_{k} K_0 \simeq K\otimes_k L.$$ So $K\otimes_{K_0} L$ is reduced.
Let $p\ge 0$ be the characteristic of $k$. We can suppose $p>0$ (otherwise any extension is separable). If $K\neq K_0$, there exists $\alpha\in K\setminus K_0$ such that some power $a=\alpha^{p}\in K_0$. Consider $L=K_0[\alpha]\subseteq K$. Then $L\simeq K_0[X]/(X^p-a)$ and $$ K_0[\alpha]\otimes_{K_0} L\simeq K_0[X]/(X^p-a)=K_0[X]/(X-\alpha)^p$$ is not reduced. This is a contradiction because on the other hand $K_0[\alpha]\otimes_{K_0} L\subseteq K\otimes_{K_0} L$ must be reduced. So $K=K_0$. | stackexchange-math | {
"answer_score": 4,
"question_score": 2,
"tags": "commutative algebra"
} |
rails, react-playerとhls.jsを用いてHLS再生の実装をしたい
railsreact/typescriptreact-playerhls.js
videoAmazon S3mp4cloudfront
react-playerhls.js
| `react-player` `hls.js` CDN `hls.js`
`hls.js` Config prop `file.hlsOptions` | stackexchange-ja_stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "javascript, reactjs, typescript, video, hls"
} |
Coffeescript class shares properties
I've detected a very weird behavior in coffeescript.
class Foo
list: []
add: (val)->
@list.push(val)
x = new Foo()
x.add(1)
console.log(x.list.length) // 1
y = new Foo()
y.add(1)
console.log(y.list.length) // 2
So as you see the @list property got shared between the two class instances in a strange way. I've never faced similar issue before, in coffeescript. | Convert it to JavaScript:
var Foo, x, y;
Foo = (function() {
function Foo() {}
Foo.prototype.list = [];
Foo.prototype.add = function(val) {
return this.list.push(val);
};
return Foo;
})();
As you can see, `Foo.prototype.list` is a property of the _prototype_ , not of an instance of your class. There's only one array and it will be shared across all of the instances of your class.
To make `list` an instance variable, add it to the constructor:
class Foo
constructor: ->
@list = []
add: (val)->
@list.push(val) | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "coffeescript"
} |
Where do I find the source for the "script" command in linux
Where do I find the source for the "script" command. I would like to change it from relative time between lines to relative time from start of script?
ie, man script SCRIPT(1) BSD General Commands Manual SCRIPT(1) NAME script - make typescript of terminal session SYNOPSIS script [-a] [-c COMMAND] [-f] [-q] [-t] [file] | Copypasted straight from my man page: <ftp://ftp.kernel.org/pub/linux/utils/util-linux/> | stackexchange-stackoverflow | {
"answer_score": -2,
"question_score": -3,
"tags": "linux"
} |
How to fix a Dask memory error for database table with over a 100 million rows
I'm connecting to a Oracle database with dask.dataframe.read_sql_table to try and bring across some larger tables, some with over 100 million rows and then write them to a s3 Bucket in parquet format. However, I keep running into memory errors even if I try and specify the number of partitions Dask recommends. I've read a bit about dask.distributed but not sure how to use it with dask.dataframe.read_sql_table. I also seem to be running into a KeyError a lot as well. Please follow the link for more information.
Only a column name can be used for the key in a dtype mappings argument
If anyone has any ideas of how to use dask.dataframe.read_sql_table for reading 100 million row tables it would be greatly appreciated.
Thanks | In principle using read_sql_table followed by a to_parquet call should be fine.
Without additional information, like a minimal reproducible example, it's not clear how else we can help. Good luck! | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, memory, dask"
} |
TC358743XBG HDMI to CSI-2 Board
I've got a project in which I have video output from a camera which I can have in either video out or HDMI out. This signal, then, is to be sent to a Raspberry Pi to be used in a computer vision application. The Raspberry Pi can process video through MIPI/CSI-2 or through USB as a standard webcam. I have looked at HDMI to MIPI/CSI-2 conversion boards, and they can run pretty expensive. I think this is because of low demand. At the core of these conversion boards is a TC358743XBG chip from Toshiba.
My question is
a) How feasible is it for me (I have soldering experience) to make my own conversion board (purely from a hardware perspective- I'll worry about drivers later)?
Would it be possible to adapt this project to suit my needs?
b) Might there be a better way? | TC358743 comes with BGA package. So hand soldering will not be possible. This can only be assembled with Re-flow process. | stackexchange-electronics | {
"answer_score": 1,
"question_score": 2,
"tags": "raspberry pi, video, hdmi"
} |
How to change the text in the revision log message?
I would like to change the bottom text, "Provide an explanation of the changes you are making. This will help other authors understand your motivations.", in the revision log message section. See attached screenshot.
!enter image description here
How should I go about changing the text? | Use the following code in a custom module or in your theme's template.php:
/**
* Implements hook_form_FORM_ID_alter().
*/
function YOURMODULE_form_CONTENTTYPE_node_form_alter(&$form, &$form_state, $form_id) {
$form['revision_information']['log']['#description'] = t('Your new instructions.');
}
_Note:_ replace `YOURMODULE` with your module/theme name and `CONTENTTYPE` with machine name of the content type you want to change. | stackexchange-drupal | {
"answer_score": 6,
"question_score": 0,
"tags": "7"
} |
How to change the fontsize of indexname without affecting the table of contents
The following document uses a different font for the indexname, unfortunately it affects the table of contents as well.
\documentclass[10pt]{book}
\usepackage{makeidx}
\makeindex
\renewcommand*{\indexname}{\Huge my index name}
\usepackage{xpatch}
\xpatchcmd\theindex{\indexname}{\makebox[1.0\linewidth]{\indexname}}{}{}
\begin{document}
\tableofcontents
\chapter{First chapter}
\index{hello}
\cleardoublepage
\addcontentsline{toc}{chapter}{\indexname}
\printindex
\end{document} | `\indexname` is also used in the running heads, so changing it directly to include the font is not a good idea. Instead, use a package to update the font changes to your index chapter, like `sectsty`:
' < test.json`
(output)>> string
Is this possible using `jq`? | Use `type`:
jq -r '[1.23,"abc",true,[],{},null][]| type' <<< '""'
number
string
boolean
array
object
null
In your example you could check:
jq '.id|type=="number"' file.json
Or use it in a `select` filter to display those ids which are **not** numbers for example:
jq '.[]|select(id|type=="number"|not)' file.json | stackexchange-stackoverflow | {
"answer_score": 24,
"question_score": 12,
"tags": "json, bash, types, jq"
} |
Efficient method for Laplace regression
I want to calculate numerically the maximum likelihood estimators of $(\beta,\sigma)$ for the linear regression model:
$$y_j = x_j^{\top}\beta + \epsilon_j, $$
where $j=1,\dots,n$, $\beta$ is $p$-dimensional, and $\epsilon_j$ are i.i.d. according to a Laplace distribution with location zero and scale $\sigma$.
Given the differentiability issues with this distribution, I cannot obtain the MLE of $\beta$ by solving the score functions. I need to do this for a number of data sets with large $p$. Is there an efficient method for doing so? | The MLE minimizes
$\min \| X \beta - y\|_{1}$
Unfortunately, there isn't any simple closed form solution to this optimization problem. However, this is a convex optimization problem for which there are many available approaches.
For reasonably small instances (e.g. $n$ on the order of $100,000$ and $p$ is less than say $1,000$), the simplest approach is to use a linear programming library routine to solve the linear programming problem:
$\min \sum_{i=1}^{n} t_{i}$
subject to
$t \geq X\beta-y$
$t \geq y-X\beta$.
For larger instances (e.g. $n$ is in the billions or even larger), you might consider a stochastic subgradient descent method. This is relatively easy to implement in a "big data" environment with hadoop. | stackexchange-stats | {
"answer_score": 6,
"question_score": 5,
"tags": "regression, laplace distribution"
} |
python requests 400 error
Hi I am using python requests module. My code is:
import requests
payload = {'AWSAccessKeyId':'AKIAJHSXAECVML4XJT7NvVLAQ',
'Action':'ListOrders',
'CreatedAfter':'2015-05-31T18%3A30%3A00Z',
'MarketplaceId':'A21TJRUUN4KGV',
'SellerId':'A3AZITEDAVC4SLU02M7',
'SignatureMethod':'HmacSHA256',
'SignatureVersion':2,
'Timestamp':'2015-06-03T10%3A13%3A48Z',
'Version':'2013-09-01'}
response = requests.post(' params=payload)
print response.status_code
_These are Fake credentials_
I get this : 400
What I am i doing wring? | I found this Third party tool called TEMBOO who provides API SDKs for many websites and there is a SKD for Amazon AWS in Python and when i downloaded it and checked the code for ListOrders.py i found these code below which makes it clear that it's expecting date in ISO 8601 date format (i.e. 2012-01-01).
super(ListOrdersInputSet, self)._set_input('AWSSecretKeyId', value)
def set_CreatedAfter(self, value):
"""
Set the value of the CreatedAfter input for this Choreo. ((optional, date) A date used for selecting orders created after (or at) a specified time, in ISO 8601 date format (i.e. 2012-01-01). Defaults to today's date if not provided.) | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "python, python requests, amazon mws"
} |
Move to the new row in datagridview using Enter Key in vb.net
This is my code for pressing Enter Key and moving to the next cell:
Private Sub dvFromAlloc_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dvFromAlloc.CellEndEdit
SendKeys.Send("{up}")
SendKeys.Send("{right}")
End Sub
Private Sub dvFromAlloc_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dvFromAlloc.KeyDown
If e.KeyCode = Keys.Enter Then
SendKeys.Send("{up}")
SendKeys.Send("{right}")
End If
End Sub
This is perfectly working, now what I want is if the user is in the last column, how can I move the cell to the first column of the second row?
Thank you. | You may try this in your `KeyDown` event ..
Private Sub dvFromAlloc_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles dvFromAlloc.KeyDown
If e.KeyCode = Keys.Enter Then
dvFromAlloc.CurrentCell = dvFromAlloc.Rows(dvFromAlloc.CurrentCell.RowIndex + 1).Cells(0)
dtg.Rows(i).Cells(aColumn(x))
End If
End Sub | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "vb.net, datagridview, row, keypress"
} |
Standard bootstrap main menu with dropdown?
When using bootstrap with drupal what is the standard way to create a main menu?
When I add the main menu block to a region it does not display as a bootstrap navbar.
When I try with superfish I can add some classes but for example the active-trail cant be changed on li. | Your "standard" Bootstrap subtheme launches with your "standard" Bootstrap Nav Bar. For most intents and purposes this is the main-menu... links added to the main menu at admin/structure/menu/manage/main-menu appear there ...
Oddly the navbar isn't available to configure from the blocks page as you might expect nevertheless ... there are some navbar options available under admin/appearance/your-bootstrap-subtheme/settings. | stackexchange-drupal | {
"answer_score": 1,
"question_score": 0,
"tags": "routes, navigation"
} |
COUNT and DISTINCT queries in CYPHER causing javaheap memory error
The cypher query:
MATCH (n1:ANIMAL)-[r:COHABITS]-(n2:ANIMAL)
RETURN distinct[id(n1),id(n2)] as tups, count(distinct[id(n1),id(n2)]) AS count
LIMIT 5
Never finishes, i.e. the query keeps running until neo4j encounters a javaheap memory failure. However when I execute:
MATCH (n1:ANIMAL)-[r:COHABITS]-(n2:ANIMAL)
RETURN n1,r,n2
LIMIT 5
I get a fast response.
Is there a reason/workaround for this? | For `distinct` Cypher needs to build up the result set in memory to check if a new result is already present in the set. Without distinct, it just streams the results and only has very little need for heap space.
Depending on the number of `:COHABITS` relationships you need to increase your heap space settings in `neo4j-wrapper.conf` | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "neo4j, cypher"
} |
EditingCommands.ToggleNumbering and EditingCommands.ToggleBullets have different indents
I'm trying to create a very simple rich text editor control based on the richtextbox control and would like Numbers and bullets to be given the same indentation.
Using the togglebullets and togglenumbering commands in EditCommands I get numbers inserted with an indent much larger than bullets. Is there a way to line them up? Or at least give me an explanation as to why this is the case?
Thanks for your help! | found this while searching for a different problem: my numbers are in a different font than the text ;) Nevertheless, I used this for adjusting the margins/indents for the lists - You have to put it somewhere before the flowDocument...
<RichTextBox.Resources>
<Style TargetType="{x:Type List}">
<Setter Property="Margin" Value="0" />
<Setter Property="MarkerOffset" Value="5" />
<Setter Property="Padding" Value="15,0,0,0" />
</Style>
<Style TargetType="{x:Type ListItem}">
<Setter Property="Margin" Value="0" />
</Style>
</RichTextBox.Resources>
Cheers, Stephan | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": ".net, wpf, richtextbox, rtf"
} |
How can I create such a form in Django and what is the name of this type of form?
I'm trying to create a form in Django, part of which is a long list of strings (component names). The user using the form should be able to select one or more components, move them from the left list to the right, and submit these names (in the right list) with the form.
This is also used in the Django administration interface as you can see on my screenshot.
Django admin interface
Unfortunately, I have no idea what this type of form is called. Therefore it is difficult to find a solution on google if you don't have the right search parameters ...;)
If someone even had a snippet of code to create this form, it would be even better. | I just found the answer myself after "adjusting" the search parameters in Google. Before, none of the results matched my question, now I had tried a query "Django forms move several elements from left to right" just for fun. ;) One of the possible solutions was this question here on stackoverflow: "Multiple left to right selection field", which then also contained the answer to my question.
If someone else is looking for this type of form, the element is called "FilteredSelectMultiple-Widget with filter_horizontal on a ManyToManyField". | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "django, forms, django forms"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.