title
stringlengths
15
150
body
stringlengths
38
32.9k
label
int64
0
3
wso2 APIManager: Add PingIdentity as new OAuth-Endpoint
<p>We are planing to use PingFederate-Server as our central identity managment solution. What are the steps to integrate the ping server oauth-endpoint to our wso2 landscape. Is there already a solution available?</p> <p>I read the blog-post <a href="https://amilasnotes.wordpress.com/2015/05/19/integrating-with-a-third-party-oauth-provider-overview" rel="nofollow">https://amilasnotes.wordpress.com/2015/05/19/integrating-with-a-third-party-oauth-provider-overview</a> and it looks like that this task is possible.</p> <p>Has someone experienced replacing the internal wso2 key-manager?</p> <p>And is it possible to use both keymanagement solution (interal and ping), so that we don't need to migrate the current applications/access-tokens?</p> <p>Thx, in advance Marty</p>
3
signal sigabrt error: Assertion failure in -[_ASDisplayLayer setNeedsLayout]
<p>I need help with the above-mentioned error. My project is using AsyncDisplayKit and I am getting the error above in the _ASDisplayLayer.mm file line 104 in the method </p> <pre><code>- (void)setNeedsLayout { ASDisplayNodeAssertMainThread();//line 104 where error is occuring [super setNeedsLayout]; } </code></pre> <p>I don't know how to solve this problem as I am new to the library and I am just rerunning a previous developer's work. Full error stack is: <strong>* Assertion failure in -[_ASDisplayLayer setNeedsLayout], /Users/.../Desktop/.../Pods/AsyncDisplayKit/AsyncDisplayKit/Details/_ASDisplayLayer.mm:104 2016-03-16 00:17:08.951 DanceRockIt[408:168719] *</strong> Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '' *** First throw call stack: (0x252fa2eb 0x24ac6dff 0x252fa1c1 0x25ad0d3b 0x27f519 0x2755f93b 0x2755f3d9 0x2756240b 0x2758f1f5 0x2949954b 0x297c4525 0x294b3a69 0x294f9e2d 0x2956c68d 0x2956d473 0x2956b935 0x345515 0x345259 0x12abcd 0x106ccbf 0x10775c3 0x106fefb 0x1079017 0x1078909 0x25030e0d 0x250309fc) libc++abi.dylib: terminating with uncaught exception of type NSException</p>
3
Can not update a system app
<p>I have a application preloaded on ROM, and put it on system app. Current version code is 3. This apk also published on Google Play.</p> <p>Note : All cases below I use same key store, same package with the apk preloaded on ROM.</p> <p><strong>* From Android Studio, I build a new version and upgrade version code to 4.</strong></p> <p><strong>Case 1:</strong></p> <p>I copy this apk to phone and install manually. Phone display "Can not install". I check the log and it show :</p> <p><em>"W/PackageManager: Package xxx signatures do not match the previously installed version; ignoring!"</em></p> <p><strong>Case 2:</strong></p> <p>I uploaded the new apk to Google Play. Google Play accept it normally. After Google approved and published the app, I open Google Play app , find my app and check the status. It displayed "UnInstalled" and "Open".( It should display "Update" but it did not).</p> <p>Right now I can not update my application. Can anybody tell me what is the reason for this case?</p>
3
hmac signature different in python and php
<p>I need little help to figure out issue with php <code>hash_hmac</code>. I am converting a existing <code>python</code> script into <code>php</code> that call an api for process data. Python script is working fine. </p> <p>There is few similar question out there, one of them is <a href="https://stackoverflow.com/questions/31919154/hmac-value-not-consistent-in-python-and-php">HMAC value not consistent in Python and PHP</a> but it dosen't help me. I have tried many way but all time i am getting error <em>your signature doesn't match</em></p> <p>Here is my <code>php</code> code</p> <pre><code>$session_id = xxxxxxxxxxxxxxxxxxxxx; $accessKey = xxxxxxxxxxxxxxxxxxxxxx; $url = '/APIENDPOINT?action=mobileAccess&amp;autoJoin=true'; $timestamp = date('r'); $body = '{"expireTime": "20160322T2359", "doorOperations": [{"operation": "guest", "doors": ["103"]}], "endPointID": "enpointID", "format": "rfid48"}'; $params["action"] = "mobileAccess"; $params["override"] = "true"; $canonicalized_query = array(); foreach ($params as $param =&gt; $value) { $param = str_replace("%7E", "~", rawurlencode($param)); $value = str_replace("%7E", "~", rawurlencode($value)); $canonicalized_query[] = $param . "=" . $value; } ksort($canonicalized_query); $canonicalized_query = implode("&amp;", $canonicalized_query); $string_to_sign = "POST\n"; $string_to_sign .= base64_encode(md5($body, true))."\n"; $string_to_sign .="application/json;charset=utf-8\n"; $string_to_sign .= $timestamp."\n"; $string_to_sign .= 'APIEDNPOINT?'.$canonicalized_query; echo strlen($string_to_sign); $header=array( 'Date: '.$timestamp, 'Content-Type: application/json;charset=utf-8', 'Content-MD5: '.base64_encode(md5($body, true)), 'Authorization: Basic '.$session_id.':'.base64_encode(hash_hmac('sha1', iconv(mb_detect_encoding($string_to_sign, mb_detect_order(), true), "UTF-8", $string_to_sign), iconv(mb_detect_encoding($accessKey, mb_detect_order(), true), "UTF-8", $accessKey), true)) </code></pre> <p>Here is working <code>python</code> code</p> <pre><code>url=self._basepath+url headers={} if body: # Encode request body as JSON body=json.dumps(body) headers['Content-Type']='application/json;charset=utf-8' # Compute MD5 digest h=hashlib.new('md5') h.update(body) headers['Content-MD5']=base64.b64encode(h.digest()) # Format the date correctly, after applying the client/server skew headers['Date']=email.Utils.formatdate(time()+self._time_skew) if sign and 'id' in self._session: # Canonicalize the URL (canonicalized_resource,q,query_string)=url.partition('?') canonicalized_resource+=q+'&amp;'.join(sorted(query_string.split('&amp;'))) # Build the string to be signed string_to_sign=method+"\n" if 'Content-MD5' in headers: string_to_sign+=headers['Content-MD5'] string_to_sign+="\n" if 'Content-Type' in headers: string_to_sign+=headers['Content-Type'] string_to_sign+="\n"+headers['Date']+"\n"+canonicalized_resource # Create the signature h=hmac.new(self._session['accessKey'].encode('utf-8'),\ string_to_sign.encode('utf-8'),hashlib.sha1) headers['Authorization']='Basic %s:%s'\ %(self._session['id'],base64.b64encode(h.digest())) </code></pre> <p>call for <code>endpoint</code> in python</p> <pre><code>ws.send_request("POST","APIENDPOINT",\ {"doorOperations": [{"doors": ["101"],"operation": "guest"}],"expireTime": "20150522T2359","format": "rfid48","endPointID":"endpointid"}) </code></pre> <p>I have checked <code>body content md5 &amp; string_to_sign</code> output is same for both script.</p>
3
Facebook Ads Insights API System user and data fetching automation
<p>I'm going to use Facebook Ads Insights API to fetch stats about campaigns (read_insights permission) and load them into my app.</p> <p>I don't want the user of my app to need to login through facebook. However, it appears that the process of getting System user is rather complicated, and even requires to produce a screencast of the user logging in (which is exactly what I don't want to implement).</p> <p>Do I really need to go through all these steps to get basic/standard API access levels? Is this the only way of generating a System user? Or of automating campaign stat fetching?</p>
3
Error in file(file, “rt”) : cannot open the connection
<p>I'm new to R, and after researching this error extensively, I'm still not able to find a solution for it. Here's the code. I've checked my working directory, and made sure the files are in the right directory. Appreciate it. Thanks</p> <pre><code>**pollutantmean &lt;- function(id, directory, ...){ x &lt;- c(NA) for(i in id){ csvfile &lt;- sprintf("%03d.csv", i) filepath&lt;- file.path(directory,csvfile) foo &lt;- read.csv(filepath, ...) x &lt;- x+foo } mean(x,na.rm=TRUE) }** </code></pre> <p>OK, and then ,I type the code like this:</p> <p><strong>pollutantmean(1:10,"specdata","sulfate")</strong></p> <p>Then, I got a trackback:</p> <p>*Error in file(file, "rt") : cannot open the connection</p> <p>In addition: Warning message: In file(file, "rt") : cannot open file 'specdata/001.csv': No such file or directory*</p> <p>I'm confused, how should I solve this problem?</p>
3
How do I mirror the curve given below?
<p>I do not know whether which are the correct function, (eg. <code>flipud</code>, <code>fliplr</code>) But I wish to mirror a curve as shown below: <a href="https://i.stack.imgur.com/ONHJI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ONHJI.jpg" alt="enter image description here"></a> TO</p> <p><a href="https://i.stack.imgur.com/hiMoI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hiMoI.png" alt="enter image description here"></a></p> <p>A</p> <p>However, the I and V values are as follows:</p> <pre><code>I= 7.533307359 7.525186507 7.519095869 7.506914591 7.486612462 7.486612462 7.482552036 7.480521823 7.47849161 7.474431184 7.470370759 7.46428012 7.462249907 7.452098842 7.433826926 7.389162242 7.309983939 7.167869035 6.930334125 6.581137504 6.116218748 5.570091475 4.983359945 4.398658627 3.838319864 3.32670621 2.873968732 2.476047001 2.126850381 1.838560148 1.590874173 1.377701817 1.203103507 1.054897965 0.926994552 0.819393267 0.726003473 0.650885596 0.585918783 0.529072821 0.480347711 0.435683027 0.397108982 0.366655789 0.334172382 0.305749401 0.285447272 0.26311493 0.244843014 0.226571098 0.210329394 0.196117904 0.181906414 0.171755349 0.163634498 0.15145322 0.145362581 0.139271943 0.131151091 0.125060452 0.118969814 0.114909388 0.110848962 0.104758323 0.100697897 0.098667684 0.092577046 0.090546833 0.08851662 0.086486407 0.082425981 0.078365555 0.076335342 0.07430513 0.072274917 0.068214491 0.066184278 0.064154065 0.062123852 0.058063426 0.047912362 0.047912362 0.045882149 0.047912362 0.047912362 0.045882149 0.045882149 0.047912362 0.047912362 0.045882149 0.045882149 0.045882149 0.045882149 0.045882149 0.047912362 0.043851936 0.047912362 0.045882149 0.047912362 0.045882149 </code></pre> <p>and </p> <pre><code>V= 0.599996469 2.099894456 3.569210247 5.00782203 6.446312 7.915719151 9.385065396 10.7932168 12.23198084 13.64010179 15.10944804 16.48692588 17.95630258 19.36433216 20.77223994 22.17975182 23.5255207 24.80912023 26.06067582 27.18810588 28.09951157 28.97908648 29.70498908 30.30847154 30.88170679 31.30260967 31.57133245 31.87149012 32.11115336 32.2905049 32.43985285 32.65094381 32.67893749 32.76855235 32.85847175 32.91808302 32.97790748 33.06861865 33.06764415 33.15862941 33.12728588 33.18784121 33.1872626 33.21741845 33.2169312 33.27773015 33.27742562 33.30770329 33.30742921 33.30715513 33.3069115 33.33731098 33.30648516 33.30633289 33.30621108 33.36725366 33.33654965 33.30584564 33.33633648 33.33624512 33.39737906 33.33609285 33.36664459 33.36655323 33.39710498 33.39707452 33.36637052 33.39695271 33.39692226 33.36627916 33.36621825 33.36615734 33.36612689 33.36609644 33.36606598 33.39661773 33.36597462 33.39655682 33.36591372 33.39646546 33.36570055 33.39631319 33.36567009 33.36570055 33.39631319 33.39628274 33.39628274 33.39631319 33.39631319 33.42689539 33.39628274 33.39628274 33.39628274 33.39628274 33.39631319 33.45747759 33.39631319 33.39628274 33.39631319 33.39628274 </code></pre> <p>which is a 100x1 array for I and V</p>
3
Scope function name is displayed instead of value when page loaded
<p>In the following AngularJS code, there is a TextArea and a span to display remaining characters allowed. [Total characters allowed is 100]</p> <p>When I type value in textarea, it displays remaining character count correctly. But when the page is loaded first time, it doesn't show it correctly - it just shows as <code>{{remaining()}}</code>. </p> <p>What change is needed to make it display remaining count as 100, when the page loaded first time? Also, what is the mistake in this code - is it in the use of scope?</p> <p><strong>Code</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.js"&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; var TextLimitController= function ($scope) { $scope.remaining = function (countryPopulation) { return 100 - $scope.message.length; }; }; &lt;/script&gt; &lt;/head&gt; &lt;body ng-app&gt; &lt;div ng-controller="TextLimitController"&gt; &lt;span&gt; Remaining: {{remaining()}} &lt;/span&gt; &lt;div&gt; &lt;textarea ng-model = "message"&gt; {{message}} &lt;/textarea&gt; &lt;/div&gt; &lt;div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>First time Load</p> <p><a href="https://i.stack.imgur.com/wlcla.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wlcla.jpg" alt="enter image description here"></a></p> <p>After Typing</p> <p><a href="https://i.stack.imgur.com/d0ycS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d0ycS.jpg" alt="enter image description here"></a></p>
3
Disable preview secure text entry UITextField
<p>When an entry is made in into an UITextField, that has secure text entry enabled. The last character that is input is given a short preview for a second or so. </p> <p>I want to disable that as well. Thus, as soon as a character is entered the black dot appears without the preview. </p>
3
Back button in Application bar
<p>I would like to ask how to add a "back" button to the app bar.</p> <p>My app bar looks like this:</p> <p><a href="http://i.stack.imgur.com/BcWcQ.png" rel="nofollow">My App bar</a></p> <p>But i would like to place this arrow to the my app bar before title.</p> <p><a href="http://i.stack.imgur.com/3gqKT.png" rel="nofollow">Arrow</a></p> <p>This is my Styles.xml</p> <pre><code>&lt;resources&gt; &lt;!-- Base application theme. --&gt; &lt;style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"&gt; &lt;!-- Customize your theme here. --&gt; &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt; &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt; &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt; &lt;/style&gt; &lt;style name="AppTheme.NoActionBar"&gt; &lt;item name="windowActionBar"&gt;false&lt;/item&gt; &lt;item name="windowNoTitle"&gt;true&lt;/item&gt; &lt;/style&gt; &lt;style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /&gt; &lt;style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /&gt; </code></pre> <p></p> <p>Can someone help me with this?</p>
3
Clear all list item on button click
<p>I have created simple chatting application and it contains some <code>ListView</code> which handles all chat messages, but every <code>ListView</code> is defined in another class. I want to clear my list items from <em>Clear Chat</em> from an overflow menu, which is present in main activity. How can I achieve this?</p> <p>Here is my main activity called <code>WiFiServiceDiscoveryActivity</code>:</p> <pre><code>public class WiFiServiceDiscoveryActivity extends AppCompatActivity implements DeviceClickListener, Handler.Callback, MessageTarget, ConnectionInfoListener { public static final String TAG = "wifidirectdemo"; // TXT RECORD properties public static final String TXTRECORD_PROP_AVAILABLE = "available"; public static final String SERVICE_INSTANCE = " "; public static final String SERVICE_REG_TYPE = "_presence._tcp"; public static final int MESSAGE_READ = 0x400 + 1; public static final int MY_HANDLE = 0x400 + 2; private WifiP2pManager manager; static final int SERVER_PORT = 4545; private final IntentFilter intentFilter = new IntentFilter(); private Channel channel; private BroadcastReceiver receiver = null; private WifiP2pDnsSdServiceRequest serviceRequest; private Handler handler = new Handler(this); private WiFiChatFragment chatFragment; private WiFiDirectServicesList servicesList; private TextView statusTxtView; Toolbar toolbar; private String friend; private WiFiP2pService service; WiFiChatFragment listView; WiFiChatFragment.ChatMessageAdapter a; public Handler getHandler() { return handler; } public void setHandler(Handler handler) { this.handler = handler; } /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); toolbar=(Toolbar)findViewById(R.id.toolbar); statusTxtView = (TextView) findViewById(R.id.status_text); intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION); intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION); intentFilter .addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION); intentFilter .addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION); manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE); channel = manager.initialize(this, getMainLooper(), null); startRegistrationAndDiscovery(); servicesList = new WiFiDirectServicesList(); getFragmentManager().beginTransaction() .add(R.id.container_root, servicesList, "services").commit(); setSupportActionBar(toolbar); } @Override protected void onRestart() { Fragment frag = getFragmentManager().findFragmentByTag("services"); if (frag != null) { getFragmentManager().beginTransaction().remove(frag).commit(); } super.onRestart(); } @Override protected void onStop() { if (manager != null &amp;&amp; channel != null) { manager.removeGroup(channel, new ActionListener() { @Override public void onFailure(int reasonCode) { Log.d(TAG, "Disconnect failed. Reason :" + reasonCode); } @Override public void onSuccess() { } }); } super.onStop(); } /** * Registers a local service and then initiates a service discovery */ private void startRegistrationAndDiscovery() { Map&lt;String, String&gt; record = new HashMap&lt;String, String&gt;(); record.put(TXTRECORD_PROP_AVAILABLE, "visible"); WifiP2pDnsSdServiceInfo service = WifiP2pDnsSdServiceInfo.newInstance( SERVICE_INSTANCE, SERVICE_REG_TYPE, record); manager.addLocalService(channel, service, new ActionListener() { @Override public void onSuccess() { //appendStatus("Added Local Service"); } @Override public void onFailure(int error) { // appendStatus("Failed to add a service"); } }); discoverService(); } private void discoverService() { /* * Register listeners for DNS-SD services. These are callbacks invoked * by the system when a service is actually discovered. */ manager.setDnsSdResponseListeners(channel, new DnsSdServiceResponseListener() { @Override public void onDnsSdServiceAvailable(String instanceName, String registrationType, WifiP2pDevice srcDevice) { // A service has been discovered. Is this our app? if (instanceName.equalsIgnoreCase(SERVICE_INSTANCE)) { // update the UI and add the item the discovered // device. WiFiDirectServicesList fragment = (WiFiDirectServicesList) getFragmentManager() .findFragmentByTag("services"); if (fragment != null) { WiFiDevicesAdapter adapter = ((WiFiDevicesAdapter) fragment .getListAdapter()); service = new WiFiP2pService(); service.device = srcDevice; service.instanceName = instanceName; service.serviceRegistrationType = registrationType; adapter.add(service); adapter.notifyDataSetChanged(); Log.d(TAG, "onBonjourServiceAvailable " + instanceName); } } } }, new DnsSdTxtRecordListener() { /** * A new TXT record is available. Pick up the advertised * buddy name. */ @Override public void onDnsSdTxtRecordAvailable( String fullDomainName, Map&lt;String, String&gt; record, WifiP2pDevice device) { Log.d(TAG, device.deviceName + " is " + record.get(TXTRECORD_PROP_AVAILABLE)); } }); // After attaching listeners, create a service request and initiate // discovery. serviceRequest = WifiP2pDnsSdServiceRequest.newInstance(); manager.addServiceRequest(channel, serviceRequest, new ActionListener() { @Override public void onSuccess() { // appendStatus("Added service discovery request"); } @Override public void onFailure(int arg0) { appendStatus("Failed adding service discovery request"); } }); manager.discoverServices(channel, new ActionListener() { @Override public void onSuccess() { //appendStatus("Service discovery initiated"); } @Override public void onFailure(int arg0) { appendStatus("Service discovery failed"); } }); } @Override public void connectP2p(WiFiP2pService service) { WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = service.device.deviceAddress; config.wps.setup = WpsInfo.PBC; if (serviceRequest != null) manager.removeServiceRequest(channel, serviceRequest, new ActionListener() { @Override public void onSuccess() { } @Override public void onFailure(int arg0) { } }); manager.connect(channel, config, new ActionListener() { @Override public void onSuccess() { appendStatus("Connecting to service"); } @Override public void onFailure(int errorCode) { appendStatus("Failed connecting to service"); } }); } @Override public boolean handleMessage(Message msg) { switch (msg.what) { case MESSAGE_READ: byte[] readBuf = (byte[]) msg.obj; // construct a string from the valid bytes in the buffer String readMessage = new String(readBuf, 0, msg.arg1); Log.d(TAG, readMessage); (chatFragment).pushMessage("Friend :" + readMessage); break; case MY_HANDLE: Object obj = msg.obj; (chatFragment).setChatManager((ChatManager) obj); } return true; } @Override public void onResume() { super.onResume(); receiver = new HomeActivity(manager, channel, this); registerReceiver(receiver, intentFilter); } @Override public void onPause() { super.onPause(); unregisterReceiver(receiver); } @Override public void onConnectionInfoAvailable(WifiP2pInfo p2pInfo) { Thread handler = null; if (p2pInfo.isGroupOwner) { Log.d(TAG, "Connected as group owner"); try { handler = new GroupOwnerSocketHandler( ((MessageTarget) this).getHandler()); handler.start(); } catch (IOException e) { Log.d(TAG, "Failed to create a server thread - " + e.getMessage()); return; } } else { Log.d(TAG, "Connected as peer"); handler = new ClientSocketHandler( ((MessageTarget) this).getHandler(), p2pInfo.groupOwnerAddress); handler.start(); } chatFragment = new WiFiChatFragment(); getFragmentManager().beginTransaction() .replace(R.id.container_root, chatFragment).commit(); statusTxtView.setVisibility(View.GONE); } public void appendStatus(String status) { String current = statusTxtView.getText().toString(); statusTxtView.setText(current + "\n" + status); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_settings: Toast.makeText(this, "Settings selected", Toast.LENGTH_SHORT) .show(); break; case R.id.clean: Toast.makeText(this, "Clear Chat", Toast.LENGTH_SHORT).show(); break; default: break; } return true; } } </code></pre> <p>And another class which has the <code>ListView</code> called <code>WiFiChatFragment</code>:</p> <pre><code>public class WiFiChatFragment extends Fragment { private View view; private ChatManager chatManager; private TextView chatLine; private ListView listView; ChatMessageAdapter adapter = null; private List&lt;String&gt; items = new ArrayList&lt;String&gt;(); @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.fragment_chat, container, false); chatLine = (TextView) view.findViewById(R.id.txtChatLine); listView = (ListView) view.findViewById(android.R.id.list); adapter = new ChatMessageAdapter(getActivity(), android.R.id.text1, items); listView.setAdapter(adapter); view.findViewById(R.id.button1).setOnClickListener( new View.OnClickListener() { @Override public void onClick(View arg0) { if (chatManager != null) { chatManager.write(chatLine.getText().toString() .getBytes()); pushMessage("Me: " + chatLine.getText().toString()); chatLine.setText(""); chatLine.clearFocus(); } } }); return view; } public interface MessageTarget { public Handler getHandler(); } public void setChatManager(ChatManager obj) { chatManager = obj; } public void pushMessage(String readMessage) { adapter.add(readMessage); adapter.notifyDataSetChanged(); } /** * ArrayAdapter to manage chat messages. */ public class ChatMessageAdapter extends ArrayAdapter&lt;String&gt; { List&lt;String&gt; messages = null; public ChatMessageAdapter(Context context, int textViewResourceId, List&lt;String&gt; items) { super(context, textViewResourceId, items); } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(android.R.layout.simple_list_item_1, null); } String message = items.get(position); if (message != null &amp;&amp; !message.isEmpty()) { TextView nameText = (TextView) v .findViewById(android.R.id.text1); if (nameText != null) { nameText.setText(message); if (message.startsWith("Me: ")) { nameText.setBackgroundResource(R.drawable.bubble_b ); nameText.setTextAppearance(getActivity(), R.style.normalText); } else { nameText.setBackgroundResource(R.drawable.bubble_a ); nameText.setTextAppearance(getActivity(), R.style.boldText); } } } return v; } } } </code></pre>
3
I want to create Revit Plugin and in that the command class will be generic
<pre><code>[Transaction(TransactionMode.Manual)] public class InteropCommand&lt;T, V&gt; : IExternalCommand { public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements ) { InterfaceDialog&lt;T, V&gt; interfaceDlgBox = new InterfaceDialog&lt;T, V&gt;( (IDocumentationModel&lt;T&gt;)Revit2014Model ); } } </code></pre> <p>The command.cs file looks like shown above. If I write class as class InteropCommand then I need to change the .Addin file accordingly otherwise the command will not work. Now I have question that how can I write a command class in such a way that it will load the Revit addin command. In current scenario I am not able to load the Revit command. </p> <p>My .Addin file look like below. Do you have any idea how to tackle with this kind of problem ? </p> <pre><code>&lt;RevitAddIns&gt; &lt;AddIn Type="Command"&gt; &lt;Text&gt;Test&lt;/Text&gt; &lt;Description&gt;Test Command&lt;/Description&gt; &lt;Assembly&gt;test.dll&lt;/Assembly&gt; &lt;FullClassName&gt;InteropCommand&lt;/FullClassName&gt; &lt;ClientId&gt;0072bf73-c900-449b-bce2-e50a899a72ae&lt;/ClientId&gt; &lt;VendorId&gt;XYZ&lt;/VendorId&gt; &lt;VendorDescription&gt;XYZ&lt;/VendorDescription&gt; &lt;/AddIn&gt; &lt;/RevitAddIns&gt; </code></pre>
3
using submodules in git for the timid
<p>I am working in a project which have few layers, each of them independent sub-projects. </p> <p>It looks like this:</p> <pre><code>[ Project C ] [ Project D ] C and D uses B and therefore A [ Project B ] B has all source code in a and adds more [ Project A ] </code></pre> <p>Setting upstream to the parent repository and issuing <code>git pull upstream</code> works well to get the changes from the upper project.</p> <p>However, how would I push a commit in the scenario of bug fix in C which affects the code shared with the parent layers? </p> <p>If I issue <code>git pull project-D</code> from Project A, it will also merge all the source code added at that layer.</p> <p>I also considered using <code>sub-trees</code> or <code>submodules</code>, but it still looks complicated.</p>
3
How can I bulk publish 11,500 coupon codes in WooCommerce Smart Coupons?
<p>We are running a deal with Groupon and have used Smart Coupons plugin with WooCommerce to import 11,500 Groupon codes. I now need to activate them (aka plublish.) However, currently in the WooCommerce interface you can only select and publish 20 coupon codes at once. This would take ~7.5 hours to publish all codes. Does anyone know of a way to easily activate all 11,500 codes at once? </p>
3
What versioning strategies are available to SignalR hubs with .NET clients?
<p>WCF offers rich support for versioning services, contracts, clients etc. I'm investigating SignalR as a way for my deployed .NET clients to talk to the server, but have not found any resources mentioning how to evolve hubs and clients independently. Is there a reason for this? Surely there must be some kind of recommended best-practice for handling hub evolution (adding methods, changing parameters in existing methods, removing operations, etc) when you don't necessarily have control over client versions. </p>
3
Bash array variable expansion inside expect command
<p>An extension to this question : <a href="https://stackoverflow.com/questions/33871500/bash-adding-extra-single-quotes-to-strings-with-spaces">Bash : Adding extra single quotes to strings with spaces</a></p> <p>After storing the arguments of command as a bash array</p> <pre><code>touch "some file.txt" file="some file.txt" # Create an array with two elements; the second element contains whitespace args=( -name "$file" ) # Expand the array to two separate words; the second word contains whitespace. find . "${args[@]}" </code></pre> <p>Then storing whole command in an array</p> <pre><code>finder=( find . "${args[@]}" ) </code></pre> <p>In bash I am able to run the command as below:</p> <pre><code>"${finder[@]}" ./some file.txt </code></pre> <p>But when I tried using expect, I am getting error</p> <pre><code>expect -c "spawn \"${finder[@]}\"" missing " while executing "spawn "" couldn't read file ".": illegal operation on a directory </code></pre> <p>Why is bash variable expansion not happening here?</p>
3
Cannot changing JSON from a mongoDB query unless I copy it into new variable
<p>I've created a MEAN app that returns some JSON, I wanted to create a simple function to change a date field in the JSON before displaying it - however i can only do this if i make a <strong>copy of the data into a new variable</strong>. Can someone explain why this is the case? I thought a knew javascript pretty well until this!! Is this to do with scope or a mongoDB thing?</p> <p>my Route:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code> JobsImportCtrl = require('../controllers/jobsImportCtrl'); module.exports = function (app) { app.get('/api/jobs', function (req, res) { Jobsctrl.getJobs(res); });</code></pre> </div> </div> </p> <p>My controller:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var Jobspretty = require('../helpers/jobspretty'); // pretty job dates etc module.exports = { // get all jobs getJobs: function(res) { Job.find(function (err, jobs){ // if there is an error retrieving, send the error. nothing after res.send(err) will execute if (err) { res.send(err); } res.json(Jobspretty.deadlineDates(jobs)); }); },</code></pre> </div> </div> </p> <p>My Helper function:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var moment = require('moment'); // momentjs library moment().format(); // human readable deadline dates using momentjs module.exports = { deadlineDates: function(jobs) { var prettyjobs = []; jobs.forEach(function(job) { var obj2 = JSON.parse(JSON.stringify(job)); obj2.deadline = moment(job.deadline).format("dddd, MMMM Do YYYY"); prettyjobs.push(obj2); }); return prettyjobs; } };</code></pre> </div> </div> </p>
3
Fit a Vertical UISlider into an Existing Container View?
<p>I want to create a vertical <code>UISlider</code> and exactly fit it into an existing container view that is sized and placed from a <code>.xib</code> file using <code>autoLayout</code>. But I simply cannot get it to work and I have Googled my fingers bloody.</p> <p>The closest I have gotten creates a slider that is too long and extends off the screen.</p> <p>Am I putting the code in the wrong place?</p> <p>I am putting my code in <code>"layOutSubviews"</code> Some Points of interest:</p> <p>1.Per Apple's docs, the view's "frame" is not valid after the transformation and should not be set.</p> <p>2.The frame of the slider is set to the future parent's dimensions <em>before</em> the transformation (with x and y swapped).</p> <p>3.The transformed view appears to maintain its bounds in the pre-transformation coordinate frame. i.e. After the 90 degree transformation, the width and height of the transformed view's bounds appear to be swapped.</p> <p>This code doesn't work. The slider looks right except that it extends off the bottom of the screen. The slider bounds and even the frame (which Apple says is not valid) seem to match the bounds and frame of the container view. The slider doesn't even stay within its own bounds.</p> <pre><code>[super layoutSubviews]; CGRect trigLevelSliderFrame=self.trigLevelSliderContainer.bounds; trigLevelSliderFrame.size.height=self.trigLevelSliderContainer.bounds.size.width; trigLevelSliderFrame.size.width=self.trigLevelSliderContainer.bounds.size.height; UISlider *mySlider=[[UISlider alloc] initWithFrame:trigLevelSliderFrame]; self.trigSlider=mySlider; [mySlider release]; self.trigSlider.transform=CGAffineTransformMakeRotation(-M_PI_2); CGPoint center=CGPointMake(self.trigLevelSliderContainer.bounds.size.width/2,self.trigLevelSliderContainer.bounds.size.height/2); self.trigSlider.center=center; [self.trigLevelSliderContainer addSubview:self.trigSlider]; </code></pre>
3
Drawing a shape
<p>I'm trying to draw an E shaped thingy and as far as I know there are 2 ways to go one of them being path.</p> <p>I could draw with path as the below documentation suggests. <a href="https://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/BezierPaths/BezierPaths.html" rel="nofollow">https://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/BezierPaths/BezierPaths.html</a></p> <p>Or I could create a rectangle with a UIView and carve it with 2 small squares and make an E by substracting those 2 spots.</p> <p>I'm not sure which way is the way to go considering efficiency and everything. If there's any other better ways, please enlighten me. Thanks!</p> <p>(I've found plenty about drawing shapes on here but none is even remotely recent and I'd like a recent answer)</p>
3
Error code:0x80071A90 - When Installing IIS on Windows 10.1
<p>I get this error: Windows couldn't complete the requested changes. The function attempted to use a name that is reserved for use by another transaction.Error code:0x80071A90, when I trying to install IIS on windows 10 Pro.</p> <p>May you kindly assist in resolving this issue.</p> <p>Kindest Regards Lucky</p>
3
How to check the type of database Heroku is using?
<p>I just updated database plans on Heroku from hobby-dev to standard-0. How can I check to make sure that the standard-0 postgres database is the one being used?</p>
3
Static config object similar to pythons logging object
<p>The logger object is as I understand a singleton, only one instance can ever exist. You get a reference by this:</p> <pre><code>import logging log = logging.getLogger('MyLogger') </code></pre> <p>I would like to do the same with a global config object, rather then have to pass my config as a parameter. What is the best approach to do this?</p>
3
Chef - restarting due to auto-encryption mechanism
<p>We have an issue with Chef in that it restarts unnecessarily. We schedule chef-client to run every 1 5 minutes. However, a restart of processes and the app occurs every time, even when the user has not made changes.</p> <p>The reason for this is we have a proprietary app we are automating that has a mechanism whereby it encrypts a plain text password in a config file, so every time chef runs, it sees a difference in the config file it generates from the template (unencrypted string), and the currently deployed config file (that this app has touched after chef and encrypted the text).</p> <p>The app team does touch this file frequently in other places so ignoring that file completely is not ideal. However, looking for options from others who may have faced the same issue.</p> <p>Thanks in advance.</p>
3
is supportablerange type graph in Highchart?
<p>Can I set a y axis labels as ["1-10","10-20","20-30","30-40","40-50","50-60"] and bar data depends on these range. Can you please provide us a JSfiddle demo here?</p>
3
Retaining category order when charting/plotting ordered categorical Series
<p>Consider the following categorical <code>pd.Series</code>:</p> <pre><code>In [37]: df = pd.Series(pd.Categorical(['good', 'good', 'ok', 'bad', 'bad', 'awful', 'awful'], categories=['bad', 'ok', 'good', 'awful'], ordered=True)) In [38]: df Out[38]: 0 good 1 good 2 ok 3 bad 4 bad 5 awful 6 awful dtype: category Categories (4, object): [bad &lt; ok &lt; good &lt; awful] </code></pre> <p>I want to draw a pie or bar chart of these. According to <a href="https://stackoverflow.com/a/31029857/2071807">this SO answer</a>, plotting categorical <code>Series</code> requires me to plot the <code>value_counts</code>, but this does not retain the categorical ordering:</p> <pre><code>df.value_counts().plot.bar() </code></pre> <p>How can I plot an ordered categorical variable and retain the ordering? <a href="https://i.stack.imgur.com/XmrXS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XmrXS.png" alt="Bar chart"></a></p>
3
How could I check if "canplaythrough" is true?
<p>I want to show an Indicator if somebody clicks on the playbutton. If the video is loaded I want to hide the preloader. This works perfectly with readystate:</p> <pre><code> var einleitung = document.getElementById('einleitung'); video.addEventListener('play', function () { if ( video.readyState === 4 ) { myApp.hidePreloader(); } else { myApp.showPreloader('Loading...'); } }); </code></pre> <p>How could I get going this with canplaythrough instead of readyState?</p> <p>Something like this is not working:</p> <pre><code> if ( video.canplaythrough == true ) {} </code></pre> <p>video.canplaythrough is "null".</p>
3
Clicking on button_to is not taking me to the intended method
<p>I am trying to get a button_to to call a controller. I've tried a number of variations and nothing seems to work. </p> <p>In my index.html.erb, I have</p> <pre><code> &lt;%= button_to "Clear Search", { :controller =&gt; 'documents', :action =&gt; 'reset_search'} %&gt; </code></pre> <p>In my documents controller, I have </p> <pre><code> helper_method :reset_search def reset_search @documents = Document.all $search = nil params[:search] = nil redirect_to documents_path $temp2 = 'testing 1 2 3' end </code></pre> <p>On the index, I put the following at the bottom. </p> <pre><code>$temp2 &lt;%= $temp2 %&gt; </code></pre> <p>Based on the $temp2 variable, I can see that I am not getting to the reset_search method when clicking the button as the contents of $temp2 are not changing</p> <p>What do I need to do to actually have the button call the reset_search method?</p>
3
What kind of project do I need to create?
<p>I need to create a .net based Restful web service to interface to an existing SOAP back end application, This web service will be deployed to Azure. Using Visual Studio 2015, what kind of project do I need to create? Could your answer cover in some detail the steps I need to create this project? </p>
3
Pairs insertion/retrieval in/from field
<p>I am trying to insert pairs in a mongoDB Document. This how i am doing it so far:</p> <pre><code>private static MongoCollection&lt;Document&gt; getCollectionn(String link, String coll){ ... } public static void main(String[] args) { MongoCollection&lt;Document&gt; fb_users; fb_users = getCollectionn("mongodb://...", "fb_users2"); Document myDoc; BasicDBObject query = new BasicDBObject(); query.put("fbid", "1"); myDoc = fb_users.find(query).first(); int postId=5; int rating=3; fb_users.updateOne(myDoc, new Document("$push", new Document("ratings", java.util.Arrays.asList(rating, postId)))); Object a = myDoc.get("ratings"); ArrayList&lt;Document&gt; b = (ArrayList&lt;Document&gt;) a; System.out.println(b.get(0);//prints [3, 5] } </code></pre> <p>This is how the array document is inserted in the collection after two runs: (the document already exists)</p> <pre><code>{ "_id": { "$oid": "56f173b5e4b04eaac6531030" }, "fbid": "1", "ratings": [ [ 3, 5 ], [ 3, 5 ] ] } </code></pre> <p>In println i get the result [3, 5]</p> <p>My question is this:</p> <p>How can i recieve the numder 3 and the number 5 seperatly? Should i insert the documents with another way? Iam using mongo java driver 3.2.0.</p>
3
Android organisation distribution - multiple oranisations
<p>I want to do organisation distribution for my app. So I found a solution <a href="https://support.google.com/a/answer/2494992?hl=en" rel="nofollow">here</a>.</p> <p>But I have the same app that should be distributed to 3 different companies (same package name). Is this possible or do I have to change the package name in manifest. In the article above is only a remark saying "same app in public and in private store is not possible", but it doesn't say anything about several private stores.</p>
3
Accesing local node.js server from iOS Emulator?
<p>We are trying to figure out how to do this:</p> <ol> <li><p>We have some service produced by Node.js server, locally hosted on our computer and initialized with npm start. </p></li> <li><p>An IONIC application that uses data from this server... </p></li> </ol> <p>Using $ionic serve, the app can obviously access the NODE.JS server because they are running on the same context... unfortunately, when emulating it with the iOS emulator ($ionic emulate ios), the server can't be accessed.</p> <p>Is there any way to keep the localhost context available to the iOS emulator?</p>
3
The linear-gradient hack for tinted images: Am I doing it wrong?
<p>Was reading how to do it on <a href="https://css-tricks.com/tinted-images-multiple-backgrounds/" rel="nofollow">https://css-tricks.com/tinted-images-multiple-backgrounds/</a></p> <pre><code>/* Working method */ .tinted-image { background: /* top, transparent red, faked with gradient */ linear-gradient( rgba(255, 0, 0, 0.45), rgba(255, 0, 0, 0.45) ), /* bottom, image */ url(image.jpg); } </code></pre> <p>For me, though, it doesn't seem to work. Fiddle: <a href="https://jsfiddle.net/w6jnv67c/" rel="nofollow">https://jsfiddle.net/w6jnv67c/</a></p> <p>Any idea what I'm doing wrong?</p>
3
how let mysql do not remove duplicate element of in parameter list
<p>background</p> <blockquote> <p>Market colleague give me an excel file, have customer mobiles, and let me send some kind coupon to these customers, some mobiles are repeat that is mean should send more than one coupon. </p> </blockquote> <p>there is a table have these data,</p> <pre><code>select * from t ; +----+------+ | id | name | +----+------+ | 1 | a | | 2 | b | | 3 | c | | 4 | d | | 5 | e | | 6 | f | +----+------+ select * from t where id in (1,2,1); +----+------+ | id | name | +----+------+ | 1 | a | | 2 | b | +----+------+ </code></pre> <p>you can see <code>mysql</code> auto remove duplicate id in <code>in</code> parameter list, but I want the effect like this</p> <pre><code>+----+------+ | id | name | +----+------+ | 1 | a | | 2 | b | | 1 | a | +----+------+ </code></pre> <p>that is <code>in</code> parameter like a <code>list</code> not a <code>set</code>. So how could implement this in <code>mysql</code>?</p>
3
Target div once user has finished dragging element
<p>I have a list:</p> <pre><code>&lt;ul class="draggable"&gt; &lt;li&gt;&lt;span class="drag"&gt;::&lt;/span&gt; item 1&lt;/li&gt; &lt;li&gt;&lt;span class="drag"&gt;::&lt;/span&gt; item 2&lt;/li&gt; &lt;li&gt;&lt;span class="drag"&gt;::&lt;/span&gt; item 3&lt;/li&gt; &lt;/ul&gt; &lt;div class="done" style="display:none;"&gt; Yay! &lt;/div&gt; </code></pre> <p>And it is draggable via:</p> <pre><code>var el = document.querySelectorAll('.draggable'); for (var i=0;i&lt;el.length; i++) { var sortable = Sortable.create(el[i], { handle: '.drag', animation: 150, onUpdate: function (evt/**Event*/){ var item = evt.item; // the current dragged HTMLElement // show .done here } }); } </code></pre> <p>Test <a href="https://jsfiddle.net/h2qnucpg/7/" rel="nofollow">jsFiddle</a>. </p> <p>My question is, how do I show the <code>.done</code> div once the user has dragged an item?</p> <p>So in onUpdate, I want to target the <code>.done</code> div. Normally, in jQuery, I would do something like:</p> <pre><code>jQuery(this).parent().parent().next().show(); </code></pre> <p>But this doesn't obviously work here. </p> <p>What the correct approach here? Note that I <strong>can't</strong> add an id to the <code>.done</code> div. </p>
3
Qt 5.5 - Windows API not Working as usual
<p>I am using <strong>Qt 5.5</strong> on <strong>Windows 10</strong> and I want to open a <code>QWidget</code> in <strong>Foreground</strong> and want to <strong>focus</strong> the <code>LineEdit</code>, like RUN (WIN + R) on Windows. The Problem is the Application is running in the background and I have only an keylogger to register a shortcut (LCTRL + LWIN + T) to toggle the window (show + focus / hidden). </p> <p>If the shortcut is pressed, I execute following Code:</p> <pre><code> if(this-&gt;isHidden()){ this-&gt;show(); //Windows API Methods: SetActiveWindow((HWND) this-&gt;winId()); SetForegroundWindow((HWND) this-&gt;winId()); SetFocus((HWND) this-&gt;winId()); this-&gt;_edit-&gt;setFocus(); qDebug() &lt;&lt; "[OUT][DONT WORKING] Window shoud be shown and focused"; }else{ this-&gt;hide(); qDebug() &lt;&lt; "[OUT][WORKING] Window shoud be hidden"; } </code></pre> <p>If I now press <strong>LCTRL + LWIN + T</strong>, it opens the Window in the background and that's not what I want. Can someone explain why this does not work? What can I do that the window opens in the foreground and the text box is <strong>focused</strong>? And I don't want to set the flag <code>StayAlwaysOnTop</code>, because then the text field is still not focused. </p> <p>I hope you can help me. Thank you very very much!</p>
3
Override postion top of pseudo element on certain page
<p>I am reusing a class that has a :before psuedo element, and want to overide a property when the element is within an element with a specific class:</p> <p>I currently have:</p> <pre><code>.section-container.accordion .title::before { content: "\e025"; font-family: "GeneralFoundicons"; speak: none; display: inline; font-size: 0.8em; display: block; position: absolute; right: 18px; top: 18px; -webkit-transition: 0.3s ease; -moz-transition: 0.3s ease; transition: 0.3s ease; } </code></pre> <p>This is fine but on a particular page I want <code>top:0;</code> how can I achieve this?</p>
3
DXT Texture working despite S3TC not being supported
<p>The topic involves OpenGL ES 2.0.</p> <p>I have a device that when queried on the extensions via </p> <pre><code>glGetString(GL_EXTENSIONS) </code></pre> <p>Returns a list of supported extensions, none of which is <code>GL_EXT_texture_compression_s3tc</code> .</p> <p>AFAIK , not haveing <code>GL_EXT_texture_compression_s3tc</code> shouldn't allow using DXT compressed textures.</p> <p>However, when DXT compressed texture are used on the device , they render without any problems.</p> <p>Texture data is commited using <code>glCompressedTexImage2D</code> .</p> <p>Tried for DXT1 , DXT3 and DXT5 .</p> <p>Why does it work ? Is it safe to use a texture compression although the compression seems to not be supported ?</p>
3
Click listener of button inside a layout view that is bind with click listener is not working in Android
<p>I am developing an Android app. In my app, I have a button inside a layout view. Layout view is set click listener. Button inside layout is also bind with click listener. But when I click button inside layout, both listeners are not working. But when I click layout view avoiding button, listener of layout view is working.</p> <p>For example, this is my layout file</p> <pre><code>&lt;LinearLayout&gt; &lt;LinearLayout android:id="@+id/child_container" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"&gt; &lt;Button android:focusable="false" android:focusableInTouchMode="false" android:text="LIKE" android:id="@+id/btn_click" android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>This is example of onCreate event of my activity</p> <pre><code>childContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //this is working } }); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //This is not working } }); </code></pre> <p>As you can see I set <code>android:focusable="false"</code> and <code>android:focusableInTouchMode="false"</code> to button in layout file. But click listener of button is not working. How can I fix that?</p>
3
how to store an added class which is created by jquery
<p>I am using this example which adds a class <strong>active</strong> when hit a link. But after a refresh, the class active is gone ofcourse. So i want to store that class locally so that it is remembered when even a refresh is done. How can i achieve that?</p> <pre><code>&lt;div id="links"&gt; &lt;a href="#"&gt;Content 1&lt;/a&gt; &lt;br /&gt; &lt;a href="#"&gt;Content 2&lt;/a&gt; &lt;br /&gt; &lt;a href="#"&gt;Content 3&lt;/a&gt; &lt;/div&gt; </code></pre> <p>and</p> <pre><code>$('document').ready(function() { $('#links a').click(function(e) { e.preventDefault(); $('#links a').removeClass('active'); $(this).addClass('active'); }); }); </code></pre> <p><a href="http://jsfiddle.net/fDZ97/55/" rel="nofollow">http://jsfiddle.net/fDZ97/55/</a></p>
3
Windows7: getaddrinfo returning "No such host is known" for [::1]
<p>I'm working on modifications to my code to support dual stack environments on Windows 7 et. al. The code uses ActiveMQ-CPP (3.8.4). I've set this up to use a connection to the broker on URI "tcp://[::1]:61616". I've already found I need to compile APR with APR_HAVE_IPV6. </p> <p>Now the issue. When APR's call_resolver() method calls getaddrinfo() with the hostname "[::1]", it returns "No such host is known" (code 11001). </p> <p>I can ping [::1] without an issue. I've tried uncommenting the ::1 entry in hostnames. I've added the Internet Protocol Version 6 checkbox on my interfaces.</p> <p>Any ideas what I'm missing?</p>
3
T-SQL Finding VarChar String with Wildcards, but Carriage Return in Field Produces Fewer Results
<p>I'm trying to find all rows with a specific variable character alpha-numeric string from a variable character field using the following code:</p> <pre><code>SELECT * FROM Table AS t WHERE t.Textfield LIKE '%abc123abc%' OR t.Textfield LIKE '%aabbcc12345abcde%'; </code></pre> <p>However, not all of the rows are being returned. I figured out that the rows which were not being returned from my query aren't showing up because of a carriage return after the final character of the alpha-numeric string I'm looking for.</p> <p>My question is what can I do to make sure all of the rows return for my query instead of just the rows not having a carriage return at the end of my variable character alpha-numeric string?</p> <p>Thanks.</p>
3
Decimal conversion scale errors
<p>I am trying to understand data types more..here are few examples which are still puzzling me.</p> <blockquote> <p>Decimal(p,s)--p is the total digits,s is number of digits after point</p> </blockquote> <p>So given below example </p> <pre><code>declare @st decimal(38,38) set @st=1.22121065111115211641641651616511616 </code></pre> <p>I am getting below error..</p> <blockquote> <p>Arithmetic overflow error converting numeric to data type numeric</p> </blockquote> <p>len(digits) after point is 35,total digits including . are 37 ...shouldn't my decimal of (38,38) work</p> <p>So my question is why i am getting the above error</p> <p>Here is my research so far..</p> <p><a href="https://stackoverflow.com/questions/2377174/how-do-i-interpret-precision-and-scale-of-a-number-in-a-database">How do I interpret precision and scale of a number in a database?</a></p> <p>Decreasing scale like below works..</p> <pre><code>declare @st decimal(38,37) set @st=1.22121065111115211641641651616511616 </code></pre> <p>Answer by boumbh points out an out of range error,but i am not getting error for same example</p>
3
Clarification on javascript scope
<p>In this code I can't understand why if I insert a breakpoint on the first if condition in success <code>if(data == 1){</code> I can see <code>fromCTA</code> variable but not <code>$form</code>: </p> <pre><code>jQuery('.pane-tab form, form#hlp_contactCTA').on('click','.input-submit',function(e){ var $form = jQuery(this).parent('form'); var fromCTA = false; var formArrSerialized = $form.serializeArray(); var len = formArrSerialized.length; for(var i=0; i&lt;len; i++ ){ if(formArrSerialized[i].name == 'message'){ var msg = formArrSerialized[i].value; } } if(msg){ if(!$form.is('#msg-form')){ //we are in user account fromCTA = true; //formArrSerialized.push({name:'fromCTA', value: 1}); } formArrSerialized.push({name:'action', value:'send_message'}); var param = jQuery.param(formArrSerialized); jQuery.ajax({ url:pathToAjax() + 'wp-admin/admin-ajax.php', data:param, type:'POST', success: function(data){ if(data == 1){ if(!fromCTA){ appendMsg(msg); } else { showMsg('Il messaggio è stato inviato',2000,function(){jQuery('#popup-contactCTA').hide();}); } } else { console.log('qualcosa è andato storto'); }; }, error: function(){ console.log('error'); } }); } e.preventDefault(); }); </code></pre> <p>The code is working fine, there are no bugs, please analyse it only to answer my question, which regards variable scope:<br> in anonymous function in success i can see in the Chrome debugger as a closure only the variable <code>fromCTA</code> and <code>msg</code> while I expected to see <code>$form</code>, <code>formArrSerialized</code> and <code>len</code>. All of them in my opinion have the same domain</p>
3
How to submit job when Spark jobs have very different executor resource requirements
<p>Let's say I have a job with the following:</p> <p>Job 1: long-running CPU bound Job 2: Needs a large heap in each executor</p> <p>I'd love to be able to run Job 1 with low memory and Job 2 with more memory. Is my only option to break it up into separate applications that can be submitted (to my YARN cluster) with separate executor configs?</p>
3
Change clear SQL to queryBuilder subquery
<p>Order entity has OneToMany OrderStatsu so any order have many statuses and I want to find all orders where last status = x.</p> <p>My query look like this (and work)</p> <pre><code>SELECT o.id, os.status_id FROM orders o LEFT JOIN( SELECT * FROM order_status GROUP BY orders_id DESC ) AS os ON o.id = os.orders_id </code></pre> <p>But I want to get it as object.</p>
3
SQL Delete with join 4
<p>I tried this request : </p> <pre><code>DELETE FROM user_tools AS UT LEFT OUTER JOIN tools AS T ON UT.tool_id = T.id WHERE UT.user_id = :user_id AND T.category = :category"; </code></pre> <p>My goal is to delete records from a table with a condition from a join in an other one. I try several solution without success. Can you help ?</p> <p>(I use PDO, it's why i have : in my where clause, but it's the same with values.</p> <p>Thanks</p>
3
Prevent double booking ASP.NET C#
<p>I 'am trying to create a vacation planner in asp.net with a SQL Server Express database.</p> <p>When you add a vacation, you have to add a <code>begintime</code>, <code>endtime</code> and of course who you are.</p> <p>Is there a way to show an error when there is already vacation with the same time and the same employee as the one they try to add. </p> <p>This way the system will prevent double vacations. Otherwise Gridview table shows two the same name in two rows with the same days. I want to prevent people from double booking.</p> <p>Let's say Person A has already booked <code>StartDate = 2016-03-06</code> and <code>EndDate = 2016-03-10</code>. Than means I want to prevent someone else to book the same <code>StartDate</code>, <code>EndDate</code>, between start and end date, not even earlier date and date between start and end date, I mean for example between 2016-03-01 and 2016-03-06 , 2016-03-07, 2016-03-08... because those dates are between start and end dates.</p> <p>I tried to create a method like following and then I don't know what to do. I would appreciate for any help // Noe edited to insert button instead method:</p> <pre><code>protected void btnInsertVacation_Click(object sender, EventArgs e) { string cs = ConfigurationManager.ConnectionStrings["ResursplaneringConnectionString"].ConnectionString; TextDateTime.Text = Calendar1.SelectedDate.ToShortDateString(); using (SqlConnection con = new SqlConnection(cs)) { string check = "SELECT EmployeeId, StartDate, EndDate FROM vacation WHERE (EmployeeId = @EmployeeId) AND(StartDate &lt;= @NewEndDate) AND(EndDate &gt;= @NewStartDate)"; SqlCommand cmd = new SqlCommand(check, con); cmd.Parameters.AddWithValue("@EmployeeId", DropDownEmployee.SelectedValue); cmd.Parameters.AddWithValue("@NewEndDate", txtStartDate.Text); cmd.Parameters.AddWithValue("@NewStartDate", txtEnd.Text); con.Open(); using (SqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { if (rdr.HasRows) { Response.Write("Dubbel booking"); } else { string insertVacation = "INSERT INTO Planering (StartDate, EndDate, EmployeeId ) VALUES (@StartDate, @EndDate, @EmployeeId)"; SqlCommand cmd2 = new SqlCommand(insertVacation, con); SqlParameter paramPlaneringStart = new SqlParameter("@StartDate", txtStartDate.Text); cmd2.Parameters.Add(paramPlaneringStart); SqlParameter paramPlaneringEnd = new SqlParameter("@EndDate", txtEnd.Text); cmd2.Parameters.Add(paramPlaneringEnd); SqlParameter paramEmployeeId = new SqlParameter("@EmployeeId", DropDownEmployee.SelectedValue); cmd2.Parameters.Add(paramEmployeeId); con.Open(); cmd2.ExecuteNonQuery(); } } } } } </code></pre>
3
I can not get a disk bigger than 10G on google cloud trial. Is this the "unannounced" default?
<p>I create a disk of size 300G when creating the instance, but when I create the instance I see it has reverted back to 10G. I just created an account to test the google cloud free trial with a view of transferring an AWS app over here, but I can't test it on 10G of disk space.</p>
3
How to add custom title tags to Joomla articles without publishing them as menu items?
<p>Is there a way to add custom title tags to Joomla articles without having to first publish them as menu items? So far I haven't seen a way to do it, so any help would be most appreciated!</p>
3
ImageView in custom row for List is out of alignment
<p>I have a custom row for a list. I want to place an image of arrow as a visual guide for the user to tap. </p> <p>The image starts on a new row and never lines up correctly on the right edge of the cell.</p> <p>Here is my XML</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;TextView android:id="@+id/txtYMMC" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Year Make Model Color" /&gt; &lt;TextView android:id="@+id/txtCallNumber" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Call Number: 0000" /&gt; &lt;ImageView android:id="@+id/imgDisclosureArrow" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:src="@drawable/arrowright" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>and here it a picture of what is happening</p> <p><a href="https://i.stack.imgur.com/GZL1z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GZL1z.png" alt="enter image description here"></a></p> <p>Here is what I want.</p> <p><a href="https://i.stack.imgur.com/KDb25.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KDb25.png" alt="enter image description here"></a></p>
3
Looping <td> depends on rowCount inside while
<p>I need loop td inside while fetch.</p> <blockquote> <p>td loop depends on rowCount variable from the first query.</p> </blockquote> <pre><code>&lt;?php include'../db/dbConnect.php'; $_GET['tb']; $t=$_GET['tb']; $q=$con-&gt;prepare("desc $t"); $q-&gt;execute(); $h=$q-&gt;rowCount(); ?&gt; &lt;table&gt; &lt;tr&gt; &lt;?php while($r=$q-&gt;fetch(PDO::FETCH_NUM)){ ?&gt; &lt;th&gt;&lt;?php echo $r[0];?&gt;&lt;/th&gt; &lt;?php } ?&gt; &lt;/tr&gt; &lt;?php $q=$con-&gt;prepare("select*from $t"); $q-&gt;execute(); while($r=$q-&gt;fetch(PDO::FETCH_NUM)){ $d=$r[0]; ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $d;?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/table&gt; </code></pre> <p>Above code give result :</p> <pre><code>col1 col2 col3 12 13 14 </code></pre> <p>But i need the result with :</p> <pre><code>col1 col2 col3 12 vala x 13 valb y 14 valc z </code></pre> <p>It must give td depends on rowCount variable.</p> <p>I tried before to loop td by using while, but this i'm not get the logic.</p> <p>I appreciate some logic or advice of the question.</p>
3
GIS software for shading drawn polygons based on data?
<p>I am looking for a program that allows me to draw (preferably import...) tracks or polygons to overlay on a map. A table in the program is then filled with data, similar to below:</p> <pre><code>Zone | Value -------------- A | 90% B | 50% C | 25% </code></pre> <p>etc.</p> <p>The area of the polygons or tracks is then shaded a designated color, with the opacity based on the values in this table. As the values are changed, the map is automatically updated.</p> <p>Anyone have any ideas on what programs are capable of this?</p> <p>Thank you for the help!</p>
3
Streaming video using fork does not return content
<p>I've experienced some sort of timeout when I try to request the same video stream twice, therefor I thought a fork could solve my problem.</p> <p>Before I start, I'm using a <a href="https://gist.github.com/ranacseruet/9826293" rel="nofollow">third party class for video streams</a>. Using my own routing system this works, but I have the problem stated above.</p> <pre><code>public function stream ($req, $res) { $video = c_video_folder . $req-&gt;get_param('id') . '.mp4'; if (file_exists($video)) { $res-&gt;videoStream($video); } else { $res-&gt;failure(204); // no content } } </code></pre> <p>After trying to use a fork, it looks like this:</p> <pre><code>public function stream ($req, $res) { $video = c_video_folder . $req-&gt;get_param('id') . '.mp4'; if (file_exists($video)) { $pid = pcntl_fork(); if ($pid == -1) { $res-&gt;videoStream($video); } else { //async $res-&gt;videoStream($video); } } else { $res-&gt;failure(204); // no content } } </code></pre> <p>The problem that occur is the response package contains no data, except the correct headers and such. Does anyone know why this happens?</p> <p>PS. the parameter $res, is simply another class setting headers and then calling the VideoStream class linked in the top.</p>
3
Create system oauth for API based on my service
<p>I would like to develop a system that can help any developer to create an application based to my API.</p> <p>My problem is authentication. I have see (for example) as work google with your services; I would like create an system of oauth (private) such as google (concept) that an developer, after sign to my portal, get APP ID and APP SECRET.</p> <p>When developer self create these credentials, can use for call API based to https.</p> <p>My API are developed by nodejs and express system.</p> <p>I say which way is more stable for create an system robust for this scenario.</p> <p>Thanks for any support. Any idea is appreciate</p>
3
AngularJS-Modify NgBoilerPlate template to modify the title of the webpage
<p>Have downloaded NgBoilerPlate from <a href="https://github.com/ngbp/ngbp" rel="nofollow">https://github.com/ngbp/ngbp</a>. Using it as a template to build a website. The flow is as follows-</p> <p><strong>index.html</strong></p> <pre><code> &lt;li ui-sref-active="active"&gt; &lt;a href ui-sref="home"&gt; &lt;i class="fa fa-home"&gt;&lt;/i&gt; Home &lt;/a&gt; &lt;/li&gt; </code></pre> <p><strong>app.js</strong></p> <pre><code>angular.module( 'ngBoilerplate', [ 'templates-app', 'templates-common', 'ngBoilerplate.home', 'ngBoilerplate.about', 'ui.router' ]) </code></pre> <p><strong>Home.js</strong></p> <pre><code>angular.module( 'ngBoilerplate.home', [ 'ui.router', 'plusOne' ]) /** * Each section or module of the site can also have its own routes. AngularJS * will handle ensuring they are all available at run-time, but splitting it * this way makes each module more "self-contained". */ .config(function config( $stateProvider ) { $stateProvider.state( 'home', { url: '/home', views: { "main": { controller: 'HomeCtrl', templateUrl: 'home/home.tpl.html' } }, data:{ pageTitle: 'Home' } }); }) </code></pre> <p>Now when the homeTab is clicked- the title is shown as <strong>Home|ngBoilerplate</strong></p> <p>How to get rid of <strong>|ngBoilerPlate</strong> from title.</p> <p>Thanks</p>
3
What web technology have been used on http://www.badassembly.com/work/
<p>I was browsing Bad Assembly website: <a href="http://www.badassembly.com/work/" rel="nofollow">http://www.badassembly.com/work/</a> and I saw something really interesting on it.</p> <p>When you scroll through different sections it changes the URL in address bar and also browser "Back" button is active and that happens without a page refresh. </p> <p>Can anyone tell me how was it achieved? Is there any framework for this. I just want to know so I can learn about it.</p> <p>Edit: Many have downvoted it and marked it as Duplicate but the thread I was provided is partially what I was looking for. The Example I've provided changes the URL or scroll. If you see the code, all the sections are there on page and when scrolled(not just clicked) to a particular section it changes the URL.</p>
3
JavaFX : How to process a webview in a non application thread
<p>I have a JavaFX application that contains a WebView among other JavaFx views in the same window. The WebView opens a URL to a NodeJs webapp that consumes a lot of CPU resources. </p> <p>With this resource consumption from the WebView, the other JavaFX views are working slowly.</p> <p>For our application, we have a very powerful system with 12 virtual threads in the processor. </p> <p>So, what I need is to deport the WebView processing to another thread so that it won't affect the behavior of the other JavaFX views. Is there any way to achieve this?</p>
3
Why does byte representation in Java store data in decimal?
<p>I was debugging a problem where I created a byte array from binary representation of strings such as below. </p> <ol> <li>While debugging the array just to see how it is stored, I could see them stored internally as decimals. Why is that? </li> <li>When it gets interpreted as bytecode I am assuming it will get converted as binary. Then why not store in binary in the first place. </li> </ol> <pre><code> String[] binArray = {"10101","11100","11010","00101"}; byte[]bytes = new byte[binArray.length]; for (int i=0; i&lt; binArray.length;i++){ bytes[i] = Byte.parseByte(binArray[i],2); } </code></pre> <p>I may be missing something here. Hence request your guidance.</p>
3
Shell Script from Unix not running on other OS
<p>I have a shell script working on SCO Unix 5.0.6. The problem is when I copy the script to another machine with SCO Unix 5.0.7 (and also other OS) then it is not running. It shows a syntax error. </p> <p>Note that when I copy all instructions and paste them in command line then they work perfectly. However, as I said they are not working as one script file. </p> <p>As example in the script I have:</p> <pre><code>case "${MODUS}" in </code></pre> <p>And I get the below error:</p> <pre><code>syntax error near unexpected token '$'in\r'' </code></pre> <p>Base on the error it seems to me something is added at the end of each instruction. </p> <p>In some cases when the error is at the end of the instruction I can fix the problem. I add a space and #(to consider the rest line as comment) at the end of each instruction. Then it works. However, the problem is that I cannot do that for all instructions. In some cases the error is in middle of the instruction and then (space#) not working. </p> <p>Please let me know what is the reason for the error and how can I fix that.</p>
3
How to configure ruby Neo4j ActiveRel object to get cascading persistance
<p>I experiment with Neo4j gem for working with Neo4j library. When you configure active nodes without using active relationships you can specify :origin property and on node.save it cascades through all graph saving everything auto-magically. Now I want to use active relationships to have some data on them and :origin is not allowed anymore on node relationship declaration and on node.save it doesn't propagate changes anymore.</p> <p>Is there a way to achieve 'single node.save call - store all graph' functionality?</p> <p>My problem is that the performance went down when I have to create each relationship separately, so maybe there is another way to batch the queries?</p> <p>Thanks!</p>
3
including the OracleClient dll file with release version
<p>I had made small c# program that use oracle database so I had to include reference </p> <blockquote> <p>Data.OracleClient</p> </blockquote> <p>after releasing my project and move it to the working environment I got problem which is missing the reference Data.OracleClient </p> <p>why the Data.OracleClient won't be included within the release version of my project ????? </p> <p>what should I have to do to force the including of that library which is necessary to let my project work sinces i am not able to copy the dll file to all PSs on my network ?? </p> <p>and if i used the </p> <blockquote> <p>Oracle.DataAccess.Client</p> </blockquote> <p>how i know the equivalent keyworks with this library ??</p> <p>should I rebuild the whole project ?!</p>
3
Bash: Why does egrepping for this string succeed?
<p>I'm trying to check if a help switch was passed to my program via egrepping it for <code>-?</code>, <code>-h</code>, or <code>--help</code>. If not, I simply forward everything to another script, like so:</p> <pre><code>if echo "$*" | egrep -q -- '-?|-h|--help'; then help exit 0 fi exec another/script "$@" </code></pre> <p>For some reason, this doesn't seem to be working on my system. I tracked it down to the fact <code>egrep</code> was returning successfully for searches on the empty string, e.g. this will print <code>0</code>:</p> <pre><code>echo '' | egrep -q -- '-?|-h|--help' echo $? </code></pre> <p>Why does this happen, and what can I do to fix it? Thanks!</p> <hr> <p><strong>edit:</strong> Also just noticed that while this command will succeed:</p> <pre><code>echo -h | egrep -- -? echo $? # 0 </code></pre> <p>Using it with regular <code>grep</code> will fail:</p> <pre><code>echo -h | grep -- -? echo $? # 1 </code></pre> <p>I'm assuming the extended grep is treating <code>?</code> as a special character, then?</p>
3
gvisGeoChart Not Recognizing Lat/Long for Marker
<p>I'm having issues running some code to plot markers on a US map using <code>googleVis</code> and <code>gvisGeoChart()</code>. I can run the following example, no problems:</p> <pre><code>require(datasets) library(googleVis) GeoMarker &lt;- gvisGeoChart(Andrew, "LatLong", sizevar='Speed_kt', colorvar="Pressure_mb", options=list(region="US")) plot(GeoMarker) </code></pre> <p>Here is the kind of code I'm using. I'm attempting to bring lists of values into a data frame and then use this data to plot markers on a US map.</p> <pre><code>library(googleVis) library(ggmap) cities &lt;- c("Norman, OK", "Madison, WI", "Tallahassee, FL") test &lt;- as.data.frame(cities) test$rank &lt;- c(2,1,3) colnames(test) &lt;- c("City","Rank") geocodes &lt;- geocode(as.character(test$City)) new &lt;- data.frame(test[,1:2],geocodes) TestPlot &lt;- gvisGeoChart(new, sizevar='Rank',options=list(region="US")) plot(TestPlot) </code></pre> <p>I then receive the following error: </p> <p><code>Error in data.frame(Latitude = numeric(0), Longitude = numeric(0), Rank = c(2, : arguments imply differing number of rows: 0, 3</code></p> <p>I have searched and can't find too many tutorials on using <code>googleVis</code> in R and especially with regards to gvisGeoChart apart from the documentation. I've inspected the <code>Andrew</code> data frame and used <code>str()</code> and can't find anything different between the two data sets. </p> <p>Thanks for any and all help and please let me know if you need any clarification!</p>
3
I can't open local Folder from link on Sharepoint website
<p>i need help : i can't open local folder from hyperlink in webPart 'Script Editor'<br> Simple Code : [a href='C:\Users\User\Desktop\Folder']open folder[/a] or like a link in Library. Any idea? weird things that is working on the another PC and not on mine. I'am working with IE 11</p>
3
Implement CERT rules using MPS
<p>I am trying to develop a DSL for CERT Java Coding guidelines. That time I got a framework called jetbrains MPS.I tried most of the documents available in jetbrains site. But those are not sufficient for my work. Two doubts are can I implement CERT Java Coding guidelines using MPS and anybody knows any previous work and good documents related to this.</p>
3
301 Redirect to single url without autosubstitution
<p>I need to redirect site's visitors from <code>/good/cats</code> to <code>/bad</code>. What i write:</p> <pre><code>Redirect 301 /good/cats http://somedomain/bad </code></pre> <p>What i get:</p> <pre><code>http://somedomain/bad/cats </code></pre> <p>What should i write to redirect to the <code>http://somedomain/bad</code>? </p>
3
Memory Available for Activation Stack?
<p>What is the maximum amount of memory available for activation stack to store activation records? I've been reading about activation stack, and was wondering what would be its limit.</p>
3
In java how can i randomize and int in an array
<p>Hi i am just learning java and want to write a sort of vocabulary trainer. It is working but i want to give the questions in a random order. The trainer pics a list from an external file and splits the file in two parts. It is asking as long the next line isn't null.</p> <pre><code>for (int i = 0; (zeile = br.readLine()) != null; i++) { splitted = zeile.split(";"); eng[i] = splitted[0]; ger[i] = splitted[1]; </code></pre> <p>then i am asking for the vocabulary. But as you can see its always in the same order. I don't know how i can correctly randomize the list before the asking part.</p> <pre><code>for (int j = 0; j &lt; eng.length; j++) { correct = false; while (!correct) { System.out.print(eng[j] + " bedeutet: "); gerEingabe = vokabel.nextLine(); if (gerEingabe.equals(ger[j])) { System.out.println("Das ist Korrekt. Auf zur nächsten Aufgabe."); correct = true; } else { System.out.println("Das war leider Falsch. Bitte versuche es noch ein mal."); </code></pre> <p>It would be nice if someone can help me with this. </p>
3
How to insert task in google task?
<p>I am trying to sync with google tasks. I got the tasks list from default list. Now I want to insert a task in default list.</p> <p>I followed the documentation for this. </p> <p><a href="https://developers.google.com/google-apps/tasks/v1/reference/tasks/insert" rel="nofollow">https://developers.google.com/google-apps/tasks/v1/reference/tasks/insert</a></p> <p>Also I have set the task api as enabled. I have generate the client id also.</p> <p>OAuth 2.0 client IDs</p> <p>Name Creation date Type Client ID </p> <p>Android client 1 Mar 19, 2016 Android 256433535354-h653umd5mddo5t139moof3cvd56asnec.apps.googleusercontent.com</p> <p>Still when I try to insert a task I get the error that of 403 forbidden and the error message is: insufficient permission.</p> <p>I have also set OAuth 2.0 scopes as manage all your task. From here:</p> <p><a href="https://developers.google.com/apis-explorer/?hl=en_US#p/tasks/v1/" rel="nofollow">https://developers.google.com/apis-explorer/?hl=en_US#p/tasks/v1/</a></p> <p>Still I am unable to insert the task.</p> <p>I am not getting what's going wrong.. Please help..</p> <pre><code>public class MainActivity extends AppCompatActivity { GoogleAccountCredential mCredential; private TextView mOutputText; ProgressDialog mProgress; static final int REQUEST_ACCOUNT_PICKER = 1000; static final int REQUEST_AUTHORIZATION = 1001; static final int REQUEST_GOOGLE_PLAY_SERVICES = 1002; private static final String PREF_ACCOUNT_NAME = "accountName"; private static final String[] SCOPES = { TasksScopes.TASKS_READONLY }; ListView listView; ArrayAdapter&lt;String&gt; adapter; List&lt;String&gt; result1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); LinearLayout activityLayout = new LinearLayout(this); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); activityLayout.setLayoutParams(lp); activityLayout.setOrientation(LinearLayout.VERTICAL); activityLayout.setPadding(16, 16, 16, 16); ViewGroup.LayoutParams tlp = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); mOutputText = new TextView(this); mOutputText.setLayoutParams(tlp); mOutputText.setPadding(16, 16, 16, 16); mOutputText.setVerticalScrollBarEnabled(true); mOutputText.setMovementMethod(new ScrollingMovementMethod()); activityLayout.addView(mOutputText); mProgress = new ProgressDialog(this); mProgress.setMessage("Calling Google Tasks API ..."); listView = (ListView) findViewById(R.id.list); setContentView(activityLayout); // Initialize credentials and service object. SharedPreferences settings = getPreferences(Context.MODE_PRIVATE); mCredential = GoogleAccountCredential.usingOAuth2( getApplicationContext(), Arrays.asList(SCOPES)) .setBackOff(new ExponentialBackOff()) .setSelectedAccountName(settings.getString(PREF_ACCOUNT_NAME, null)); } /** * Called whenever this activity is pushed to the foreground, such as after * a call to onCreate(). */ @Override protected void onResume() { super.onResume(); if (isGooglePlayServicesAvailable()) { refreshResults(); } else { mOutputText.setText("Google Play Services required: " + "after installing, close and relaunch this app."); } } /** * Called when an activity launched here (specifically, AccountPicker * and authorization) exits, giving you the requestCode you started it with, * the resultCode it returned, and any additional data from it. * @param requestCode code indicating which activity result is incoming. * @param resultCode code indicating the result of the incoming * activity result. * @param data Intent (containing result data) returned by incoming * activity result. */ @Override protected void onActivityResult( int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch(requestCode) { case REQUEST_GOOGLE_PLAY_SERVICES: if (resultCode != RESULT_OK) { isGooglePlayServicesAvailable(); } break; case REQUEST_ACCOUNT_PICKER: if (resultCode == RESULT_OK &amp;&amp; data != null &amp;&amp; data.getExtras() != null) { String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); if (accountName != null) { mCredential.setSelectedAccountName(accountName); SharedPreferences settings = getPreferences(Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putString(PREF_ACCOUNT_NAME, accountName); editor.apply(); } } else if (resultCode == RESULT_CANCELED) { mOutputText.setText("Account unspecified."); } break; case REQUEST_AUTHORIZATION: if (resultCode != RESULT_OK) { chooseAccount(); } break; } super.onActivityResult(requestCode, resultCode, data); } /** * Attempt to get a set of data from the Google Tasks API to display. If the * email address isn't known yet, then call chooseAccount() method so the * user can pick an account. */ private void refreshResults() { if (mCredential.getSelectedAccountName() == null) { chooseAccount(); } else { if (isDeviceOnline()) { new MakeRequestTask(mCredential).execute(); } else { mOutputText.setText("No network connection available."); } } } /** * Starts an activity in Google Play Services so the user can pick an * account. */ private void chooseAccount() { startActivityForResult( mCredential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER); } /** * Checks whether the device currently has a network connection. * @return true if the device has a network connection, false otherwise. */ private boolean isDeviceOnline() { ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); return (networkInfo != null &amp;&amp; networkInfo.isConnected()); } /** * Check that Google Play services APK is installed and up to date. Will * launch an error dialog for the user to update Google Play Services if * possible. * @return true if Google Play Services is available and up to * date on this device; false otherwise. */ private boolean isGooglePlayServicesAvailable() { final int connectionStatusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (GooglePlayServicesUtil.isUserRecoverableError(connectionStatusCode)) { showGooglePlayServicesAvailabilityErrorDialog(connectionStatusCode); return false; } else if (connectionStatusCode != ConnectionResult.SUCCESS ) { return false; } return true; } /** * Display an error dialog showing that Google Play Services is missing * or out of date. * @param connectionStatusCode code describing the presence (or lack of) * Google Play Services on this device. */ void showGooglePlayServicesAvailabilityErrorDialog( final int connectionStatusCode) { Dialog dialog = GooglePlayServicesUtil.getErrorDialog( connectionStatusCode, MainActivity.this, REQUEST_GOOGLE_PLAY_SERVICES); dialog.show(); } /** * An asynchronous task that handles the Google Tasks API call. * Placing the API calls in their own task ensures the UI stays responsive. */ private class MakeRequestTask extends AsyncTask&lt;Void, Void, List&lt;String&gt;&gt; { private com.google.api.services.tasks.Tasks mService = null; private Exception mLastError = null; public MakeRequestTask(GoogleAccountCredential credential) { HttpTransport transport = AndroidHttp.newCompatibleTransport(); JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); mService = new com.google.api.services.tasks.Tasks.Builder( transport, jsonFactory, credential) .setApplicationName("Google Tasks API Android Quickstart") .build(); } /** * Background task to call Google Tasks API. * @param params no parameters needed for this task. */ @Override protected List&lt;String&gt; doInBackground(Void... params) { try { //getTasks(); // insertTask(); return getTasks(); } catch (Exception e) { mLastError = e; cancel(true); return null; } } /** * Fetch a list of the first 10 task lists. * @return List of Strings describing task lists, or an empty list if * there are no task lists found. * @throws IOException */ private List&lt;String&gt; getTasks() throws IOException{ List&lt;String&gt; result1 = new ArrayList&lt;String&gt;(); List&lt;Task&gt; tasks = mService.tasks().list("@default").setFields("items/title").execute().getItems(); if (tasks != null) { for (Task task : tasks) { result1.add(task.getTitle()); } } else { result1.add("No tasks."); } adapter = new ArrayAdapter&lt;String&gt;(MainActivity.this, android.R.layout.simple_list_item_1, result1); listView.setAdapter(adapter); return result1; } private void insertTask() throws IOException { Task task = new Task(); task.setTitle("New Task"); task.setNotes("Please complete me"); Task result = mService.tasks().insert("@default", task).execute(); System.out.println(result.getTitle()); } private List&lt;String&gt; getDataFromApi() throws IOException { // List up to 10 task lists. List&lt;String&gt; taskListInfo = new ArrayList&lt;String&gt;(); TaskLists result = mService.tasklists().list() .setMaxResults(Long.valueOf(10)) .execute(); List&lt;TaskList&gt; tasklists = result.getItems(); if (tasklists != null) { for (TaskList tasklist : tasklists) { taskListInfo.add(String.format("%s (%s)\n", tasklist.getTitle(), tasklist.getId())); } } return taskListInfo; } @Override protected void onPreExecute() { mOutputText.setText(""); mProgress.show(); } @Override protected void onPostExecute(List&lt;String&gt; output) { mProgress.hide(); if (output == null || output.size() == 0) { mOutputText.setText("No results returned."); } else { output.add(0, "Data retrieved using the Google Tasks API:"); mOutputText.setText(TextUtils.join("\n", output)); } } @Override protected void onCancelled() { mProgress.hide(); if (mLastError != null) { if (mLastError instanceof GooglePlayServicesAvailabilityIOException) { showGooglePlayServicesAvailabilityErrorDialog( ((GooglePlayServicesAvailabilityIOException) mLastError) .getConnectionStatusCode()); } else if (mLastError instanceof UserRecoverableAuthIOException) { startActivityForResult( ((UserRecoverableAuthIOException) mLastError).getIntent(), MainActivity.REQUEST_AUTHORIZATION); } else { mOutputText.setText("The following error occurred:\n" + mLastError.getMessage()); } } else { mOutputText.setText("Request cancelled."); } } } } </code></pre> <p>Thank you..</p>
3
How can I handle the deletion of these items from SharedPreferences?
<p>I'm building an app that will silence people's ringers based on their location. I use a PlacePicker API, then save the name of the place to SharedPreferences and add it to a ListView. I have problems with deleting the items, though. When the user long clicks a listview item, it is supposed to be deleted from SharedPreferences. The problem is, after the first deletion, my method of referring to which SharedPrefs item to delete is bad and it doesn't work. How can I fix it?</p> <pre><code>public class MainActivity extends AppCompatActivity implements LocationListener { PlacePicker.IntentBuilder builder; int PLACE_PICKER_REQUEST; ListView placeListView; ArrayList&lt;String&gt; placeArrayList; ArrayAdapter&lt;String&gt; arrayAdapter; SharedPreferences sharedPreferences; SharedPreferences.Editor editor; ArrayList&lt;Double&gt; latitudeList; Integer counter; LocationManager locationManager; String provider; double lat; double lng; Place place; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); placeListView = (ListView) findViewById(R.id.placeListView); latitudeList = new ArrayList&lt;&gt;(); placeArrayList = new ArrayList&lt;String&gt;(); arrayAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, placeArrayList); placeListView.setAdapter(arrayAdapter); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); provider = locationManager.getBestProvider(new Criteria(), false); placeListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView&lt;?&gt; parent, View view, final int position, long id) { new AlertDialog.Builder(MainActivity.this) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle("Are you sure?") .setMessage("Do you want to delete this place?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { placeArrayList.remove(position); SharedPreferences sharedPreferences = MainActivity.this.getSharedPreferences("myPrefs", Context.MODE_PRIVATE); sharedPreferences.edit().remove("name" + position).apply(); arrayAdapter.notifyDataSetChanged(); } }) .setNegativeButton("No", null) .show(); return false; } }); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling // ActivityCompat#requestPermissions // here to request the missing permissions, and then overriding // public void onRequestPermissionsResult(int requestCode, String[] permissions, // int[] grantResults) // to handle the case where the user grants the permission. See the documentation // for ActivityCompat#requestPermissions for more details. return; } Location location = locationManager.getLastKnownLocation(provider); if (location != null){ lat = location.getLatitude(); lng = location.getLongitude(); Toast.makeText(getApplicationContext(), String.valueOf(lat) + String.valueOf(lng), Toast.LENGTH_LONG).show(); }else{ Toast.makeText(getApplicationContext(), "Unable to get location", Toast.LENGTH_LONG).show(); } sharedPreferences = getSharedPreferences("myPrefs", Context.MODE_PRIVATE); editor = sharedPreferences.edit(); sharedPreferences.edit().putInt("counter", 0); counter = sharedPreferences.getInt("counter", -1); arrayAdapter.notifyDataSetChanged(); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { PLACE_PICKER_REQUEST = 1; builder = new PlacePicker.IntentBuilder(); pickPlace(); } }); } public void pickPlace(){ try { startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST); } catch (GooglePlayServicesRepairableException e) { e.printStackTrace(); } catch (GooglePlayServicesNotAvailableException e) { e.printStackTrace(); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == PLACE_PICKER_REQUEST) { if (resultCode == RESULT_OK) { place = PlacePicker.getPlace(data, this); // String toastMsg = String.format("Place: %s", place.getName()); //Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show(); counter = sharedPreferences.getInt("counter", -1); counter = counter + 1; sharedPreferences.edit().putInt("counter", counter).apply(); LatLng latLng = place.getLatLng(); sharedPreferences.edit().putFloat("latitude" + String.valueOf(counter), (float) latLng.latitude).apply(); sharedPreferences.edit().putFloat("longitude" + String.valueOf(counter), (float) latLng.longitude).apply(); placeArrayList.add(place.getName().toString()); sharedPreferences.edit().putString("name" + placeArrayList.size(), place.getName().toString()).apply(); arrayAdapter.notifyDataSetChanged(); } } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } @Override public void onLocationChanged(Location location) { for (int i = counter; i &gt;= 0; i--){ if (lat &gt;= sharedPreferences.getFloat("latitude" + String.valueOf(i), -1) - .005 &amp;&amp; lat &lt;= sharedPreferences.getFloat("latitude" + String.valueOf(i), -1) + .005 &amp;&amp; lng &gt;= sharedPreferences.getFloat("longitude" + String.valueOf(i), -1) - .005 &amp;&amp; lng &lt;= sharedPreferences.getFloat("longitude" + String.valueOf(i), -1) + .005){ AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.setStreamVolume(AudioManager.STREAM_RING, AudioManager.RINGER_MODE_SILENT, AudioManager.FLAG_SHOW_UI); } } } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderEnabled(String provider) { } @Override public void onProviderDisabled(String provider) { } } </code></pre>
3
How to sort python lists due to certain criteria
<p>I would like to sort a list or an array using python to achive the following: Say my initial list is:</p> <pre><code>example_list = ["retg_1_gertg","fsvs_1_vs","vrtv_2_srtv","srtv_2_bzt","wft_3_btb","tvsrt_3_rtbbrz"] </code></pre> <p>I would like to get all the elements that have 1 behind the first underscore together in one list and the ones that have 2 together in one list and so on. So the result should be:</p> <pre><code>sorted_list = [["retg_1_gertg","fsvs_1_vs"],["vrtv_2_srtv","srtv_2_bzt"],["wft_3_btb","tvsrt_3_rtbbrz"]] </code></pre> <p>My code:</p> <pre><code>import numpy as np import string example_list = ["retg_1_gertg","fsvs_1_vs","vrtv_2_srtv","srtv_2_bzt","wft_3_btb","tvsrt_3_rtbbrz"] def sort_list(imagelist): # get number of wafers waferlist = [] for image in imagelist: wafer_id = string.split(image,"_")[1] waferlist.append(wafer_id) waferlist = set(waferlist) waferlist = list(waferlist) number_of_wafers = len(waferlist) # create list sorted_list = [] for i in range(number_of_wafers): sorted_list.append([]) for i in range(number_of_wafers): wafer_id = waferlist[i] for image in imagelist: if string.split(image,"_")[1] == wafer_id: sorted_list[i].append(image) return sorted_list sorted_list = sort_list(example_list) </code></pre> <p>works but it is really awkward and it involves many for loops that slow down everything if the lists are large.</p> <p>Is there any more elegant way using numpy or anything?</p> <p>Help is appreciated. Thanks.</p>
3
Libgdx No signing identity found matching '/(?i)iPhone Developer|iOS Development/'
<p>I would fill my app I'm doing with Android libgdx and study, using robovm , but I did not recognize the certificate .</p> <p>The certificate from xcode preferences correctly was downloaded , and then usually always worked .... what I did because it renew expired and then I re-downloaded with xCode .</p> <p>Does anyone know advise me how to solve ? Thank you</p> <pre><code> [ERROR] Couldn't compile app java.lang.IllegalArgumentException: No signing identity found matching '/(?i)iPhone Developer|iOS Development/' at org.robovm.compiler.target.ios.SigningIdentity.find(SigningIdentity.java:69) at org.robovm.compiler.target.ios.AppleDeviceTarget.init(AppleDeviceTarget.java:1089) at org.robovm.compiler.config.Config.build(Config.java:938) at org.robovm.compiler.config.Config.access$5200(Config.java:94) at org.robovm.compiler.config.Config$Builder.build(Config.java:1606) at org.robovm.idea.compilation.RoboVmCompileTask.compileForRunConfiguration(RoboVmCompileTask.java:206) at org.robovm.idea.compilation.RoboVmCompileTask.execute(RoboVmCompileTask.java:73) at com.intellij.compiler.impl.CompileDriver.executeCompileTasks(CompileDriver.java:627) at com.intellij.compiler.impl.CompileDriver.access$400(CompileDriver.java:88) at com.intellij.compiler.impl.CompileDriver$3.run(CompileDriver.java:410) at com.intellij.compiler.progress.CompilerTask.run(CompilerTask.java:203) at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:563) at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137) at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:126) at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:400) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56) </code></pre>
3
Can't get content on the same row
<p>Ive been working on this menu and I can't get my parts of my menu to display within the same row. So far I've been going off how to nest rows under bootstrap's website. Any help is appreciated! Thanks in advance! This is what I have so far: </p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="row"&gt; &lt;div class="menu container-fluid"&gt; &lt;div class="row"&gt; &lt;div class="dropdownn col-xs-12 col-md-6"&gt; &lt;button class="btn dropdown-toggle" type="button" id="espressoDrinks" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"&gt; Espresso Drinks &lt;span class="caret"&gt;&lt;/span&gt; &lt;/button&gt; &lt;ul class="dropdown-menu" aria-labelledby="espressoDrinks"&gt; &lt;ul&gt; &lt;li&gt;Espresso&lt;/li&gt; &lt;p&gt;2 oz. 4 oz. or 6 oz. of the finest pure espresso&lt;/p&gt; &lt;li&gt;Americano&lt;/li&gt; &lt;p&gt;Fresh brewed espresso with hot water&lt;/p&gt; &lt;li&gt;Macchiato&lt;/li&gt; &lt;p&gt;Espresso with a dallop of foam&lt;/p&gt; &lt;li&gt;Cappuccino&lt;/li&gt; &lt;p&gt;Espresso with steamed milk, topped with a crown of foam&lt;/p&gt; &lt;/ul&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- &lt;/div&gt; --&gt; &lt;div class="row"&gt; &lt;div class="dropdown col-xs-12 col-md-6"&gt; &lt;button class="btn dropdown-toggle" type="button" id="blendedEspresso" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"&gt; Blended Espresso Shakes &lt;span class="caret"&gt;&lt;/span&gt; &lt;/button&gt; &lt;ul class="dropdown-menu" aria-labelledby="blendedEspresso"&gt; &lt;ul&gt; &lt;li&gt;Blended Bliss&lt;/li&gt; &lt;p&gt;Espresso, chocolate and lowfat ice milk blended into a refreshing shake, topped with whipped cream. Delicious!&lt;/p&gt; &lt;li&gt;Java Chill&lt;/li&gt; &lt;p&gt;Brewed espresso blended with lowfat ice milk, a splash of a flavor of your choosing, and topped with whipped cream&lt;/p&gt; &lt;li&gt; White Mocha Chill&lt;/li&gt; &lt;p&gt;Blended Ghirardelli white chocolate mocha capped with whipped cream&lt;/p&gt; &lt;li&gt;Malty-Malt&lt;/li&gt; &lt;p&gt;Blended chocolate mocha with malted milk and topped with whipped cream&lt;/p&gt; &lt;li&gt;Minty-Mint&lt;/li&gt; &lt;p&gt;Blended mocha spun with a whole peppermint patty and topped with cream&lt;/p&gt; &lt;/ul&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- begin snippet: js hide: false --&gt;</code></pre> </div> </div> </p>
3
Casting error, IO C program
<p>Overall objective: Read arbitrary file into a buffer, copy buffer over to farray while removing null characters.</p> <p>Error: </p> <blockquote> <p>Allocating memory for arrays (which is reuqired)</p> </blockquote> <p>error msg:</p> <blockquote> <p>warning: incompatible implicit declaration of built-in function ‘malloc’ [enabled by default] farray = (char *) malloc(sizeof(char));</p> </blockquote> <p>EDIT: #include , and all other obvious ones included</p> <pre><code>char *farray; const char* sarray; farray = (char *) malloc(sizeof(char)*120); sarray = (char *) malloc(sizeof(char)*120); </code></pre>
3
Replacing values in each column independently according to value order in R
<p>I have a matrix:</p> <pre><code>mat &lt;-structure(c(0.35, 0.27, 0.26, 0.28, 0.23, 0.37, 0.28, 0.27, 0.28, + 0.22, 0.34, 0.27, 0.25, 0.25, 0.24, 0.35, 0.27, 0.25, 0.29, 0.27, + 0.66, 0.37, 0.49, 0.46, 0.42, 0.64, 0.4, 0.48, 0.45, 0.42, 0.81, + 0.39, 0.36, 0.37, 0.36, 0.34, 0.34, 0.43, 0.42, 0.34), .Dim = c(5L, + 8L), .Dimnames = list(c("a", "b", "c", "d", "e"), c("f", "g", + "h", "i", "j", "k", "l", "m"))) print(mat) f g h i j k l m a 0.35 0.37 0.34 0.35 0.66 0.64 0.81 0.34 b 0.27 0.28 0.27 0.27 0.37 0.40 0.39 0.34 c 0.26 0.27 0.25 0.25 0.49 0.48 0.36 0.43 d 0.28 0.28 0.25 0.29 0.46 0.45 0.37 0.42 e 0.23 0.22 0.24 0.27 0.42 0.42 0.36 0.34 </code></pre> <p>For each column I want the lowest <code>k</code> values to be replaced by 0</p> <p>To achieve this, I used a for loop and ifelse:</p> <pre><code>k &lt;- 3 for (j in 1:ncol(mat)) { mat[,j][tail(order(mat[,j], decreasing = TRUE, na.last = FALSE), ifelse(nrow(mat)&lt;=k, 0, nrow(mat)-k))] &lt;- 0 } print(mat) f g h i j k l m a 0.35 0.37 0.34 0.35 0.66 0.64 0.81 0.34 b 0.27 0.28 0.27 0.27 0.00 0.00 0.39 0.00 c 0.00 0.00 0.25 0.00 0.49 0.48 0.00 0.43 d 0.28 0.28 0.00 0.29 0.46 0.45 0.37 0.42 e 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 </code></pre> <p>So, it all worked fine but unfortunately the loop is very slow for a large number of columns.</p> <p>How can I speed up things? <code>apply</code> seems not to be suitable as I want to the whole matrix returned.</p>
3
Changing message to already pulled commits
<p>I've been working on a project where all commit messages where made in Spanish. Now I'm working with people from other countries so I'd like to change commit messages to English. Is it possible?</p>
3
SQL retrieving filtered value in subquery
<p>in this cust_id is a foreign key and <em>ords</em> returns the number of orders for every customers</p> <pre><code>SELECT cust_name, ( SELECT COUNT(*) FROM Orders WHERE Orders.cust_id = Customers.cust_id ) AS ords FROM Customers </code></pre> <p>The output is correct but i want to filter it to retrieve only the customers with less than a given amount of orders, i don't know how to filter the subquery <em>ords</em>, i tried <code>WHERE ords &lt; 2</code> at the end of the code but it doesn't work and i've tried adding <code>AND COUNT(*)&lt;2</code> after the cust_id comparison but it doesn't work. I am using MySQL</p>
3
Form is empty, so it gives me a validation error even before I submit
<p>Im really new to php, so hear me out. I made a simple page with a form that validates whether the data you sent was ok to send, but it gives me a validation error I made even before I enter anything. Heres the code:</p> <pre><code> &lt;html&gt; &lt;body&gt; &lt;form action="first.php" method="post"&gt; Username:&lt;input type="text" name="username"&gt;&lt;br /&gt; Password:&lt;input type="password" name="password"&gt;&lt;br /&gt; &lt;input type="submit" name="submit"&gt;&lt;br /&gt; &lt;/form&gt; &lt;?php $errors = array(); $username = $_POST['username']; $password = $_POST['password']; $errors = array(); if(!isset($username) || empty($username)){ $errors = "Empty username&lt;br /&gt;"; } if ($username &gt; 10){ $errors['username'] = "Username out of range&lt;br /&gt;"; } if (!empty($errors)){ echo "Error&lt;br /&gt;"; print_r ($errors); } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
3
Can't get polymer databinding to custom html tag to work while it works on standard tags
<p>I'm using polymer 1.3.1 but can't get the following to work inside a polymer-element named: <code>poly-main</code>. The text of the <code>&lt;div&gt;</code> should be in red but isn't.</p> <pre><code>&lt;div testcolor="[[colorLocalRed]]"&gt; --&gt;ERROR This must be RED because testcolor="[[colorLocalRed]]" (expected "myred" and styles.css translates this to color="red") &lt;/div&gt; </code></pre> <p>with the following at the start of the script tag:</p> <pre><code>Polymer({ is: 'poly-main', properties: { colorLocalRed: { type: String, value: "myred", notify: true }, </code></pre> <p>And the following inside styles.css:'</p> <pre><code>[testcolor="myred"] { color: red; } </code></pre> <p>Note: the following works as it should: <code>&lt;div testcolor="myred"&gt; some red text &lt;/div&gt;</code></p> <p>Not using the custom tag <code>testcolor</code> but using directly style or color is not an option because this example is only to show the problem of databinding to a non-standard html-tag</p>
3
How to form Elastic Search Request to return records using Group By
<p>My requirement is I need to form a request to get the count of All the Guests whose 'arrivalDt' is greater than the current date group by 'resId'. The data has resId, Guest Info, arrivalDt. There will multiple records with the same resrvationId(resId) with Individual Guest details for that reservation.</p> <p>I have formed the below query that returns the count based on reservationId, but am unable to add the above date condition.</p> <pre><code>{ "size": 0, "aggs": { "group_by_reservation": { "terms": { "field": "resId" } } } } </code></pre>
3
Retrieve header values from post request
<p>I'm trying to retrieve values from the header response, but can't seem to retrieve this? i've tried with <code>allHeaderFields</code>, but does not seem to be a member of <code>NSURLResponse</code>?</p> <pre><code>testProvider.request(.SignIn(email, password), completion: { result in switch result { case let .Success(response): do { try response.filterSuccessfulStatusCodes() let data = try response.mapJSON() } catch { // show an error to your user } case let .Failure(error): print(error) let description = "Error! Please check your internet connection" delegate.loginProvider(self, didError: description) } }) </code></pre>
3
Regular Expression in java to get parameters from javascript methods
<p>Long story short, i would like to get the parameters list from JavaScript methods in Java. It works well if i got any parameters, but if the parameter list is empty it's just not working. For example</p> <pre><code>function() { return fn.num(tra.getMaster_id(fg)+1) </code></pre> <p>My regular expression is:</p> <pre><code>(?&lt;=\({1}).*?(?=\){1}) </code></pre> <p>The result i get:</p> <pre><code>tra.getMaster_id(fg </code></pre> <p>The result i want is the empty space between the <code>()</code>.</p> <p>If i test it with <a href="https://regex101.com/" rel="nofollow">Here</a> everything is fine, but in java it didn't working yet :(</p> <p>I would appreciate any ideas!</p>
3
git: hook processed files?
<p>Good evening it's strange that git hooks obviously don't know anything about handled files, e.g.:</p> <pre><code># Checkout any files which were deleted in the local workspace git ls-files -d | xargs git checkout -- </code></pre> <p>This command calls the post-checkout script - but does not pass all handled files.</p> <p>Is there a solution to call a git hook for each handled file and the action happaned to it? (file was update, created, deleted, …)</p> <p>Thanks a lot for any help!, kind regards, Tom</p>
3
How do I access a directive scope from a parent directive/controller?
<p>I have a template that goes something like this: </p> <pre><code>&lt;parent-directive&gt; &lt;child-directive binding="varFromParent"&gt;&lt;/child-directive&gt; &lt;button ng-click="parentDirective.save()"&gt;&lt;/button&gt; &lt;/parent-directive&gt; </code></pre> <p>When executing a function in the <code>parentDirective</code> controller, is it possible to access and manipulate the scope variables of the <code>childDirective</code> for e.g. if I have them set up as so</p> <pre><code>angular.module('app').directive('parentDirective', function() { return { restrict: 'E', templateUrl: '...', controllerAs: 'parentDirective', controller: function($rootScope, $scope) { //... this.save = () =&gt; { //Need to manipulate childDirective so that its //scope.defaultValue == 'NEW DEFAULT' } } } }); </code></pre> <p>and </p> <pre><code>angular.module('app').directive('childDirective', function() { return { restrict: 'E', templateUrl: '...', scope: { binding: '=' }, controllerAs: 'childDirective', link: function(scope, elm, attrs) { scope.defaultValue = 'DEFAULT'; } } }); </code></pre> <p>How would I go about doing this? Is there any way to do this without setting up a bidirectional binding? I would like to avoid a mess of attributes on the <code>&lt;child-directive&gt;</code> element if possible. </p>
3
Qt Removing Window Widgets
<p>I'm using Qt5.5 and I would like a window without any widgets, here is a snippet from my Window constructor:</p> <pre><code> Qt::WindowFlags flags = (Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint) &amp; ~Qt::WindowMaximizeButtonHint; setWindowFlags(flags); </code></pre> <p>This produces a window with no close widget and no minimize widget, however the maximize widget is still visible and can be clicked on to maximize the window, also the window can be resized by dragging the window edges.</p> <p>I am trying to create a tool window that is always on top and doesn't have any widgets and is a fixed size.</p> <p>In QtCreator I've set the sizePolicy to:</p> <pre><code> Horizontal Policy: Fixed Vertical Policy: Fixed </code></pre> <p>Yet I am still able to resize the window?</p> <p>I am aware that this is a very similar question to others posted before, but so far having read those and tried the suggestions nothing has worked.</p> <p>I'm running on Ubtuntu 14.04.</p>
3
Getting specific rows from sqlite database upon text changed
<p>I have multiple records in my sqlite database and upon the text changed(change of date in the 'Date edit text'),I want the corresponding row to be displayed in a table. I have the following code which works for the last record in the database but I don't know how to display rows corresponding to the date chosen. Please help as I am fairly new to android. This is my code:</p> <pre><code> public class measurement extends AppCompatActivity{ Button button; EditText Date; int index=0; TextView HEIGHT,WEIGHT,BMI,BLOODPRESSURE,PULSE,TEMPERATURE,GLUCOSELEVEL,OXYGENLEVEL; DatabaseAdapterMeasurements MeasurementsDataBaseAdapter; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.measurement); button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(measurement.this); final DatePicker picker = new DatePicker(measurement.this); picker.setCalendarViewShown(false); builder.setTitle("Create Year"); builder.setView(picker); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setPositiveButton("Select", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int day = picker.getDayOfMonth(); int month = (picker.getMonth() + 1); int year = picker.getYear(); Date.setText(day + "/" + month + "/" + year); // Toast.makeText(measurement.this, picker.getDayOfMonth() + " / " + (picker.getMonth() + 1) + " / " + picker.getYear(), Toast.LENGTH_LONG).show(); } }); builder.show(); } }); MeasurementsDataBaseAdapter = new DatabaseAdapterMeasurements(this); MeasurementsDataBaseAdapter = MeasurementsDataBaseAdapter.open(); Measurements studentCourse = new Measurements(); studentCourse.setDATE("ppp"); studentCourse.setEMAIL("hh@HOTMAIL.COM"); studentCourse.setREFERENCE("lkj"); studentCourse.setHEIGHT("1121"); studentCourse.setWEIGHT("CIS11"); studentCourse.setBMI("A-"); studentCourse.setBLOODPRESSURE("A-"); studentCourse.setPULSE("A-"); studentCourse.setTEMPERATURE("A-"); studentCourse.setGLUCOSELEVEL("A-"); studentCourse.setOXYGENLEVEL("A-"); MeasurementsDataBaseAdapter.insertEntry(studentCourse); studentCourse.setDATE("lll"); studentCourse.setEMAIL("v=bb@HOTMAIL.COM"); studentCourse.setREFERENCE("uhu"); studentCourse.setHEIGHT("111"); studentCourse.setWEIGHT("CIS11"); studentCourse.setBMI("A-"); studentCourse.setBLOODPRESSURE("A-"); studentCourse.setPULSE("A-"); studentCourse.setTEMPERATURE("A-"); studentCourse.setGLUCOSELEVEL("A-"); studentCourse.setOXYGENLEVEL("A-"); MeasurementsDataBaseAdapter.insertEntry(studentCourse); studentCourse.setDATE("jjj"); studentCourse.setEMAIL("cc@HOTMAIL.COM"); studentCourse.setREFERENCE("lol"); studentCourse.setHEIGHT("1671"); studentCourse.setWEIGHT("CIS11"); studentCourse.setBMI("A-"); studentCourse.setBLOODPRESSURE("A-"); studentCourse.setPULSE("A-"); studentCourse.setTEMPERATURE("A-"); studentCourse.setGLUCOSELEVEL("A-"); studentCourse.setOXYGENLEVEL("A-"); MeasurementsDataBaseAdapter.insertEntry(studentCourse); studentCourse.setDATE("jjj"); studentCourse.setEMAIL("hhfg@HOTMAIL.COM"); studentCourse.setREFERENCE("plo"); studentCourse.setHEIGHT("1091"); studentCourse.setWEIGHT("CIS11"); studentCourse.setBMI("A-"); studentCourse.setBLOODPRESSURE("A-"); studentCourse.setPULSE("A-"); studentCourse.setTEMPERATURE("A-"); studentCourse.setGLUCOSELEVEL("A-"); studentCourse.setOXYGENLEVEL("A-"); MeasurementsDataBaseAdapter.insertEntry(studentCourse); List&lt;Measurements&gt; measurements= MeasurementsDataBaseAdapter.getAllMeasurements(); HEIGHT = (TextView) findViewById(R.id.HEIGHT); WEIGHT = (TextView) findViewById(R.id.WEIGHT); BMI = (TextView) findViewById(R.id.BMI); BLOODPRESSURE = (TextView) findViewById(R.id.BP); PULSE = (TextView) findViewById(R.id.PULSE); TEMPERATURE=(TextView) findViewById(R.id.TEMP ); GLUCOSELEVEL = (TextView) findViewById(R.id.GL); OXYGENLEVEL = (TextView) findViewById(R.id.OL); Date = (EditText) findViewById(R.id.Date); for(Measurements mn: measurements) { String log="EMAIL"+mn.getEMAIL()+"REFERENCE"+mn.getREFERENCE()+"HEIGHT"+mn.getHEIGHT()+"WEIGHT"+mn.getWEIGHT()+"BMI"+mn.getBMI()+"BLOODPRESSURE"+mn.getBLOODPRESSURE()+"PULSE"+mn.getPULSE()+"TEMPERATURE"+mn.getTEMPERATURE()+"GLUCOSELEVEL"+mn.getGLUCOSELEVEL()+"OXYGENLEVEL"+mn.getOXYGENLEVEL(); HEIGHT.setText(mn.getHEIGHT()); WEIGHT.setText(mn.getWEIGHT()); BMI.setText(mn.getBMI()); BLOODPRESSURE.setText(mn.getBLOODPRESSURE()); PULSE.setText(mn.getPULSE()); TEMPERATURE.setText(mn.getTEMPERATURE()); GLUCOSELEVEL.setText(mn.getGLUCOSELEVEL()); OXYGENLEVEL.setText(mn.getOXYGENLEVEL()); } } } </code></pre>
3
Loops in Unix script
<p>Currently, I have written my script in the following manner:</p> <pre><code>c3d COVMap.nii -thresh 10 Inf 1 0 -o thresh_cov_beyens_plus10.nii c3d COVMap.nii -thresh 9.7436 Inf 1 0 -o thresh_cov_beyens_plus97436.nii c3d COVMap.nii -thresh 9.4872 Inf 1 0 -o thresh_cov_beyens_plus94872.nii c3d COVMap.nii -thresh 9.2308 Inf 1 0 -o thresh_cov_beyens_plus92308.nii c3d COVMap.nii -thresh 8.9744 Inf 1 0 -o thresh_cov_beyens_plus89744.nii c3d COVMap.nii -thresh 8.7179 Inf 1 0 -o thresh_cov_beyens_plus87179.nii c3d COVMap.nii -thresh 8.4615 Inf 1 0 -o thresh_cov_beyens_plus84615.nii c3d COVMap.nii -thresh 8.2051 Inf 1 0 -o thresh_cov_beyens_plus82051.nii c3d COVMap.nii -thresh 7.9487 Inf 1 0 -o thresh_cov_beyens_plus79487.nii c3d COVMap.nii -thresh 7.6923 Inf 1 0 -o thresh_cov_beyens_plus76923.nii c3d COVMap.nii -thresh 7.4359 Inf 1 0 -o thresh_cov_beyens_plus74359.nii c3d COVMap.nii -thresh 7.1795 Inf 1 0 -o thresh_cov_beyens_plus71795.nii c3d COVMap.nii -thresh 6.9231 Inf 1 0 -o thresh_cov_beyens_plus69231.nii </code></pre> <p>But I want the values in the form of some array like <code>x=[10,9.7436,9.4872...,6.9231]</code></p> <p>And I want the script to be called as follows:</p> <pre><code>x=[10,9.7436,9.4872...,6.9231] c3d COVMap.nii -thresh x[0] Inf 1 0 -o thresh_cov_beyens_plus10.nii c3d COVMap.nii -thresh x[1] Inf 1 0 -o thresh_cov_beyens_plus97436.nii c3d COVMap.nii -thresh x[2] Inf 1 0 -o thresh_cov_beyens_plus94872.nii c3d COVMap.nii -thresh x[3] Inf 1 0 -o thresh_cov_beyens_plus92308.nii ... c3d COVMap.nii -thresh x[14] Inf 1 0 -o thresh_cov_beyens_plus87179.nii </code></pre> <p>Could someone please suggest a method to loop this? </p>
3
Results aren't ordered
<p>The following query returns all records, but they are not in descending order. It seems the query is unaffected by the second parameter of orderBy.</p> <pre><code>\app\models\Lookup::find()-&gt;orderBy('id',SORT_DESC)-&gt;all() </code></pre>
3
child classes not toggling in jquery
<p>I am new to jquery trying to add css classes using jquery to style html, but here inner child's are not toggling...<a href="https://jsfiddle.net/venumadhav/v6u54Lzm/1/" rel="nofollow">here is my fiddle</a></p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() { $("#styling").click(function() { //header $("header").find("h2").toggleClass("heading"); //navigation $(".list-items").find("li").toggleClass("list"); //content styles $(".content &gt; div:nth-child(1)").toggleClass("lft-cnt"); $(".content &gt; div:nth-child(2)").toggleClass("rgt-cnt"); $(".rgt-cnt").find("&gt;, div").toggleClass("image"); $(".testimonials").children().toggleClass("slide"); $(".slide:nth-child(2n + 1)").css("background-color", "#bbf"); }); });</code></pre> <pre class="snippet-code-css lang-css prettyprint-override"><code> * { box-sizing: border-box; margin: 0; padding: 0; } body { margin: 0; } .container { width: 630px; height: 100%; margin: 0 auto; } header { width: 100%; height: 100px; background: skyblue; text-align: center; } .heading { line-height: 100px; text-transform: Capitalize; font-family: tahoma; } ul { width: 100%; } .list { display: inline-block; padding: 10px 43px; background: white; } .content { width: 100%; height: auto; margin-top: 20px; display: inline-block; } .lft-cnt { width: 50%; float: left; height: auto; padding: 0 10px 10px 10px; } .rgt-cnt { width: 49%; float: left; height: auto; padding: 0 10px 10px 10px; text-align: center; position: relative; } .testimonials { width: 100%; height: auto; text-align: center; } .slide { width: 130px; height: 100px; font-family: tahoma; text-align: center; display: inline-block; background-color: #FAD3D3; } footer { width: 100%; height: 40px; background: black; margin: 15px; text-align: center; } .copyright { color: grey; line-height: 40px; font-family: tahoma; font-size: 14px; } .styles { width: 100%; height: 70px; text-align: center; position: relative; } .btn-wrapper { width: 100%; right: 50%; position: absolute; bottom: 50%; transform: translate(50%, 50%); } button { background: #fff; border: 2px solid #000; padding: 10px 8px; cursor: pointer; } .image { width: 150px; height: 150px; background: orange; position: absloute; right: 50%: bottom: 50%; transform: translate(50%, 50%); }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt; &lt;header&gt; &lt;h2&gt;heading&lt;/h2&gt; &lt;/header&gt; &lt;div class="list-items"&gt; &lt;ul&gt; &lt;li&gt;home&lt;/li&gt; &lt;li&gt;home&lt;/li&gt; &lt;li&gt;home&lt;/li&gt; &lt;li&gt;home&lt;/li&gt; &lt;li&gt;home&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div class="content"&gt; &lt;div&gt; &lt;p&gt;It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution.&lt;/p&gt; &lt;p&gt;It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution.&lt;/p&gt; &lt;p&gt;It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution.&lt;/p&gt; &lt;/div&gt; &lt;div&gt; &lt;div&gt; image &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="testimonials"&gt; &lt;div&gt;slide-one&lt;/div&gt; &lt;div&gt;slide-two&lt;/div&gt; &lt;div&gt;slide-three&lt;/div&gt; &lt;div&gt;slide-four&lt;/div&gt; &lt;/div&gt; &lt;footer&gt; &lt;div class="copyright"&gt;copyright@2016&lt;/div&gt; &lt;/footer&gt; &lt;div class="styles"&gt; &lt;div class="btn-wrapper"&gt; &lt;button id="styling"&gt;style&lt;/button&gt; &lt;!-- &lt;button id="nav"&gt;Navigation-styles&lt;/button&gt; &lt;button id="cnt"&gt;content-styles&lt;/button&gt; &lt;button id="ftr"&gt;footer-styles&lt;/button&gt; --&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>I am new to jquery trying to add css classes using jquery to style html, but here inner child's are not toggling...<a href="https://jsfiddle.net/venumadhav/v6u54Lzm/1/" rel="nofollow">here is my fiddle</a></p>
3
How to correctly unwrap `data` inside `data`?
<p>I’m trying to access nested data (<code>Foo.y</code> inside <code>Bar</code> in the example below), but the straightforward approaches for unwrapping <code>Foo</code> inside <code>Bar</code> that come to mind do not work. But how to unwrap it correctly?</p> <p>Here my data:</p> <pre><code>module Foo where import Prelude data Foo = Foo { y :: Int } data Bar = Bar { x :: Int , foo :: Foo } </code></pre> <p>The following (of course) does not compile, error is <code>Could not match type { y :: Int } with type Foo</code> — just like <code>Bar</code>, <code>Foo</code> needs unwrapping first:</p> <pre><code>fn1 :: Bar -&gt; Int fn1 (Bar { x, foo }) = x + foo.y </code></pre> <p>So I put up my hopes for the following, but alas, compiler says “no” (parentheses around <code>Foo</code> constructor don’t help):</p> <pre><code>fn2 :: Bar -&gt; Int fn2 (Bar { x, Foo { y } }) = x + y fn3 :: Bar -&gt; Int fn3 (Bar { x, Foo f }) = x + f.y </code></pre> <p>The following works, using a helper function to do the unwrapping, but there has got to be a better way:</p> <pre><code>getY (Foo foo) = foo -- helper function fn4 :: Bar -&gt; Int fn4 (Bar { x, foo }) = let foo2 = getY foo in x + foo2.y </code></pre> <p>So, how do I do nested “unwrap”?</p> <p>[EDIT]</p> <p>After an hour or two of trying things out, I came up with this, which works:</p> <pre><code>fn5 :: Bar -&gt; Int fn5 (Bar { x, foo = (Foo f) }) = x + f.y </code></pre> <p>Is this the idiomatic way to do it? Why don’t <code>fn2</code> and <code>fn3</code> work?</p>
3
Merge libgdx game with android studio project
<p>I have created a libgdx game and an android studio project. I want to be able to open my game from the application using a game button. How can I add the game to the android project?</p>
3
ElasticSearch analyzer that allows for query both with and without hypens
<p>How do you construct an analyzer that allows you to query fields both with <em>and</em> without hyphens?</p> <p>The following two queries must return the same person:</p> <pre><code>{ "query": { "term": { "name": { "value": "Jay-Z" } } } } { "query": { "term": { "name": { "value": "jay z" } } } } </code></pre>
3
Join multiple Rows as columns with many where and having clauses
<p>I'm trying to solve (a complex?) Problem, which I can't get to work on my own.</p> <p>I got the following Tables: (Coordinates are dummys)</p> <p>Table A:</p> <pre><code>ID | Name |Attribute 1 | Attribute 2 | Lat | Lon | Car Country 1 | Test 1 | Blue | BMW | 6.4 | 6.2 | German 2 | Hallo | Red |Porsche | 6.4 |6.2 | German 3 | Miau | Silver |Ferrari | 2.5 | 1.4 | Italy </code></pre> <p>Table B</p> <pre><code>ID |ID Car| Slot | Path 1 | 1 | 1 |jsjf.jpg 2 | 2 | 1 | hkfu.jpg 3 | 2 | 2 | eqfwg.png </code></pre> <p>User can upload a Car with attributes and a coordinate and with unlimited pictures. Pictures are then saved in the Table B with the path, Slot (first Image, second image, ...) and the car it's belonging to.</p> <p>So now i want to get every car within my radius and the first 3 images. As a Result for the coordinates 6.4&amp;6.2 I need:</p> <pre><code>ID | Name | Attribute 1 | Attribute 2 | image1 | image2 |image3 1 | Test 1 | Blue | BMW | jsjf.jpg | Null | Null 2 | Hallo | Red | Porsche | hkfu.jpg | eqfwg.png | Null </code></pre> <p>My Query at the moment is:</p> <pre><code>SELECT a.id, a.name, a.attribute1, a.attribute2, MAX(CASE WHEN b.slot= 1 THEN b.path ELSE NULL END) image1, MAX(CASE WHEN b.slot= 2 THEN b.path ELSE NULL END) image2, MAX(CASE WHEN b.slot= 3 THEN b.path ELSE NULL END) image3, ( 6371 * acos( cos( radians( 6.4 ) ) * cos( radians( lat ) ) * cos( radians( lon ) - radians( 6.2 ) ) + sin( radians( 6.4 ) ) * sin( radians( lat ) ) ) ) AS distance FROM a left join bon a.id=b.idcar WHERE carcountry= 'German' HAVING distance &lt;= 50 ORDER BY distance asc LIMIT 0, 10 </code></pre> <p>Without the Max() and join everything works....</p>
3
Spatial4j - Create circle using centroid and radius in miles
<p>Using Spatial4j, I want to create a circle using a centroid and radius specified in miles (or kilometers). The Javadoc says "The units of "distance" should be the same as x &amp; y." which I am confused by. </p> <p>I understood x and y (lat, lon) to be in degrees and I don't know how to express the radius in degrees. I want to express it in miles, so I imagine I need to convert miles to degrees, however I also know the conversion is different based on where the centroid is on the surface of the planet.</p> <p>Is there a way within Spatial4j to easily handle this conversion so I can express the radius in miles and create an accurate circle?</p> <p>Thanks!</p>
3
Saving and loading ArrayLists in Android
<p>I am working on an android application that will randomly choose a activity for people to do from an array list. I want this list to be edited by the user of the application by adding or removing activities from the list. I would like the list to be loaded when the application is opened and saved when paused, closed, or destroyed.</p> <p>I cannot figure out how to store the array list an load it. I have tried to understand posts in the past about this topic but cannot make sense of how to implement them.</p> <p>I you can help, it would be greatly appreciated.</p>
3
Maintaining a Relative Order of Flex Tasks in a SQL DB
<p>I have a task scheduling app that allows people to create 2 types of tasks...</p> <p>•Strict- tasks with a set start time and duration •Flex- tasks that have a duration, but no specific start time</p> <p>Its also important to understand how flex tasks operate- Flex tasks will continuously reschedule themselves throughout your day in the nearest time you have open...so for example if the only task on your schedule today is a flex task like "Go workout - duration:60mins" and you open the app at 4pm it will have "Go workout" scheduled from 4-5pm for you , if you dont click the checkbox indicating you completed the task and open the app again at 5PM "Go workout will be rescheduled to 5-6pm so that the stuff you are meaning to get done is constantly in your face and trying to fit itself into the gaps of your life. </p> <p>When a user views their schedule here are the steps I go through: •Grab a array of all strict tasks •Grab a array of all flex tasks •Loop through each strict task and figure out how big of a time gap there is between the task currently being looped's end time and the next tasks start time. •if a gap exists loop through the flex tasks and see if any of them will fit in the time gap in question. if a flex task is small enough to fit in the time gap add it to the strictTasksArray between the task being currently looped and the next task.</p> <p>This works great as long as there is no need for any kind of ordering when it comes to flex tasks, but now we have added the ability for users to drag and drop flex tasks into a specific relative order aka if I have Task A,B,C,D and I drag Task D &amp; B to the front so that its now D,B,A,C it needs to save that ordering so that if you close and reopen the app the app will still remember to try to fit task D in , followed by B, A &amp; C .....but im having big trouble thinking of a efficient way to do considering the ordering is relative and not strict...any ideas how to save relative ordering in a SQLIte DB without having to update every tasks's DB record every time a user drag/drops a task and changes the relative ordering? </p>
3
Correct way to reset class values in unit testing with setup
<p>I'm new to Objective-C so please bear with me. </p> <p>I have a unit test class that looks something like this:</p> <pre><code>static NSString * const kTestingUserID = @"userID"; @interface UserPreferencesTest @property(nonatomic) UserPreferences *userPreferences; @end @implementation UserPreferencesTest - (void)setUp { [super setUp]; self.userPreferences = [[UserPreferences alloc] init]; } - (void)testEmptyDictionary { STAssertFalse([self.userPreferences getLockoutStatus:kTestingUserID], @"An unset username should always return false"); } - (void)testBlockManualEntry { //lock the username [self.userPreferences lockout:kTestingUserID]; STAssertTrue([self.userPreferences getLockoutStatus:kTestingUserID], @"The account has been locked out"); } @end </code></pre> <p>They call the following methods in the userPreferences Class:</p> <pre><code>- (void)lockout:(NSString *) userID { NSMutableDictionary *dictionary = [[self.defaults objectForKey:dict] mutableCopy]; dictionary[userID] = [NSNumber numberWithBool:YES]; [self.defaults setObject:[NSDictionary dictionaryWithDictionary:dictionary] forKey:dict]; [self synchronize]; } - (BOOL) getLockoutStatus:(NSString *) userID { NSDictionary *dictionary = [self.defaults objectForKey:dict]; if ([dictionary objectForKey:userID]) return true; return false; } </code></pre> <p>If I comment out the testBlockManualEntry the test passes. If I run the two tests together the first one, testEmptyDictionary fails. The issue to my understanding is that the username is set in the 2nd test and then is found in the 1st test. </p> <p>If I were to write a similar unit test in java I would use @Before in my setup and thus setup would run before each test method is called. That would ensure that the userPreferences is created each time and thus the values in that object are reset.</p> <p>What am I missing here? My understanding of setup in Objective-C is that it should behave similarly (clearly it's not unless theres another bug that I'm not seeing). </p> <p>Also please ignore the fact that a set would be better used in this scenario than a dict, I'm just looking (and how to fix the issue) for why the tests fail when run together.</p>
3
Using TestContext.TestName in Managed C++ Tests
<p>How can I use the TestName member of the TestContext class in managed VS C++ test code to automatically output the name of the test method to the debug console?</p> <p>Every example I've been able to find is in C# and I cannot translate it into C++ properly. Here I attempt to do this by capturing a TestContext object during the static ClassInitialize method, but this does not work.</p> <pre><code>#include &lt;windows.h&gt; #include &lt;msclr/marshal_cppstd.h&gt; using namespace Microsoft::VisualStudio::TestTools::UnitTesting; [TestClass] public ref class SampleTestClass { public: [TestMethod] void testMethod1() { } [TestMethod] void testMethod2() { } [TestMethod] void testMethod3() { } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Tests Setup and Teardown // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// static TestContext^ myTestContext; [TestInitialize] void testCaseInitialize() { msclr::interop::marshal_context context; std::wstring testName = context.marshal_as&lt;std::wstring&gt;( myTestContext-&gt;TestName ); std::wstring dbgSend = L"initializing " + testName; ::OutputDebugString( dbgSend.c_str() ); } [TestCleanup] void testCaseCleanup() { msclr::interop::marshal_context context; std::wstring testName = context.marshal_as&lt;std::wstring&gt;( myTestContext-&gt;TestName ); std::wstring dbgSend = L"tearing down " + testName; ::OutputDebugString( dbgSend.c_str() ); } [ClassInitialize] static void testClassInitialize( TestContext^ context ) { myTestContext = context; } [ClassCleanup] static void testClassCleanup() { } }; </code></pre> <p>Output</p> <pre><code>[9404] initializing testMethod1 [9404] tearing down testMethod1 [9404] initializing testMethod1 [9404] tearing down testMethod1 [9404] initializing testMethod1 [9404] tearing down testMethod1 </code></pre> <p>Desired Output</p> <pre><code>[9404] initializing testMethod1 [9404] tearing down testMethod1 [9404] initializing testMethod2 [9404] tearing down testMethod2 [9404] initializing testMethod3 [9404] tearing down testMethod3 </code></pre>
3
Customize kendo ui column bars
<p>I have the following kendo ui column chart.</p> <p><a href="http://dojo.telerik.com/ibijO" rel="nofollow">http://dojo.telerik.com/ibijO</a></p> <p>I need to make all the bars wider and centered them. Is that possible through kendo ui configuration, not through css I have changed them through css but now I have problem because the exportImage method export the initial display.</p>
3
How can I see the final version of a Qweb template in Odoo/Openerp
<p>Example:</p> <p>I have a template which two custom modules modify. Because module 1 removes an element that module 2 depends on (it's in its Xpath) the module 2 cannot be installed.</p> <p>How can I see the architecture of the template after modification by other modules?</p>
3

Dataset Card for [Stackoverflow Post Questions]

Dataset Description

Companies that sell Open-source software tools usually hire an army of Customer representatives to try to answer every question asked about their tool. The first step in this process is the prioritization of the question. The classification scale usually consists of 4 values, P0, P1, P2, and P3, with different meanings across every participant in the industry. On the other hand, every software developer in the world has dealt with Stack Overflow (SO); the amount of shared knowledge there is incomparable to any other website. Questions in SO are usually annotated and curated by thousands of people, providing metadata about the quality of the question. This dataset aims to provide an accurate prioritization for programming questions.

Dataset Summary

The dataset contains the title and body of stackoverflow questions and a label value(0,1,2,3) that was calculated using thresholds defined by SO badges.

Languages

English

Dataset Structure

title: string, body: string, label: int

Data Splits

The split is 40/40/20, where classes have been balaned to be around the same size.

Dataset Creation

The data set was extracted and labeled with the following query in BigQuery:

SELECT
  title,
  body,
  CASE
    WHEN score >= 100 OR favorite_count >= 100 OR view_count >= 10000 THEN 0
    WHEN score >= 25 OR favorite_count >= 25 OR view_count >= 2500  THEN 1
    WHEN score >= 10 OR favorite_count >= 10 OR view_count >= 1000 THEN 2
    ELSE 3
  END AS label
FROM `bigquery-public-data`.stackoverflow.posts_questions

Source Data

The data was extracted from the Big Query public dataset: bigquery-public-data.stackoverflow.posts_questions

Initial Data Collection and Normalization

The original dataset contained high class imbalance:

label count 0 977424 1 2401534 2 3418179 3 16222990 Grand Total 23020127

The data was sampled from each class to have around the same amount of records on every class.

Contributions

Thanks to @pacofvf for adding this dataset.

Downloads last month
1
Edit dataset card