qid
int64
1
74.7M
question
stringlengths
0
70k
date
stringlengths
10
10
metadata
list
response
stringlengths
0
115k
32,630,425
I have the following form: ``` = semantic_form_for @contact, :url => club_contact_path(id: @club.id), :html => {:novalidate => false, :id => 'contact_club_form'} do |f| .sm-12.xl-5 = f.input :club_id, :as => :hidden, :input_html => { :value => @club.id } = f.input :firstname, :required => true = f.input :lastname, :required => true = f.input :email, :required => true = f.input :telephone, :as => :phone, :required => false = f.input :question, :required => true, :as => :text, :input_html => {:rows => 5, :cols => 40} = f.action :submit, :button_html => {:class => 'btn btn-aqua', :value => 'Submit'} ``` Below I have added the `contact_params` method to the controller. This errors out and tells me I have a `Rails::ForbiddenAttributesError`, but I can't seem to figure out why. ``` def contact_params params.require(:contact).permit(:firstname, :lastname, :email, :telephone, :question, :club_id) end ``` My model is the following: ``` class Contact < ActiveRecord::Base belongs_to :club validates_presence_of :firstname, :lastname, :email, :question, :telephone, :club_id end ``` **EDIT: Added action** ``` def contact_club @contact = params[:contact] if Contact.create(@contact) byebug ContactMailer.send_contact_mail_to_club(@contact) render :nothing => true end end ```
2015/09/17
[ "https://Stackoverflow.com/questions/32630425", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4444642/" ]
More of a regular expression: ``` :%s/\(\w\+\):.\+/\1: build_average(:\1),/ ``` Note that this applies to all lines in your file. To only replace in a region, select the region (using `V`) and then use `:s` (which results in `:<,>s/...`). Using more complex regular expressions in VIM can be tricky, because metacharacters are different from "normal" regular expression syntax (you need to write `\+` instead of `+`, but can use `.` without escaping it, for example). I found this guide very handy to refer to the special VIM-syntax of regular expressions: <http://vimregex.com/#pattern>
27,975,199
I am trying to enumerate all paired bluetooth devices with my device. In settings I can view the paired devices, but the following code does not return any items: ``` BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); Set<BluetoothDevice> pairedDeviceSet = bluetoothAdapter.getBondedDevices(); ``` I have seen [this](https://stackoverflow.com/questions/7199482/finding-android-bluetooth-paired-devices) and other posts that use this method, but I cannot seem to get it to work. I have the following permissions in Manifest.xml: ``` <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> ``` Furthermore, if I put one of the paired devices into discovery mode, and scan, then the device comes back as paired. If I check: ``` device.getBondState() == BluetoothDevice.BOND_BONDED ``` from the scan, it returns true. What am I doing wrong or not understanding?
2015/01/15
[ "https://Stackoverflow.com/questions/27975199", "https://Stackoverflow.com", "https://Stackoverflow.com/users/371077/" ]
Your code is completely correct. I have the exact same thing in my app and I never got any complain from any user that this feature does not work. Please check for other parts of your app. Below is the snippet of my app that does the same thing, and I have the same permission as you described. ``` BluetoothAdapter mBtAdapter = BluetoothAdapter.getDefaultAdapter(); Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices(); if (pairedDevices.size() > 0) { findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE); for (BluetoothDevice device : pairedDevices) { mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress()); } } else { mPairedDevicesArrayAdapter.add("No Paired Device."); } ```
24,703
Given a published mathematics article, is there a way to find its tree of subsequent citations starting from the date of publication? Does such a (reverse bibliography) database exist? *I'm at a student in a relatively well-known university with access to virtually every mathematics journal imaginable, but I can't seem to find such a simple and useful tool.* Thanks!
2011/03/02
[ "https://math.stackexchange.com/questions/24703", "https://math.stackexchange.com", "https://math.stackexchange.com/users/2720/" ]
There are several, including the public [CiteSeerX](https://citeseerx.ist.psu.edu/) and [Google Scholar](https://scholar.google.com/) as well as many commercial databases.
56,106,536
I have 2 lists if a list2 value equal to list1 value then I want to add a class to the HTML option with matched values. ```js // var list1 = $('select#workers option').toArray().map(item => item.value); list1 = ["19", "78", "73", "26", "79", "93", "63", "70", "82", "60", "42", "90", "91", "84", "92", "64", "1", "83", "85", "61", "21", "45"]; list2= ["93", "78", "91", "60", "83", "90", "84", "79", "82", "42"]; $.each(list1, function( index, value ) { var list1val = value; $.each(list2, function( index, value ) { var list2val = value; if(list1val==list2val){ // $('select#workers option').addClass('green'); console.log('Add class'); } else{ $('select#workers option').addClass('red'); } }); }); ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <select class="form-control" id="workers" multiple="" size="5"> <option value="19">Administration</option> <option value="78">Alan </option> <option value="73">Allister </option> <option value="26">Andrew </option> <option value="79">Chris </option> <option value="93">Clayton </option> <option value="63">Dale Morcom</option> <option value="70">David </option> <option value="82">Dean </option> <option value="60">Deano </option> <option value="42">Drew </option> <option value="90">Gabriel </option> <option value="91"> Grant</option> <option value="84">Jeremy Beeston</option> <option value="92"> Rolfe</option> <option value="64"> Johnson</option> <option value="1">Luke </option> <option value="83">Matt </option> <option value="85">Michelle </option> <option value="61">Playsafe</option> <option value="21">Squizzy </option> <option value="45">Stuart </option> </select> ``` I want to add a class to the option which have matched values from list 2. but `$('select#workers option').addClass('green');` is adding class to all options.
2019/05/13
[ "https://Stackoverflow.com/questions/56106536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11490991/" ]
`*args` are not called magic variables, but [arbitrary argument lists](https://docs.python.org/3/tutorial/controlflow.html#arbitrary-argument-lists), or `variadic arguments`, and they are used to send arbitrary number of arguments to a function, and they are wrapped in a tuple like the example below ``` In [9]: def f(a,*args): ...: print(a) ...: print(args) ...: In [10]: f(1,2,3,4) 1 (2, 3, 4) ``` So in order to access these variables, you would do what you do for any class instance variable, assign it via `self.args = args` and access them via `self.args` Also note that we use `camel-case` for class names, so the class name changes to `MyClass` and `snake-case` for functions, so the function name changes to `my_func` ``` class MyClass: def __init__(self, name, *args): self.name = name #Assigning variadic arguments using self self.args = args def my_func(self): #Accessing variadic arguments using self for i in self.args: print(i) obj = MyClass('Joe',1,2,3) obj.my_func() ``` The output will be ``` 1 2 3 ```
13,510,464
I'm generating Javadoc for a library that is mainly plain Java, but because one class is generated and I need to add a method to that class (and I can't use inheritance for this), I've created an AspectJ file for it. Naturally, I have to define the new method by prefixing it with the class that it belongs to. Now Javadoc is aborting with the error message: ``` javadoc: error - Illegal package name: "C:\company\project\library\trunk\library\src\main\java\com\company\project\library\classname_extensionname.aj" ``` (names substituted to protect the innocent) Inside the .aj file I have: ``` package com.company.project.library; import com.company.project.library.classname; public aspect classname_extensionname { // various static final variables // various static methods to help the method I'm publicising public String classname.toString() { StringBuffer buffer = new StringBuffer(); buffer.append( /* various bits and pieces */ ); return buffer.toString(); } } ``` (original question erroneously had ".aj" at the end of the line beginning "public aspect") So what is wrong with that? I'm using jdk 1.7\_09 within Spring Tool Suite 3.1.0.RELEASE (Eclipse) P.S. I tried using ajdoc, but that couldn't resolve org.junit, org.slf4j or org.apache.xxx.
2012/11/22
[ "https://Stackoverflow.com/questions/13510464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1844643/" ]
*rune* is an alias for *int32*, and when it comes to encoding, a rune is assumed to have a Unicode character value (code point). So the value `b` in `rune(b)` should be a unicode value. For 0x00 - 0xFF this value is identical to Latin-1, so you don't have to worry about it. Then you need to encode the runes into UTF8. But this encoding is simply done by converting a `[]rune` to `string`. This is an example of your function without using the bytes package: ``` func toUtf8(iso8859_1_buf []byte) string { buf := make([]rune, len(iso8859_1_buf)) for i, b := range iso8859_1_buf { buf[i] = rune(b) } return string(buf) } ```
25,398,788
In my android application activity, I need to arrange 6 buttons as shown below: The buttons are named from 1 to 6. When I try to add each button as background to the buttons, there is a problem that the buttons are overlapping each other. The background png image of the button are triangular in shape. When I add these background png to the buttons, its background image changes, but the borders of the button are still rectangle in shape. So I need the buttons with triangular borders, so that I can place them in a format like the below screenshot. Also I don't which layout suits most for this type pattern. So please do suggest that also.. ![enter image description here](https://i.stack.imgur.com/mHizt.png)
2014/08/20
[ "https://Stackoverflow.com/questions/25398788", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1547124/" ]
Try this for triangle shape: call it as a background for your textview or any. triangle.xml ``` <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <rotate android:fromDegrees="45" android:toDegrees="45" android:pivotX="-40%" android:pivotY="100%" > <shape android:shape="rectangle"> <corners android:radius="15dip" /> <solid android:color="@color/blue" /> </shape> </rotate> </item> </layer-list> ``` //TEXTVIEW CALLING ``` <TextView android:layout_width="@dimen/triangle" android:layout_height="@dimen/triangle" android:rotation="90" android:layout_centerVertical="true" android:background="@drawable/triangle"/> ```
73,555,733
I have pandas column, one sample value looks like this ``` colName1 {'key1': {'key2': {'ke3': {'label': '3 minutes, 16 seconds'}}, 'simpleText': '3:16'}, 'style': 'DEFAULT'} ``` tried this but din't work. ``` df1['XYZ'] = df1['colName1'].apply(lambda x: x['key1']['key2']['simpleText']) ``` How can I retrieve the value of 'simpleText' which equals to 3:16
2022/08/31
[ "https://Stackoverflow.com/questions/73555733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13285387/" ]
Let's try ```py df1['XYZ'] = df1['colName1'].str['key1'].str['simpleText'] ```
37,213,305
i have a Json file where i have saved some Chinese text. when i print it in my pdfkit project this is the result = [![enter image description here](https://i.stack.imgur.com/C7IMQ.png)](https://i.stack.imgur.com/C7IMQ.png) the blue thext is write inside the code and works. the red is get by a Json file and don't works (if i change the json file into normal characters works)
2016/05/13
[ "https://Stackoverflow.com/questions/37213305", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5292219/" ]
You use a [`DateTimeFormat`](http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html) to invoke the [`LocalDate.parse(String, DateTimeFormatter)`](http://joda-time.sourceforge.net/apidocs/org/joda/time/LocalDate.html#parse%28java.lang.String,%20org.joda.time.format.DateTimeFormatter%29) method. Something like, ``` val y = Years.yearsBetween( LocalDate.parse("1988-Jul-21", DateTimeFormat.forPattern("yyyy-MMM-dd")), LocalDate.parse("2016-Dec-18", DateTimeFormat.forPattern("yyyy-MMM-dd"))) ```
58,887,407
I am trying to apply the style to the .lvl-2 to apply an indent to a particular div, but it is getting overriden by something in materialize. Chrome inspector scrennshots below [![the style that overrides](https://i.stack.imgur.com/rPOnF.png)](https://i.stack.imgur.com/rPOnF.png) [![My style in inspector](https://i.stack.imgur.com/UEwBM.png)](https://i.stack.imgur.com/UEwBM.png) I have some HTML (below is excerpt it is in a list) ``` <li key={elements.index}> <div className="row"> <div className="col red s4">f</div> <div className="col blue s8">f</div> </div> <div className="row"> <div className="col red s4 lvl-2">indented</div> <div className="col green s8">f</div> </div> ``` I have some CSS ``` li> .lvl-2 { padding: 0 0 0 10px; } ``` I have also tried being more specific but when I do inspector doesn't see the style at all (which is wierd ) ``` li div> div .lvl-2 { padding: 0 0 0 10px; } ``` The problem is that when I view in the inspector it say that the style is being overwritten by the style below from materialize ``` ul:not(.browser-default) { padding-left: 0; list-style-type: none; } ``` Unfortunately if I just override it it won't work because I want different syles on different li's ``` ul:not(.browser-default) { padding: 0 0 0 10px; list-style-type: none; } ```
2019/11/16
[ "https://Stackoverflow.com/questions/58887407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11345174/" ]
Your CSS was incorrect defined, that's the reason why you don't see your style applied. With your HTML markup: ```html <li key={elements.index}> <div className="row"> <div className="col red s4">f</div> <div className="col blue s8">f</div> </div> <div className="row"> <div className="col red s4 lvl-2">indented</div> <div className="col green s8">f</div> </div> </li> ``` And you want to style `.lvl-2`, the proper one should be : `li .row .lvl-2 {}` , Of course the CSS specificity might not be stronger than the one defined in Material UI, in that case you should add more specificity, something like: `ul li > .row > .col.lvl-2` Please, never ever using "!important" unless you're forced to. In this scenario, it's still quite easy to fix and this will save your future-self. ========= Updated answer on Nov 18th: Let's go through each of your attempt one by one and see what went wrong: 1) ``` li> .lvl-2 { padding: 0 0 0 10px; } ``` This means "get all **the direct child elements** with `.lvl-2` class from `li`", this won't apply because your HTML markup is different. To be more specific, your `lvl-2` element has a wrapper div with class `row`, as of now the direct children from `li` are divs with `.row` class. The `>` stands for "get direct child`. If you want to use direct selector, the selector should be like `li .row > .lvl-2`. 2) ``` li div> div .lvl-2 { padding: 0 0 0 10px; } ``` Once again, the CSS won't run because your HTML markup is different from what your CSS defines. In this case, it means "from any `li` element, select all `divs` children, from each selected `div`, get all direct `div` children, then get all element with `.lvl-2` class from each direct selected `div`.". That might be hard to get the first time, but let me show you the HTML markup which will work in your second attempt. ``` <li> <div class="wrapper"> <div class="child"> <div class="lvl-2"> </div> </div> </div> </li> ``` or even another markup ``` li div div div div.lvl-2 ``` To answer for your question, I think you should read on this article, it will help you easier than my explanation "<https://dev.to/emmawedekind/css-specificity-1kca>" In your scenario, and also from my experience, you should define CSS selectors using class, not with type selectors (e.g like `div, li, button`). * Type selector is the lowest priority in CSS specificity calculation. Use with caution. * In term of project scalability, using type selector means you're forcing the element to be that specific type. E.g: `li span` means only the `<span>` tag, what happens if another developer or an upcoming request change, that tag needs to be replaced with a `div`. So saving your future-self, use with classes like `li .item`, it will both apply either to `<li> <span class="item">` or `<li> <div class="item">`. * It reduces confusion as much as possible, and increase readability CSS code. Reading something `.list .item` always helps a clearer vision than a `li span`. * Most of the time, when your Frontend architect depends on a 3rd party like Bootstrap or Material-UI, they all use class selectors. To override them, the only way is to use class selectors. Hope this helps,
26,534,015
I want to parse the page of my own app at the app store using this code ``` NSError *error = nil; NSURL *url = [NSURL URLWithString:@"https://itunes.apple.com/us/app/id892887222?ls=1&mt=8"]; NSStringEncoding encoding; NSString *webData= [NSString stringWithContentsOfURL:url encoding:encoding error:&error]; ``` webData is nil and `[error localizedDescription]` shows **The file โ€œid892887222โ€ couldnโ€™t be opened.** I suppose this happens because this page is dynamic, created on-the-fly by pulling a database, but how do I get the source code of this page?
2014/10/23
[ "https://Stackoverflow.com/questions/26534015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/316469/" ]
This code gives me the HTML of the page as a NSString object: ``` NSStringEncoding encoding; NSError *error; NSString *contentsOfAppleComAsString = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"https://itunes.apple.com/us/app/id892887222?ls=1&mt=8"] usedEncoding:&encoding error:&error]; if(contentsOfAppleComAsString) { NSLog(@"contents of Apple.com is %@", contentsOfAppleComAsString); } else { NSLog(@"error from trying to get contents of Apple.com is %@", [error localizedDescription]); } ```
14,756
Inspired by [this question](https://judaism.stackexchange.com/questions/14729/am-i-yotzei-bikur-cholim-by-visiting-someones-facebook-page): If one receives a friend request on Facebook, especially from another Jew, is it permissible to reject them? On the one hand, "ื—ื‘ืจื™ื ื›ืœ ื™ืฉืจืืœ" - "All Jews are friends"; but on the other hand, it is non-beneficial to be socially connected to someone you don't know well. --- **This question is [Purim Torah](http://en.wikipedia.org/wiki/Purim_Torah) and is not intended to be taken completely seriously. See the [Purim Torah policy](http://meta.judaism.stackexchange.com/questions/797/).**
2012/02/27
[ "https://judaism.stackexchange.com/questions/14756", "https://judaism.stackexchange.com", "https://judaism.stackexchange.com/users/489/" ]
In Pirkei Avos (1:15), we find clear instructions regarding this matter: > > ื”ื•ื™ ืžืงื‘ืœ ืืช ื›ืœ ื”ืื“ื ื‘ืกืคืจ ืคื ื™ื > > > One should accept all persons on Facebook. > > >
73,596,093
I have a response from an external api that looks like this, if i send in properties like this: ``` { "color": "blue" "type": "dog" } ``` and then if i enter an invalid value of any of these i get a short error message back and a longer description for the property i sent in that was wrong. So lets say i send in ``` { "color": "blue" "type": "banana" } ``` I would get ``` { "problem": "invalid pet", "type": "banana is not a valid type of pet ", "messageProperties": [ "color", "type" ] } ``` Then if i send in ``` { "color": "banana", "type: "dog" } ``` I would get ``` { "problem": "wrong pet color", "color": "banana is not a valid color for a pet", "messageProperties": [ "color", "type" ] } ``` Is there an easy way of handling this? The best solution i found so far feels overly complex. Is there a better way? I'm using .NET 6 ``` public class MyErrorClass { public MyErrorClass(string json) { dynamic data = JsonConvert.DeserializeObject<dynamic>(json); foreach (KeyValuePair<string, JToken> kw in ((JObject)((JContainer)data))) { switch (kw.Key) { case "context": context = (string) kw.Value; break; case "messageProperties": { List<JToken> children = kw.Value.Children().ToList(); messageVariables = children.Values<string>().ToList(); break; } default: error = (string) kw.Value; break; } } } public string context { get; set; } public string error { get; set; } public List<string> messageVariables { get; set; } } ```
2022/09/04
[ "https://Stackoverflow.com/questions/73596093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1394634/" ]
One approach is to use [`JsonExtensionData`](https://www.newtonsoft.com/json/help/html/DeserializeExtensionData.htm). For example: ```cs class Resp { public string Problem { get; set; } public List<string> MessageProperties { get; set; } [JsonIgnore] public Dictionary<string, string> Extras { get; set; } [JsonExtensionData] private IDictionary<string, JToken> _additionalData; [OnDeserialized] private void OnDeserialized(StreamingContext context) { Extras = _additionalData.ToDictionary(d => d.Key, d => d.Value.ToString()); } } ``` Or based on your example: ``` class MyErrorClass { public string Problem { get; set; } public List<string> MessageProperties { get; set; } [JsonIgnore] public string Error { get; set; } [JsonExtensionData] private IDictionary<string, JToken> _additionalData; [OnDeserialized] private void OnDeserialized(StreamingContext context) => Error = _additionalData?.FirstOrDefault().Value?.ToString(); } ```
58,086,172
I am studying a project with LiveDatas on Android Studio (Java). I would like to know if it exists an Android Studio option to see where a particular LiveData is observed in the project, to see all the objects that are been notified and in which method.
2019/09/24
[ "https://Stackoverflow.com/questions/58086172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7674438/" ]
you can access by typing `.observe` into **Find in Path**(cmd + shift + f in Mac): sample live data observing: ``` viewModel.liveData.observe(this, Observer {}) ```
70,394,935
in Flutter how can I use **MediaQuery.of(context).copyWith(textScaleFactor:1.0)** in the following main.dart? I want my app is independent from the various screen size of iOS and Android that the user can set in the settings ``` return MultiProvider( providers: <SingleChildWidget>[ ...providers, ], child: DynamicTheme( defaultBrightness: Brightness.light, data: (Brightness brightness) { if (brightness == Brightness.light) { return themeData(ThemeData.light()); } else { return themeData(ThemeData.dark()); } }, themedWidgetBuilder: (BuildContext context, ThemeData theme) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'MyApp', theme: theme, initialRoute: '/', onGenerateRoute: router.generateRoute, localizationsDelegates: <LocalizationsDelegate<dynamic>>[ GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, EasyLocalization.of(context).delegate, DefaultCupertinoLocalizations.delegate ], supportedLocales: EasyLocalization.of(context).supportedLocales, locale: EasyLocalization.of(context).locale, ); })); ```
2021/12/17
[ "https://Stackoverflow.com/questions/70394935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17619110/" ]
I don't fully understand what you are after, but maybe try something like this: ``` def interact(): while True: try: num = int(input("Please input an integer: ")) if (num % 2) == 0: print ("{0} is even".format(num)) else: print("{0} is odd".format(num)) except: continue if input("Would you like to play again? Y/N: ").lower() == "y": continue else: print("goodbye") break ``` I believe this will give the effect your are after.
750,609
I have my posts public on youtube/googleplus, basically the same entity now, and I can't find a way to see all of the comments I have made. I have been at this for about an hour and feel like an idiot. The best thing I have found so far involved searching based on usernames or content. Normally, I don't complain with a big change to something like youtube. Change is always hard/new, but this interface is infuriatingly obtuse. Is it possible to see ALL of the youtube comments one has made in the past, preferably in chronological order? Or do I just have to wait until they randomly bubble up to the top of my googleplus page? Isn't googleplus/google+ a terrible choice for a name that has to be referenced by typing symbols into search enginges where plus/+ has a different meaning than the word 'plus'? Google is straight slipping with this one.
2014/05/07
[ "https://superuser.com/questions/750609", "https://superuser.com", "https://superuser.com/users/38105/" ]
Try a Google search using this query: **site:youtube.com "your username" inurl:all\_comments** Replace ***your username*** with your YouTube user name. Keep the quotes around it, though. Hope this helps.
1,044,634
I have not updated my Windows system for over 5 months now (Windows 7, 64bit, SP1). This happened by mistake, not on purpose, because Windows update was set to install updates manually with prompting at 3:00 am. Today I tried to install the updates. The following happened in sequence: 1. I started updating a set of files totalling to 400 Mb or so, but I had to cancle after 1 minute, because Windows had to restart for a different reason. 2. After restart, I started update manually again, but it hang on "preparing system for installation". 3. Subsequently I ran the Windows update fix tool: <https://support.microsoft.com/en-gb/gp/windows-update-issues/en> This lead to a partial fix only. The tool ran unfortunately in German. It says "Windows update error" in the second row and the first two items say "not fixed" [![enter image description here](https://i.stack.imgur.com/5dcYI.jpg)](https://i.stack.imgur.com/5dcYI.jpg) 4. I ran the update tool again. Now apparently it was reset, since the earlier runs were not visible anymore. I had to search for updates again, which took a long time (3 hours). Then it stopped with error 80244019. See image. It says in german unknown error 80244019. [![enter image description here](https://i.stack.imgur.com/aQkN1.jpg)](https://i.stack.imgur.com/aQkN1.jpg) 5. I am now trying to run fix: <https://support.microsoft.com/en-us/kb/3102810> right now, but this fix says "Searching for updates on this computer" and does not show progress so far. 6. After installation of this fix, Windows Update found and installed the updates successfully again. 7. However: it only find Windows updates and in fact it says "You receive updates: only for windows" on the start page. In fact I remember unchecking a box for "receiving updates for other Microsoft products" following an advice in this thread: [Windows Update fails with code 80244019](https://superuser.com/questions/965004/windows-update-fails-with-code-80244019). I did this before installing the MSU in step 5. Now, however, I cannot find this check box back in the MSU setting. See image. How can I now configure MSU to find MS Office updates etc.? [![enter image description here](https://i.stack.imgur.com/lZlGy.jpg)](https://i.stack.imgur.com/lZlGy.jpg) Screenshot translation: There are only two check boxes: "Make available recommended updates in the same way as critical updates" and "Allow all users to install updates". An option to to switch on searching for other updates is missing. **Edit**: I found a screenshot on MS Office Help which shows how MSU should look and in fact looked **before** I updated it in step 5. You can see that the checkbox for "other MS products" which is checked in the example disappeared. It is the box I unchecked before step 5. In fact there is another checkbox below the yellow marked area which also disappeared after the MSU update. Very strange. [![enter image description here](https://i.stack.imgur.com/DorbO.jpg)](https://i.stack.imgur.com/DorbO.jpg) Again I need your help; perhaps this is a new topic and would deserve a new thread, but because it occures following the fix of the 80244019 problem, I leave it here. **EDIT 2:** I opened a new thread adressing the new issue described in step 7 only here: [Microsoft update (MSU) does not find updates for other Microsoft products (e.g. Office) after MSU update](https://superuser.com/questions/1044846/microsoft-update-msu-does-not-find-updates-for-other-microsoft-products-e-g)
2016/02/23
[ "https://superuser.com/questions/1044634", "https://superuser.com", "https://superuser.com/users/276596/" ]
To fix the update problem install <https://support.microsoft.com/en-us/kb/3102810>. To fix the missing checkbox problem after the update follow instructions in [Microsoft update (MSU) does not find updates for other Microsoft products (e.g. Office) after MSU update](https://superuser.com/questions/1044846/microsoft-update-msu-does-not-find-updates-for-other-microsoft-products-e-g).
6,333
Can you determine any number of magic squares, that when treated as matrices, can be applied mathematical operations to return a new magic-matrix? **You cannot use the same matrix twice!** *The answer should be given as a mathematical equation using the matrices you find.* > > Magic squares follow the general magic square rules, they contain 1, .., $n \times n$ once, and each row, column, and diagonal sum to 1 number. > > > **Allowed Operations: Add, Subtract, Multiply, Exponention, Logarithms**
2014/12/21
[ "https://puzzling.stackexchange.com/questions/6333", "https://puzzling.stackexchange.com", "https://puzzling.stackexchange.com/users/2383/" ]
It is possible. Fix $n$. Let $M$ denote the set of all $n$-by-$n$ magic squares. $M$ is *really huge* - for $n=6$, we have $|M| \sim 10^{19}$ (see [OEIS](https://oeis.org/A006052)). Consider all $2^{|M|}$ sums of subsets of $M$. Each one is an $n$-by-$n$ matrix whose entries are positive integers which are at most $n^2|M|$. There are $(n^2|M|)^{n^2}$ matrices which fit this description. If $|M|$ is large enough, then $2^{|M|} > (n^2|M|)^{n^2}$. Then by Pigeonhole, two of the sums of subsets are equal. Using this equality, we can express one of the magic squares as a sum/difference of others. What is "large enough"? Taking logs on the inequality, we find that even $|M|=O(n^3)$ is large enough for sufficiently large $n$. For $n=4,5,6$ this works. I cannot find any references to back this up, but I bet there are enough magic squares that this works for all $n\geq4$.
64,161,010
Hello i'm trying to play around with python dictionaries i was able to create a dictionary through user input but i can't find a way to update and delete a dictionary by taking a user input. ``` dictionary = {} ele = int(input("How many element u want? ")) for i in range(ele): inn = input("Key: ") nam = input("Value: ") dictionary.update({inn:nam}) print(dictionary) ``` this is my code to create a dictionary through user input now i need help with deleting and updating a dictionary through user input if possible.
2020/10/01
[ "https://Stackoverflow.com/questions/64161010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7545914/" ]
``` mov eax, nvalue cmp eax, 0 je case0 cmp eax, 1 je case1 cmp eax, 2 je case2 cmp eax, 3 je case3 case0: ``` What this code does is 1. Load the address of `nvalue` into `eax`. 2. Compare this address with 0, 1, 2 and 3. 3. If the comparison with 1, 2 or 3 succeeds, jump away to corresponding labels. 4. Otherwise, jump or fall through to `case0`. What you actually want, first of all, is to read the *value* of `nvalue` into `eax`. And this is done by ``` mov eax, [nvalue] ``` if you had `nvalue` defined with `dd`. If you leave it as it's now, with `dw`, then the loading could be like ``` movzx eax, word [nvalue] ``` And the second point, you may want to add a jump away before the `case0` label, if you don't want to fall through to it when all comparisons fail. Alternatively place the block where you print the *defaultMsg*, between `je case3` ... `case0:`. This way you shave off the extra `jmp`.
65,754,355
Accessing vector elements using 0/1 indexing. ============================================= ``` t <- c("Sun","Mon","Tue","Wed","Thurs","Fri","Sat") y <- t[c(0,0,0,0,0,0,1)] print(y) [1] "Sun" ``` Could not follow why answer is Sunday rather than Saturday. All elements have been coded 0 whilst the 7th is coded 1 hence I expected the 7th day of the week Saturday to be the answer Similarly Adjusting the indexing as below ``` y <- t[c(1,1,1,1,1,1,1)] print(y) [1] "Sun" "Sun" "Sun" "Sun" "Sun" "Sun" "Sun" ``` Answer continues to be Sun. Could someone elaborate the logic for me.
2021/01/16
[ "https://Stackoverflow.com/questions/65754355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15020663/" ]
When you are using numeric indexing, the indices correspond to the positions of elements in the vector. You will see that ``` > t[0] character(0) > t[1] [1] "Sun" > t[c(0, 1)] [1] "Sun" ``` From you post, it seems you want to use index as a mask. In that case, you may need to use boolean values for indexing, which act like a switch, e.g., "on" and "off", to decide if the element in place should be selected, e.g., ``` > t[c(0, 0, 1, 0, 0, 0, 1) > 0] [1] "Tue" "Sat" ``` since ``` > c(0, 0, 1, 0, 0, 0, 1) > 0 [1] FALSE FALSE TRUE FALSE FALSE FALSE TRUE ```
19,239,991
I'm trying to change part of line in txt file. It is working, but if the line in the file contains special characters like ?!( its not working What is wrong? ``` import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; public class nomarks { public static void main(String[] args) { FileInputStream fstream; try { fstream = new FileInputStream("readme.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(fstream)); String oldText = "i have !? in my text"; String textToChange = "cant solve the problem"; String line; String holeFile = ""; while ((line = br.readLine()) !=null) { holeFile += line + "\r\n"; } br.close(); FileWriter writer = new FileWriter("readme.txt"); String newtext = holeFile.replaceAll(oldText, textToChange); writer.write(newtext); writer.close(); } catch (IOException e) { e.printStackTrace(); } } } ```
2013/10/08
[ "https://Stackoverflow.com/questions/19239991", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2780927/" ]
Use `replace` in your case: ``` String newtext = holeFile.replace(oldText, textToChange); ``` `replaceAll` uses `regexp` (and you have question mark in your string), that's why you can have a problem. See docs [here](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#replace%28java.lang.CharSequence,%20java.lang.CharSequence%29),
58,272,405
I would like to have one YAML file that could serve to both create virtual environments and (most importantly) as a base for installing packages by conda into the global env. I am trying: ``` conda install --file ENV.yaml ``` But it is not working since conda expects `pip`-like format of the requirements. What command should I execute to install packages from my YAML file globally?
2019/10/07
[ "https://Stackoverflow.com/questions/58272405", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2340598/" ]
You want the `conda-env` command instead, specifically ``` conda env update -n my_env --file ENV.yaml ``` Read the `conda env update --help` for details. If you wish to install this in the **base** env, then you would use ``` conda env update -n base --file ENV.yaml ``` Note that the **base** env isn't technically "global", but rather just the default env as well as where the `conda` Python package lives. All envs are isolated unless you are either [using the `--stack` flag during activation](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#nested-activation) to override the isolation or have - [contra recommended practice](https://docs.conda.io/projects/conda/en/latest/release-notes.html#recommended-change-to-enable-conda-in-your-shell) - manually manipulated `PATH` to include an env.
26,282,239
I'm trying to capture all DOM events on a page. This is the source code I've come up with to do so. It requires jQuery. Is there a better implementation out there? See any problems with my implementation? // required jQuery ``` $('*').each(function () { var ignore = [ 'mousemove', 'mouseover', 'mouseout', 'mouseenter', 'mouseleave' ]; for (var key in this) { if (key.substring(0, 2) === 'on') { $(this).on(key.substr(2), function (event) { var eventName = event.type, tag = this.tagName.toLowerCase(), id = this.id ? ('#' + this.id) : ''; if (ignore.indexOf(eventName) === -1) { console.log(tag + id + ' ' + eventName); } }); } } }); ```
2014/10/09
[ "https://Stackoverflow.com/questions/26282239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11574/" ]
Maybe something like this: ``` function doSomething() { console.log('yay'); } var eventName, prefix; for (var key in document) { prefix = key.substr(0, 2); if (prefix === "on") { eventName = key.substr(2); document.addEventListener(eventName, doSomething, true); } } ``` It doesn't require jQuery and adds the listeners in capture mode, which means that if propagation is stopped the event will be triggered anyway. Of course you can add filtering if you like. [Fiddle](http://jsfiddle.net/k0f7cdmy/1/)
123,388
[Exactly 1 in 3 SAT ($X3SAT$)](https://en.wikipedia.org/wiki/Boolean_satisfiability_problem#Exactly-1_3-satisfiability) is a variation of the Boolean Satisfiabilty problem. Given an instance of clauses where each clause has three literals, is there a set of literals such that each clause contains exactly one literal from the set. $X3SAT$ is NP-Complete even when the instance is monotone and linear. Monotone means all literals are positive. Linear means no two clauses share more than one variable in common. The algorithm I describe is basically [Davis, Putnam, Logeman, Loveland ($DPLL$)](https://en.wikipedia.org/wiki/DPLL_algorithm) with fixed variable order and without unit clause propogation or pure literal elimination. The algorithm also has a simple [Conflict Driven Clause Learning ($CDCL$)](https://en.wikipedia.org/wiki/Conflict-driven_clause_learning) procedure. This $CDCL$ procedure is key to the proof. Order the literals in each clause lexicographically. Then, order the clauses lexicographically. Reorder the literals based on the first clause the literal appears in. This instance has $n=13$ variables and $m=10$ clauses. The clauses are in lexicographical order: $\quad(a,c,k)(a,i,l)(b,j,m)(c,d,e)(c,f,g)(e,g,k)(e,h,l)(f,k,l)(g,j,l)(i,k,m)$ The order the literals first appear in a clause: $\quad a,c,k,i,l,b,j,m,d,e,f,g,k,h,l,j,i,m$ Algorithm description: 1) Choose the lowest order clause that has not been satisfied. Choose the lowest order unset literal in this clause and set it to true. 2) Process all clauses containing this true literal and set any unset literals in these clauses to false. Keep a list of the literals set to false by this true literal. 3) Reduce any learned clauses. If there are any unit learned clause that haven't already been listed, add the inverse of these unit clauses to the list of literals set to false on step 2. 4) They only way a conflict can occur is when all literals in a clause are set to false. If there are no such clauses go to step 1. Else, find the lowest order clause with all literals set to false. Determine which true literals forced the literals in this clause to be false. Create a disjunction of the inverses of these true literals. Note, this learned clause won't have more than three literals. 5) Add the new learned clause to the set of learned clauses and restart. If there are unit learned clauses when restarting, assume the inverses of these units clauses are set false. These starting unit learned clauses should be added to the list of literals set to false on the first step. Example: Set $a$ to true in $(a,c,k)$. Literals forced to be false are $c,k,i,l$. Set $b$ to true in $(b,j,m)$. Literals forced to be false are $j,m$. Set $d$ to true in $(c,d,e)$. Literal forced to be false is $e$. Set $f$ to true in $(c,f,g)$. Literal forced to be false is $g$. All the literals in $(e,g,k)$ are false. $k$ was set false when $a$ was set true. $e$ was set false when $d$ was set true. $g$ was set false when $f$ was set true. Create the learned clause $(\bar a \lor \bar d \lor \bar f)$ and restart. Set $a$ to true in $(a,c,k)$. Literals forced to be false are $c,k,i,l$. Set $b$ to true in $(b,j,m)$. Literals forced to be false are $j,m$. Set $d$ to true in $(c,d,e)$. Literal forced to be false are $e,f$. $f$ is set to false because of the learned clause. $(f,k,l)$ is a new conflict. $k$ and $l$ were set false when $a$ was set true. $f$ was set false when $d$ was set true. Create the learned clause $\quad(\bar a \lor \bar d)$. Repeating this process eventually creates the following learned clauses; $\quad(\bar a \lor \bar d \lor \bar f)(\bar a \lor \bar d)(\bar a \lor \bar b)(\bar a \lor \bar j)(\bar a \lor \bar e)(\bar a)(\bar c)(\bar k)$ The learned clauses $(\bar a)(\bar c)(\bar k)$ prove the clause $(a,c,k)$ can't be satisfied. The instance is unsatisfiable. If an instance is unsatisfiable, this algorithm must find a conflict before it processes all $m$ of the clauses. A conflict generates an unique learned clause. There are at most $O(n^3)$ unique learned clauses and each learned clause requires processing fewer than $m$ clauses. This algorithm can determine if a monotone, linear $X3SAT$ instance is unsatisfiable in $O(m \cdot n^3)$ steps. What is wrong with this proof? At first, I wondered if the method for generating learned clauses was sound. Now, I think I can show all the learned clauses can be derived using resolution. An $X3SAT$ instance can be converted to a $2+SAT$ instance using this transformation: $\quad (a,b,c) = (a \lor b \lor c)(\bar a \lor \bar b)(\bar a \lor \bar c)(\bar b \lor \bar c)$ The learned clause $(\bar a \lor \bar d \lor \bar f)$ can be derived from the $X3SAT$ clauses $(a,c,k)(a,i,l)(c,d,e)(c,f,g)(e,g,k)$. Converting to $2+SAT$ gives an expression that includes the clauses $(e \lor g \lor k)(\bar d \lor \bar e)(\bar f \lor \bar g)(\bar a \lor \bar k)$. Resolving these clauses gives $(\bar a \lor \bar d \lor \bar f)$. Transforming the clause $(f,k,l)$ allows us to resolve $(f \lor k \lor l)(\bar a \lor \bar k)(\bar a \lor \bar l)$ to get $(\bar a \lor f)$. Resolving $(\bar a \lor f)$ with $(\bar a \lor \bar d \lor \bar f)$ gives $(\bar a \lor \bar d)$. The resolution derivation can get quite long when numerous learned clauses are involved in the derivation. This $CDCL$ procedure can be easily modified to include unit clause resolution and can be modified to apply to $3SAT$. --- There seems to be some confusion because I combine $X3SAT$ with $3SAT$. To eliminate the confusion, I will show how this algorithm can be used to solve [Monotone 3SAT](http://courses.csail.mit.edu/6.890/fall14/scribe/lec4.pdf) instances. The monotone in monotone $3SAT$ has a different definition than the monotone in monotone $X3SAT$. Monotone $3SAT$ means every clause has all positive literals or all negative literals. I will use "positive clause" for clauses with all positive literals and "negative clause" for clauses with all negative literals. Assume we have a monotone $X3SAT$ instance as above. Convert this instance to monotone $3SAT$ using the following tranformation: $\quad (a,b,c) = (a \lor b \lor c)(\bar a \lor \bar b)(\bar a \lor \bar c)(\bar b \lor \bar c)$ The transfomed instance will have positive 3-clauses and negative 2-clauses. The algorithm above will need minor changes. We only need to order the positive clauses. The first step becomes: 1) Choose the lowest order positive clause. This might be a unit clause. Set the lowest order unassigned variable in this clause to true. The instance is satisfiable if there are no positive clauses. All remaining clauses have at least one negated literal. Assuming all the unset variables are false will satisfy all remaining clauses. The second and third steps above get combined into one step. 2) Reduce the instance using the latest positive decision variable. Propagate any negative unit clauses. Keep a list of all negative unit clause that haven't already been listed. Do not propagate positive unit clauses. The other steps remain the same as above. As before, any conflict can be shown to be caused by no more than three positive decision variables. I removed the section about propagating positive unit clauses. At the moment, I can't show the learned clause created by propagating positive unit clauses can be created using resolution.
2020/03/30
[ "https://cs.stackexchange.com/questions/123388", "https://cs.stackexchange.com", "https://cs.stackexchange.com/users/39998/" ]
The monotone version of X3SAT that your proof is based on has the nice property that setting a literal false in one clause will never cause the negation of that literal to be true in another, which means you can say > > The only way a conflict can occur is when all literals in a clause are set to false. > > > and it will be true because forcing two literals false in one clause will never force their two negations true in another, since there are no negated variables in the formula. The problems come when you start learning clauses. First, you can't just learn a disjunction like $(\bar a \lor \bar d \lor \bar f)$ because that's not a X3SAT clause, it's a 3CNF clause. You'll have to convert this normal 3CNF clause to a set of equivalent X3SAT clauses, e.g. using Schaefer's method. This means more clauses, but it's a polynomial blowup so you're still OK. The second problem is unfortunately a killer for your proof. The learned X3SAT clauses will have negated variables in them, making the formula no longer monotone. With a non-monotone formula you can no longer rely on all-false literals being the only kind of conflict clause; now you must worry about clauses with more than one true literal as they can now be produced by setting two other literals false elsewhere. Your proof has no provision for handling these unsatisfied clauses.
21,103,826
I was trying to compile an application for 32 bit target on x86\_64 ubuntu 12.04 machine. I installed the required packages using ``` sudo apt-get install gcc-multilib g++-multilib libc6-i386 libc6-dev-i386 ``` The first command works generating the 32 bit version. However, the second command errors out ``` 1. g++ -m32 hello.c 2. gcc -m32 hello.c skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc.a when searching for -lgcc /usr/bin/ld: cannot find -lgcc /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libgcc_s.so when searching for -lgcc_s /usr/bin/ld: cannot find -lgcc_s ``` Could anyone explain to me why gcc fails to work. Am I missing some libraries? Thanks! --- ---
2014/01/14
[ "https://Stackoverflow.com/questions/21103826", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1979266/" ]
I upgraded my g++ to 4.8 and g++ -m32 stopped working too. Installing g++-4.8-multilib made -m32 option work with both gcc and g++.
22,535,819
I have two strings timestamp and an UTC offset. ``` "timestamp":"2014-03-18T06:40:40+00:00","utc_offset":"+02:00" ``` I am trying to find a way to use these two to parse and create a UTC date. I am able to parse the timestamp to DateTime, but not find help from the standard DateTime classes to parse the utc\_offset and couldn't add the offset to the timestamp. Without going to String manipulation, is there a standard way to handle this?
2014/03/20
[ "https://Stackoverflow.com/questions/22535819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/402814/" ]
You will have to create a `TimeSpan` object and add it to your `DateTime`. ``` TimeSpan tspan = TimeSpan.Parse("-02:00"); Console.WriteLine(tspan); //This will print -02:00:00 ``` See the following answer on how to convert an offset string ("+02:00") to a `TimeSpan`: [How to convert string offset to timespan in c#](https://stackoverflow.com/questions/18292805/how-to-convert-string-offset-to-timespan-in-c-sharp) **EDIT: Please note that if you have the character `'+'` in your offset string, you will have to remove it before performing `TimeSpan.Parse("offsetString")`. This is the only string manipulation required. A negative offset requires the `'-'` character, but that should be obvious.**
53,182,440
I'm trying to create a helper function that will calculate how many rows are there in a data.frame according parameters. ``` getTotalParkeds <- function(place, weekday, entry_hour){ data <- PARKEDS[ PARKEDS$place == place, PARKEDS$weekday == weekday, PARKEDS$entry_hour == entry_hour ] return(nrow(data)) } ``` Then I'm running this like: ``` getTotalParkeds('MyPlace', 'mon', 1) ``` So it is returning this error: ``` Warning: Error in : Length of logical index vector must be 1 or 11 (the number of columns), not 10000 ``` I'm totally new to R, so I have no idea on what is happening.
2018/11/07
[ "https://Stackoverflow.com/questions/53182440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4515940/" ]
Here's the correction you need for your approach - ``` getTotalParkeds <- function(place, weekday, entry_hour){ data <- PARKEDS[ PARKEDS$place == place & PARKEDS$weekday == weekday & PARKEDS$entry_hour == entry_hour, ] return(nrow(data)) } ```
18,842,088
Recently , I am facing an issue with sequence in Oracle. ``` alter sequence seq_name increment by 100 ``` will give me an error "Invalid sequence name" However, if I changed it to ``` alter sequence "seq_name" increment by 100 ``` It will work perfectly fine. Anyone is able to explain the rational behind this? Thanks Sebastian *ps. I am using rails with oci8 to create my oracle tables.*
2013/09/17
[ "https://Stackoverflow.com/questions/18842088", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2629437/" ]
Your sequence was created with case-sensitive name (using quatation marks), so you can refer to it only with strict name - in quotation marks. If you want to refer to it without such problems just create sequence not using quotation marks. Examples below (with table name): ``` SQL> create table "t1"(c int); Table created. SQL> select * from t1; select * from t1 * ERROR at line 1: ORA-00942: table or view does not exist SQL> select * from "t1"; no rows selected SQL> select * from "T1"; select * from "T1" * ERROR at line 1: ORA-00942: table or view does not exist SQL> create table t2(c int); Table created. SQL> select * from t2; no rows selected SQL> select * from T2; no rows selected SQL> select * from "t2"; select * from "t2" * ERROR at line 1: ORA-00942: table or view does not exist SQL> select * from "T2"; -- name without quatation marks is uppercase by default no rows selected ```
46,276,954
In my project using **MobileVLCKit 3.0.0** for playing media. All types of videos successfully playing on iOS9&10 but on **iOS 11 video audio able to listen but the picture doesn't display and shows the black screen**. Gives below logs: ``` 2017-09-18 18:26:17.640065+0800 DemoPlayer[39923:369260] creating player instance using shared library ================================================================= Main Thread Checker: UI API called on a background thread: -[UIView bounds] PID: 39923, TID: 369593, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 21 Backtrace: 4 DemoPlayer 0x0000000108349895 Open + 405 2017-09-18 18:26:23.490963+0800 DemoPlayer[39923:369593] [reports] Main Thread Checker: UI API called on a background thread: -[UIView bounds] PID: 39923, TID: 369593, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 21 Backtrace: 4 DemoPlayer 0x0000000108349895 Open + 405 ================================================================= Main Thread Checker: UI API called on a background thread: -[UIView initWithFrame:] PID: 39923, TID: 369593, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 21 Backtrace: 4 DemoPlayer 0x0000000108349f3b -[VLCOpenGLES2VideoView initWithFrame:zeroCopy:voutDisplay:] + 91 2017-09-18 18:26:23.875359+0800 DemoPlayer[39923:369593] [reports] Main Thread Checker: UI API called on a background thread: -[UIView initWithFrame:] PID: 39923, TID: 369593, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 21 Backtrace: 4 DemoPlayer 0x0000000108349f3b -[VLCOpenGLES2VideoView initWithFrame:zeroCopy:voutDisplay:] + 91 2017-09-18 18:26:23.959355+0800 DemoPlayer[39923:369593] CoreAnimation: [EAGLContext renderbufferStorage:fromDrawable:] was called from a non-main thread in an implicit transaction! Note that this may be unsafe without an explicit CATransaction or a call to [CATransaction flush]. shader program 1: WARNING: Output of vertex shader 'TexCoord1' not read by fragment shader WARNING: Output of vertex shader 'TexCoord2' not read by fragment shader ``` thanks in advance.
2017/09/18
[ "https://Stackoverflow.com/questions/46276954", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2226399/" ]
Finally, got the solution... Now 'MobileVLCKit-Unstable' version updated into master on Sep 20 with UIKit from a background thread(iOS 11 Video play) issue. Solution1: Add `pod 'MobileVLCKit-unstable', '3.0.0a38'` to podfile and run `pod install` Solution 2: 1. Cloned the repo from the following URL: <http://code.videolan.org/videolan/VLCKit.git> 2. Open terminal, navigate to root directory and execute `./buildMobileVLCKit.sh -f` (Note: It may take 1-2 hours to complete) 3. On successful completion, the `MobileVLCKit.framework` will be generated in VLCKit/build/ folder location. 4. Simply drag it to your project.
237,826
I have the below code that takes the sql data and exports it to xml or csv. The xml is processing at good speed but my csv sometimes takes 1 hour depending on how many data rows it exports. My question is my code effective writing the csv or it can be improved for speed? Has around 40 columns and x rows which can be over 10k. ``` public static void SqlExtract(this string queryStatement, string xFilePath, string fileName) ย ย ย ย ย ย ย  { ย ย ย ย ย ย ย ย ย ย ย  string connectionString = @"Data Source=ipaddress; Initial Catalog=name; User ID=username; Password=password"; ย ย ย ย ย ย ย ย ย ย ย  using (SqlConnection _con = new SqlConnection(connectionString)) ย ย ย ย ย ย ย  ย ย ย ย { ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  using (SqlCommand _cmd = new SqlCommand(queryStatement, _con)) ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  { ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  using (SqlDataAdapter _dap = new SqlDataAdapter(_cmd)) ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  { ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  if (fileName == "item1" || fileName == "item2" || fileName == "item3") ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  { ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  DataSet ds = new DataSet("FItem"); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  _con.Open(); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  ย ย ย ย ย ย ย _dap.Fill(ds); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  _con.Close(); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  FileStream fs = new FileStream(xFilePath, FileMode.Create, FileAccess.Write, FileShare.None); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  StreamWriter writer = new StreamWriter(fs, Encoding.UTF8); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  ds.WriteXml(writer, XmlWriteMode.IgnoreSchema); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  fs.Close(); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  StringWriter sw = new StringWriter(); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  ds.WriteXml(sw, XmlWriteMode.IgnoreSchema); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  string OutputXML = sw.ToString(); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  OutputXML = OutputXML.Replace("Table", "Item"); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  System.IO.File.WriteAllText(xFilePath, OutputXML); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  } ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  else ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  { ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  DataTable table1 = new DataTable("Table1"); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  _con.Open(); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  _dap.Fill(table1); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  _con.Close(); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  string exportCSV = string.Empty; ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  foreach (DataRow row in table1.Rows) ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  { ย ย ย ย ย ย ย ย  ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย int i = 1; ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  foreach (DataColumn column in table1.Columns) ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  { ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  if (row[1].ToString() == "002" && i > 41 || row[1].ToString() == "END" && i > 4) ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  { ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  //do nothing ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  } ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  else ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  { ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  if (i > 1) ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  { ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  exportCSV += ";"; ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  } ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  exportCSV += row[column.ColumnName].ToString(); ย ย ย ย ย ย ย ย ย ย  ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย } ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  i++; ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  } ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  exportCSV += "\r\n"; ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  } ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  //Write CSV ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  File.WriteAllText(xFilePath, exportCSV.ToString()); ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  } ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  } ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย  } ย ย ย ย ย ย ย ย ย ย ย  } ย ย ย ย ย ย ย  } ```
2020/02/24
[ "https://codereview.stackexchange.com/questions/237826", "https://codereview.stackexchange.com", "https://codereview.stackexchange.com/users/135180/" ]
Your biggest problem targeting performance is the use of string concatenation by using `exportCSV +=`. Each time such a line will be executed a new string object will be created which takes time. By using a `StringBuilder` like so ``` StringBuilder exportCSV = new StringBuilder(1024); foreach (DataRow row in table1.Rows) { int i = 1; foreach (DataColumn column in table1.Columns) { if (row[1].ToString() == "002" && i > 41 || row[1].ToString() == "END" && i > 4) { //do nothing } else { if (i > 1) { exportCSV.Append(";"); } exportCSV.Append(row[column.ColumnName].ToString()); } i++; } exportCSV.AppendLine(); } ``` the performance will get a lot better. --- The xml-part should be rewritten like so ``` DataSet ds = new DataSet("FItem"); _con.Open(); _dap.Fill(ds); _con.Close(); StringWriter sw = new StringWriter(); ds.WriteXml(sw, XmlWriteMode.IgnoreSchema); string outputXML = sw.ToString().Replace("Table", "Item"); System.IO.File.WriteAllText(xFilePath, OutputXML); ```
49,224,066
I encounter a question on the interview and it was challenging. The topic was based in Decision analysis. The question is that Let's assume we have a tuple; ``` (15, 8, 8, 3) ``` And we want to create all sums of all combinations one by one without repeating and summing same numbers such as this output; ``` [(23, 8, 3), (18, 8, 8), (15, 11, 8)] ``` Another example; ``` (6, 5, 3, 8) ``` And output is: ``` [(11, 3, 8), (9, 5, 8), (14, 5, 3), (6, 8, 8), (6, 13, 3), (6, 5, 11)] ``` Note: Order is flexible. I just really wonder the answer so if anyone is interested in this coding challenge, would help me to improve my mind structure.
2018/03/11
[ "https://Stackoverflow.com/questions/49224066", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9403870/" ]
I think the best way to solve problems like this is to start with the slow, brute-force solution, because then you can visually see where the work is happening. Others disagree and prefer to think through the possible algorithms up-front, but this is my answer, so... Start by ignoring the duplicate number rule, to make things simpler: ``` def sumcombos(tup): for i, x in enumerate(tup): for j, y in enumerate(tup[i+1:], i+1): yield tup[:i] + (x+y,) + tup[i+1:j] + tup[j+1:] ``` You should be able to understand how that works, right? If you explicitly need a `list` of `tuple`s instead of any iterable, wrap it: ``` def sumcomboslist(lst): return list(sumcombos(lst)) ``` Now, the problem is that this is going to output `(23, 8, 3)` twice, and it's also going to output `(15, 16, 3)`. The rule to avoid that is "without repeating and summing same numbers". Interpreting what that means isn't easy,\* but once you do, implementing it is: ``` def sumcombos(lst): for i, x in enumerate(lst): if x in lst[:i]: continue for j, y in enumerate(lst[i+1:], i+1): if y in lst[:j]: continue yield tup[:i] + (x+y,) + tup[i+1:j] + tup[j+1:] ``` So, what's the performance? Well, the inner loop obviously runs `N**2` times, and we've got an `if y in lst[:j]` that takes linear time inside that loop, so it's `N**3`. Now, for our examples, where the largest `N` ever seen is 4, that's fine, but in most real-life situations, cubic algorithms are a problem. If we can use linear space, we can improve that by building a dict up-front mapping each value to its first position (which only takes linear time), and then that `if y in lst[:j]:` becomes the constant-time `if first_positions[y] < j:`. We could then take this memoization farther and cache the results of all sublists, so the inner loop only has to calculate each one the first time. But, once you've done that, you can see what's actually happening (if not, add some `print`s in the middle) and come up with the cleverer algorithm that stores all the pair-sums up-front. --- \* The rule is vague enough that everyone on this page (including me) guessed wrong at what it meant. Thinking of all the ways it can be interpreted and looking over the expected output, I think I can figure out what they must have meant. But in a real-life specification, I would definitely ask them to clarify instead of guessing. And that's even more true for an interview, where getting you to ask for clarification may actually be the point.
42,787,885
I am trying to Set default audio device when two playback devices with same names are connected. **Details:** For single or playback devices with a different name, I can set default using nircmd.exe. But When connecting a USB Speaker in my laptop. In Playback devices it is showing two Speakers with the same name as "Speakers". In this scenario, I'm not able to set default playback device as per my request. It is by default setting first Speaker as Set Default. So can anybody please help me on this. ![Refer image for this Scenario](https://i.stack.imgur.com/sAyfm.jpg)
2017/03/14
[ "https://Stackoverflow.com/questions/42787885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3959119/" ]
Got the Solution. For this we can just refer First Child of Speaker. If it matches with your requirement. Then we'll get the reference of that and perform suitable action.
70,856,007
I'm trying to get the name of an element by way the ID using Revit python wrapper in Revit python shell but I'm having issues. I am typically able to do it using c# but rpw is new to me. I try: `doc.GetElement(2161305).name` or `doc.GetElement(2161305).Name` and I get this error: ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: expected Reference, got int ``` I've looked a bit through the docs and watched some of the videos but haven't found anything that has covered this. I'm sure its easy, I'm just not not finding the answer. Any help / direction is appreciated.
2022/01/25
[ "https://Stackoverflow.com/questions/70856007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5410188/" ]
If both of these websites have a different subdomain, then the browser by default prevents access to another website's cookies for security reasons. You can allow website 2 to get website 1's cookies by adding the following HTTP headers inside website 1: ``` header("Access-Control-Allow-Origin: http://website2.example.com"); header("Access-Control-Allow-Credentials: true"); header("Access-Control-Allow-Methods: GET, POST"); header("Access-Control-Allow-Headers: Content-Type, *"); ``` of course, change `http://website2.example.com` to your website 2's domain.
124,833
Wouldn't recent questions be a better name for the default view? After all, these are not the top questions in any sense other than they were recently edited/answered.
2012/03/07
[ "https://meta.stackexchange.com/questions/124833", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/161100/" ]
That list order the questions basing also on how recently an existing answer has been edited, not only basing on the recently edited, or answered questions. To me "recent questions" would mean the recently asked questions, which is more reductive than the actual list being shown. It makes sense to call the list "top questions" because the list shows a very limited set of questions; the page doesn't even have a pager.
16,115,358
``` class Foo def do_before ... end def do_something ... ``` Is there a way to run `do_before` method before each other method in the `Foo` class (like `do_something`)? It seems that the Sinatra `before` block runs before each HTTP request, which has nothing to do with this class. EDIT: As Michael pointed out in the comments, the only similar functionality that Rails offers is in the Controller. However, both Rails and Sinatra offer something similar to this functionality.
2013/04/20
[ "https://Stackoverflow.com/questions/16115358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/336920/" ]
As [iain](https://stackoverflow.com/users/335847/iain) pointed out in the comments, the example you specify is not specific to Rails/Sinatra. I'm assuming you want before filter like the ones in Rails and this is what Sinatra offers: Sinatra's modular apps: ``` class Foo < Sinatra::Base before do "Do something" end get '/' do "Hello World" end end class Bar < Sinatra::Base before do "Do something else" end get '/' do "Hello World" end end ``` In your `config.rb` file, ``` require 'foo.rb' require 'bar.rb' map '/foo' do run Foo end map '/bar' do run Bar end ``` This is the nearest analogy for a Rails controller in Sinatra. Create more classes like this and you'll have a similar functionality (similar, but may not be the same as you might expect in Rails world).
11,804,133
I have a Jenkins master running on Windows 2008 SP2 set up with Active Directory authentication. The authentication is working fine and normally there is no issue with Login. Occasionally however Jenkins will take 4 to 5 minutes to log a user in. This seems to correlate with the amount of time a user has been inactive (i.e. A user who has not logged in for 2 or 3 weeks will experience extremely slow response when trying to log in). Has anyone else experienced this behavior? I'm really not sure if I should start looking at active directory or Jenkins to troubleshoot this.
2012/08/03
[ "https://Stackoverflow.com/questions/11804133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1146396/" ]
That's why they call it a stream. You put bytes in at one end and TCP guarantees they come out in the same order, none missing or duplicated, at the far end. Anything bigger than a byte is your problem. You have to accumulate enough bytes in a buffer to have your header. Then interpret it and start processing additional bytes. You may have a few left over that start the next header. This is normal behavior. When your application is not receiving data the system will be buffering it for you. It will try to hand off the available data the next time you make a request. On the other side, a large write may travel over connections that do not support an adequate frame size. They will be split as needed and arrive eventually in dribs and drabs.
72,046,094
I have created bottomsheet dialog which work great when it is in portait mode but it shows white backgrund when screen in landscape mode [attaching the error image](https://i.stack.imgur.com/SDn5g.jpg) here is code that i used xml: <https://github.com/windowschares/test/blob/main/bottomsheet.xml> java code : ``` final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this); bottomSheetDialog.setContentView(R.layout.layout_bottomsheet); LinearLayout sheetView =findViewById(R.id.bottom_sheet_id); SwitchCompat disable_pip = bottomSheetDialog.findViewById(R.id.disable_pip); SwitchCompat Enable_fullscreen = bottomSheetDialog.findViewById(R.id.Enable_fullscreen); ImageView external_player = bottomSheetDialog.findViewById(R.id.external_player); bottomSheetDialog.show(); ```
2022/04/28
[ "https://Stackoverflow.com/questions/72046094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18963519/" ]
Instead doing this: ``` //After every rendering ONLY IF `prop` or `state` changes in this case `userDate always change` useEffect(() => { loadUserData() }, [userData]) ``` do this: ``` //Runs ONCE after initial rendering useEffect(() => { loadUserData() }, []) ``` To say why of this you should know the dependencies argument of useEffect(callback, dependencies). Here the difference case of use 1-) **Not provided dependencies:** the side-effect runs after every rendering. **example:** ``` useEffect(() => { // Runs after EVERY rendering }); ``` 2-) **An empty array []:** This is what you should do. The side-effect runs once after the initial rendering. **example:** ``` useEffect(() => { // Runs ONCE after initial rendering }, []); ``` 3-) **Has props or state values:** this is your problem. The side-effect runs only when any depenendecy value changes. **example:** ``` useEffect(() => { // Runs ONCE after initial rendering // and after every rendering ONLY IF `prop` or `state` changes }, [prop, state]); ```
30,698,462
I've been reading other questions like: [sending mail with php & escaping hotmails junk folder](https://stackoverflow.com/questions/250234/sending-mail-with-php-escaping-hotmails-junk-folder) but I don't see where the problem is. I spent some hours setting up everything. I searched for some complete headers and I'm using them. I also set up SPF. The only thing I didn't read/saw in other questions is if hotmail detects the domain name from where the mail was sent: * I have a subdomain to register/login and from that subdomain some mails are sent (verification/change password mails). * The sender email domain is not the subdomain name. * The link provided in the mail sends to the subdomain (where the script is executed) So I'm not sure if that's the reason why hotmail don't "aprove" my mails... Here is the source of the mail (hotmail): ``` x-store-info:4r51+eLowCe79NzwdU2kRyU+pBy2R9QCQ99fuVSCLVNK5Qy3tNqo8vMm9jiywJSb4AMHHDpThtTp0/868JYjtiuwXZKN6huGiKorTLfam2nlYixnKNQu5eplyIAwMuvqi0o7Xe5KjgM= Authentication-Results: hotmail.com; spf=pass (sender IP is 195.154.9.53) [email protected]; dkim=none header.d=corporativelines.com; x-hmca=pass [email protected] X-SID-PRA: [email protected] X-AUTH-Result: PASS X-SID-Result: PASS X-Message-Status: n:n X-Message-Delivery: Vj0xLjE7dXM9MDtsPTA7YT0wO0Q9MjtHRD0yO1NDTD00 X-Message-Info: 11chDOWqoTnmN+ivpBVEjsVU8moIb13En8xpAAkdU6D2Jw9iq84N9UKCWMkB8jcijAo9uBZZpNSfs4N4ZmryrVmAm+9DT92cCh1N4AGxo+UI9VDYmm7c0Ui7BmjOCJdw5s8hvwwVCQJ3zP8VMfuIxZhQ1EirTyAADSXPIzac4tMV3En7hamwIe+Ox0V9g6xITx6WyNuJQtaCfKqkehC89rqbEhbKZ45Z Received: from sd-22000 ([195.154.9.53]) by COL004-MC5F5.hotmail.com with Microsoft SMTPSVC(7.5.7601.23008); Sun, 7 Jun 2015 13:29:16 -0700 Received: (qmail 1503 invoked by uid 7798); 7 Jun 2015 20:26:51 -0000 To: [email protected] Subject: =?UTF-8?B?QWN0aXZhdGUgYWNjb3VudA==?= MIME-Version: 1.0 Content-Type: text/HTML; charset="UTF-8"; Content-Transfer-Encoding: 8bit Date: Sun, 07 Jun 2015 21:26:51 +0100 Message-ID: <[email protected]> From: "AET LTD" <[email protected]> Reply-To: "AET LTD" <[email protected]> X-Mailer: PHP 5.4.41 X-Originating-IP: 195.154.9.53 Return-Path: [email protected] X-OriginalArrivalTime: 07 Jun 2015 20:29:16.0804 (UTC) FILETIME=[A00F6440:01D0A160] <html> <head> <title>Activate account</title> </head> <body> <p>In order to activate your account follow this link: </p> <a href="http://auth.corporativelines.com/activateAccount?code=e9a7fbefc95171ed153739457c4bf78d231a067f&[email protected]">Activate account</a> </body> </html> ``` These are the headers I'm using: ``` $headers = array ( 'MIME-Version: 1.0', 'Content-Type: text/HTML; charset="UTF-8";', 'Content-Transfer-Encoding: 8bit', // quoted-printable for compatibility 'Date: ' . date('r', $_SERVER['REQUEST_TIME']), 'Message-ID: <' . $_SERVER['REQUEST_TIME'] . md5($_SERVER['REQUEST_TIME']) . '@corporativelines.com>', 'From: ' . $from, 'Reply-To: ' . $from, 'Return-Path: ' . $from, 'X-Mailer: PHP ' . phpversion(), 'X-Originating-IP: ' . $_SERVER['SERVER_ADDR'] ); ``` So I don't why hotmail keeps pushing my mails to the junk folder... Maybe a dns problem? I'm not sure about that kind of stuff. Edit: this question have nothing to do with: [PHP mail() function cannot send to hotmail?](https://stackoverflow.com/questions/5797626/php-mail-function-cannot-send-to-hotmail) I (almost) already did the basic configuration to not get flagged as spam, as in other questions says, but the problem persists. So this is a unique question, not a duplicated one.
2015/06/07
[ "https://Stackoverflow.com/questions/30698462", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4067132/" ]
With my cap 3 setup, i have a `config/deploy/production.rb` file where the environment gets set. Are you doing the same for both staging & production? ``` set :stage, :staging server 'example.com', user: 'aaron', roles: %w{web app db} set :rails_env, :staging ``` Need to be sure it sets the proper environment, so the db tasks will know what database to connect to.
4,676,624
I know I can get the color of an element by doing ``` var col = $('a').css('color'); ``` However how do I get the color of that same element when it's hovered? Would sending a *mouseover* event to the element trigger a hover state and if I then read the color would I get the hover color? (this code is running on somebody else's page and I'm looking to get link colors to pass to an iframe so that it can match style with the parent).
2011/01/13
[ "https://Stackoverflow.com/questions/4676624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/573658/" ]
I don't know of any javascript library's that attempt to predict css attributes, so yes, you would have to trigger the event and read it when triggered.
20,324,478
My database has a lot of tables. How can I display all the table names along with the count of column names in each table? myoutput: ``` ------------ table_name count(*) ---------- -------- table_t1 12 x_a 5 Y_k 23 samptabl 0 ```
2013/12/02
[ "https://Stackoverflow.com/questions/20324478", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2849710/" ]
Use `USER_TAB_COLS` view to get the column\_count. ``` SELECT table_name, count(*) column_count FROM user_tab_cols GROUP BY table_name; ```
24,728,772
Consider the following ``` <div class="container"> <div class="grid"> <div class="unit"></div> <div class="unit"></div> <div class="unit"></div> <div class="unit"></div> <div class="unit"></div> <div class="unit"></div> .... </div> </div> ``` Using images, basically what I have is something like this ![enter image description here](https://i.stack.imgur.com/8SL4Y.jpg) As you can see the green blocks and the container are aligned to the left What I want to acheive is something like this. ![enter image description here](https://i.stack.imgur.com/JGnp2.jpg) The `.unit` elements have constant width The `.grid` element should expand with width (so that more `unit` elements would fit into 1 line) while being always centered within `.container`. Any clue how to achieve that using only CSS (and maybe some html wrappers if necessary) ?
2014/07/14
[ "https://Stackoverflow.com/questions/24728772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3548762/" ]
Let me begin by saying that this is an interesting question and my first thought was that flexbox is the way to solve this. I have tried all manner of flexbox arrangements, but this type of solution eluded me. So, below is the solution that uses floating, clearing, and media queries. For this example, I have assumed that each row would have at least 3 and no more than 9 boxes. However, you can extend this solution to handle anywhere between 1 and more than 9 boxes. Here's HTML: ``` <div class="grid"> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> <div></div> </div> ``` Here's a CSS that (1) performs a mini-reset to eliminate browser-applied paddings and margins that may interfere with sizing and (2) formats the `.grid` and its `div` children: ``` * { margin: 0; padding: 0; } .grid { display: table; outline: 1px solid blue; min-width: 330px; margin: 0 auto; } .grid > div { width: 100px; height: 61px; margin: 5px; background-color: teal; float: left; } ``` The `.container` block was eliminated because `.grid` is displayed as a table. The latter is a block that shrinkwraps around its children and `margin: 0 auto` can be applied to center it on the page. The `.grid`'s `min-width` of 330px assures that a minimum of three blocks can fit per line. Whenever floating happens within a `table` element, its margins do not collapse, therefore no explicit clearing of floats (e.g., via clearfix) is necessary. Each `.grid` `div` child takes 110px of horizontal space (100px width + 10px in left and right margins). This number is important for the media queries code that follows below: ``` @media screen and (min-width: 330px) and (max-width: 439px) { .grid > div:nth-of-type(3n + 1) { clear: left; } } @media screen and (min-width: 440px) and (max-width: 549px) { .grid > div:nth-of-type(4n + 1) { clear: left; } } @media screen and (min-width: 550px) and (max-width: 659px) { .grid > div:nth-of-type(5n + 1) { clear: left; } } @media screen and (min-width: 660px) and (max-width: 769px) { .grid > div:nth-of-type(6n + 1) { clear: left; } } @media screen and (min-width: 770px) and (max-width: 879px) { .grid > div:nth-of-type(7n + 1) { clear: left; } } @media screen and (min-width: 880px) and (max-width: 989px) { .grid > div:nth-of-type(8n + 1) { clear: left; } } @media screen and (min-width: 990px) { .grid > div:nth-of-type(9n + 1) { clear: left; } } ``` The rationale behind the code is this: if there is enough space to include only n blocks per line, then every (n + 1)th block's left edge is cleared, which moves the block to a new line. And, here's a fiddle: <http://jsfiddle.net/5hWXw/>. Resize the preview window to see the adjustments.
23,705,634
``` Variable ParameterEstimate slope 1 intercept 2.5 slope 2 intercept 5.6 slope 22.2 intercept 9 ``` Suppose my dataset looks something like this, where the variable names are `Variable` and `ParameterEstimate`. I want to extract just the ParameterEstimates of the slope. However, I can't think of a simple way to do that. How can I go about getting just the slopes, i.e just 1, 2, and 22.2?
2014/05/16
[ "https://Stackoverflow.com/questions/23705634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3391549/" ]
You may want to use a **multiChart** type, which has **two Y axis**. There seems to be no documentation on the nvd3 website, but you can see a live example here: <http://goo.gl/DnLU6S> Also, if you're using AngularJS, check this out: <http://krispo.github.io/angular-nvd3/#/multiChart>
11,673,154
I'm running a cuda kernel function on a multiple GPUs system, with `4` GPUs. I've expected them to be launched concurrently, but they are not. I measure the starting time of each kernel, and the second kernel starts after the first one finishes its execution. So launching the kernel on `4` GPUs is not faster than `1` single GPU. How can I make them work concurrently? This is my code: ``` cudaSetDevice(0); GPU_kernel<<< gridDim, threadsPerBlock >>>(d_result_0, parameterA +(0*rateA), parameterB + (0*rateB)); cudaMemcpyAsync(h_result_0, d_result_0, mem_size_result, cudaMemcpyDeviceToHost); cudaSetDevice(1); GPU_kernel<<< gridDim, threadsPerBlock >>>(d_result_1, parameterA +(1*rateA), parameterB + (1*rateB)); cudaMemcpyAsync(h_result_1, d_result_1, mem_size_result, cudaMemcpyDeviceToHost); cudaSetDevice(2); GPU_kernel<<< gridDim, threadsPerBlock >>>(d_result_2, parameterA +(2*rateA), parameterB + (2*rateB)); cudaMemcpyAsync(h_result_2, d_result_2, mem_size_result, cudaMemcpyDeviceToHost); cudaSetDevice(3); GPU_kernel<<< gridDim, threadsPerBlock >>>(d_result_3, parameterA +(3*rateA), parameterB + (3*rateB)); cudaMemcpyAsync(h_result_3, d_result_3, mem_size_result, cudaMemcpyDeviceToHost); ```
2012/07/26
[ "https://Stackoverflow.com/questions/11673154", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1555209/" ]
I have done some experiments on achieving concurrent execution on a cluster of `4` Kepler K20c GPUs. I have considered `8` test cases, whose corresponding codes along with the profiler timelines are reported below. **Test case #1 - "Breadth-first" approach - synchronous copy** *- Code -* ``` #include "Utilities.cuh" #include "InputOutput.cuh" #define BLOCKSIZE 128 /*******************/ /* KERNEL FUNCTION */ /*******************/ template<class T> __global__ void kernelFunction(T * __restrict__ d_data, const unsigned int NperGPU) { const int tid = threadIdx.x + blockIdx.x * blockDim.x; if (tid < NperGPU) for (int k = 0; k < 1000; k++) d_data[tid] = d_data[tid] * d_data[tid]; } /******************/ /* PLAN STRUCTURE */ /******************/ template<class T> struct plan { T *d_data; }; /*********************/ /* SVD PLAN CREATION */ /*********************/ template<class T> void createPlan(plan<T>& plan, unsigned int NperGPU, unsigned int gpuID) { // --- Device allocation gpuErrchk(cudaSetDevice(gpuID)); gpuErrchk(cudaMalloc(&(plan.d_data), NperGPU * sizeof(T))); } /********/ /* MAIN */ /********/ int main() { const int numGPUs = 4; const int NperGPU = 500000; const int N = NperGPU * numGPUs; plan<double> plan[numGPUs]; for (int k = 0; k < numGPUs; k++) createPlan(plan[k], NperGPU, k); double *inputMatrices = (double *)malloc(N * sizeof(double)); // --- "Breadth-first" approach - no async for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); gpuErrchk(cudaMemcpy(plan[k].d_data, inputMatrices + k * NperGPU, NperGPU * sizeof(double), cudaMemcpyHostToDevice)); } for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); kernelFunction<<<iDivUp(NperGPU, BLOCKSIZE), BLOCKSIZE>>>(plan[k].d_data, NperGPU); } for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); gpuErrchk(cudaMemcpy(inputMatrices + k * NperGPU, plan[k].d_data, NperGPU * sizeof(double), cudaMemcpyDeviceToHost)); } gpuErrchk(cudaDeviceReset()); } ``` *- Profiler timeline -* [![enter image description here](https://i.stack.imgur.com/fPlIo.jpg)](https://i.stack.imgur.com/fPlIo.jpg) As it can be seen, the use of `cudaMemcpy` does not enable achieving concurrency in copies, but concurrency is achieved in kernel execution. **Test case #2 - "Depth-first" approach - synchronous copy** *- Code -* ``` #include "Utilities.cuh" #include "InputOutput.cuh" #define BLOCKSIZE 128 /*******************/ /* KERNEL FUNCTION */ /*******************/ template<class T> __global__ void kernelFunction(T * __restrict__ d_data, const unsigned int NperGPU) { const int tid = threadIdx.x + blockIdx.x * blockDim.x; if (tid < NperGPU) for (int k = 0; k < 1000; k++) d_data[tid] = d_data[tid] * d_data[tid]; } /******************/ /* PLAN STRUCTURE */ /******************/ template<class T> struct plan { T *d_data; }; /*********************/ /* SVD PLAN CREATION */ /*********************/ template<class T> void createPlan(plan<T>& plan, unsigned int NperGPU, unsigned int gpuID) { // --- Device allocation gpuErrchk(cudaSetDevice(gpuID)); gpuErrchk(cudaMalloc(&(plan.d_data), NperGPU * sizeof(T))); } /********/ /* MAIN */ /********/ int main() { const int numGPUs = 4; const int NperGPU = 500000; const int N = NperGPU * numGPUs; plan<double> plan[numGPUs]; for (int k = 0; k < numGPUs; k++) createPlan(plan[k], NperGPU, k); double *inputMatrices = (double *)malloc(N * sizeof(double)); // --- "Depth-first" approach - no async for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); gpuErrchk(cudaMemcpy(plan[k].d_data, inputMatrices + k * NperGPU, NperGPU * sizeof(double), cudaMemcpyHostToDevice)); kernelFunction<<<iDivUp(NperGPU, BLOCKSIZE), BLOCKSIZE>>>(plan[k].d_data, NperGPU); gpuErrchk(cudaMemcpy(inputMatrices + k * NperGPU, plan[k].d_data, NperGPU * sizeof(double), cudaMemcpyDeviceToHost)); } gpuErrchk(cudaDeviceReset()); } ``` *- Profiler timeline -* [![enter image description here](https://i.stack.imgur.com/4eeMn.jpg)](https://i.stack.imgur.com/4eeMn.jpg) This time, concurrency is not achieved neither within memory copies nor within kernel executions. **Test case #3 - "Depth-first" approach - asynchronous copy with streams** *- Code -* ``` #include "Utilities.cuh" #include "InputOutput.cuh" #define BLOCKSIZE 128 /*******************/ /* KERNEL FUNCTION */ /*******************/ template<class T> __global__ void kernelFunction(T * __restrict__ d_data, const unsigned int NperGPU) { const int tid = threadIdx.x + blockIdx.x * blockDim.x; if (tid < NperGPU) for (int k = 0; k < 1000; k++) d_data[tid] = d_data[tid] * d_data[tid]; } /******************/ /* PLAN STRUCTURE */ /******************/ template<class T> struct plan { T *d_data; T *h_data; cudaStream_t stream; }; /*********************/ /* SVD PLAN CREATION */ /*********************/ template<class T> void createPlan(plan<T>& plan, unsigned int NperGPU, unsigned int gpuID) { // --- Device allocation gpuErrchk(cudaSetDevice(gpuID)); gpuErrchk(cudaMalloc(&(plan.d_data), NperGPU * sizeof(T))); gpuErrchk(cudaMallocHost((void **)&plan.h_data, NperGPU * sizeof(T))); gpuErrchk(cudaStreamCreate(&plan.stream)); } /********/ /* MAIN */ /********/ int main() { const int numGPUs = 4; const int NperGPU = 500000; const int N = NperGPU * numGPUs; plan<double> plan[numGPUs]; for (int k = 0; k < numGPUs; k++) createPlan(plan[k], NperGPU, k); // --- "Depth-first" approach - async for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); gpuErrchk(cudaMemcpyAsync(plan[k].d_data, plan[k].h_data, NperGPU * sizeof(double), cudaMemcpyHostToDevice, plan[k].stream)); kernelFunction<<<iDivUp(NperGPU, BLOCKSIZE), BLOCKSIZE, 0, plan[k].stream>>>(plan[k].d_data, NperGPU); gpuErrchk(cudaMemcpyAsync(plan[k].h_data, plan[k].d_data, NperGPU * sizeof(double), cudaMemcpyDeviceToHost, plan[k].stream)); } gpuErrchk(cudaDeviceReset()); } ``` *- Profiler timeline -* [![enter image description here](https://i.stack.imgur.com/989kb.jpg)](https://i.stack.imgur.com/989kb.jpg) Concurrency is achieved, as expected. **Test case #4 - "Depth-first" approach - asynchronous copy within default streams** *- Code -* ``` #include "Utilities.cuh" #include "InputOutput.cuh" #define BLOCKSIZE 128 /*******************/ /* KERNEL FUNCTION */ /*******************/ template<class T> __global__ void kernelFunction(T * __restrict__ d_data, const unsigned int NperGPU) { const int tid = threadIdx.x + blockIdx.x * blockDim.x; if (tid < NperGPU) for (int k = 0; k < 1000; k++) d_data[tid] = d_data[tid] * d_data[tid]; } /******************/ /* PLAN STRUCTURE */ /******************/ template<class T> struct plan { T *d_data; T *h_data; }; /*********************/ /* SVD PLAN CREATION */ /*********************/ template<class T> void createPlan(plan<T>& plan, unsigned int NperGPU, unsigned int gpuID) { // --- Device allocation gpuErrchk(cudaSetDevice(gpuID)); gpuErrchk(cudaMalloc(&(plan.d_data), NperGPU * sizeof(T))); gpuErrchk(cudaMallocHost((void **)&plan.h_data, NperGPU * sizeof(T))); } /********/ /* MAIN */ /********/ int main() { const int numGPUs = 4; const int NperGPU = 500000; const int N = NperGPU * numGPUs; plan<double> plan[numGPUs]; for (int k = 0; k < numGPUs; k++) createPlan(plan[k], NperGPU, k); // --- "Depth-first" approach - no stream for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); gpuErrchk(cudaMemcpyAsync(plan[k].d_data, plan[k].h_data, NperGPU * sizeof(double), cudaMemcpyHostToDevice)); kernelFunction<<<iDivUp(NperGPU, BLOCKSIZE), BLOCKSIZE>>>(plan[k].d_data, NperGPU); gpuErrchk(cudaMemcpyAsync(plan[k].h_data, plan[k].d_data, NperGPU * sizeof(double), cudaMemcpyDeviceToHost)); } gpuErrchk(cudaDeviceReset()); } ``` *- Profiler timeline -* [![enter image description here](https://i.stack.imgur.com/P5J0V.jpg)](https://i.stack.imgur.com/P5J0V.jpg) Despite using the default stream, concurrency is achieved. **Test case #5 - "Depth-first" approach - asynchronous copy within default stream and unique host `cudaMallocHost`ed vector** *- Code -* ``` #include "Utilities.cuh" #include "InputOutput.cuh" #define BLOCKSIZE 128 /*******************/ /* KERNEL FUNCTION */ /*******************/ template<class T> __global__ void kernelFunction(T * __restrict__ d_data, const unsigned int NperGPU) { const int tid = threadIdx.x + blockIdx.x * blockDim.x; if (tid < NperGPU) for (int k = 0; k < 1000; k++) d_data[tid] = d_data[tid] * d_data[tid]; } /******************/ /* PLAN STRUCTURE */ /******************/ template<class T> struct plan { T *d_data; }; /*********************/ /* SVD PLAN CREATION */ /*********************/ template<class T> void createPlan(plan<T>& plan, unsigned int NperGPU, unsigned int gpuID) { // --- Device allocation gpuErrchk(cudaSetDevice(gpuID)); gpuErrchk(cudaMalloc(&(plan.d_data), NperGPU * sizeof(T))); } /********/ /* MAIN */ /********/ int main() { const int numGPUs = 4; const int NperGPU = 500000; const int N = NperGPU * numGPUs; plan<double> plan[numGPUs]; for (int k = 0; k < numGPUs; k++) createPlan(plan[k], NperGPU, k); // --- "Depth-first" approach - no stream double *inputMatrices; gpuErrchk(cudaMallocHost(&inputMatrices, N * sizeof(double))); for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); gpuErrchk(cudaMemcpyAsync(plan[k].d_data, inputMatrices + k * NperGPU, NperGPU * sizeof(double), cudaMemcpyHostToDevice)); kernelFunction<<<iDivUp(NperGPU, BLOCKSIZE), BLOCKSIZE>>>(plan[k].d_data, NperGPU); gpuErrchk(cudaMemcpyAsync(inputMatrices + k * NperGPU, plan[k].d_data, NperGPU * sizeof(double), cudaMemcpyDeviceToHost)); } gpuErrchk(cudaDeviceReset()); } ``` *- Profiler timeline -* [![enter image description here](https://i.stack.imgur.com/Lyms2.jpg)](https://i.stack.imgur.com/Lyms2.jpg) Concurrency is achieved once again. **Test case #6 - "Breadth-first" approach with asynchronous copy with streams** *- Code -* ``` #include "Utilities.cuh" #include "InputOutput.cuh" #define BLOCKSIZE 128 /*******************/ /* KERNEL FUNCTION */ /*******************/ template<class T> __global__ void kernelFunction(T * __restrict__ d_data, const unsigned int NperGPU) { const int tid = threadIdx.x + blockIdx.x * blockDim.x; if (tid < NperGPU) for (int k = 0; k < 1000; k++) d_data[tid] = d_data[tid] * d_data[tid]; } /******************/ /* PLAN STRUCTURE */ /******************/ // --- Async template<class T> struct plan { T *d_data; T *h_data; cudaStream_t stream; }; /*********************/ /* SVD PLAN CREATION */ /*********************/ template<class T> void createPlan(plan<T>& plan, unsigned int NperGPU, unsigned int gpuID) { // --- Device allocation gpuErrchk(cudaSetDevice(gpuID)); gpuErrchk(cudaMalloc(&(plan.d_data), NperGPU * sizeof(T))); gpuErrchk(cudaMallocHost((void **)&plan.h_data, NperGPU * sizeof(T))); gpuErrchk(cudaStreamCreate(&plan.stream)); } /********/ /* MAIN */ /********/ int main() { const int numGPUs = 4; const int NperGPU = 500000; const int N = NperGPU * numGPUs; plan<double> plan[numGPUs]; for (int k = 0; k < numGPUs; k++) createPlan(plan[k], NperGPU, k); // --- "Breadth-first" approach - async for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); gpuErrchk(cudaMemcpyAsync(plan[k].d_data, plan[k].h_data, NperGPU * sizeof(double), cudaMemcpyHostToDevice, plan[k].stream)); } for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); kernelFunction<<<iDivUp(NperGPU, BLOCKSIZE), BLOCKSIZE, 0, plan[k].stream>>>(plan[k].d_data, NperGPU); } for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); gpuErrchk(cudaMemcpyAsync(plan[k].h_data, plan[k].d_data, NperGPU * sizeof(double), cudaMemcpyDeviceToHost, plan[k].stream)); } gpuErrchk(cudaDeviceReset()); } ``` *- Profiler timeline -* [![enter image description here](https://i.stack.imgur.com/Iv0Ti.jpg)](https://i.stack.imgur.com/Iv0Ti.jpg) Concurrency achieved, as in the corresponding "depth-first" approach. **Test case #7 - "Breadth-first" approach - asynchronous copy within default streams** *- Code -* ``` #include "Utilities.cuh" #include "InputOutput.cuh" #define BLOCKSIZE 128 /*******************/ /* KERNEL FUNCTION */ /*******************/ template<class T> __global__ void kernelFunction(T * __restrict__ d_data, const unsigned int NperGPU) { const int tid = threadIdx.x + blockIdx.x * blockDim.x; if (tid < NperGPU) for (int k = 0; k < 1000; k++) d_data[tid] = d_data[tid] * d_data[tid]; } /******************/ /* PLAN STRUCTURE */ /******************/ // --- Async template<class T> struct plan { T *d_data; T *h_data; }; /*********************/ /* SVD PLAN CREATION */ /*********************/ template<class T> void createPlan(plan<T>& plan, unsigned int NperGPU, unsigned int gpuID) { // --- Device allocation gpuErrchk(cudaSetDevice(gpuID)); gpuErrchk(cudaMalloc(&(plan.d_data), NperGPU * sizeof(T))); gpuErrchk(cudaMallocHost((void **)&plan.h_data, NperGPU * sizeof(T))); } /********/ /* MAIN */ /********/ int main() { const int numGPUs = 4; const int NperGPU = 500000; const int N = NperGPU * numGPUs; plan<double> plan[numGPUs]; for (int k = 0; k < numGPUs; k++) createPlan(plan[k], NperGPU, k); // --- "Breadth-first" approach - async for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); gpuErrchk(cudaMemcpyAsync(plan[k].d_data, plan[k].h_data, NperGPU * sizeof(double), cudaMemcpyHostToDevice)); } for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); kernelFunction<<<iDivUp(NperGPU, BLOCKSIZE), BLOCKSIZE>>>(plan[k].d_data, NperGPU); } for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); gpuErrchk(cudaMemcpyAsync(plan[k].h_data, plan[k].d_data, NperGPU * sizeof(double), cudaMemcpyDeviceToHost)); } gpuErrchk(cudaDeviceReset()); } ``` *- Profiler timeline -* [![enter image description here](https://i.stack.imgur.com/zwAJ9.jpg)](https://i.stack.imgur.com/zwAJ9.jpg) Concurrency is achieved, as in the corresponding "depth-first" approach. **Test case #8 - "Breadth-first" approach - asynchronous copy within the default stream and unique host `cudaMallocHost`ed vector** *- Code -* ``` #include "Utilities.cuh" #include "InputOutput.cuh" #define BLOCKSIZE 128 /*******************/ /* KERNEL FUNCTION */ /*******************/ template<class T> __global__ void kernelFunction(T * __restrict__ d_data, const unsigned int NperGPU) { const int tid = threadIdx.x + blockIdx.x * blockDim.x; if (tid < NperGPU) for (int k = 0; k < 1000; k++) d_data[tid] = d_data[tid] * d_data[tid]; } /******************/ /* PLAN STRUCTURE */ /******************/ // --- Async template<class T> struct plan { T *d_data; }; /*********************/ /* SVD PLAN CREATION */ /*********************/ template<class T> void createPlan(plan<T>& plan, unsigned int NperGPU, unsigned int gpuID) { // --- Device allocation gpuErrchk(cudaSetDevice(gpuID)); gpuErrchk(cudaMalloc(&(plan.d_data), NperGPU * sizeof(T))); } /********/ /* MAIN */ /********/ int main() { const int numGPUs = 4; const int NperGPU = 500000; const int N = NperGPU * numGPUs; plan<double> plan[numGPUs]; for (int k = 0; k < numGPUs; k++) createPlan(plan[k], NperGPU, k); // --- "Breadth-first" approach - async double *inputMatrices; gpuErrchk(cudaMallocHost(&inputMatrices, N * sizeof(double))); for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); gpuErrchk(cudaMemcpyAsync(plan[k].d_data, inputMatrices + k * NperGPU, NperGPU * sizeof(double), cudaMemcpyHostToDevice)); } for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); kernelFunction<<<iDivUp(NperGPU, BLOCKSIZE), BLOCKSIZE>>>(plan[k].d_data, NperGPU); } for (int k = 0; k < numGPUs; k++) { gpuErrchk(cudaSetDevice(k)); gpuErrchk(cudaMemcpyAsync(inputMatrices + k * NperGPU, plan[k].d_data, NperGPU * sizeof(double), cudaMemcpyDeviceToHost)); } gpuErrchk(cudaDeviceReset()); } ``` *- Profiler timeline -* [![enter image description here](https://i.stack.imgur.com/cc0Md.jpg)](https://i.stack.imgur.com/cc0Md.jpg) Concurrency is achieved, as in the corresponding "depth-first" approach. **Conclusion** *Using asynchronous copies guarantees concurrent executions, either using purposely created streams or using the default stream.* **Note** *In all the above examples, I have taken care to provide enough work to do the GPUs, either in terms of copies and of computing tasks. Failing to provide enough work to the cluster may prevent observing concurrent executions.*
6,352,132
I have set an image for an `ImageView` using the `setImageResource(R.drawable.icon1)`. Now my requirement is to find out what is the image that is set for an `ImageView` and do some processing. Like ``` if (imageView.getImageResource() == R.drawable.icon1) { //do some processing else if (imageView.getImageResource() == R.drawable.icon2) { //do somethign else else //display ``` So I would like to know if there exists a method(AFAIK, it doesn't) and if it doesn't how to keep a track of what resources have been set for an `ImageView`. Thanks. Sana.
2011/06/15
[ "https://Stackoverflow.com/questions/6352132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/402637/" ]
You're assuming that because you put an integer in, you are able to get an integer back out, and that's not how `setImageResource()` works. See [ImageView#setImageResource()](http://developer.android.com/reference/android/widget/ImageView.html#setImageResource(int)). This is just a convenience method for you: what Android is doing behind the scenes, is looking up the Drawable resource (in most cases, it's a BitmapDrawable, but it could be any type), and then applying that resource to the ImageView as a Bitmap object (i.e., image data only -- it does not have any idea what its original "resource id" was previously). Your best solution is going to be keeping track of the last resource id you used: ``` imageView.setImageResource(R.drawable.image1); this.mLastResourceId = R.drawable.image1; // ... // Later, when checking the resource: if (this.mLastResourceId == R.drawable.image1) { // Do something } ```
47,151,106
I have done keyboard appearing below textfield using on View did Load adding a observer() ``` NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(Gold_Loan_First_ViewController.keyboardDidShow(_:)), name: UIKeyboardDidShowNotification, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(Gold_Loan_First_ViewController.keyboardWillBeHidden(_:)), name: UIKeyboardWillHideNotification, object: nil) ``` And then updating the frame ``` weak var activeField: UITextField? func textFieldDidEndEditing(textField: UITextField) { self.activeField = nil } func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool { if textField==txtOTP { txtOTP.errorMessage="" } return true } func textFieldDidBeginEditing(textField: UITextField) { self.activeField = textField } func keyboardDidShow(notification: NSNotification) { if let activeField = self.activeField, let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue() { let contentInsets = UIEdgeInsets(top: 0.0, left: 0.0, bottom: keyboardSize.height, right: 0.0) self.scrollView.contentInset = contentInsets self.scrollView.scrollIndicatorInsets = contentInsets var aRect = self.view.frame aRect.size.height -= keyboardSize.size.height if (!CGRectContainsPoint(aRect, activeField.frame.origin)) { self.scrollView.scrollRectToVisible(activeField.frame, animated: true) } } } func keyboardWillBeHidden(notification: NSNotification) { let contentInsets = UIEdgeInsetsZero self.scrollView.contentInset = contentInsets self.scrollView.scrollIndicatorInsets = contentInsets } ``` But how do I do it for a textView. I tried the same code with didBeginEditing of textView with no positive effect
2017/11/07
[ "https://Stackoverflow.com/questions/47151106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6402891/" ]
One of the easy and no code of line solution is to use the following pods in your app. [IQKeyboardManger](https://github.com/hackiftekhar/IQKeyboardManager) Later you need to just import that in App Delegate and add this two lines of code in didfinishLaunching method: ``` IQKeyboardManager.sharedManager().enable = true ``` Your problem will be solved for whole app. For Swift 5: ``` IQKeyboardManager.shared.enable = true ```
7,922,404
How can I to know if resource file is loaded by a page using Javascript? For example some .css, js or other sort of sort of file?
2011/10/27
[ "https://Stackoverflow.com/questions/7922404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/733596/" ]
Use jQuery.ready event which means that all the page has been setup and then you start executing your JavaScript logic ``` $(document).ready(function(){ //your code }); ``` If you have the need to load stuff asynchronously then you should use your JavaScript code to load it like the example of loading a script: ``` $.getScript("http://.../some.js", function(){ //script loaded and hooked on the page; your custom logic here }); ``` For anything more complex I'd suggest some dependency management system like [requireJS](http://requirejs.org/).
326,319
I recently asked a [question](https://stackoverflow.com/questions/37807263/could-not-find-function-allprevious-in-tibco-spotfire) which had a typo in it. Mainly because I had my Stack Overflow account only on my mobile and it is actually "complicated" to write code there. The question was asking why Tibco Spotfire is complaining that the function `AllPrevious` is not available. The following code ``` sum([cost]) OVER (AllPrevious[Axis.X]) ``` was included in the question. The code had an obvious typo, namely it should have been `AllPrevious([Axis.X])`. However, this is (IMHO obviously) not related to the problem. Somebody pointed that out in an answer and even got an up vote. If he would have tried it out he could have matched it based on the error message. So I pointed this out in a comment: > > While you have a point that my stmt was incorrect it can not explain > the error and also gives a completely different error message your > answer should rather have been a (valuable) comment. > > > I was expecting him to delete the answer and place a comment, which would have allowed me to fix the question, without rendering his answer useless. However, I got only some offending answer: > > I'll be sure to skip your questions next time. > > > I was wondering what is the right way to deal with such answers which obviously miss the point of the question.
2016/06/16
[ "https://meta.stackoverflow.com/questions/326319", "https://meta.stackoverflow.com", "https://meta.stackoverflow.com/users/5707705/" ]
When someone points out a typo in code I have in a question or an answer -- which is quite rare, because I usually copy and paste my code from an editor that checks my syntax -- **the first thing I do is apologize for the presence of the typo because it means that I cut corners.** Typos can send people down the wrong path and waste the time of readers, so apologies are warranted. If someone posts an answer that merely points out a typo in my code, that's not the brightest thing to do on their part, but I'm still the one who managed to post the typo in the first place so I'm the one responsible for the mess. It really does not matter how *obvious* the typo is. **I also thank the person who notified me of the typo because without their help more time could have been wasted.** Once the typo is fixed though, the answer is useless so I vote accordingly.
32,809
I [posted a question](https://math.stackexchange.com/questions/3903361/6-cdot-7-10-is-there-a-natural-bijection-between-s-6-times-s-7-and-s-1) on math.SE a few weeks back, which received a fair bit of attention and some promising leads in the comments but no clear answers. I posted a +100 bounty on the question, and during the bounty period an answer was posted which provided some mildly interesting discussion of why $6!\cdot 7!=10!$ but did not provide anything resembling a bijection, which was the explicit aim of the question and associated bounty. The bounty has now expired with no additional answers. Because the question has been fairly popular, the answer has been upvoted by 4 of the 684 viewers of the question (and downvoted by one), even though it doesn't seem like the community's overall opinion is particularly favorable - the question itself was upvoted 16 times over the same period since the answer was posted. As such, it will receive a +100 bounty if I manually award it, and a +50 bounty if I let the bounty expire, per my understanding of the bounty system. I am unsure of the proper response here. On the one hand, I appreciate the answer, and found it somewhat interesting - I would rather have read it than not. (I haven't voted on it either way.) I also don't want to let the 100 reputation "go to waste", as it were. This would suggest directly awarding the bounty. On the other hand, the answer does not even attempt to provide the bijection my question was looking for, and it seems like it would be bad for the site to set the expectation that posting incomplete answers on popular-but-hard bountied questions is a way to earn easy reputation. It feels sort of unfair to me to award the same bounty to an incomplete answer that I would have liked to award to a full response to the question. This would suggest not awarding the bounty, but as the voting patterns make this impossible, letting it expire for half-credit as a fallback plan. Right now, I am thinking of letting the bounty expire and giving +50 reputation to the existing answer, and editing my question or adding a comment to make clear that I will create and award a new +100 bounty to any future answer that resolves this question. Is this a reasonable choice to make? Are there factors I'm neglecting, or any other thoughts on what the right choice is in this situation? I'm relatively new to the site and don't want to violate any math.SE norms or slight the user who posted an answer, if possible.
2020/11/27
[ "https://math.meta.stackexchange.com/questions/32809", "https://math.meta.stackexchange.com", "https://math.meta.stackexchange.com/users/214490/" ]
Welcome to the meta site! You are entirely within your rights to let the bounty expire. Personally, I think of bounties as a sort of 'custom order'. When you post a question on the site, you're *de facto* opening the door to any answers that appear, which you can accept or vote up/down as you please. When you post a bounty, however, because you're carving your own rep you are allowed to be more discerning, and in my opinion sometimes that means letting the bounty pass for another day. I've developed a personal habit of leaving comments on answers to questions I've posted a bounty that explain why or why not the answer is worthy of the bounty. Many times, it's something to the effect of, 'this is just what I wanted; if nothing better comes along, the bounty is yours'. Other times, I'm more critical or explain why I feel my request isn't being met. Somewhere on the main site I read something to the effect of 'part of what you are paying for is increased exposure to your question.' This view in particular supports the idea that bounties are not a guaranteed inheritance to those who answer the question but are a reward to be disbursed at the whim of whoever put the bounty up.
30,520,841
I have a data frame where one column is a factor. I want to map that column into integers. For instance, in the example below, I want to map `healthy` to the value `2`, `sick` to the value `1`, and `dead` to the value `0`. In this example the order of the states is important, because I want state 2 to be healthier than state 1, and state 1 to be healthier than state 0. ``` x <- data.frame(id = c(1, 1, 2, 2), day = c(1, 2, 1, 2), state = c('healthy', 'sick', 'sick', 'dead')) id day state 1 1 1 healthy 2 1 2 sick 3 2 1 sick 4 2 2 dead ``` What is the easiest way to manipulate the data frame `x` in order to get the following output data frame? ``` id day state state_int 1 1 1 healthy 2 2 1 2 sick 1 3 2 1 sick 1 4 2 2 dead 0 ```
2015/05/29
[ "https://Stackoverflow.com/questions/30520841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/856624/" ]
As factors are already stored as integers this is a simple oneliner. If you want a certain order use the `ordered` function. If the order is not important - as it very often is -, `as.numeric(x$state)` is all you need ! To answer your question with certain order required: ``` x$state_num <- as.numeric(ordered(x$state, levels = c("dead", "sick", "healthy"))) -1 id day state state_num 1 1 1 healthy 2 2 1 2 sick 1 3 2 1 sick 1 4 2 2 dead 0 ```
55,694,631
I have coordinates of two bounding boxes. I want to compare them. How can I compute area of each box? Coordinates: ``` Box1 : 0.20212765957446807 0.145625 0.24822695035460993 0.10875 Box2: 0.15212765957446807 0.145625 0.25822695035460993 0.8875 ``` overlaping\_bbox\_area1/bbox\_area\_image\_2 A quantity saying if the bboxes in avarerage are larger or small in image one than in image two.
2019/04/15
[ "https://Stackoverflow.com/questions/55694631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/51151/" ]
``` from bbox import BBox2D box1 = BBox2D([0.20212765957446807, 0.145625, 0.24822695035460993, 0.10875]) box2 = BBox2D([0.6693262411347518, 0.146875, 0.31382978723404253, 0.06875]) print(box2.height * box2.width) print(box1.height * box1.width) ``` I have found the solution.
16,810,925
An interesting one. On a team of half a dozen developers, I am the only one experiencing the following problem so we are reasonably sure that it is something local to myself but we can't seem to track down what is causing it. Using a Orchard based site, the default home page is overridden using a Route provider: ``` public IEnumerable<RouteDescriptor> GetRoutes() { return new[]{ new RouteDescriptor{ Name = "Homepage", Priority = 85, Route = new Route( "", new RouteValueDictionary{ {"area", "Area"}, {"controller", "BingoGame"}, {"action", "BingoRealm" }, {"realm", "realmName" } }, new RouteValueDictionary(), new RouteValueDictionary{ {"area", "Area"} }, new MvcRouteHandler()) }, ... ``` However, once I log in to the application (where I expect to the be taken to the home page the following error occurs: > > No route in the route table matches the supplied values. > > > **Description:** An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. > > > **Exception Details:** System.InvalidOperationException: No route in the route table matches the supplied values. > > > **Source Error:** > > > ``` Line 160: public void EndProcessRequest(IAsyncResult result) { Line 161: try { Line 162: _httpAsyncHandler.EndProcessRequest(result); Line 163: } Line 164: finally { ``` So here we have somewhere that establishes a route yet try to access that route and nothing is found. As I mentioned, only myself is experiencing this particular error and we can think of nothing local to my machine that should be influencing this matter. Solutions? Suggestions? Questions?
2013/05/29
[ "https://Stackoverflow.com/questions/16810925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1592583/" ]
There are three problems with the code: * `recvData` is unitialised when passed to `strlen()`. `strlen()` determines the length of the buffer when it finds a null terminating character, which could be within the buffer or outside. The size of the buffer, less one for terminating null character, should be passed as the maximum number of bytes to read. * the result of `recv()` is not queried. The code will use `recvData` even if the `recv()` failed, which is a bug. * `recv()` does not null terminate the buffer. Save the result of `recv()` and if not `-1` use it as an index into `recvData` to insert the null terminating character. Alternatively, as this is c++ use a `std::vector<char>` and to manage dynamic memory allocation for you (if dynamic memory allocation is really required): ``` std::vector<char> recvData(1025); // Default initializes all elements to 0. int result = recv(socket, recvData.data(), recvData.size() - 1); if (result != -1) { std::cout << recvData.data() << std::endl; } ``` Remember that data sent via sockets it just a stream of bytes, it is not separated into distinct messages. This means that: ``` out.write("I am your client :D"); ``` *might* not be read by a single call to `recv()`. Equally: ``` out.write("I am your client :D"); out.write("OK"); ``` *might* be read by a single call to `recv()`. It is the programmer's responsibility to implement a protocol if message-based processing is required.
35,925,661
I'm calling this code: ``` function LickEx(pickID){ alert('yo'); $(pickID).datepicker({ format : "mm/dd/yyyy", autoclose : true }); } ``` With: `onClick="LickExpDt('#example2');"` The 'alert' fires every time, but the '.datepicker' will only fire if I click on it once, click somewhere else, then click on it a 2nd time (along with the 'alert) .. then it acts like normal. I tried wrapping the function in a `$(document).ready(function () {` : ``` $(document).ready(function () { function LickEx(pickID){ alert('yo'); $(pickID).datepicker({ format : "mm/dd/yyyy", autoclose : true }); } }); ``` Nothing fires and I get a "Uncaught TypeError: LickEx is not a function" I need to call LickEx this way so that I can pass the variable in as a parameter (it's the ID of the input box) is there a way to pass a variable of the ID of input box being clicked on with this: ``` $(document).ready(function () { $([put_var_here]).datepicker({ format : "mm/dd/yyyy", autoclose : true }); }); ``` OR fix the original?
2016/03/10
[ "https://Stackoverflow.com/questions/35925661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6046634/" ]
Why not just have a class on the element(s) for which you want to add the date picker functionality ? ``` $('.datepicker').datepicker({ ``` The reason it only works on the second click in your case is that you are attaching the datepicker, only when you click on that element. So it takes an additional click to see it.
43,959,913
I wrote a function that replace the letter if the letter is the same as the next letter in the string: ``` word = 'abcdeefghiijkl' def replace_letter(word): for i in range(len(word)-1): if word[i] == word[i+1]: word = word.replace(word[i],'7') return word replace_letter(word) ``` This should give me `'abcd7efgh7ijkl'`, but I got `'abcd77fgh77jkl'`. Once the letter is the same with the next one both are replaced with `'7'`. Why?
2017/05/14
[ "https://Stackoverflow.com/questions/43959913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7292363/" ]
You should use: ``` word = word.replace(word[i],'7', 1) ``` to indicate that you want to make one character replacement. Calling `replace()` without indicating how many replacements you wish to make will replace any occurrence of the character `"e"` (as found at `word[i]`) by `"7"`.
110,443
I'm an Italian noahide. I read what Rambam says in Avodat Kochavim 3: 10-11 about the making of images by a Jew. I also read the following words in a Jewish forum: > > โ€œThe Torah says, "Don't make a carved statue or the image of anything in the heaven above or the earth below..." This verse prohibits making > a three-dimensional image. The Code of Jewish Law codifies this > prohibition, and adds that even owning an idol is forbidden. One may > neither own, use, nor derive any benefit from an idol whatsoever. One > is not even allowed to throw it in the garbage; Rather, one must > "throw it into the Dead Sea" or otherwise destroy it. However, most > people follow the ruling of the Chochmat Adam. He says that nowadays, > it is permitted to own images - even an image of a human being. He > explains as follows: The whole reason it was forbidden to own an image > was so that nobody would suspect the owner of being a "closet" idol > worshipper. But since people generally do not worship idols today, > there is no longer any cause for suspicion.โ€ > > > If I understand correctly, here the Chochmat Adam speaks in terms of the lawfulness of just owning three-dimensional human images. Is it correct or does Rabbi Danzig extend his reasoning also to the lawfulness concerning realization of three-dimensional human images?
2019/12/21
[ "https://judaism.stackexchange.com/questions/110443", "https://judaism.stackexchange.com", "https://judaism.stackexchange.com/users/16336/" ]
The Chochmas Odom 85,3 clearly states there is a Prohibition for a Jew to carve images even though they are not for worshipping > > ื›ืชื™ื‘ ืœื ืชืขืฉื•ืŸ ืืชื™ ืืœื”ื™ ื›ืกืฃ ื›ื•' ื•ืงื‘ืœื• ื—ื–"ืœ ื“ื–ื”ื• ืื–ื”ืจื” **ืฉืืกื•ืจ ืœืฆื™ื™ืจ ืฆื•ืจื•ืช ืฉื‘ืžื“ื•ืจ ืขืœื™ื•ืŸ ื•ืชื—ืชื•ืŸ** ื•ืจ"ืœ ืœื ืชืขืฉื•ืŸ ื“ืžื•ืช ื”ืฆื•ืจื•ืช ืฉื”ื ืืชื™ ื‘ืžืจื•ื ื•ืœื›ืŸ ืืกื•ืจ ืœืฆื™ื™ืจ ืฆื•ืจื•ืช ื“' ืคื ื™ื ืฉื‘ืžืจื›ื‘ื” ื•ืฆื•ืจื•ืช ืฉืจืคื™ื ื•ืžื”"ืฉ ื•ื›ืŸ ืืกื•ืจ ืฆื•ืจืช ืื“ื ืœื‘ื“ื• ื•ืืคื™' ืœื’ื•ื™ ืื• ืืคื™' ื‘ืฉื‘ื™ืœ ื›ื•ืชื™ืช ืืกื•ืจ ืœืขืฉื•ืช > > > It is written in the Torah: "do not make with me golden gods..." our Rabbis explained that this a prohibition to carve graven images of heavenly beings or a person, even though one is just selling the sculpture to a gentile (i.e not for worship) > > > In 85,5 The Chochmas Odom says one cannot even instruct a gentile to make him an image (of heavenly beings or humans). But if one ends up with an image of a human he is not suspect of worshipping it. Of course if he removes an eye or defects the sculpture, he is not suspect of worshipping the statue and can subsequently keep it, as long as it has not been worshipped which is usually the case nowadays: > > ื›ืฉื ืฉืืกื•ืจ ืœืขืฉื•ืชืŸ ื›ืš ืืกื•ืจ ืœื•ืžืจ ืœื ื›ืจื™ ืœืขืฉื•ืชืŸ ื“ืืžื™ืจื” ืœื ื›ืจื™ ืฉื‘ื•ืช ื‘ื›ืœ ื”ืžืฆื•ืช ื•ืืคื™' ืœื”ืฉื”ื•ืชืŸ ืืกื•ืจ ืžืฉื•ื ื—ืฉื“ (ืฉ"ืš ืก"ืง ื›"ื’) ื•ื "ืœ ื“ืฆื•ืจืช ืื“ื ื‘ื–ืžื”"ื– ืžื•ืชืจ ืœืฉื”ื•ืชืŸ ื“ื›ื™ื•ืŸ ื“ืื™ื ื• ืืœื ืžืฉื•ื ื—ืฉื“ ื•ื™ื“ื•ืข ื“ื‘ื–ืžื”"ื– ืื™ืŸ ืขื•ื‘ื“ื™ืŸ ืœืฆื•ืจืช ืื“ื ื•ืื•ืชื• ืฉื ืขื‘ื“ ืขื•ืฉื™ืŸ ืื•ืชื• ืžืฉื•ื ื” ื•ื›ืŸ ืžืชืœืžื™ื“ื™ื• ื”ืขื‘ื“ื™ื ื™ืฉ ื‘ื›ืœ ื' ืžื”ืŸ ืกื™ืžืŸ ื•ืืœื• ื•ื“ืื™ ืืกื•ืจ ืœื”ืฉื”ื•ืชืŸ ืื‘ืœ ืฉืืจ ืฆื•ืจืช ืื“ื ื•ืžื›"ืฉ ืื ืกื™ืžื ืขื™ื ื™ื• ื•ื›ื™ื•ืฆื ื‘ื• ื“ืื™ืŸ ื‘ื• ืžืฉื•ื ื—ืฉื“ > > >
55,808,627
I'm trying to display a statement 1000 times in QBASIC (using for statement). I think the program works properly, but I cannot see the 1000 statements because I cannot scroll up and down in the output window of QBASIC. I can see only the last part of the 1000 statements. ``` FOR x = 1 TO 1000 PRINT "maydie"; PRINT NEXT x ```
2019/04/23
[ "https://Stackoverflow.com/questions/55808627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11398949/" ]
your `folders` variable should be initialized as an array and not as a string, eg : ``` folders=($(ls -d */ | sed 's/\///g' | sed -e 's/^[[:space:]]//g' | sed -e's/[[:space:]]*$//' | tr '\n' ' ')) ```
57,096,032
I have data frame which looks like : ``` Id survey suvery_link Primary_call alternate call 1 form1 link1 7/18/19 1 form1 link1 8/18/19 2 form1 link1 8/18/19 2 form1 link1 9/18/19 3 form1 link1 8/18/19 3 form1 link1 9/18/19 4 form1 link1 7/18/19 4 form1 link1 8/18/19 1 form2 link2 8/18/19 1 form2 link2 9/18/19 2 form2 link2 7/18/19 2 form2 link2 8/18/19 3 form2 link2 7/18/19 3 form2 link2 8/18/19 4 form2 link2 8/18/19 4 form2 link2 9/18/19 ``` ### I am trying to get new data frame as following ``` Id survey suvery_link Primary_call alternate call 1 form1 link1 7/18/19 8/18/19 1 form2 link2 8/18/19 9/18/19 2 form1 link1 8/18/19 9/18/19 2 form2 link2 7/18/19 8/18/19 3 form1 link1 8/18/19 9/18/19 3 form2 link2 7/18/19 8/18/19 4 form1 link1 7/18/19 8/18/19 4 form2 link2 8/18/19 9/18/19 ``` I used the following code but is not code ``` df.sort_values(['Id','survey',survey_link','Primary_call','alternate call']).drop_duplicate('ID') ``` its not working
2019/07/18
[ "https://Stackoverflow.com/questions/57096032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7942512/" ]
``` df.groupby(['Id','survey','suvery_link'], as_index=False)[['Primary_call','alternate_call']].max() ```
16,954,058
here is my code: index.html ``` <!DOCTYPE html> <html ng-app="myApp"> <head> <meta charset="utf-8" /> <title>AngularJS Plunker</title> <link rel="stylesheet" type="text/css" href="http://angular-ui.github.com/ng- grid/css/ng-grid.css" /> <link rel="stylesheet" type="text/css" href="style.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script> <script type="text/javascript" src="http://angular-ui.github.com/ng-grid/lib/ng-grid.debug.js"></script> <script src="app.js"></script> </head> <body ng-controller="MyCtrl"> <div class="gridStyle" ng-grid="gridOptions"></div> <div class="selectedItems">Selected ID:{{mySelections[0].id}}</div><br><br> </body> </html> ``` app.js ``` var app = angular.module('myApp', ['ngGrid']); app.controller('MyCtrl', function($scope) { $scope.mySelections = []; $scope.myData = [{empno: 111, name: "Moroni", id: 1}, {empno: 222, name: "Tiancum", id: 2}, {empno: 333, name: "Jacob", id: 3}, {empno: 444, name: "Nephi", id: 4}, {empno: 555, name: "Akon", id: 5}, {empno: 666, name: "Enos", id: 6}]; $scope.gridOptions = { data: 'myData', selectedItems: $scope.mySelections, multiSelect: false }; }); ``` Q1: I want to hide the id column in ng-grid. Q2: After hiding the id column, may I get the id value when I select some row? How can modify the code? Hear is the plunk: [Plunk demo](http://plnkr.co/OG7WuC05Cp5PO3uYTYWC)
2013/06/06
[ "https://Stackoverflow.com/questions/16954058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2450397/" ]
Just add below lines to configuration and it will work ``` columnDefs: [ {field: 'empno', displayName: 'empno'}, {field:'name', displayName:'name'} ] ```
15,758,526
I know this is a duplicate question. But I don't find a good solution to my problem. I created a JSP page with some tabs. I want to reload the contents of a tab when the user clicks on the tab. ``` <div class="navbar btn-navbar"> <div id="tabs" class="tabbable"> <ul id="myTab" class="nav nav-tabs"> <li><a href="#datacollector" target="main" data-toggle="tab">Data Collector</a></li> <li><a href="#fromDB" target="main" data-toggle="tab">Data Load</a></li> <li><a href="#fromFile" target="main" data-toggle="tab">Data Load</a></li> <li><a href="#email" target="main" data-toggle="tab">Data Load</a></li> <li><a href="ajax/DataFieldMapping.jsp" target="main" data-toggle="tab">Data Map</a></li> <li><a href="#schedule" target="main" data-toggle="tab">Schedule</a></li> </ul> ``` What should be my script?
2013/04/02
[ "https://Stackoverflow.com/questions/15758526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2189617/" ]
Yes there is a option called "exception breakpoint" Open Breakpoint view, click on `j!` option and add desired exception ![enter image description here](https://i.stack.imgur.com/awElU.jpg)
49,933
Assume I'm an investor that wants to sell exotic put options. No one else is selling my kind of put option, so I need to determine my own "Market Price" through Monte Carlo simulation. I know that by the law of one price, this should hold: $$P\_t = E^Q[P\_t|\mathcal{F}\_t] = E^P[P\_t|\mathcal{F}\_t]$$ In my risk neutral Monte Carlo valuation, I model my stock price as: $$dS = rS\_tdt + \sigma S\_tdW\_t$$ In my real world Monte Carlo valuation, I model my stock price as: $$dS = \mu S\_tdt + \sigma S\_tdW\_t$$ Just thinking about this intuitively though, the put option valued under my real world Monte Carlo simulation will be way cheaper than the put option under my risk neutral simulations, because the growth rate is so much higher. So what am I missing here? Am I wrong in my first statement, that expectation under the P and Q measures are equal, or am I formulating my second statements incorrectly?
2019/11/26
[ "https://quant.stackexchange.com/questions/49933", "https://quant.stackexchange.com", "https://quant.stackexchange.com/users/42122/" ]
From the moment you are talking about probability, you define a measure, and a model. Usually , when you hear Delta 10, it means that under the risk-neutral measure, and very likely, the Black model, you have a probability of 10 % to exercise, everything is incorporated in that 10%, whether gamma or vega is high or not. This number is exact, it is not a random variable. Now , if you believe in this model, you could create a process $X(t,S\_t)$ $$X(t,x)=\mathbb{P}(S\_T>K|S\_t=x)$$, this variable may help you.
28,020,184
I'm debugging a web application running in visual studio with some breakpoints on some code that runs on every request to my web application. I find that in chrome, as I type the url past the host, it triggers a request for everything I type as I type it... As if chrome prefetches the page to make it load faster or something. While great for browsing the web, it's highly annoying when debugging code.. Anyone know of a way to disable, I've googled it a few different ways and what I can turn off I have, but it still makes requests as I type.
2015/01/19
[ "https://Stackoverflow.com/questions/28020184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2419089/" ]
Under the **privacy** settings (`Settings -> show advanced settings... -> Privacy`) in `Chrome (Version 46.0.2490.80 m)` **uncheck** these two settings: * Use a prediction service to help complete searches and `URLs` typed in the address bar or the `app launcher` search box * Prefetch resources to load pages more quickly
58,757
Yesterday, a lightning struck the SLS' umbilical tower during a scrubbed wet dress rehearsal. Is it normal for a lightning to strike the umbilical tower instead of the 3 lightning arresters around the pad? What would have happened if the lightning struck the Orion Launch Escape System instead of the umbilical tower?
2022/04/04
[ "https://space.stackexchange.com/questions/58757", "https://space.stackexchange.com", "https://space.stackexchange.com/users/37584/" ]
The goal of the Apollo missions was to land humans on the Moon and return them to Earth. That requires a surprisingly large delta-V capability. (In terms of delta-V, is easier to land a vehicle on Mars and leave it there than it is to land a vehicle on the Moon and leave it there.) The Space Launch System plus the Orion capsule do not have the delta-V needed to land a vehicle on the Moon and return it to Earth. SLS plus Orion does not even have the delta-V needed to insert into and later return from low lunar orbit. On the other hand, the Orion capsule has an extremely capable environmental control and life support system (ECLSS), capable of supporting a crew of six for 21 days. It can afford to make a leisurely trip. The Apollo vehicles did not have this luxury as they had a rather limited ECLSS capabilities. The outbound and inbound trajectories to and from the Moon were intentionally designed to be suboptimal with regard to delta-V so as to make the trip take less time. Had the Apollo vehicles used optimal trajectories (from the perspective of delta-V) the result would have been dead bodies returning to Earth. The Apollo missions had the spacecraft immediately enter low lunar orbit upon getting close to the Moon. The Artemis-1 mission will instead use close lunar approach as a powered gravity assist and days later inject the vehicle into a distant retrograde orbit (DRO) about the Moon. The drift from closest approach to the Moon to DRO insertion will take a few days. Targeting lunar DRO as opposed to targeting low lunar orbit reduces the required delta-V to something the SLS+Orion can handle. (Subsequent missions will place the vehicle into a near-rectilinear halo orbit, with similar delta-V requirements.) The greater time needed for a fuel-optimal trajectory to lunar periapsis followed by a drift to DRO altitude combine to make the outgoing trip take eight days rather than a bit more than the three days used by the Apollo missions.
43,401,239
This is the php script I have written to get the data from a MySQL database but it gives the error mentioned later and also the app where I am using this script gives a timeouterror . PHP Script: ``` <?php define('HOST','***'); define('USER','***'); define('PASS','***'); define('DB','champion_trial_database'); $con = mysqli_connect('HOST', 'USER', 'PASS', 'DB'); $sql ="SELECT * FROM `trial`"; $r = mysqli_query($con,$sql); $res = mysqli_fetch_array($r); echo ("name:"+$res); mysqli_close($con); ?> ``` Main\_activity.java file where a GET request is generated using the volley library is as follows: ``` import android.app.ProgressDialog; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; import com.android.volley.Request; import com.android.volley.RequestQueue; import com.android.volley.Response; import com.android.volley.VolleyError; import com.android.volley.toolbox.StringRequest; import com.android.volley.toolbox.Volley; public class MainActivity extends AppCompatActivity implements View.OnClickListener { private EditText editTextId; private Button buttonGet; private TextView textViewResult; private ProgressDialog loading; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); editTextId = (EditText) findViewById(R.id.editTextId); buttonGet = (Button) findViewById(R.id.buttonGet); textViewResult = (TextView) findViewById(R.id.textViewResult); buttonGet.setOnClickListener(this); } private void getData() { String id = editTextId.getText().toString().trim(); if (id.equals("")) { Toast.makeText(this, "Please enter an id", Toast.LENGTH_LONG).show(); return; } loading = ProgressDialog.show(this,"Please wait...","Fetching...",false,false); String url = "http://www.champion6346.5gbfree.com/getData.php"; RequestQueue requestQueue = Volley.newRequestQueue(this); StringRequest stringRequest = new StringRequest(Request.Method.GET,url, new Response.Listener<String>() { @Override public void onResponse(String response) { loading.dismiss(); textViewResult.setText("Name: "+response); // showJSON(response); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Toast.makeText(MainActivity.this,error.getMessage(),Toast.LENGTH_LONG).show(); Log.d("TAG:","Error mode entered "); error.printStackTrace(); } }); requestQueue.add(stringRequest); } @Override public void onClick(View v) { getData(); } } ``` This the error log of the server when I try to run the php script mentioned above: ``` [13-Apr-2017 13:43:50 America/Denver] PHP Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/champion6346/public_html/getData.php on line 9 [13-Apr-2017 13:43:50 America/Denver] PHP Warning: mysqli_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/champion6346/public_html/getData.php on line 9 [13-Apr-2017 13:43:50 America/Denver] PHP Warning: mysql_query(): Access denied for user ''@'localhost' (using password: NO) in /home/champion6346/public_html/getData.php on line 14 [13-Apr-2017 13:43:50 America/Denver] PHP Warning: mysql_query(): A link to the server could not be established in /home/champion6346/public_html/getData.php on line 14 [13-Apr-2017 13:43:50 America/Denver] PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/champion6346/public_html/getData.php on line 16 [13-Apr-2017 13:43:50 America/Denver] PHP Warning: mysql_close() expects parameter 1 to be resource, boolean given in /home/champion6346/public_html/getData.php on line 20 ```
2017/04/13
[ "https://Stackoverflow.com/questions/43401239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7131341/" ]
You need to use `preventDefault()` if you want to to cancel the event, that is to disallow text box from accepting non-numeric input. So that you don't have to bother about deleting it. However, `preventDefault()` does not work with `onkeyup`. Use `onkeydown`. **JS**: ``` function checkKey(e) { if (e.keyCode != 8 && // allow backspace e.keyCode != 46 && // allow delete e.keyCode != 37 && // allow left arrow e.keyCode != 39 && // allow right arrow (e.keyCode < 48 || e.keyCode > 57)) // allow numerics only { e.preventDefault(); } } ``` **HTML**: ``` <input type="text" onkeydown="checkKey(event)" /> ``` Note - Alerting user on each key press / down / up is terrible. Simply annoying. Avoid! Silently block the unwanted keys as I showed above.
6,387,604
Fellows, I have a query as follows: ``` SELECT A.ID, B.ID, (HUGE SUBQUERY) as HS FROM TABLE_A JOIN TABLE_B ON A.ID = B.ID WHERE (HUGE SUBQUERY) > 0 ``` I'd like to avoid repeating the subquery. Is there any way to rewrite my WHERE as something like ``` WHERE HS > 0 ``` Or I must turn my subquery into a join?
2011/06/17
[ "https://Stackoverflow.com/questions/6387604", "https://Stackoverflow.com", "https://Stackoverflow.com/users/263034/" ]
You could use a [CTE](http://msdn.microsoft.com/en-us/library/ms190766.aspx): ``` WITH cteHS AS ( SELECT xxx AS Value FROM Huge Subquery ) SELECT A.ID, B.ID, cteHS.Value as HS FROM TABLE_A, cteHS JOIN TABLE_B ON A.ID = B.ID WHERE cteHS.Value > 0 ```
14,313,423
Does anyone have a working example on how to get a text drawn in openGL, the erlang bindings? Im using a texture right now to load the one created by wxBitmap. And I am considering moving the GL code to Java or C++.
2013/01/14
[ "https://Stackoverflow.com/questions/14313423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/417896/" ]
Have you run "wx:demo()" from the erlang shell, it contains one example of how to do it. Click OpenGL and have a look at the code.
61,220,850
I have a Spring REST endpoint with Optional request params like below: ``` public ResponseEntity<Product> globalProduct(@RequestParam Optional<Integer> id, @RequestParam Optional<String> name){ return ResponseEntity.ok(tm)); } ``` when I'm trying to test this endpoint which uses Mockito framework ``` @Test public void testGlobalProduct() throws Exception { URI uri = UriComponentsBuilder.fromPath("/api/products") .queryParam("id", Optional.of(1) .queryParam("name", Optional.empty()) .build().toUri(); mockMvc.perform( MockMvcRequestBuilders.get(uri) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultHandlers.print()) .andReturn(); } ``` So the queryParams id and name should be Optional.of(1) and Optional.empty() , but when I debug in the rest api implementaion I see `id` and `name` has been wrapped with values `Optional[Optional[1]]` and `Optiona[Optional.empty]]` . I know I can use @RequestParams(required=false) but I dont want to use that way in this context. How do we unwrap `Optional[Optional[1]]` `Optiona[Optional.empty]]` Is this correct? Any suggestions please? Thanks in Advance!
2020/04/15
[ "https://Stackoverflow.com/questions/61220850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10119268/" ]
That is because you are passing an Optional in the query param which is again wrapped in an optional at controller layer. Try following and check. ``` @Test public void testGlobalProduct() throws Exception { URI uri = UriComponentsBuilder.fromPath("/api/products") .queryParam("id", 1) .build().toUri(); mockMvc.perform( MockMvcRequestBuilders.get(uri) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultHandlers.print()) .andReturn(); } ```
6,808,221
In a .js-file, I need to get the template-directory of a Wordpress theme, i.e. I need to get the return-value of `<?php bloginfo('template_directory');?>` within the js-file. The idea is something like: ``` var blogTemplateDir = "<?php bloginfo('template_directory');?>"; ``` How can this be achieved? What is the standard (Wordpress) way of doing this?
2011/07/24
[ "https://Stackoverflow.com/questions/6808221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/795016/" ]
Wordpress offers a `wp_localize_script()` function that allows you to pass a PHP array to a .js file when you register it with Wordpress. **It works like this** 1) Register your script with Wordpress using [wp\_register\_script()](http://codex.wordpress.org/Function_Reference/wp_register_script); Build an array of your parameters that you want to send to the script. ``` wp_enqueue_script('my-script','/path/to/script.js'); ``` 2) Build an array of your parameters that you want to send to the script. ``` $params = array('foo' => 'bar','setting' => 123); ``` 3) Call [wp\_localize\_script()](http://codex.wordpress.org/Function_Reference/wp_localize_script) and give your parameters a unique name. ``` wp_localize_script( 'my-script', 'MyScriptParams', $params ); ``` 4) You can access the variables in JavaScript as follows: ``` <script> alert(object_name.some_string); </script> ``` **Note:** you need to use wp\_enqueue\_script() when you want Wordpress to incluse the JavaScript file in the header. **Pulling it all together** ``` <?php $myPlugin = new MyPlugin(); //Add some JS to the admin section add_action('admin_enqueue_scripts', array($myPlugin, 'adminJavaScript')); class MyPlugin{ public function adminJavaScript() { $settings = array( 'foo' => 'bar', 'setting' => 123 ); wp_register_script('myJavaScriptName', plugins_url('/myJavaScript.min.js', __FILE__)); wp_localize_script('myJavaScriptName', 'settings', $settings); //pass any php settings to javascript wp_enqueue_script('myJavaScriptName'); //load the JavaScript file } } ?> <script> alert(settings.foo); </script> ```
259,919
There will be a data export happening from our org for large number of objects and records using a cloud based ETL tool. We have a business scenario where we need to make sure that there is no data update made in the org for a window of 48 hours during which cloud based ETL tool will be exporting data out of salesforce. We are making sure no user updates data through profile level login hours. We have lots of Batch, Schedule, Queue apex as well as usage of @future in classes. We need to make sure these asynchronous jobs do not make data changes. What are some ways to achieve the same with minimum effort ? One way we are considering is deleting all the scheduled jobs before the 48 hour window and then recreating the scheduled jobs after the window. Scheduled jobs are owned by an Integration User, is it a good idea to disable the Integration User ? Will we also need to abort currently running jobs ? Will it be a good idea to do this : ``` for ( AsyncApexJob aJob : [ Select id ,Status, ApexClass.Name from AsyncApexJob where Status!='Aborted' and Status!='Completed' ] ) { System.AbortJob(aJob.Id); } ```
2019/04/24
[ "https://salesforce.stackexchange.com/questions/259919", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/10799/" ]
I would do this with a [hierarchy custom setting](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_customsettings.htm). Create a new setting object with a checkbox. Then, for each object you want to lock down, add a simple validation rule: ``` NOT($Setup.Lockdown__c.AllowUpdates__c) ``` Where Lockdown is the name of the custom setting, AllowUpdates is the name of the checkbox. Enable this checkbox at the org level until it's time to lock everything down. Then, when the time comes, uncheck the box in the org defaults, and let your ETL run. This validation rule will block all attempts to update records, including any batches, scheduled updates, time-based workflow, etc. When you're done with the ETL, just check the box again, and you're good to go. This is the most efficient method I can think of, though other solutions would also be possible.
167,015
DCC Core Rulebook pg. 49 > > Familiars: More than one wizard has found comfort in the company of a black cat, hissing snake, or clay homunculus. A wizard may utilize the spell *find familiar* to obtain such a partner. > > > For the life of me, I can't figure out what this means. I can only see three plausible interpretations: 1. Wizards automatically learn the *find familiar* spell, in addition to their other spells. This explanation doesn't seem right since this feature is phrased so differently than the elf's "Supernatural patrons" feature. 2. Elves cannot learn the spell *find familiar,* since they don't have the "Familiars" feature. 3. This feature does literally nothing. In that case, why is it even there?
2020/03/31
[ "https://rpg.stackexchange.com/questions/167015", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/35687/" ]
As Page 56 of the DCC Core Rulebook says: > > Elves can cast spells as wizards do. An elf of the same power level as a human wizard also has many decades of combat experience. As such, elves typically cast their spells just as competently as human wizards and also have martial skills. > > > The feature is there so you know that only wizards (including elves) can get a familiar, since it is possible to attempt wizard spells without having the class. (Scrolls for instance, can be read by even warriors). Also, page 316 goes into depth in explaining familiars, which never really says Elf wizards can't have the spell. > > A wizard can summon a familiar with the spell find familiar. The resulting familiar is determined by his spell check and alignment. The higher the spell check, the more powerful the familiar and the greater effect it has on the wizardโ€™s magic. > > > Page 320 further supports the idea that all races should have access to all the spells, but in a re-skin fashion: > > Racial casting: Why should an elfโ€™s spell be the same as a wizardโ€™s? Furthermore, why should a dark elfโ€™s be the same as a high elfโ€™s? And further still, why would an orc shaman cast spells the same as either elf or human? > > > Also, some food for thought. Elves have this note explaining exceptions in their section, but there is no such exceptions noted anywhere when it comes to the Wizard / familiars section. Page 57 says > > Elf spells are determined randomly like a wizardโ€™s, except for invoke patron and patron bond, as described below... > > > Which further confirms my belief that elves should have access to it. Otherwise there would also be an exception note on the Wizard section on familiars, and there isn't.
355,257
Consider the following problem involving [neural networks](https://en.wikipedia.org/wiki/Artificial_neural_network). The input of the neural network are $n$ paths of a diffusion model i.e.: $ dX(t)=\mu dt + \sigma dW(t) $, at some random time $t$. $$ input = [ x\_{1j}, x\_{2j}, x\_{3j}, ...,x\_{nj} ] $$ And the training data for the network is the average of the input $$ training\\_data = k\_j = \frac{1}{n} \sum\_{i=1}^{n} \lambda x\_{ij}^2 $$ $$ model = \bar k\_j = \frac{1}{n} \sum\_{i=1}^{n} \lambda x\_{ij}^2 $$ The loss function is the MSE of the following difference $$ loss\\_function =\frac{1}{m} \sum\_{j=0}^{m-1} (k\_j-\bar k\_j)^2 $$ Where * $i$ - is the path index (or input node index) * $j$ - is the time index (shuffled randomly) * $k\_j$ - is the squared function average * $\bar k\_j$ - is the squared function average with $\lambda$ approximated by the network * $\lambda$ - is some constant to approximate. The goal here is to generate training data with i.e.: $\lambda=0.25$, and see if the network can find that value. In other words I want the network single node output to converge to a value of $\lambda$ which minimizes the loss function. For example, **Step 1** - Create the neural network input by simulating the paths [![enter image description here](https://i.stack.imgur.com/RysMO.png)](https://i.stack.imgur.com/RysMO.png) **Step 2** - Create the training data with $\lambda = 0.25$ [![enter image description here](https://i.stack.imgur.com/GSwZm.png)](https://i.stack.imgur.com/GSwZm.png) **Step 3** - Create the neural network architecture as follows and initialize attempt to approximate the right $\lambda$. [![enter image description here](https://i.stack.imgur.com/nmBXN.png)](https://i.stack.imgur.com/nmBXN.png) **Step 4** - Train the network by selecting randomized $j$ indexes. However, the network is not converging to the $\lambda$ value which the training data was generated from. I know there are things that can help convergence such as data normalization, advanced stochastic gradient descent methods, deep hidden layers, or mini-batch and batch training, etc. But beside the normal tricks - is there something fundamentally wrong with my problem. Can the neural network learn the average sum squared of the input? I will add any additional information if necessary. Any help is truly appreciated as this problem is very important to me. **Motivation** > > Does $\lambda$ depend on $x$? > > > This is a great question. I had some doubts but this is how I convinced myself. So, in real life, we do not know what $k$ looks like, and it would only be observed from data. So the classic thing to do is fit a universal function approximator like the Taylor polynomials, i.e.: $$ k(a) = c\_0+c\_1(x-a)+c\_2(x-a)^2...+c\_n(x-a)^n $$ Note that if we keep the second term only and evaluate at zero by choice - the function looks a lot like the second term. $$ k(a) = c\_2(x-a)^2 = \lambda x^2 $$ Furthermore, $c\_2$ is just another assumption that the derivative of the function is a constant but the second term formula is $$ \frac{k"(a)}{2!}(x-a)^2 $$ Hence, my assumption is that $\lambda$ is the derivative value and a function of $x$. Also, I am not trying to predict $k$. I have a model for it which is $\bar k$. I am only trying to fit $\lambda$ by modifying the loss function - but I don't know if I am allowed to do that. But I did make this up - so I could be wrong - and I apologize in advance. **Update** I found that I had coded some derivatives wrong. Once I fixed my library - it appeared to start working. After 20 or so epoch the gradients explode but that is another problem. [![enter image description here](https://i.stack.imgur.com/vgOGR.png)](https://i.stack.imgur.com/vgOGR.png) However, I think I am just making use of the gradient descent here - I am not sure that the neural network is doing anything.
2018/07/09
[ "https://stats.stackexchange.com/questions/355257", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/87106/" ]
> > But beside the normal tricks - is there something fundamentally wrong with my problem. > > > Yes, I think there is something fundamentally wrong with your problem statement. From your description of the training data and the loss function I infer that you train the network to predict $k$. However, at the same time you *somehow* expect that the network generates $\lambda$ as output. Obviously, the network cannot do it. Also, note that according to your description the true $\lambda$ does not depend at all on $x$, thus no model in the world would be able to predict $\lambda$ observing only $x$. On the other hand, the $k$'s depend on $\lambda$ (and vice versa) and thus if one extends the training data set and includes $k$'s one could predict $\lambda$. However, in this situation NN would an overkill, because estimating $\lambda$ given $x$ and $k$'s is straightforward. > > Can the neural network learn the average sum squared of the input? > > > Yes. **Update** > > Hence, my assumption is that $\lambda$ > is the derivative value and a function of $x$. > > > Whatever this sentence means, the second derivative of quadratic function is constant and doesnโ€™t depend on $x$. > > Also, I am not trying to predict $k$. I have a model for it which is $\bar{k}$ > > > Your loss function suggest that you do. Also note that itโ€™s straightforward to estimate $\lambda$ if you have $x$ and $\bar{k}$.
31,859,520
I am working on a project in django 1.5.12. version with django-cms installed . I have a file generated by command "pip freeze > frozen.txt" where is next information with what I have installed: ``` Django==1.5.12 MySQL-python==1.2.5 South==1.0.2 argparse==1.2.1 distribute==0.6.24 django-classy-tags==0.6.2 django-cms==2.4.3 django-mptt==0.5.2 django-sekizai==0.8.2 html5lib==1.0b7 six==1.9.0 wsgiref==0.1.2 ``` Well, my problem is that I have an app in my project where I have next code in views.py: ``` from django.shortcuts import * def test(request): data = {'test 1': [ [1, 10] ], 'test 2': [ [1, 10] ],'test 3':[ [2,20]] } print data # to see if function works return render_to_response("project_pages.html",{'data':data},context) ``` And in my template project\_pages.html I have this : ``` <table> <tr> <td>field 1</td> <td>field 2</td> <td>field 3</td> </tr> {% for author, values in data.items %} <tr> <td>{{author}}</td> {% for v in values.0 %} <td>{{v}}</td> {% endfor %} </tr> {% endfor %} </table> ``` and isn't render the response to the template. And in terminal doesn't show me any errors. The function is working because it is printing data. If try to return something like this: ``` return render_to_response("project_pages.html",{'data':data}) ``` without context at the end (it is different call) it gives me next error: ``` "You must enable the 'sekizai.context_processors.sekizai' template " TemplateSyntaxError: You must enable the 'sekizai.context_processors.sekizai' template context processor or use 'sekizai.context.SekizaiContext' to render your templates. ``` In my settings.py I have sekizai: ``` TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.i18n', 'django.core.context_processors.request', 'django.core.context_processors.media', 'django.core.context_processors.static', 'cms.context_processors.media', 'sekizai.context_processors.sekizai', 'sekizai.context.SekizaiContext', ) ``` So, what should I do?
2015/08/06
[ "https://Stackoverflow.com/questions/31859520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5198633/" ]
Review what context variable have. It should have something like that: Example: ``` from django.template import RequestContext def view(request): ... return render_to_response( "project_pages.html", {'data':data}, context_instance=RequestContext(request), ) ```
4,386,641
$G \subseteq A^2$ $G = \{(x|y): x > y\}$ $G^{-1} = \{(y|x): x > y\} = \{(y|x): y > x\}$ **or** $G^{-1} = \{(y|x): y < x\}$ ? The converse of the "greater than"-relation is the "lesser than"-relation, but does that mean the converse of $x > y$ is $y > x$? Or is the converse $y < x$? I think $y > x$ should be right, $y < x$ would essentially be the same relation? However my actual problem is that I'm not quite sure how to interpret the set-builder notation in this case, how can I know what exactly is meant?
2022/02/20
[ "https://math.stackexchange.com/questions/4386641", "https://math.stackexchange.com", "https://math.stackexchange.com/users/855926/" ]
Note that one possibility is the following: The inversion/transposing already happens when you exchange the roles of $x$ and $y$, that is if: $$ R = \{(x,y) \in A^2 : \text{some term}(x,y) \} $$ you get the converse from flipping $x$ and $y$, that is $$ R^{-1} = \{(y,x) \in A^2 : \text{the same term}(x,y) \} $$ Hence, in your case for $$ G = \{(x,y) \in A^2: x > y \} $$ we have $$ G^{-1} = \{(y,x) \in A^2: x > y\} = \{(y,x) \in A^2 : y < x \} $$ Note, that for the last term above we just rewrote the term such that $y$ and $x$ appear in the right order (that is in the same order as in the beginning. You also can do inversion by flipping $x$ and $y$ in the term, that is for $$ R = \{(x,y) \in A^2 : \text{term}(x,y) \} $$ you get the converse from flipping $x$ and $y$ in the term $$ R^{-1} = \{(y,x) \in A^2 : \text{term}(y,x) \} $$ In our case: For $$ G = \{(x,y) \in A^2: x > y \} $$ we have $$ G^{-1} = \{(x,y) \in A^2: y > x\} = \{(x,y) \in A^2 : x < y \}. $$ In the end, note that if you flip $x$ and $y$ in both positions, you are just renaming variables, hence $$ G = \{(x,y) \in A^2: x > y \} = \{(y,x) \in A^2: y > x \} $$
56,697,129
I have a List[Int], perhaps like this: ``` List(1,2,3,3,4,5,6,6,7,8,9) ``` There will be occasional duplication (always 2, not more). When there's a dup I want to merge the elements together with a function. So in this simple example if my function is to add the 2 numbers together I'd get: ``` List(1,2,6,4,5,12,7,8,9) ``` What's a concise way to do this? List.map() only looks at/transforms 1 element at a time.
2019/06/21
[ "https://Stackoverflow.com/questions/56697129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/675066/" ]
After so many tries, I have created an [issue](https://issuetracker.google.com/issues/135865377) on Google Issue Tracker under [component](https://issuetracker.google.com/issues?q=componentid:409906), also submitted the code sample to the team and they replied as: > > Your Worker is package protected, and hence we cannot instantiate it using the default WorkerFactory. > > > If you looked at Logcat, you would see something like: ``` 2019-06-24 10:49:18.501 14687-14786/com.example.workmanager.periodicworksample E/WM-WorkerFactory: Could not instantiate com.example.workmanager.periodicworksample.MyWorker java.lang.IllegalAccessException: java.lang.Class<com.example.workmanager.periodicworksample.MyWorker> is not accessible from java.lang.Class<androidx.work.WorkerFactory> at java.lang.reflect.Constructor.newInstance0(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:334) at androidx.work.WorkerFactory.createWorkerWithDefaultFallback(WorkerFactory.java:97) at androidx.work.impl.WorkerWrapper.runWorker(WorkerWrapper.java:228) at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:127) at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764) 2019-06-24 10:49:18.501 14687-14786/com.example.workmanager.periodicworksample E/WM-WorkerWrapper: Could not create Worker com.example.workmanager.periodicworksample.MyWorker ``` > > Your Worker needs to be public > > > And by making My Worker class public I got resolved the issue. Reference of Google's Reply on the issue: <https://issuetracker.google.com/issues/135865377#comment4>
35,370
So I want to use this microphone both for skype and for my general audio recording purposes, but it is really sensitive (not exactly a bad thing). Is there a way I can set it up so that it picks up sound only louder than a certain decibel value?
2015/06/10
[ "https://sound.stackexchange.com/questions/35370", "https://sound.stackexchange.com", "https://sound.stackexchange.com/users/14756/" ]
Aren't Cherry MX Blues practically designed to be loud? I heard once that DasKeyboard used to offer ear plugs as an accessory (as a joke)... I love my mechanical keyboards, but I use MX Browns any time there's going to be a mic in use (like for videoconferencing. Obviously I don't use a keyboard at all when I'm recording something important.) That said, the answer to your question is *yes*, you would use something called a [noise gate](http://en.wikipedia.org/wiki/Noise_gate) on your input. You can read the Wikipedia article, but it basically kills the signal until the input is above a certain threshold, with some other parameters for response time. The caveat to this is that, first, your level of speech must be ABOVE that of your keyboard, and second, when your mic is on because you're speaking into it, it's still going to pick up the sound of the keyboard if you happen to be typing at the same time. It's not a filter. BUT, let's talk about filters! In my experience with MX Blue keyswitches, the sound they make tends to be very high in pitch. You might consider recording the sounds that your keyboard makes, and running an [FFT](http://en.wikipedia.org/wiki/Fast_Fourier_transform) to determine which frequencies it is loudest at. Then, you could run your signal through a [filter](http://en.wikipedia.org/wiki/Audio_filter) or EQ that would "zero out" those frequencies. This only works if the keyboard frequency band is relatively well-contained -- if you zero out too much bandwidth, you'll significantly affect the sound of your voice going through the same filter.
31,067,413
How can i add two numbers from text box when the page loads? it only works when i try to create a button for adding. ```js function sum() { var txtFirstNumberValue = document.getElementById('totalprice').value; var txtSecondNumberValue = document.getElementById('price1').value; var result = parseInt(txtFirstNumberValue) * parseInt(txtSecondNumberValue); if (!isNaN(result)) { document.getElementById('totalprices').value = result; } } ```
2015/06/26
[ "https://Stackoverflow.com/questions/31067413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4620010/" ]
This is [shortest path problem](https://en.wikipedia.org/wiki/Shortest_path_problem), where nodes are cells in the grid, and edges are possible moves from cell to cell. Simplest solution to it is using a [BFS](https://en.wikipedia.org/wiki/Breadth-first_search) (since the graph is unweighted). An improvement is using a [bi-directional BFS](https://stackoverflow.com/a/7220294/572670). An AI oriented improvement is to use an *informed algorithm* such as [A\*](https://en.wikipedia.org/wiki/A*_search_algorithm). You are going to need an [admissible heuristic](https://en.wikipedia.org/wiki/Admissible_heuristic) function to use it, can you think of any? (There is a classic well known one, but I'll let you figure it out on your own).
51,180,106
First, let me say I understand that I have a custom component "Card" that I use in one of my routes, "Home". Card.js ``` import s from 'Card.css'; class Card { ... render(){ return (<div className={cx(className, s.card)}> {this.props.children} </div>); } } ``` Card.css ``` .card { display: block; } ``` Home.js ``` <Card className={s.testCard}> ... </Card> ``` Home.css ``` .testCard { display: none; } ``` A problem I faced here, is that the card remained visible even though I set the display to none, because of seemingly random CSS ordering in the browser. This ordering did not change even if Javascript was disabled. To get .testCard to correctly load after .card, I used "composes:": Home.css ``` .testCard { composes: card from 'components/Card.css'; display: none; } ``` Apparently this causes css-loader to recognize that .testCard should load after .card. Except, if I disable Javascript, the page reverts back to the old behavior: the .card is loaded after .testCard and it becomes visible again. What is the recommended way to get our page to prioritize .testCard over card that behaves consistently with or without Javascript enabled?
2018/07/04
[ "https://Stackoverflow.com/questions/51180106", "https://Stackoverflow.com", "https://Stackoverflow.com/users/943645/" ]
As I'm using CSS modules, charlietfl solution wouldn't really work as is. `.card` is automatically mangled to a name like `.Card-card-l2hne` by the css-loader, so referencing it from a different component wouldn't work. If I import it into the CSS file of `Home.css`, that also doesn't work, because it creates a new class with a name like `.Home-card-lnfq`, instead of referring to `.Card-card-l2hna`. I don't really think there's a great way to fix this so I've resorted to being more specific using a parent class instead. As an example, Home.js: ``` import s from 'Home.css'; import Card from './components/Card'; class Home { ... render(){ return ( <div className={s.root}> <Card className={s.testCard}>Hi</Card> </div> ); } } ``` Home.css ``` .root { margin: 10px; } .root > .testCard { display: none; } ``` This way, we don't need to know what class names component `Card` is using internally, especially since in cases like CSS Modules or styled components, the class name is some unique generated name. I don't think I would have come to this solution if it wasn't for charlieftl's solution, so thank you very much for that.
496,716
I am intalling Pythonika on Ubuntu 14.04. I downloaded the files of Pythonika from the following url. <https://github.com/szhorvat/Pythonika> I was able to compile Pythonika on Ubuntu 12.04 using Makefile.linux. However I got the following error after Ubuntu 14.04 upgrade. Any help will be appreciated. Regrads, Yoshihiro Sato My system is Ubuntu 14.04 64bit and Mathematica 9.0 for Linux x86 (64-bit) (February 18, 2013). ``` $ python --version Python 2.7.7 :: Anaconda 2.0.1 (64-bit) $ which python /home/satouy/anaconda/bin/python $ make -f Makefile.linux cc -I/usr/local/Wolfram/Mathematica/9.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86- 64/CompilerAdditions -I/usr/include/python2.7/ Pythonika.o Pythonikatm.o - L/usr/local/Wolfram/Mathematica/9.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86- 64/CompilerAdditions /usr/local/Wolfram/Mathematica/9.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86- 64/CompilerAdditions/libML64i3.a -lstdc++ -lrt -lpython2.7 -o Pythonika /usr/bin/ld: /usr/local/Wolfram/Mathematica/9.0/SystemFiles/Links/MathLink/DeveloperKit/ Linux-x86-64/CompilerAdditions/libML64i3.a(mlnumenv.c.o): undefined reference to symbol 'fmod@@GLIBC_2.2.5' /lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make: *** [Pythonika] error 1 ``` I used the following Makefile.linux. ``` $ cat Makefile.linux # Set the paths according to your MathLink Developer Kit location. # (The paths should not contain whitespaces) MATHEMATICA_INSTALL_DIR = /usr/local/Wolfram/Mathematica/9.0 MLINKDIR = ${MATHEMATICA_INSTALL_DIR}/SystemFiles/Links/MathLink/DeveloperKit ##SYS = Linux SYS = Linux-x86-64 CADDSDIR = ${MLINKDIR}/${SYS}/CompilerAdditions INCDIR = ${CADDSDIR} LIBDIR = ${CADDSDIR} MPREP = "${CADDSDIR}/mprep" MCC = "${CADDSDIR}/mcc" # Modify the following for Python versions other than 2.6 PYTHON_VERSION_MAJOR = 2 ##PYTHON_VERSION_MINOR = 6 PYTHON_VERSION_MINOR = 7 # Path to the Python includes (modify according to Python version) # PYTHONINC = /usr/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/ PYTHONIKA = Pythonika INCLUDES = -I${INCDIR} -I${PYTHONINC} # libstdc++ and librt are, apparently, needed for correct compilation under Linux # with libMLi3 statically linked # ##LIBS = -L${LIBDIR} ${LIBDIR}/libML32i3.a -lstdc++ -lrt - lpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} ## 64-bit system LIBS = -L${LIBDIR} ${LIBDIR}/libML64i3.a -lstdc++ -lrt - lpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} all : Pythonika Pythonika: ${PYTHONIKA}.o ${PYTHONIKA}tm.o ${CC} ${INCLUDES} ${PYTHONIKA}.o ${PYTHONIKA}tm.o ${LIBS} -o ${PYTHONIKA} ${PYTHONIKA}tm.o: ${PYTHONIKA}.tm ${MPREP} ${PYTHONIKA}.tm -o ${PYTHONIKA}tm.c ${CC} -c ${PYTHONIKA}tm.c ${INCLUDES} ${PYTHONIKA}.o: ${PYTHONIKA}.c ${CC} -c ${PYTHONIKA}.c ${INCLUDES} clean : rm -f ${PYTHONIKA}tm.* ${PYTHONIKA}.o ${PYTHONIKA} ``` After changing my python environment, I tried to compile it. I have almost same error message. Would you please show me how to resolve this problem ? ``` $ python --version Python 2.7.6 $ which python /usr/bin/python $ make -f Makefile.linux cc -I/usr/local/Wolfram/Mathematica/9.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86- 64/CompilerAdditions -I/usr/include/python2.7/ Pythonika.o Pythonikatm.o -L/usr/local/Wolfram/Mathematica/9.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions /usr/local/Wolfram/Mathematica/9.0/SystemFiles/Links/MathLink/DeveloperKit/Linux-x86-64/CompilerAdditions/libML64i3.a -lstdc++ -lrt -lpython2.7 -o Pythonika /usr/bin/ld: /usr/local/Wolfram/Mathematica/9.0/SystemFiles/Links/MathLink/DeveloperKit/ Linux-x86-64/CompilerAdditions/libML64i3.a(mlnumenv.c.o): undefined reference to symbol 'fmod@@GLIBC_2.2.5' //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make: *** [Pythonika] error 1 ```
2014/07/12
[ "https://askubuntu.com/questions/496716", "https://askubuntu.com", "https://askubuntu.com/users/304746/" ]
I have succeeded in compiling pythonika on Ubuntu 14.04. I need to add -lpthread -lm to the command line. ``` ## Ununtu 14.04 LIBS = -L${LIBDIR} ${LIBDIR}/libML64i3.a -lstdc++ -lpthread -lm -lrt -lpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} ``` Thanks, Yoshihiro Sato
50,780,438
My javascript code doesnt seem to run when i use this codes to validate the radio button is clicked. Its suppose to dropdown the inputs when the card radio button is clicked and it is suppose to slide up the inputs when the paypal button is clicked.1st code javascript. 2nd code html. ```js if (document.getElementById('paypal').checked) { //Paypal radio button is checked $(".input-fields").slideDown("slow"); } else if (document.getElementById('card').checked) { //Card radio button is checked $(".input-fields").slideUp("slow"); }; ``` ```html <div class="panel-body"> <h2 class="title">Checkout</h2> <div class="bar"> <div class="step active"></div> <div class="step active"></div> <div class="step"></div> <div class="step"></div> </div> <div class="payment-method"> <label for="card" class="method card"> <div class="card-logos"> <img src="img/visa_logo.png" /> <img src="img/mastercard_logo.png" /> </div> <div class="radio-input"> <input id="card" type="radio" name="payment"> Pay $<%= total %> with credit card </div> </label> <label for="paypal" class="method paypal"> <img src="img/paypal_logo.png" /> <div class="radio-input"> <input id="paypal" type="radio" name="payment"> Pay $<%= total %> with PayPal </div> </label> </div> <div class="input-fields"> <div class="column-1"> <label for="cardholder">Cardholder's Name</label> <input type="text" id="cardholder" /> <div class="small-inputs"> <div> <label for="date">Valid thru</label> <input type="text" id="date" placeholder="MM / YY" /> </div> <div> <label for="verification">CVV / CVC *</label> <input type="password" id="verification" /> </div> </div> </div> <div class="column-2"> <label for="cardnumber">Card Number</label> <input type="password" id="cardnumber" /> <span class="info">* CVV or CVC is the card security code, unique three digits number on the back of your card separate from its number.</span> </div> </div> </div> ```
2018/06/10
[ "https://Stackoverflow.com/questions/50780438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9094611/" ]
The main issues with `sorter()` are (1) that it won't return until the thread function returns, and (2) the thread function is `sorter()`, so you have an indefinite loop. This is likely a problem with trying to abstract your code into the question. There are nitty-gritty details to fix up like the types of the functions, etc. The issues with `network()` might be similar or different; you've not shown the function you call from `main()`, so it is not clear what you intend. The code in `networker()` is not good; it makes `pthread_create()` call a function with an incorrect signature โ€” thread functions should have the signature `void *function(void *arg);`. However, in general, there is no problem with starting different threads in code from different source files. If the threads are not detached โ€” if you're going to join them โ€” then you'll need to make the `pthread_t` initialized by `pthread_create()` available for the code that manages the joining โ€” possibly because they're in global variables or part of a global array, or possibly because you provide functional access to private data stored in the separate source files. So, you might have: **`network.c`** ``` static pthread_t thread2; static void *network_thread(void *arg); void network(void) { if (pthread_create(&thread2, NULL, network_thread, NULL) != 0) โ€ฆhandle errorโ€ฆ } void network_join(void) { void *vp = 0; if (pthread_join(&thread2, &vp) != 0) โ€ฆreport errorโ€ฆ โ€ฆmaybe use the return value in vpโ€ฆ } ``` **`sorter.c`** ``` static pthread_t thread1; static void *sorter_thread(void *arg); void sorter(void) { if (pthread_create(&thread1, NULL, sorter_thread, NULL) != 0) โ€ฆhandle errorโ€ฆ } void sorter_join(void) { void *vp = 0; if (pthread_join(&thread1, &vp) != 0) โ€ฆhandle errorโ€ฆ โ€ฆmaybe use value in vpโ€ฆ } ``` **`main.c`** ``` #include "sorter.h" #include "network.h" int main(void) { network(); sorter(); network_join(); sorter_join(); return 0; } ``` You would probably build checks into `network_join()` and `sorter_join()` such that if you've not already called `network()` or `sorter()`, the code won't try to join an invalid thread.
48,236,493
I am new to Angular and Ionic. I am looping through an array of content that is store in my Firestore database. When the app recompiles and loads, then I go to the settings page (that's where the loop is happening), I see the array of content just fine. I can update it on Firestore and it will update in real time in the app. It's all good here. But if I click "Back" (because Settings is being visited using "navPush"), then click on the Settings page again, the whole loop content will be gone. Stuff is still in the database just fine. I have to recompile the project to make the content appear again. But once again, as soon as I leave that settings page, and come back, the content will be gone. Here's my code: HTML Settings page (main code for the loop): ``` <ion-list> <ion-item *ngFor="let setting of settings"> <ion-icon item-start color="light-grey" name="archive"></ion-icon> <ion-label>{{ setting.name }}</ion-label> <ion-toggle (ionChange)="onToggle($event, setting)" [checked]="setting.state"></ion-toggle> </ion-item> </ion-list> ``` That Settings page TS file: ``` import { Settings } from './../../../models/settings'; import { DashboardSettingsService } from './../../../services/settings'; import { Component, OnInit } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular'; @IonicPage() @Component({ selector: 'page-dashboard-settings', templateUrl: 'dashboard-settings.html', }) export class DashboardSettingsPage implements OnInit { settings: Settings[]; checkStateToggle: boolean; checkedSetting: Settings; constructor(public dashboardSettingsService: DashboardSettingsService) { this.dashboardSettingsService.getSettings().subscribe(setting => { this.settings = setting; console.log(setting.state); }) } onToggle(event, setting: Settings) { this.dashboardSettingsService.setBackground(setting); } } ``` And my Settings Service file (the DashboardSettingsService import): ``` import { Settings } from './../models/settings'; import { Injectable, OnInit } from '@angular/core'; import * as firebase from 'firebase/app'; import { AngularFireAuth } from 'angularfire2/auth'; import { AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument } from 'angularfire2/firestore'; import { Observable } from 'rxjs/Observable'; @Injectable() export class DashboardSettingsService implements OnInit { settings: Observable<Settings[]>; settingsCollection: AngularFirestoreCollection<Settings>; settingDoc: AngularFirestoreDocument<Settings>; public checkedSetting = false; setBackground(setting: Settings) { if (this.checkedSetting == true) { this.checkedSetting = false; } else if(this.checkedSetting == false) { this.checkedSetting = true; }; this.settingDoc = this.afs.doc(`settings/${setting.id}`); this.settingDoc.update({state: this.checkedSetting}); console.log(setting); } constructor(private afAuth: AngularFireAuth,private afs: AngularFirestore) { this.settingsCollection = this.afs.collection('settings'); this.settings = this.settingsCollection.snapshotChanges().map(changes => { return changes.map(a => { const data = a.payload.doc.data() as Settings; data.id = a.payload.doc.id; return data; }); }); } isChecked() { return this.checkedSetting; } getSettings() { return this.settings; } updateSetting(setting: Settings) { this.settingDoc = this.afs.doc(`settings/${setting.id}`); this.settingDoc.update({ state: checkedSetting }); } } ``` Any idea what is causing that? My loop was in a custom component before, so I tried putting it directly in the Dashboard Settings Page, but it's still not working. I have no idea what to check here. I tried putting the : ``` this.dashboardSettingsService.getSettings().subscribe(setting => { this.settings = setting; }) ``` ...part in an ngOninit method instead, or even ionViewWillLoad, and others, but it's not working either. I am using Ionic latest version (3+) and same for Angular (5) Thank you!
2018/01/13
[ "https://Stackoverflow.com/questions/48236493", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1290453/" ]
From the Code you posted i have observed two findings that might be the potential cause for the issue , 1. Calling of the Service method in the constructor : When your setting component is created , then that constructor will be called but but if you were relying on properties or data from child components actions to take place like navigating to the Setting page so move your constructor to any of the life cycle hooks. ``` ngAfterContentInit() { // Component content has been initialized } ngAfterContentChecked() { // Component content has been Checked } ngAfterViewInit() { // Component views are initialized } ngAfterViewChecked() { // Component views have been checked } ``` Even though you add your service calling method in the life cycle events but it will be called only once as you were subscribing your service method in the constructor of the Settings service file . so just try to change your service file as follows : ``` getSettings() { this.settingsCollection = this.afs.collection('settings'); this.settingsCollection.snapshotChanges().map(changes => { return changes.map(a => { const data = a.payload.doc.data() as Settings; data.id = a.payload.doc.id; return data; }); }); } ``` **Update :** Try to change the Getsettings as follows and please do update your question with the latest changes ``` getSettings() { this.settingsCollection = this.afs.collection('settings'); return this.settingsCollection.snapshotChanges().map(changes => { return changes.map(a => { const data = a.payload.doc.data() as Settings; data.id = a.payload.doc.id; return data; }); }); } ```
117,797
I have already seen [How to perform grep on FTP?](https://unix.stackexchange.com/questions/35538/how-to-perform-grep-on-ftp) - that question implies that a `grep` in the remote file contents is needed; and as such, the answer is that the `ftp` protocol does not support that (download of all remote files locally is needed, before a search in their contents can be initiated). I'm looking for something a bit more "simple" - I'd just like to grep/search for remote filenames; I'd imagine this requires that the remote directory tree is somehow downloaded. How could I do this through the command line?
2014/03/02
[ "https://unix.stackexchange.com/questions/117797", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/8069/" ]
Here is one way - using GNU `ftpsync`. Note that the download links on <http://www.gnu.org/software/ftpsync/> seem to be broken as of now; the page you'd need is <http://savannah.gnu.org/projects/ftpsync> ... It seems that I got this via git, probably through the address: ``` git clone git://git.sv.gnu.org/ftpsync.git ``` Note that `ftpsync` is a Perl script, in the `src/` directory of this repo. (Note also there is a different tool, `ftpsync.py` in Python, found at [ftpsync2d - Google Project Hosting](http://code.google.com/p/ftpsync2d/)) Anyways, the trick is simply to try to sync the remote FTP tree to an empty local directory, while having set `ftpsync` to info mode (`-i`) (so no actual download actions are performed), and in verbose mode. Note though, verbose mode (`-v`) seems to be buggy (I get even *less* output to stdout than if I don't use `-v`) ; so below I've used `-d` for debug mode, which seems to work as advertised. Ultimately, I do this: ``` $ mkdir /tmp/test $ cd /tmp/test $ /path/to/ftpsync-git/src/ftpsync -d -i ftp://user:[email protected]/www . 2>&1 | tee _ftpsync_.log Building remote tree ftp://[email protected]/www Detecting if passive needed... Passive Logging in as user. Sync file /tmp/Q44CbrEGUU => Q44CbrEGUU Localtime before 1393782144, Remote 1393782120, after 1393782144 Clock sync offset: 0h00m00s Dir: in www Mod:1327878000 Size:737 .htaccess Mod:1237503600 Size:241 .hiddenfile Dir: stuff in www ... Mod:1353452400 Size:4812800 somefile Building local tree of . Dir: Mod: Size: Died at /path/to/ftpsync-git/src/ftpsync line 1011. ``` After this process is done, you should be having a list of all files and directories under `www/` on remote server, locally in `_ftpsync_.log` - thus later you can grep through this file, to search for remote filenames and subdirectory names. Well - would still like to hear if there are alternative tools for doing this.
30,185
How does one see that the cyclic group $C\_n$ of order $n$ has $\phi(d)$ elements of order $d$ for each divisor $d$ of $n$? (where $\phi(d)$ is the Euler totient function)
2011/03/31
[ "https://math.stackexchange.com/questions/30185", "https://math.stackexchange.com", "https://math.stackexchange.com/users/965/" ]
Given that $h''(u)$ is continuous, you have it right.
163,299
I am trying to output information from one of my org's pricebooks into excel for another department to review. I'm capable of getting the information with a basic select statement, but they would like it formatted differently. I'm currently using the following query: ``` SSELECT Product2Id, Name, CurrencyIsoCode, UnitPrice FROM PricebookEntry WHERE Pricebook2Id = '1234567890' ORDER BY Name, CurrencyIsoCode ``` This gets me a table that looks like this: ``` Product2Id NAME CURRENCYISOCODE UNITPRICE 12345 Example1 EUR 4960 12345 Example1 GBP 4000 12345 Example1 NOK 80000 12345 Example1 USD 5000 12346 Example2 EUR 1000 12346 Example2 GBP 950 12346 Example2 NOK 50000 12346 Example2 EUR 900 ``` Instead I would like to consolidate every row that shares the same productname or associated product2id, to get an output that looks more like this: ``` Product2Id NAME EUR GBP NOK USD 12345 Example1 4960 4000 80000 5000 12346 Example2 1000 950 50000 900 ``` Is there a clean way to do this using just the SOQL query editor in the data loader, or would I need something more advanced to consolidate the data in this fashion?
2017/03/06
[ "https://salesforce.stackexchange.com/questions/163299", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/42647/" ]
Adding this as an answer, after noticing the expected result. Such a advanced query is not supported by a SOQL through dataloader and would not be even possible by a standard report, as you want to create different columns based on currency. You would have two options: 1. Easy but manual- Manipulate the exported excel sheet through dataloader manually. 2. Customization- Create a Visualforce page (having `contentType` as `application/octet-stream"` with logic to display data. When you view this page it would be downloaded automatically. Based upon the requirement you can choose the option.
6,698,265
I have a weird problem where I can't use the normal sizzle selector to correctly select something in jQuery: These two lines don't do the same thing. ``` ele.children("div.a > div").addClass("badActive"); ele.children("div.b").children("div").addClass("active"); ``` <http://jsfiddle.net/wGvEu/1/>
2011/07/14
[ "https://Stackoverflow.com/questions/6698265", "https://Stackoverflow.com", "https://Stackoverflow.com/users/257493/" ]
`ele.children("div.a > div")` selects `div`s that are both children of `div.a` elements (from the `>` combinator) and `ele` (from the `.children()` call). It also implies that `ele` itself represents a `div.a` element. `ele.children("div.b").children("div")` selects `div`s that are children of `div.b` elements, that themselves are children of `ele`. `ele` itself may be any kind of element, but it must contain `div.b` children, and its `div.b` children need to have `div` children. As Felix Kling says in the above comment, you need to use `.find()` to search all descendants. This applies to your first case with the `>` combinator, as `ele.find("div.a > div")`.
42,613,157
I have a small menu made with `dat.gui` JavaScript library. I use different lines with some initial values which are displayed (these initial values are modified during the execution of code). My issue is, for example, that instead of display a value "`15`", I would like to display "15.0000". I try to used `toFixed(4)` function but without success. Here's the raw (without "`toFixed(4)`" function) code snippet : ``` var componentThetaInit = 15; var componentPhiInit = 15; var gui = new dat.GUI({ autoplace: false, width: 350, height: 9 * 32 - 1 }); var params = { StartingVector : '', ComponentVectorTheta : componentThetaInit, ComponentVectorPhi : componentPhiInit }; gui.add(params, 'StartingVector').name('Starting Vector :'); controllerComponentVectorTheta = gui.add(params, 'ComponentVectorTheta', minComponentTheta, maxComponentTheta, 0.0001).name('Component &theta; '); controllerComponentVectorPhi = gui.add(params, 'ComponentVectorPhi', minComponentPhi, maxComponentPhi, 0.0001).name('Component &phi; '); ``` Now I tried : ``` var params = { StartingVector : '', ComponentVectorTheta : componentThetaInit.toFixed(4), ComponentVectorPhi : componentPhiInit.toFixed(4) }; ``` but this doesn't work. Here's below a capture of what I get ("`15`" instead of "`15.0000`") before the execution : [![no floating displayed](https://i.stack.imgur.com/lsLKv.png)](https://i.stack.imgur.com/lsLKv.png) Once the code is running, the 4 floating points are well displayed (because values are no more integers) : this is actually the initial values (before animation) that I would like to be displayed like "`15.0000`" instead of "`15`". The result is the same by declaring : ``` var componentThetaInit = 15.0000; var componentPhiInit = 15.0000; ``` I have also tried : ``` ComponentVectorTheta : parseFloat(componentThetaInit.toFixed(4)), ComponentVectorPhi : parseFloat(componentPhiInit.toFixed(4)) ``` If anyone could see what's wrong, this would be nice. Thanks
2017/03/05
[ "https://Stackoverflow.com/questions/42613157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1773603/" ]
First, some minor bugs. There were some missing variable declarations. I added: ``` var minComponentTheta = -10.0; var maxComponentTheta = 100.0; var minComponentPhi = -100.0; var maxComponentPhi = 100.0; ``` 2) The autoplace param (which should be autoPlace, capital P) has nothing to do with decimal places... it appears to be an option to automatically add the UI to the DOM. None of this actually fixes the issue. It's a problem that starts with javascript. If you put this code in the console you'll see the same problem: ``` var a = 15.0000; console.log(a); // prints 15 and not 15.0000 ``` When a number is an integer, it's an integer. To get around this, you can have your default value have a non integer value like 15.0001. This probably isn't what you're looking for though. So, if you are up for modifying the code for dat.gui.js you can force it to set the value of the input to the string version of the number value. Find the code that looks like this and copy and paste the code below replacing it. I've simply added a toFixed at the end of the first line in the function. Be aware that when you get the value now, it will be a string and not a number, so to do math with it you'll want to parseFloat() on it before using it. ``` NumberControllerBox.prototype.updateDisplay = function updateDisplay() { this.__input.value = this.__truncationSuspended ? this.getValue() : roundToDecimal(this.getValue(), this.__precision).toFixed(this.__precision); return _NumberController.prototype.updateDisplay.call(this); }; ``` In the unminified JS version, ^ that's on line 2050. I verified this works as you want [![4 decimal places](https://i.stack.imgur.com/Wi1q8.png)](https://i.stack.imgur.com/Wi1q8.png)
8,558,711
How to call a stored procedure from sqlplus? I have a procedure: ``` Create or replace procedure testproc(parameter1 in varachar2,parameter2 out varchar2) begin Do something end; ``` I tried exec `testproc(12,89)` ::Returns error
2011/12/19
[ "https://Stackoverflow.com/questions/8558711", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1083287/" ]
The second parameter of your procedure is an `OUT` parameter -- its value will be assigned to the variable passed when the procedure completes. So you can't use a literal value for this parameter. You can declare a bind variable at the SQLPlus prompt and use that: ``` -- Declare bind variable VARIABLE x NUMBER -- If necessary, initialize the value of x; in your example this should be unnecessary -- since the value of the second parameter is never read EXEC :x := 1 -- Call the procedure EXEC testproc(12, :x) -- Print the value assigned to the bind variable PRINT x ``` Alternatively, you can use an anonymous PL/SQL block: ``` -- Activate client processing of dbms_output buffer SET SERVEROUTPUT ON -- In anonymous block, declare variable, call procedure, print resulting value DECLARE x NUMBER; BEGIN testproc(12, x); dbms_output.put_line( x ); END; / ```
2,266
As it is December 2012, we are now going to reset our Community Promotion Ads for the new year. ### What are Community Promotion Ads? Community Promotion Ads are community-vetted advertisements that will show up on the main site, in the right sidebar. The purpose of this question is the vetting process. Images of the advertisements are provided, and community voting will enable the advertisements to be shown. ### Why do we have Community Promotion Ads? This is a method for the community to control what gets promoted to visitors on the site. For example, you might promote the following things: * cool web app related open source apps * the site's twitter account * cool events or conferences * anything else your community would genuinely be interested in The goal is for future visitors to find out about *the stuff your community deems important*. This also serves as a way to promote information and resources that are *relevant to your own community's interests*, both for those already in the community and those yet to join. ### Why do we reset the ads every year? Some services will maintain usefulness over the years, while other things will wane to allow for new faces to show up. Resetting the ads every year helps accommodate this, and allows old ads that have served their purpose to be cycled out for fresher ads for newer things. This helps keep the material in the ads relevant to not just the subject matter of the community, but to the current status of the community. We reset the ads once a year, every December. The community promotion ads have no restrictions against reposting an ad from a previous cycle. If a particular service or ad is very valuable to the community and will continue to be so, it is a good idea to repost it. It may be helpful to give it a new face in the process, so as to prevent the imagery of the ad from getting stale after a year of exposure. ### How does it work? The answers you post to this question *must* conform to the following rules, or they will be ignored. 1. All answers should be in the exact form of: ``` [![Tagline to show on mouseover][1]][2] [1]: http://image-url [2]: http://clickthrough-url ``` Please **do not add anything else to the body of the post**. If you want to discuss something, do it in the comments. 2. The question must always be tagged with the magic [community-ads](/questions/tagged/community-ads "show questions tagged 'community-ads'") tag. In addition to enabling the functionality of the advertisements, this tag also pre-fills the answer form with the above required form. ### Image requirements * The image that you create must be **220 x 250 pixels** * Must be hosted through our standard image uploader (imgur) * Must be GIF or PNG * No animated GIFs * Absolute limit on file size of 150 KB ### Score Threshold There is a **minimum score threshold** an answer must meet (currently **6**) before it will be shown on the main site. You can check out the ads that have met the threshold with basic click stats [here](https://webapps.meta.stackexchange.com/ads/display/2266).
2012/12/10
[ "https://webapps.meta.stackexchange.com/questions/2266", "https://webapps.meta.stackexchange.com", "https://webapps.meta.stackexchange.com/users/5225/" ]
[![Follow Web Apps on Twitter!](https://i.stack.imgur.com/5aP3b.png)](http://twitter.com/StackWebApps)
211,171
Can a FOC control scheme be done using a rotary encoder to measure the position, speed and acceleration directly, or is measuring current necessary? FOC is a motor control scheme as described in links below: <http://www.atmel.com/Images/doc32126.pdf> <http://www.eetimes.com/document.asp?doc_id=1279321> Quote from the second link: > > Field Oriented Control is one of the methods used in variable frequency drives or variable speed drives to control the torque (and thus the speed) of three-phase AC electric motors by controlling the current. With FOC, the torque and the flux can be controlled independently. FOC provides faster dynamic response than is required for applications like washing machines. There is no torque ripple and smoother, accurate motor control can be achieved at low and high speeds using FOC. > > >
2016/01/13
[ "https://electronics.stackexchange.com/questions/211171", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/61946/" ]
You appear to have two questions. > > Can 3-phase FOC control be done without current measurement? > > > No; The point of field orientated control is to ... control the field in the electrical machine. This relies on knowing what the field is > > Can a FOC control scheme be done using a rotary encoder to measure the > position, speed and acceleration directly, or is measuring current > necessary? > > > Well, Field orientated control relies on knowing where the rotor is so that correctly phase aligned currents can be synthesised. A rotary encoder (resolver, analogue hall effect sensing etc...) can be used to measure the instantaneous position & thus derive speed and acceleration. The existence of position sensing is to complement current sensing. Sensorless control would remove the need for a rotary encoder, although the workable schemes end up using voltage sensing so "sensorless" is a bit misleading.
47,638
I was trying to remove the **rel=prev** and **rel=next** tags from my website as my SEO gut suggested. I found those functions which perfectly do the magic: ``` remove_action('wp_head', 'start_post_rel_link', 10, 0 ); remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); ``` however, after a while my SEO guy suggested to leave it on a categories section where over there it's necassary as far as SEO. is there a simple way of implementing the **rel=prev** and **rel=next** tags **only on a categories** pages?, e.g: **www.website.com/category/category-name** and remove it from all other post types? (post, page, homepage etc etc) Thanks, GIl
2012/04/02
[ "https://wordpress.stackexchange.com/questions/47638", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7730/" ]
Not entirely sure if I agree with the explanation of your SEO guy as rel=prev and rel=next are used for **paginated** archives. Of course categories can be one, but also your blog if it'd contain multiple pages. Anyways, here's what I'm currently using: ``` remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' ); add_action( 'wp_head', 'cor_rel_next_prev_pagination' ); /** * Pagination with rel="next" and rel="prev". * * @link wp-includes|default-filters.php * @link http://core.trac.wordpress.org/ticket/18672 Implement rel="prev" and rel="next" for archives * @link http://googlewebmastercentral.blogspot.com/2011/09/pagination-with-relnext-and-relprev.html Pagination with rel="next" and rel="prev" */ function cor_rel_next_prev_pagination() { global $paged; if ( get_previous_posts_link() ) { ?> <link rel="prev" href="<?php echo get_pagenum_link( $paged - 1 ); ?>"> <?php } if ( get_next_posts_link() ) { ?> <link rel="next" href="<?php echo get_pagenum_link( $paged + 1 ); ?>"> <?php } } ``` Edit: also I believe `start_post_rel_link` is no longer being used.
1,533,999
This seems inconsistent, but probably is due to the fact that I'm new to javascript's prototype inheritance feature. Basically, I have two base class properties, "list" and "name". I instantiate two subclasses and give values to the properties. When I instantiate the second subclass, it gets the list values from the first subclass instance, but only for the "list" and not for "name". What's going on?? Of course, I would prefer that any subsequent subclass instances not get values from other instances, but if that's going to happen, it should be consistent! Here is a code snippet: ``` function A() { this.list = []; this.name = "A"; } function B() { } B.prototype = new A(); var obj1 = new B(); obj1.list.push("From obj1"); obj1.name = "obj1"; var obj2 = new B(); //output: //Obj2 list has 1 items and name is A //so, the name property of A did not get replicated, but the list did alert("Obj2 list has " + obj2.list.length + " items and name is "+ obj2.name); ```
2009/10/07
[ "https://Stackoverflow.com/questions/1533999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/185925/" ]
The thing with prototypes, is that you can do reads all day long from them, and it wont change the underlying structure of what is pointing to what. However, the first time you do an assignment, you are replacing, on *that* instance, what that property points to. In your case, you didn't actually reassign the prototyped property, you modifed the value of the underlying structure that was found at in that property. What this means is that all objects that share a prototype of A actually *share* the implementation of A. That means any state carried in A will be found on all instances of B. The moment you do an assignment to that property on an instance of B, you have effectively replaced what that instance (and only that instance) points to (I believe this is due to the fact there is a new property "name" on B that gets hit in the scope chain, before it reaches the "name" implementation on A). EDIT: To give a more explicit example of whats going on: ``` B.prototype = new A(); var obj1 = new B(); ``` Now, the first time we do a read, the intepreter does something like this: ``` obj1.name; ``` Interpreter: "I need property name. First, check B. B does not have 'name', so lets continue down the scope chain. Next up, A. Aha! A has 'name', return that" However, when you do a write, the interpreter doesn't actually care about the inherited property. ``` obj1.name = "Fred"; ``` Interpreter: "I need to assign to property 'name'. I'm within the scope of this *instance* of B, so assign 'Fred' to B. But I leave everything else farther down the scope chain alone (i.e., A)" Now, next time you do a read... ``` obj1.name; ``` Interpreter: "I need property 'name'. Aha! this *instance* of B has the property 'name' already sitting on it. Just return that - I don't care about the rest of the scope chain (i.e. A.name)" So, the first time you write to name, it inserts it as a first class property on the instance, and doesn't care anymore about what is on A. A.name is *still there*, it's just further down the scope chain, and the JS interpreter doesn't get that far before it found what it was looking for. If "name" had a default value in A (as you have, which is "A"), then you would see this behaviour: ``` B.prototype = new A(); var obj1 = new B(); var obj2 = new B(); obj1.name = "Fred"; alert(obj1.name); // Alerts Fred alert(obj2.name); // Alerts "A", your original value of A.name ``` Now, in the case of your array, you never actually *replaced* list on the scope chain with a new array. What you did is grab a handle on the array itself, and added an element to it. Hence, all instances of B are affected. Interpreter: "I need to get the 'list' propery, and add an element to it. Checking this instance of B ... nope, does not have a 'list' property. Next in the scope chain: A. Yep, A has 'list', use that. Now, push onto that list" This would *not* be the case if you did this: ``` obj1.list = []; obj1.push(123); ```
56,560,927
I am trying to connect angular 6 project with spring boot application. When I run angular project, it constantly gives this error, although I have installed all the dependencies and imports. I have used following line of code in controller class. > > @CrossOrigin(origins = "<http://localhost:4200/>", maxAge = 3600) > > > I have also included this SimpleCORSFilter.java file in java folder: ``` package com.oms; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @Component public class SimpleCORSFilter implements Filter { private final Logger log = LoggerFactory.getLogger(SimpleCORSFilter.class); public SimpleCORSFilter() { log.info("SimpleCORSFilter init"); } @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Credentials", "true"); response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); response.setHeader("Access-Control-Max-Age", "3600"); response.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With, remember-me"); chain.doFilter(req, res); } @Override public void init(FilterConfig filterConfig) { } @Override public void destroy() { } } ``` Also I have created proxy.conf.json file in angular project: ``` { "/api": { "target": "http://localhost:8080", "secure": false } } ``` This file is included like this in angular.json: > > "start": "ng serve --proxy-config proxy.conf.json", > > > Still I am getting this error: > > Access to XMLHttpRequest at > '<http://localhost:8080/fetchAll>' from origin > '<http://localhost:4200>' has been blocked by CORS policy: Request > header field authorization is not allowed by > Access-Control-Allow-Headers in preflight response.\*\* > > > I referred such type of queries, but could not get the exact solution. I am really confused, if there is any error in code? What steps should be taken to resolve this issue?
2019/06/12
[ "https://Stackoverflow.com/questions/56560927", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8826507/" ]
When you are using Spring Boot, I would suggest you to add a **CorsFilter** bean in your configurations instead of introducing a CORS filter. Let me know if this helps. ``` @Bean public CorsFilter corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); config.addAllowedOrigin("*"); config.addAllowedHeader("*"); config.addAllowedMethod("OPTIONS"); config.addAllowedMethod("GET"); config.addAllowedMethod("POST"); config.addAllowedMethod("PUT"); config.addAllowedMethod("DELETE"); source.registerCorsConfiguration("/**", config); return new CorsFilter(source); } ``` > > Happy Coding :) > > >
20,781,908
I have developed application using iOS 6 . Now as there is requirement I have updated my application with iOS 7 look and feel with some UI changes . And it is running well on iOS 7 device . But how can I use same application to run on iOS 6 device with iOS look and feel. I have set the deployment target to 5 . The first problem is my Xcode 5 is not detecting the iOS 6 device . can anybody help me ?
2013/12/26
[ "https://Stackoverflow.com/questions/20781908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1355169/" ]
I think the answer you are looking for is this. <http://www.docjar.com/docs/api/sun/reflect/generics/parser/SignatureParser.html>
146,013
After a reinstall of Ubuntu 12.04 ,it's impossible to install commercial games, e.g Oil Rush. It gives this error: ``` Failed to fetch https://private-ppa.launchpad.net/commercial-ppa-uploaders/oilrush/ubuntu/dists/oneiric/main/binary-amd64/Packages The requested URL returned error: 401 Failed to fetch https://private-ppa.launchpad.net/commercial-ppa-uploaders/oilrush/ubuntu/dists/oneiric/main/binary-i386/Packages The requested URL returned error: 401 Some index files failed to download. They have been ignored, or old ones used instead. ``` I bought these games in 11.10, but I installed these games in 12.04 before... How can I solve this problem?
2012/06/03
[ "https://askubuntu.com/questions/146013", "https://askubuntu.com", "https://askubuntu.com/users/68145/" ]
I had the same problem trying to reinstall Steel Storm: Burning Retribution. Error 401 is an authentication error. I just found out to get it back for my case I hope it will help. First, you need to know that your authentication details for the PPA are stored in `/etc/apt/auth.conf`. Second you need to verify that the details are correct by going to <https://launchpad.net> and connecting with the details you used to purchase the software. Once logged in click on your name if the right top corner (next to the logout button). In the "Personal package archives" section click on "View your private PPA subscriptions". On the right side of the line corresponding to your purchase click on "view" You should now see something that looks like this: ``` deb https://**USERNAME**:**PASSWORD**@private-ppa.launchpad.net/commercial-ppa-uploaders/**PURCHASE**/ubuntu **YOUR\_UBUNTU\_VERSION\_HERE** main ``` Verify that **`USERNAME`** and **`PASSWORD`** respectively match **login** and **password** in your `/etc/apt/auth.conf` file. Once `/etc/apt/auth.conf` is updated with the correct details, run as `sudo apt-get update` from the terminal and check if you still get error messages, if you don't you should now be able to re-install the game. Another problem that you can have is if your game doesn't have a PRECISE version yet, in that case you need to go in `/etc/apt/sources.list.d/` and modify the file containing the description of the private PPA (in my case `/etc/apt/sources.list.d/private-ppa.launchpad.net_commercial-ppa-uploaders_steel-storm2_ubuntu.list`). ### Example in my case: I had to replace this line: ``` deb https://private-ppa.launchpad.net/commercial-ppa-uploaders/steel-storm2/ubuntu precise main ``` ...with this: ``` deb https://private-ppa.launchpad.net/commercial-ppa-uploaders/steel-storm2/ubuntu oneiric main ```
162,907
I am developing a series of maps in ArcGIS 10 and don't have a lot of space to label the features on the map. This is why I thought I would number each feature in the dataframe through and then export the labels as a list and put them in the map legend. So a list in the following way is created and added to the legend ``` SO 1 Label 2 Label 3 Label ``` My current workflow to do this is the following: I am adding an attribute 'number' manually for example for all the orange SO points, then I label them with the number. I then export it as a table into Excel and then into Illustrator to generate a nice looking table and copy it back into ArcMap as an image. Is there an easier way to do this in ArcGIS, I have a lot of maps to do and doing this manually takes a lot of time? Can you think of a better solution to do this?
2015/09/14
[ "https://gis.stackexchange.com/questions/162907", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/44668/" ]
Here's a cursor free option that I think would work. ``` arcpy.SelectLayerByLocation_management(Polygons, "CONTAINS", peakPoints, "NEW_SELECTION") arcpy.SelectLayerByLocation_management(Polygons, "CONTAINS", troughPoints, "REMOVE_FROM_SELECTION") field = "area_calc" arr = arcpy.da.TableToNumpyArray(Polygons, field) maxArea = arr["area_calc"].max() arcpy.SelectLayerByAttribute_management(Polygons, ' "area_calc" = ' + str(maxArea)) arcpy.FeatureClassToFeatureClass_conversion(Polygons, OutputGDB, OutputFC) ``` You can do more Select by locations with "REMOVE\_FROM\_SELECTION" if you have more feature classes that you need to exclude.
80,701
I was trying to find the setting to disable the wallpaper on my Android phone. I've found some suggestion which suggest to make a fake black png or something like that, but it's going around the problem instead of solving it. Technically, it's still a wallpaper, and I don't want to have any... How to set **not** to use wallpaper on Android? There must be some way, even on Windows it's possible... I'm using Samsung Galaxy S4
2014/08/17
[ "https://android.stackexchange.com/questions/80701", "https://android.stackexchange.com", "https://android.stackexchange.com/users/10447/" ]
I found the easiest way to do this was with the application [Color Wallpaper](https://play.google.com/store/apps/details?id=com.ellipselab.android.colorwallpaper). All the possible colors selectable from a menu, and i haven't changed the color in months. You can set it and forget it. Even uninstall after setting, if that is your wish. Disclaimer: I am not the developer of this application, just a satified user - for years.
19,408,349
My htaccess file works on localhost but doesn't work when i deploy it to EC2 instance. I'm using Macbook and in finder i cannot see the htaccess file, i thought that perhaps it didn't get copied to EC2 instance but i don't think this is the problem because when i copy the project i can see the htaccess file in my editor. Is there something enabling mod rewrite in EC2 linux instance? If there is, i didn't do it or it enables mod rewrite as default? ``` RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php/$1 [L] ```
2013/10/16
[ "https://Stackoverflow.com/questions/19408349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1672029/" ]
I pieced together some info from various posts so I thought I'd put up an answer. 1. As Paul commented, If you're running Amazon EC2 Linux, you're probably running httpd instead of Apache. The file is therefore in `/etc/httpd/conf/httpd.conf` 2. You have to change the file as root user. (from ssh access) Do this: `sudo vim /etc/httpd/conf/httpd.conf` ([How to edit httpd.conf file in AMAZON EC2](https://stackoverflow.com/questions/15112424/how-to-edit-httpd-conf-file-in-amazon-ec2)) 3. `DocumentRoot "/var/www/html"` was listed in two places for me. I had to change the subsequent `AllowOverride None` to `AllowOverride All` in those two places. 4. Restart apache. I restarted my whole ec2 instance (i have apache configured to start automatically) although just restarting apache should work. But I see the change is working. I was trying to make the same changes in a .htaccess file (removing the index.php from urls in a code igniter application). Hope it helps!
56,571,968
I am trying to partition the hive table with distinct timestamps. I have a table with timestamps in it but when I execute the hive partition query, it says that it is not a valid partition column. Here's the table: ``` +---+-----------------------+ |id |rc_timestamp | +---+-----------------------+ |1 |2017-06-12 17:18:39.824| |2 |2018-06-12 17:18:39.824| |3 |2019-06-12 17:18:39.824| +---+-----------------------+ ``` ``` spark.sql("SET hive.exec.dynamic.partition.mode=nonrestrict") val tempTable = spark.sql("SELECT * FROM partition_table") val df = tempTable.select("rc_timestamp") val a = x.toString().replaceAll("[\\[\\]]","") df.collect().foreach(a => { spark.sql(s"ALTER TABLE mydb.partition_table ADD IF NOT EXISTS PARTITION (rc_timestamp = '$a')").show() )} ``` Here's the error which I'm getting: ``` org.apache.spark.sql.AnalysisException: rc_timestamp is not a valid partition column in table mydb.partition_table.; ```
2019/06/13
[ "https://Stackoverflow.com/questions/56571968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11157223/" ]
First thing is check your syntaxes using this [InsertSuite test case](https://github.com/apache/spark/blob/master/sql/hive/src/test/scala/org/apache/spark/sql/hive/InsertSuite.scala) specially [this](https://github.com/apache/spark/blob/master/sql/hive/src/test/scala/org/apache/spark/sql/hive/InsertSuite.scala#L773) AFAIK you need msck repair or refresh table ``` spark.sql(s"refresh table tableNameWhereYouAddedPartitions") ``` what it does is it will refresh the existing partitions. you can go with `spark.sql('MSCK REPAIR TABLE table_name')` There is something called `recoverPartitions` (Only works with a partitioned table, and not a view). This is aliased version of `msck repair table`. you can go ahead and try this.. see this [ddl.scala](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala#L570) seems like its equalent by documentation. example usage : ``` spark.catalog.recoverPartitions(tableName) ``` Note: The RECOVER PARTITIONS clause automatically recognizes any data files present in these new directories, the same as the REFRESH statement does.
61,208,657
I have an application, where depending by a condition i want to hide or to show data. So, i added the condition: ```js columnTitle:selectedRowKeys.length > 0? { selections: true }: { selections: false }, ``` But the condition does not work. When i will click on a checkbox, i want to display `selections`, and when none of a checkbox is clicked, i want to hide the `selections`. This is my code: <https://codesandbox.io/s/custom-selection-ant-design-demo-mvy5j?file=/index.js:982-1017> How to solve the issue? selections is this dropdown: [![enter image description here](https://i.stack.imgur.com/IFQyo.png)](https://i.stack.imgur.com/IFQyo.png)
2020/04/14
[ "https://Stackoverflow.com/questions/61208657", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12540500/" ]
Your code should be like this (false should also work instead of null) ``` columnTitle: selectedRowKeys.length > 0 ? true : null, ``` You can also do like this (double NOT to make it boolean) ``` columnTitle: !!selectedRowKeys.length, ``` instead of (what you have now.) ``` columnTitle:{selections : selectedRowKeys.length > 0 ? true : false}, ``` Check this - <https://codesandbox.io/s/custom-selection-ant-design-demo-g1u4f>
39,348,171
I am trying to understand "synchronized block" in Java. I have written very basic code to see what happens if I lock and change the object in thread\_1 and access to it from another thread\_2 (race condition) via another method. But I am in trouble to understand the behaviour because I was expecting Thread\_1 would change value first and then Thread\_2 would access the new value but the result was not as I expected. ``` public class Example { public static void main(String[] args){ final Counter counter = new Counter(); Thread threadA = new Thread(new Runnable() { @Override public void run() { System.out.println("THREAD_1_START"); counter.add(1); System.out.println("THREAD_1_END"); } }); Thread threadB = new Thread(new Runnable() { @Override public void run() { System.out.println("THREAD_2_START"); System.out.println("GET_A_BY_THREAD_2:"+counter.getA(2)); System.out.println("THREAD_2_END"); } }); threadA.start(); threadB.start(); } } public class Counter{ String A = "NONE"; public void add(long value){ synchronized (A) { System.out.println("LOCKED_BY_"+value); for(int i = 0; i < 1000000000; i++ ){} setA("THREAD_"+value); System.out.println("GET_A_BY_THREAD:"+getA(value)); } } public void setA(String A){ System.out.println("Counter.setA()"); this.A = A; System.out.println("Counter.setA()_end"); } public String getA(long value){ System.out.println("Counter.getA()_BY_"+value); return this.A; } } ``` The Output is: ``` THREAD_1_START THREAD_2_START LOCKED_BY_1 Counter.getA()_BY_2 GET_A_BY_THREAD_2:NONE THREAD_2_END Counter.setA() Counter.setA()_end Counter.getA()_BY_1 GET_A_BY_THREAD:THREAD_1 THREAD_1_END ``` Thread\_1 locks the "A" string object and changes it but Thread\_2 can read the value before it changes. When "A" is in lock, how can thread\_2 can access the "A" object?
2016/09/06
[ "https://Stackoverflow.com/questions/39348171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4128283/" ]
> > Thread\_1 locks the "A" string object and changes it > > > No, Thread\_1 locks on the "NONE" string object, creates a new String object, and overwrites the `A` field with a reference to this new object. Thread\_2 can now acquire its free lock, however in your current code the `getA` method doesn't even attempt to acquire it. You must use locking for *all* access, not just writing. Therefore `getA` must also contain a synchronized block. The general rule is to never use mutable instance fields for locking. Doing that provides you with no useful guarantees. Therefore your `A` field should be `final` and you must delete all code that disagrees with that.
66,608,701
I have a parquet file and created a new External table, but the performance is very slow as compare to a normal table in the synapse. Can you please let me know how to over come this.
2021/03/12
[ "https://Stackoverflow.com/questions/66608701", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1992023/" ]
Very broad question. So I'll give broad answer: 1. Use normal table. Hard to beat performance of "normal table" with external tables. "normal table" means a table created in a Dedicated SQL pool using `CREATE TABLE`. If you're querying data from one or more tables repeatedly and each query is different (group-by, join, selected columns) then you can't get beat performance of "normal" table with external tables. 2. Understand and apply basic [best practices](https://learn.microsoft.com/en-us/azure/synapse-analytics/sql/best-practices-sql-on-demand): * Use parquet format, which you're doing. * Pick right partition column and partition your data by storing partitions to different folders or file names. * If a query targets a single large file, you'll benefit from splitting it into multiple smaller files. * Try to keep your CSV (if using csv) file size between 100 MB and 10 GB. * Use correct data type. * Manually create statistics for CSV files * Use CETAS to enhance query performance and joins ...and many more.
9,974
**Background of problem** We are developing an extranet. It's primary purpose is to share pdf's and xls files with external customers. After content deployment, everything works as expected, except the pdf's and xls documents fail to import. I will respond as quickly as possible to any additional requests for background on the behavior. **Topology** We have an internal authoring environment and an external content deployment target outside the firewall. We set up content deployment between the two environments. The source site is based upon the team site site collection template. **Due Diligence** 1. I have confirmed that both the source and the target are at the same patch level for SharePoint and SQL 2008 2. The target site was created leaving the site collection as "Choose template later" 3. Our 2 custom solutions that provision the lists and styling were deployed to the target, but their features were not activated. 4. The lists do *not* require content approval. **What works** When we run content deployment, the following work as expected: 1. Custom features are activated 2. Master pages, images, css are deployed 3. Custom lists are created. **Issue** Everything behaves as expected, except none of the "meat" of the site (the actual document library items) is created. **Log** Below is the log section for both a master page and an example pdf. Note that they are nearly exactly the same (Names changed to protect the innocent). ``` Good: [3/2/2011 9:24:08 AM] [ListItem] [Foo.Default.Master] Progress: Importing [3/2/2011 9:24:08 AM] [ListItem] [Foo.Default.Master] Verbose: List URL: /_catalogs/masterpage [3/2/2011 9:24:08 AM] [ListItem] [Foo.Default.Master] Progress: Importing Links [3/2/2011 9:24:08 AM] [ListItem] [Foo.Default.Master] Verbose: Import 1 server-relative links. Bad [3/2/2011 9:24:08 AM] [ListItem] [ExampleDocument.pdf] Progress: Importing [3/2/2011 9:24:08 AM] [ListItem] [ExampleDocument.pdf] Verbose: List URL: /Customer Reports [3/2/2011 9:24:08 AM] [ListItem] [ExampleDocument.pdf] Progress: Importing Links [3/2/2011 9:24:08 AM] [ListItem] [ExampleDocument.pdf] Verbose: Import 1 server-relative links. ``` We also received ~100 of these exceptions on the first run of content deployment, but the amount of errors do not correspond to the number of imported documents (~5000). Googling around a bit hints that this might not be the reason for our problems, but I'm putting it out there in case I'm wrong. ``` [3/2/2011 9:26:01 AM] Debug: at Microsoft.SharePoint.Deployment.ImportObjectManager.FixBrokenMvlInListItem(ListItemMvl brokenField) at Microsoft.SharePoint.Deployment.ImportObjectManager.FixBrokenLookup(DeploymentLookupField brokenField) ``` ...Peter
2011/03/05
[ "https://sharepoint.stackexchange.com/questions/9974", "https://sharepoint.stackexchange.com", "https://sharepoint.stackexchange.com/users/1289/" ]
Content deployment is tricky to get working in SharePoint 2007, and you seem to have done everything right from reading through the question. Obviously, the larger the amount of content, the trickier it is. There seem to be problems related to the length of time it takes to migrate the content. A good starting point is [Stefan Gossner's blog series on this subject](http://blogs.technet.com/b/stefan_gossner/archive/2007/08/30/deep-dive-into-the-sharepoint-content-deployment-and-migration-api-part-1.aspx). In SharePoint 2010 the content deployment mechanism seems to be a lot faster and more reliable.
29,357,429
I have a short question! I am selecting a number of rows as simple as the following: ``` SELECT * FROM ... WHERE ... GROUP BY ... ``` I would like to add another field/attribute to results sets, let's say `last`, which determines if the current row is the last one in the results set. I would like the results set look like the following? ``` id name last --- ---- ---- 12 foo false 20 smth false 27 bar true ```
2015/03/30
[ "https://Stackoverflow.com/questions/29357429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/774437/" ]
You can use the [gsutil stat](https://cloud.google.com/storage/docs/gsutil/commands/stat) command.
52,771,321
I am trying to loop this if statement until the user inputs the right answer. it does not end when ran even if i put in the right input. Also how do i use the playerPick variable outside of the while loop without messing up the code? ``` System.out.println("Please choose either Applaro, Svartra, Tunholmen, or Godafton."); boolean temp = true; while (temp) { String playerPick = console.next(); if (!playerPick.equals("Applaro") && !playerPick.equals("Svartra") && !playerPick.equals("Tunholmen") && !playerPick.equals("Godafton")) { System.out.println("Please enter a valid input."); } else if (playerPick.equals("Applaro") || playerPick.equals("Svartra") || playerPick.equals("Tunholmen") || playerPick.equals("Godafton")) { System.out.println("You have picked " + playerPick); } } ```
2018/10/12
[ "https://Stackoverflow.com/questions/52771321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10492729/" ]
Just set `temp = false` like example below: ``` System.out.println("Please choose either Applaro, Svartra, Tunholmen, or Godafton."); boolean temp = true; while (temp) { String playerPick = console.next(); if (!playerPick.equals("Applaro") && !playerPick.equals("Svartra") && !playerPick.equals("Tunholmen") && !playerPick.equals("Godafton")) { System.out.println("Please enter a valid input."); } else if (playerPick.equals("Applaro") || playerPick.equals("Svartra") || playerPick.equals("Tunholmen") || playerPick.equals("Godafton")) { System.out.println("You have picked " + playerPick); //here temp = false; } } ```