pid
int64 2.28k
41.1M
| label
int64 0
1
| text
stringlengths 1
28.3k
|
---|---|---|
6,101,464 | 0 | <p>You are trying to assign a const pointer to a non const pointer. If you make t a "const char*" in fun1() it will be fine.</p> |
24,488,559 | 0 | <pre><code>$myArr3 = array_merge_recursive($myArr1, $myArr2); foreach($myArr3 as $key => $value){ if(!is_array($myArr3[$key])){ continue; } if($value[0] === $value[1]){ $myArr3[$key] = $value[0]; }else{ $myArr3[$key] = implode(' ', $value); } } // print_r($myArr3); </code></pre> |
23,604,438 | 0 | <p>Do you experience the same behaviour if you run the experimental instance without attaching a debuggger? If yes, check your exception handling settings for debug mode. Probably throwing is disabled which might be the reason why everything seems to work, because you won´t get notified about exceptions... </p> |
34,180,763 | 0 | <p>In symfony, you only have to persist a new entity. If you update an existing entity found by your entity manager and then flush, your entity will be updated in database even if you didn't persist it.</p> <p>Edit : you can detach an entity from the entity manager before flushing it using this line of code :</p> <pre><code>$em->detach($formModelEntity); </code></pre> |
37,776,557 | 1 | Cannot print a specific number from a sublist within a list <p>I want to be able to print the 3rd number with in a list of sublist. I am okay with interacting through the list and sublist, but unsure with how i can print the 3rd number of each sublist. for example <code>[[1,2,3,4][1,2,3,4][,1,2,3,4][1,2,3,4]]</code> i was to achieve <code>3,3,3,3</code></p> <p>I have manage this so far, being able to print out all numbers with the sublists</p> <pre><code>def Contact(num):<br/> for i in range(len(num)):<br/> for j in range(len(num[i])):<br/> print(num[i][j]) Contact([[1,2,3,4][1,2,3,4][,1,2,3,4][1,2,3,4]]) </code></pre> |
9,558,912 | 0 | <p>How about this:</p> <pre><code>function clean($text) { $parts = explode(' ', $text); foreach ($parts as $key => $value) $parts[$key] = preg_replace('/\s/', ' ', $value); return implode(' ', $parts); } </code></pre> <p>Indeed, if instead of cleaning the JSON file like this, you can use <a href="http://php.net/manual/en/function.json-encode.php" rel="nofollow">json_encode</a> to create it, you will get rid this problem in a previous step.</p> |
10,748,650 | 0 | The program is showing null pointer exception....converting double to int <p>My program causes a null pointer exception... I think the problem is in converting lat3 and lon3 from double to int... Is there some other way of parsing the location in double to int to give it to GeoPoint?</p> <p>Code:</p> <pre><code>public class mapLoc extends com.google.android.maps.MapActivity implements LocationListener { TextView t ; int lat2,lon2,lat3,lon3; Double presentlon,presentlat; Drawable d; MapView mv; MapController mc; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.map); t = (TextView)findViewById(R.id.maptxt); Intent intent = getIntent(); Bundle extra = intent.getExtras(); String latitude = extra.getString("latitude"); String longitude = extra.getString("longitude"); t.append(latitude+"\t"); t.append(longitude); Float lat1 = Float.parseFloat(latitude); Float lon1 = Float.parseFloat(longitude); lat2 = (int) (lat1*1E6); lon2 = (int) (lon1*1E6); mv = (MapView)findViewById(R.id.maps); mc = mv.getController(); mc.setZoom(14); mv.setBuiltInZoomControls(true); mv.displayZoomControls(true); mv.setClickable(true); List<Overlay> mapOverlays = mv.getOverlays(); Drawable drawable = this.getResources().getDrawable(R.drawable.marker); overlay itemizedoverlay = new overlay(drawable, this); lat3 = (int)(presentlat * 1E6); lon3 = (int)(presentlon * 1E6); GeoPoint point = new GeoPoint(lat3, lon3); OverlayItem overlayitem = new OverlayItem(point, "Hello, user", "This is your present location"); mc.animateTo(point); itemizedoverlay.addOverlay(overlayitem); mapOverlays.add(itemizedoverlay); GeoPoint point2 = new GeoPoint(lat2, lon2); OverlayItem overlayitem2 = new OverlayItem(point2, "This is your","saved location"); itemizedoverlay.addOverlay(overlayitem2); mapOverlays.add(itemizedoverlay); } @Override public void onLocationChanged(Location location) { presentlat = location.getLatitude(); presentlon = location.getLongitude(); } @Override public void onProviderDisabled(String provider) { // TODO Auto-generated method stub } @Override public void onProviderEnabled(String provider) { // TODO Auto-generated method stub } @Override public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; }; } </code></pre> <p>Logcat errors:</p> <pre><code>05-25 10:21:52.444: W/dalvikvm(342): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 05-25 10:21:52.444: E/AndroidRuntime(342): Uncaught handler: thread main exiting due to uncaught exception 05-25 10:21:52.454: E/AndroidRuntime(342): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.loc/com.loc.mapLoc}: java.lang.NullPointerException 05-25 10:21:52.454: E/AndroidRuntime(342): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496) 05-25 10:21:52.454: E/AndroidRuntime(342): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 05-25 10:21:52.454: E/AndroidRuntime(342): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 05-25 10:21:52.454: E/AndroidRuntime(342): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 05-25 10:21:52.454: E/AndroidRuntime(342): at android.os.Handler.dispatchMessage(Handler.java:99) 05-25 10:21:52.454: E/AndroidRuntime(342): at android.os.Looper.loop(Looper.java:123) 05-25 10:21:52.454: E/AndroidRuntime(342): at android.app.ActivityThread.main(ActivityThread.java:4363) 05-25 10:21:52.454: E/AndroidRuntime(342): at java.lang.reflect.Method.invokeNative(Native Method) 05-25 10:21:52.454: E/AndroidRuntime(342): at java.lang.reflect.Method.invoke(Method.java:521) 05-25 10:21:52.454: E/AndroidRuntime(342): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 05-25 10:21:52.454: E/AndroidRuntime(342): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 05-25 10:21:52.454: E/AndroidRuntime(342): at dalvik.system.NativeStart.main(Native Method) 05-25 10:21:52.454: E/AndroidRuntime(342): Caused by: java.lang.NullPointerException 05-25 10:21:52.454: E/AndroidRuntime(342): at com.loc.mapLoc.onCreate(mapLoc.java:71) 05-25 10:21:52.454: E/AndroidRuntime(342): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 05-25 10:21:52.454: E/AndroidRuntime(342): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) </code></pre> |
7,091,032 | 0 | <p><a href="http://stackoverflow.com/questions/5484030/lisp-on-embedded-platforms">This question</a> was on Common Lisp, but <a href="http://stackoverflow.com/questions/5484030/lisp-on-embedded-platforms/5485906#5485906">one particular answer</a> referenced <a href="http://www.ccs.neu.edu/home/stamourv/papers/picobit.pdf" rel="nofollow">Picobit</a>, which is essentially a Scheme for microcontrollers. It very well fits in my conditions, as the paper says it can work on as little as 7 kb of memory. </p> <p>I've decided to <a href="http://github.com/whitequark/picobit" rel="nofollow">fork</a> Picobit and port it to ARM processors.</p> |
21,599,471 | 0 | <p>You cannot cast the value in mysql using float type.</p> <p>The type can use following values:</p> <ul> <li>BINARY[(N)]</li> <li>CHAR[(N)]</li> <li>DATE</li> <li>DATETIME</li> <li>DECIMAL[(M[,D])]</li> <li>SIGNED [INTEGER]</li> <li>TIME</li> <li>UNSIGNED [INTEGER]</li> </ul> <p>So in your case you have to use decimal, e.g:</p> <pre><code>select cast(amount AS DECIMAL(10,2)) as 'float-value' from amounts </code></pre> |
9,375,756 | 0 | <p>Just commented the line</p> <pre><code>CFIndex n = ABAddressBookGetPersonCount(addressBook); </code></pre> <p>And replaced with this to get total number of records</p> <pre><code>CFIndex n = CFArrayGetCount(all); </code></pre> <p>Because the count is different for all(Array) and for the variable n. </p> <p>Hope this will help others too.</p> |
24,979,554 | 0 | <p>You don't need to store it in a session necessarily, it's the fact that $_SESSION is an array.</p> <p>So, what you would want would be something like this:</p> <pre><code>echo json_encode(array('sessionID' => $sessionID)); </code></pre> <p>And then when you parse the JSON with JavaScript you can access it like this:</p> <pre><code>obj = JSON.parse(jsonObj); alert(obj.sessionID); </code></pre> <p>Obviously, <code>jsonObj</code> is the JSON passed from the server.</p> <p>Hope this helps!</p> |
20,195,133 | 0 | <p>There are a large number of things you can do to extend the GHCi prompt. <a href="http://www.haskell.org/haskellwiki/GHC/GHCi" rel="nofollow">This page</a> talks about an old project called GHCi on Acid which suggests a lot of ideas. Generally, by editing your .ghcirc file you can add many command-line call-outs including to tools like commandline lambdabot/hoogle/pointfree.</p> |
14,516,289 | 0 | <p>I think this issue has been fixed here </p> <p><a href="https://github.com/scrapy/scrapy/pull/186" rel="nofollow">https://github.com/scrapy/scrapy/pull/186</a></p> <p>It has been fixed after <code>0.15</code> release of scrapy</p> |
13,899,304 | 0 | <p>This is a typical computer vision task (it might even be AI-complete), so it's not easy. However, there's an excellent opensource C++ library called <a href="http://opencv.org" rel="nofollow">OpenCV</a> which works well with iOS. I even found a <a href="http://www.aishack.in/2010/07/tracking-colored-objects-in-opencv/" rel="nofollow">tutorial</a> about detecting a colored object.</p> <p>The basic algorithm is, by the way, something like this: go through each pixel and see if it's red or not (you can do this by comparing it agains some kind of threshold value of the red, green and blue components). If this is done, grab the pixels which were good and figure out where the continuous area they're in is. A method for this would be counting the pixels, then assuming they form a circle, then dividing their number by pi and getting the square root - this would tell you the radius of the circle, that you can double for obtaining its diameter ("width").</p> |
38,764,090 | 0 | How to open a pop-up using JSF without it being blocked by the browser <p>I'm working on a PrimeFaces 6.0, JSF 2.2 (Mojarra 2.2.7) application.</p> <p>I need to load a web page from an external site and highlight a DOM node. My approach is to create a JavaScript function to open a pop-up window, load the web page through a servlet (to avoid cross domain issues) and highlight the node. The parameters I send to my function are generated in a managed bean.</p> <p>I tried to do so in two different ways:</p> <ol> <li>Using <code>RequestContext.getCurrentInstance().execute("myFunction(...)")</code> in my action (yes, I'm using PrimeFaces).</li> <li>Using <code>oncomplete="#{myBean.myJsCall}"</code> on my command button.</li> </ol> <p>Both ways the call is executed and the call is correct, but I run into my browser's (Chromium) pop-up blocker:</p> <p><img src="https://i.stack.imgur.com/hNX6Y.png" alt="The following pop-ups were blocked on this page"></p> <p>Is there a way to open pop-ups in JSF or specifically in PrimeFaces without them being blocked?</p> <p>This is not really relevant, but this is the simplified version of my JavaScript function.</p> <p>I developed this script using plain HTML and JS. There it was opening the pop-up without the blocker interfering. Also, when pasting the call into the console when running the JSF application, the pop-up is opened.</p> <pre><code>function myFunction(url, selector) { var popup = window.open("", "popup", "height=500,width=700"); var req = new XMLHttpRequest(); req.open("GET", url, true); req.onreadystatechange = function() { if (req.readyState === XMLHttpRequest.DONE) { popup.document.open(); popup.document.write(req.responseText); popup.document.close(); popup.document.addEventListener( "DOMContentLoaded", function() { /* Some code highlighting the selector */ }, false ); } } req.send(); } </code></pre> |
38,469,648 | 0 | unexpected non-void return value in void function in new Swift class <p>I'm just starting to learn about Object Oriented, and I've begun writing up a user class that has a method for calculating the user's distance from an object. It looks like this:</p> <pre><code>class User{ var searchRadius = Int() var favorites : [String] = [] var photo = String() var currentLocation = CLLocation() func calculateDistance(location: CLLocation){ let distance = self.currentLocation.distanceFromLocation(location)*0.000621371 return distance //Error returns on this line } } </code></pre> <p>At the line marked above, I get the following error:</p> <pre><code>(!) Unexpected non-void return value in void function </code></pre> <p>I've looked elsewhere for a solution, but can't seem to find anything that applies to this instance. I've used the distanceFromLocation code elsewhere, and it's worked okay, so I'm not sure what's different about the usage in this case.</p> <p>Thanks for any help!</p> |
31,868,176 | 0 | How to set velocity layout directory and default template with spring in boot application.properties <p>If we don't use spring boot ,we could user velocity.properties just like this<code> tools.view.servlet.layout.directory =layout/ tools.view.servlet.layout.default.template=default.vm </code> or use this bean in our springmvc project </p> <pre><code><bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver"> <property name="cache" value="false" /> <property name="layoutUrl" value="/layout/default.vm" /> <property name="prefix" value="/templates/" /> <property name="suffix" value=".vm" /> <property name="exposeSpringMacroHelpers" value="true" /> <property name="contentType" value="text/html;charset=UTF-8" /> <property name="viewClass" value="org.springframework.web.servlet.view.velocity.VelocityLayoutView" /> <!-- <property name="toolboxConfigLocation" value="classpath:web/config/toolbox.xml" /> <property name="exposeSessionAttributes" value="true" /> --> </bean> </code></pre> <p>but I want to know how to set velocity layout through application.properties. And I also has some confusion about the "spring.velocity.properties.* =" in application.properties. How and when we could use it.I could't find one demo about this.</p> |
31,523,266 | 0 | Images won't load in Chrome Extension when installed via ChromeStore <p>I have a chrome extension in webstore for several months now, and it has been working flawlessly. Recently, I changed the UI and added several new images in the extension. I have added the image folder in the "web_accessible_resources" property in the manifest file. <code>"src/lib/imgs/*"</code> </p> <p>Problem is:When a user installs the extension via Chrome store, some images failed to load, and I have no idea why. All the images are in same folder. Some works and some does not. I myself have Chrome developers edition.</p> <p>I am pretty sure all images were uploaded fine. I have chrome Version 43.0.2357.134 dev-m and when I install it from chrome webstore, it works fine. However when I install the same plugin on my different laptop that has chrome Version 43.0.2357.134 m.</p> <p>By using this plugin <a href="https://chrome.google.com/webstore/detail/chrome-extension-source-v/jifpbeccnghkjeaalbbjmodiffmgedin?utm_source=chrome-app-launcher-info-dialog" rel="nofollow">https://chrome.google.com/webstore/detail/chrome-extension-source-v/jifpbeccnghkjeaalbbjmodiffmgedin?utm_source=chrome-app-launcher-info-dialog</a> I could see the source file of my extension in the chrome store and all files are there.</p> <p>Does anyone have any suggestion or any idea what might be the issue here? Please let me know if my question is not clear or if you need more info to understand this issue.</p> <p>Here is the beta version if you wanna try the plugin: chrome.google.com/webstore/detail/cpacflpjhonhpgpjkbilfblopejajlai/ (you can signup using any fake email address) - Please note once the issue is resolved i will have this beta version removed from the store.</p> <p>Thanks,</p> |
35,956,868 | 0 | Unable to install python-recsys module <p>I am trying to install python-recsys module. But i get this error</p> <blockquote> <p>Could not find a version that satisfies the requirement python-recsys (from versions: ) No matching distribution found for python-recsys</p> </blockquote> <p>I am using Python 3.4 The code that i am using to install the module is: <code>pip.exe install python-recsys</code></p> |
13,604,393 | 0 | <p>If you look closely, you'll see that the bars for the first and the fourth items are drawn at the same positions and overlap.</p> <p>The fundamental problem is that the code is using the data itself (which is duplicated) to identify individual elements. If you want to have different elements with the same data values, you'll need to give them unique identifiers so that the code is able to distinguish between them. The scales in the code are set up such that the same input value will map to the same output value, i.e. if you have the same name, the bars will be drawn at the same position.</p> <p>One way of solving this problem would be to use a unique ID as input to the scale functions and then a formatter to make the labels from this ID.</p> |
24,687,017 | 0 | <p>Another option would be <code>misschk</code> from the <em>SPost</em> site. Type <code>findit misschk</code> to install it. Here's an example:</p> <pre><code>sysuse auto,clear replace price=. if (_n==1|_n==3) // additional missing values misschk </code></pre> <p>Without specifying the <code>varlist</code>, <code>misschk</code> just checks all variables. </p> <p>The standard output gives you the number as well as percentage of missing values on each variable.</p> <pre><code>Variables examined for missing values # Variable # Missing % Missing -------------------------------------------- 1 price 2 2.7 2 mpg 0 0.0 3 rep78 5 6.8 4 headroom 0 0.0 5 trunk 0 0.0 6 weight 0 0.0 7 length 0 0.0 8 turn 0 0.0 9 displacement 0 0.0 10 gear_ratio 0 0.0 11 foreign 0 0.0 </code></pre> <p>It also counts all the different missing patterns.</p> <pre><code> Missing for | which | variables? | Freq. Percent Cum. ---------------+----------------------------------- 1_3__ _____ _ | 1 1.35 1.35 1____ _____ _ | 1 1.35 2.70 __3__ _____ _ | 4 5.41 8.11 _____ _____ _ | 68 91.89 100.00 ---------------+----------------------------------- Total | 74 100.00 </code></pre> <p>Lastly, it summarizes the amount of missing values by cases.</p> <pre><code>Missing for | how many | variables? | Freq. Percent Cum. ------------+----------------------------------- 0 | 68 91.89 91.89 1 | 5 6.76 98.65 2 | 1 1.35 100.00 ------------+----------------------------------- Total | 74 100.00 </code></pre> <p><code>misschk</code> also has a couple of other neat features with additional options you can find out about with <code>help misschk</code>.</p> |
15,174,396 | 0 | <p>Since the ZBarReaderViewController scans the image in continuous mode, it could be that the image is scanned twice before you dismiss the ZBarReaderViewController. You may try making the reader (ZBarReaderViewController *reader ) an instance variable of your class, and in the delegate method:</p> <pre><code>- (void)imagePickerController:(UIImagePickerController*)reader didFinishPickingMediaWithInfo:(NSDictionary*)info { // Stop further scanning [reader.readerView stop]; ... //Continue with processing barcode data. } </code></pre> |
16,153,751 | 0 | <p>Look at some of the options here:</p> <p><a href="http://highcharts.uservoice.com/forums/55896-general/suggestions/804783-gantt-chart" rel="nofollow">http://highcharts.uservoice.com/forums/55896-general/suggestions/804783-gantt-chart</a></p> <p>Best option is not to use actual bars, but to use line series with lineWidth set to a high enough value to mimic bars visually.</p> |
40,023,705 | 0 | <p>Based on the description of what you are doing, I don't understand why you think your query works.</p> <p>The overlap query should look like this:</p> <pre><code>SELECT AssetID as UnAvailableAsset FROM agreementasset WHERE CheckOutDate <= @RentEndDate AND ExpectedReturnDate >= @RentStartDate; </code></pre> <p>This type of query can be difficult to optimize (in most databases). You can start with an index on <code>agreementasset(CheckOutDate, ExpectedReturnDate, AssetID)</code>.</p> |
28,593,287 | 0 | <p>I had a very similar experience to @user1501382, but tweaked everything slightly in accordance with <a href="http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/" rel="nofollow">the documentation</a> </p> <p>1) <code>cd c:</code> //changes to C drive</p> <p>2) <code>mkdir data</code> //creates directory data</p> <p>3) <code>cd data</code></p> <p>4) <code>mkdir db</code> //creates directory db </p> <p>5) <code>cd db</code> //changes directory so that you are in <code>c:/data/db</code></p> <p>6) run <code>mongod -dbpath</code> </p> <p>7) close this terminal, open a new one and run <code>mongod</code></p> |
26,900,933 | 0 | <p>Maybe something like this..</p> <p>This is for InfoBanner.qml</p> <pre><code>import QtQuick 2.2 Loader { id: messages function displayMessage(message) { messages.source = ""; messages.source = Qt.resolvedUrl("InfoBannerComponent.qml"); messages.item.message = message; } width: parent.width anchors.bottom: parent.top z: 1 onLoaded: { messages.item.state = "portrait"; timer.running = true messages.state = "show" } Timer { id: timer interval: 2500 onTriggered: { messages.state = "" } } states: [ State { name: "show" AnchorChanges { target: messages; anchors { bottom: undefined; top: parent.top } } PropertyChanges { target: messages; anchors.topMargin: 100 } } ] transitions: Transition { AnchorAnimation { easing.type: Easing.OutQuart; duration: 300 } } } </code></pre> <p>This is for InfoBannerComponent.qml</p> <pre><code>import QtQuick 2.2 Item { id: banner property alias message : messageText.text height: 70 Rectangle { id: background anchors.fill: banner color: "darkblue" smooth: true opacity: 0.8 } Text { font.pixelSize: 24 renderType: Text.QtRendering width: 150 height: 40 id: messageText anchors.fill: banner horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter wrapMode: Text.WordWrap color: "white" } states: State { name: "portrait" PropertyChanges { target: banner; height: 100 } } MouseArea { anchors.fill: parent onClicked: { messages.state = "" } } } </code></pre> <p>This is for main.qml</p> <pre><code>import QtQuick 2.3 import QtQuick.Window 2.2 Window { visible: true width: 360 height: 360 MouseArea { anchors.fill: parent onClicked: { Qt.quit(); } } Text { text: qsTr("Hello World") anchors.centerIn: parent } InfoBanner { id: messages } Component.onCompleted: messages.displayMessage("Hello World"); } </code></pre> <p>credit to marxian at marxoft dot co dot uk</p> |
37,945,521 | 0 | <p>It's called an enhanced <code>for</code> loop. The first part, <code>Card card</code>, says that the current version of <code>Card</code> of this iteration is going to be called <code>card</code>. The second part, <code>myDeck</code>, is the array of <code>Cards</code> that you are iterating through.</p> <p><a href="https://blogs.oracle.com/CoreJavaTechTips/entry/using_enhanced_for_loops_with" rel="nofollow">https://blogs.oracle.com/CoreJavaTechTips/entry/using_enhanced_for_loops_with</a></p> |
13,281,562 | 0 | Is it possible to transfer javascript value to PHP? <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2338942/access-a-javascript-variable-from-php">Access a JavaScript variable from PHP</a> </p> </blockquote> <p>Let's say I have the following javascript:</p> <pre><code><script> var today = new Date(); var dd = today.getDate(); var mm = today.getMonth()+1; //January is 0! var yyyy = today.getFullYear(); if(dd<10){dd='0'+dd} if(mm<10){mm='0'+mm} today = mm+'/'+dd+'/'+yyyy; </script> </code></pre> <p>Now I want to get the value of today variable into PHP.</p> <pre><code>$cur_date = '<script type="text/javascript"> document.write(today) </script>'; echo "current date: $cur_date"; $checkin = strtotime($cur_date); </code></pre> <p>Although I can output the current date but how can I transfer it to $checkin variable with strtotime function?</p> |
24,557,099 | 0 | convert JSONObject to ContentValues <p>I want to convert JSONObject to ContentValue. How can i do that without knowing what columns i have in JSONObject?</p> <p>columns in JSONObject are the same as columns in SQLite database on the device and they are in the same order.</p> <p>I can do it like this</p> <pre><code>ContentValues values = new ContentValues(); values.put(TASK_NAME, json.getString("name")); values.put(TASK_KEY_PROJECT, json.getString("project")); values.put(TASK_KEY_CATEGORY, json.getString("category")); values.put(TASK_KEY_TAG, json.getString("tag")); //TODO CATCH NO TAG EXCEPTION </code></pre> <p>but i want to know better way thanks in advance</p> |
40,178,052 | 0 | install.packages("RCurl") for Mac os Siera using RStudio <p>i and new to R, have tried to install the above package R but keep getting the following error. Error: unexpected symbol in "install.packages("install.packages("RCurl"</p> <p>thanks</p> |
1,389,183 | 0 | <p>An other solution that may not appeal to some but is fast to implement and works well is to introduce a new property on the object for sorting purposes. Make the new property contain a sorting character as the first character (a number works well) and the actual sorting value as the rest of the characters. Implement some easy if-else statements to set the appropriate value of the sorting property.</p> <p>When adding this column to the grid just make it hidden and sort on that column.</p> <p>Possibly a less elegant solution than the one proposed by najmeddine, but it works.</p> |
28,207,912 | 0 | Change font sizes with style sheets for RStudio presentation <p>I am using RStudio Presentation and I'd like to change the font size for the main elements (e.g.: header, bullet, and sub bullet). I was able to add a style sheet to my rmd file but I do not know what to change in the css file. I have tried changing the font size in various places in the css file but nothing worked.</p> <pre><code>## Slide with Bullets - Bullet 1 + Sub bullet - Bullet 2 - Bullet 3 </code></pre> |
28,659,306 | 0 | <pre><code>$(function(){ $("#changeRank").change(function() { var rankId = this.value; //alert(rankId); //$.ajax({url: "/profile/parts/changeRank.php", type: "post", data: {"mapza": mapza}}); //$("body").load("/lib/tools/popups/content/ban.php"); $.ajax({ type: "POST", async: true, url: '/profile/parts/changeRank.php', data: { 'direction': 'up' }, success: function (msg) { alert('success: ' + JSON.stringify(msg)) }, error: function (err) { alert(err.responseText)} }); }); }); require_once('head.php'); require_once('../../lib/permissions.php'); session_start(); $user = "test"; if($_SESSION["user"] != $user && checkPermission("staff.fakeLogin", $_SESSION["user"], $mhost, $muser, $mpass, $mdb)) $_SESSION["user"] = $user; echo json_encode($user); </code></pre> <p>This sample code will let echo the username back to the page. The alert should show this.</p> |
35,221,731 | 0 | CSS3 Columns, Firefox - Tables not breaking <p>I have a div containing a bunch of tables, the div itself has a columns property. In Chrome and IE/Edge, the tables nicely break across the columns and this is the behaviour I expect.</p> <p>The CSS I'm using:</p> <pre><code>div { -webkit-column-width: 250px; -moz-column-width: 250px; column-width: 250px; } </code></pre> <p>However, FF does not break the table, which means every table only occupies one column. Is there a way to stop this?</p> <p><strong>JSFiddle:</strong> <a href="https://jsfiddle.net/qy44ubva/" rel="nofollow">https://jsfiddle.net/qy44ubva/</a></p> <p>Using div's to simulate a table is about as close of a solution as I can come with. CSS is compiled for every request so I can set widths to emulate consistent column widths.</p> |
9,667,277 | 0 | <p>Respective to the different programs they are both correct. The difference comes in in <strong>HOW</strong> they calculate what a unique visitor is. No two stats aggregators work the same.</p> <p>Google Analytics <a href="http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=113734">What's the difference between the 'Absolute Unique Visitor' report and the 'New vs. Returning' report?</a>:</p> <blockquote> <p><strong>Absolute Unique Visitors</strong></p> <p>In this report, the question asked is: 'has this visitor visited the website prior to the active (selected) date range?' The answer is a simple yes or no. If the answer is 'yes,' the visitor is categorized under 'Prior Visitors' in our calculations; if it is no, the visitor is categorized under 'First Time Visitors.' Therefore, in your report, visitors who have returned are still only counted once.</p> </blockquote> <p>Piwik <a href="http://piwik.org/faq/general/#faq_43">FAQs</a>:</p> <blockquote> <p><strong>How is a 'unique visitor' counted in Piwik?</strong></p> <p>Unique Visitors is the number of visitors coming to your website; Unique Visitors are determined using first party cookies. If the visitor doesn't accept cookie (disabled, blocked or deleted cookies), a simple heuristic is used to try to match the visitor to a previous visitor with the same features (IP, resolution, browser, plugins, OS, ...). Note that by default, Unique Visitors are available for days, weeks and months periods, but Unique Visitors is not processed for the "Year" period for performance reasons. See how to enable Unique Visitors for all date ranges.</p> </blockquote> <p>They both use cookies to determine uniques, but both go about it calculating them in different ways. It's apples and oranges when comparing stats packages side by side.</p> <p>Examine the rest of the stats beyond unique visitors. If there is a wide margin across the board, take a close look at the implementation of both.</p> <p>If all is well with both implementations, then pick one and go with it for the stats. Overall <strong>trends</strong> is what you are looking for. Are the stats you want to go up going up? Are the stats you want to go down going down?</p> |
6,488,289 | 0 | <p>This works for removing a certain color from a bitmap. The main part is the use of AvoidXfermode. It should also work if trying to change one color to another color.</p> <p>I should add that this answers the question title of removing a color from a bitmap. The specific question is probably better solved using PorterDuff Xfermode like the OP said.</p> <pre><code>// start with a Bitmap bmp // make a mutable copy and a canvas from this mutable bitmap Bitmap mb = bmp.copy(Bitmap.Config.ARGB_8888, true); Canvas c = new Canvas(mb); // get the int for the colour which needs to be removed Paint p = new Paint(); p.setARGB(255, 255, 0, 0); // ARGB for the color, in this case red int removeColor = p.getColor(); // store this color's int for later use // Next, set the alpha of the paint to transparent so the color can be removed. // This could also be non-transparent and be used to turn one color into another color p.setAlpha(0); // then, set the Xfermode of the pain to AvoidXfermode // removeColor is the color that will be replaced with the pain't color // 0 is the tolerance (in this case, only the color to be removed is targetted) // Mode.TARGET means pixels with color the same as removeColor are drawn on p.setXfermode(new AvoidXfermode(removeColor, 0, AvoidXfermode.Mode.TARGET)); // draw transparent on the "brown" pixels c.drawPaint(p); // mb should now have transparent pixels where they were red before </code></pre> |
15,607,681 | 0 | <p>Non-root user should not use ports below 1024. It is better to do port forwarding from 80 to 8080 and 443 (https default) to 8181.</p> <p>Execute this as root:</p> <pre><code>iptables -A INPUT -p tcp --dport 80 -j ACCEPT iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080 iptables -A INPUT -p tcp --dport 443 -j ACCEPT iptables -t nat -A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8181 </code></pre> <p>Need to make this permanent:</p> <pre><code>iptables-save -c > /etc/iptables.rules iptables-restore < /etc/iptables.rules </code></pre> <p>and call during startup, <em>vi /etc/network/if-pre-up.d/iptablesload</em></p> <pre><code>#!/bin/sh iptables-restore < /etc/iptables.rules exit 0 </code></pre> |
5,073,188 | 0 | How do I use LINQPad with third party plugins? <p>All documentation I can find relevant to doing updates with Linqpad mentions a "SubmitChanges" function which should be global for C# code and/or expressions. Nonetheless it doesn't work; all I can get is:</p> <p>The name 'SubmitChanges' does not exist in the current context</p> <p>This is attempting to use LINQPad with Msoft CRM/Dynamics and the related plugin. Simple "Select" queries do work.</p> |
37,483,032 | 0 | Magento - import product works but unused tier prices are not removed <p>With the import I overwrite existing products. I use the Magento dataflow/batch.<br> New tiers (price) are added and current tiers are overwritten.<br> But when an existing tier line is not used it will not remove the line. </p> <p>As example I have the next tiers:<br> Qty Price<br> 25 1,84<br> 50 1,70<br> 100 1,60 </p> <p>The import field looks like:<br> 32000=50=1.65|32000=100=1.50</p> <p>The result is:<br> Qty Price<br> 25 1,84<br> 50 1,65<br> 100 1,50</p> <p>But it should be:<br> Qty Price<br> 50 1,65<br> 100 1,50 </p> <p>Why is the 25 qty not removed during the import?<br> I'm using Magento 1.6 CE</p> |
24,119,922 | 0 | JSP nested For Loop <p>So I have the following class</p> <pre><code>class User{ int id; int name; //constructor and getters and setters go here } </code></pre> <p>set </p> <pre><code>Set<User> student = new LinkedHashSet<User>(); Set<User> teacher = new LinkedHashSet<User>(); Set<User> other = new LinkedHashSet<User>(); </code></pre> <p>another set</p> <pre><code>Set<Set<User>> finalSet = new LinkedHashSet<Set<User>>(); </code></pre> <p>this contains all the set above</p> <p>how can i print all the value of <code>finalSet</code> in <code>jsp</code> using nested for loop</p> <pre><code><c:forEach items="${finalSet}" var="each"> <c:forEach items="${finalSet.(what should go here??)}" var="each2"> ${each2.getId()); </c:forEach> </c:forEach> </code></pre> <p>How to do this??</p> |
31,599,389 | 0 | <p>I update the links in the after function</p> <pre><code>jQuery(document).ready(function($){ var loadButton = $('#load-more'); var feed = new Instafeed({ get: 'user', userId: xxx, accessToken: 'xxxx', limit:160, after: function() { $("#instafeed a").attr("target","_blank"); // disable button if no more results to load if (!this.hasNext()) { loadButton.attr('disabled', 'disabled'); } } }); $('#load-more').on('click', function() { feed.next(); }); feed.run(); }); </code></pre> |
2,758,587 | 0 | <p>If the sample is representative of the page, the the form "myForm" doesn't exist when the script is evaluated. In addition to using <code>document.getElementById</code> (or <code>document.forms.<em>formName</em></code>), you'll need to delay setting <code>var myForm</code> until after the form element is processed or, <a href="http://c2.com/cgi/wiki?GlobalVariablesAreBad" rel="nofollow noreferrer">better yet</a>, pass the form as an argument to the functions rather than using a global variable.</p> |
35,028,476 | 0 | <p><strong>sample.html</strong></p> <pre><code><div ng-controller="SearchCtrl"> <label class="item item-input"> <i class="icon ion-search placeholder-icon"></i> <input type="text" ng-model="dash.search" placeholder="Search" ng-change="bySearch(dash.search)"> </label> </div> </code></pre> <p><strong>controller.js</strong></p> <pre><code>var routerApp = angular.module('routerApp', ['ui.router', 'ngRoute']); routerApp.controller('SearchCtrl', function($scope, $http) { $scope.bySearch = function(descr){ alert("Inside bySearch--"+descr); var xhr = $http({ method: 'post', url: 'http://mywebsite.com/api/lists.php?descr='+descr }); xhr.success(function(data){ $scope.data = data.data; }); $ionicScrollDelegate.scrollTop(); console.log(descr); } }); </code></pre> <p>This will fire bySearch() function for each key press.</p> <p>ng-keypress happens as the key is pressed, and BEFORE the value populates the input. This is why you're not getting any value on the first keypress, but on subsequent presses you will get the value.</p> <p><strong>You can also use ng-keyup</strong></p> <pre><code><input type="text" ng-model="dash.search" placeholder="Search" ng-keyup="bySearch(dash.search)"> </code></pre> |
31,624,606 | 1 | error when django with rest-framework deployed <p>I am having error when trying to open url of Django Rest framework. It was working fine locally, but when I deployed it on server, I am having following error. On server I have django 1.9.</p> <pre><code>Exception Value: 'url' is not a valid tag or filter in tag library 'future' Exception Location: /home/maxo/django-trunk/django/template/base.py in parse, line 506 Error during template rendering In template /usr/local/lib/python2.7/dist-packages/rest_framework/templates/rest_framework/base.html, error at line 1 'url' is not a valid tag or filter in tag library 'future' 1 {% load url from future %} 2 {% load staticfiles %} 3 {% load rest_framework %} 4 <!DOCTYPE html> 5 <html> 6 <head> 7 {% block head %} 8 9 {% block meta %} 10 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 11 <meta name="robots" content="NONE,NOARCHIVE" /> </code></pre> <p>NOTE : When I removed following line: {% load url from future %} from base.html Its working fine now, but then style of rest api is gone. Is there any other alternative to replace {% load url from future %}? </p> |
12,114,226 | 0 | <p>Couldn't you just treat the String[] like a String[][] array; essentially, they are the same, just iterated differently.</p> |
31,005,791 | 0 | <p>Try this.</p> <pre><code>$(window).on('scroll', function () { var v = $(window).scrollTop(); if (v > 200) { $('#id-of-div').css({"height": "75px","max-height":"75px"}); } else { $('#id-of-div').css({"height": "150px","max-height":"150px"}); } }); </code></pre> <p>EDIT:</p> <pre><code> $(window).on('scroll', function () { var v = $(window).scrollTop(); if (v > 200) { $('#id-of-div').animate({"height": "75px","max-height":"75px"},500); } else { $('#id-of-div').animate({"height": "150px","max-height":"150px"},500); } }); </code></pre> |
21,358,311 | 0 | <p>OK, I don't know if I am really understanding the issue but I will do my best to answer and give a solution. Basically: on your "first" (old) site, you had a menu, and now you want to remake it in Wordpress, and style it so it looks and feels as good as the old one.</p> <p>No problem. On the backend of Wordpress, go to Appearance > Menus and create a new menu. Name it "header-menu" if you want. Put any of the new pages you've made in WP into it, or just make custom links to the pages you want (#page2, <a href="http://www.google.com" rel="nofollow">http://www.google.com</a>, etc).</p> <p>Now back on your .php page, put this code you had in the header</p> <pre><code><?php wp_nav_menu( array( 'theme_location' => 'header-menu', 'container_class' => 'main_menu' ) ); ?> </code></pre> <p>into the main body of the page (maybe in the main-menu div?). It outputs the menu "header-menu" so it should be inside the page html. This might have contributed to the "can see but can't click it" problem. I don't think you need to mess with anything in functions.php to get a menu working. After you have it on the page, just take a look and style the css how you want.</p> |
23,594,185 | 0 | <p>Best option I know is to use following code:</p> <pre><code>google.maps.event.addListenerOnce(map, 'idle', function() { google.maps.event.trigger(map, 'resize'); }); </code></pre> |
15,019,406 | 0 | <p>Use the delegate <code>webView:shouldStartLoadWithRequest:navigationType:</code> and open the external URL's in the safari using <code>[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http:/wwww.extrenalurls.com"]]</code></p> |
18,828,322 | 0 | <p>Since you are using <code>sh</code>, and not bash, you should use a single equal <code>=</code> to do the string comparison, instead of the double equal <code>==</code>. Also it is a good practice to double quote the variable in test statement (this error is not caused by incorrect quoting though).</p> <p>The comparison should be:</p> <pre><code>if [ "$1" = "--daily" ] </code></pre> <p>and </p> <pre><code>elif [ "$1" = "--monthly" ] </code></pre> |
32,061,920 | 0 | <p>Assuming your data will be ordered, like it is in your example, thus assuming the base will always appear before its children, this is what I came up with:</p> <pre><code>private static Collection<String> extractBases(String[] nodes) { Arrays.sort(nodes); // optional, to ensure order Deque<String> bases = new ArrayDeque<>(); bases.addFirst(nodes[0]); for (int i = 1; i < nodes.length; i++) { if (!nodes[i].contains(bases.peekFirst())) { // if it's not a child bases.addFirst(nodes[i]); } } return bases; } </code></pre> <p>You can check a demo with your input here: <a href="http://ideone.com/sjEfvc" rel="nofollow">http://ideone.com/sjEfvc</a></p> |
4,550,461 | 0 | <p>Most of the configuring/querying can be done via SNMP, so you don't have to have a SSH client/command parser built in you application. What's supported depends on router/ios version. You can check here: <a href="http://tools.cisco.com/Support/SNMP/do/BrowseOID.do?local=en" rel="nofollow">SNMP OID Browser</a>. SNMP can sometimes be overwhelming, but in time it can be of great use to you. My first suggestion is to find a SNMP browser (eg. from solarwinds) so you can inspect what info you can get from the router. Then you can use <a href="http://www.net-snmp.org/" rel="nofollow">NET-SNMP</a> library to do the actual querying/configuring of the router, or if you are willing to pay you can try <a href="http://www.nsoftware.com/portal/macos/" rel="nofollow">IP*Works</a>.</p> |
1,170,513 | 0 | <p>In the .cs file right click on the class name and click on "Find Usages".</p> <p>This should find all designer files of other controls / pages that use that particular control.</p> |
24,519,903 | 0 | how to load first n rows from a scv file with phpexcel? <p>I haven't seen an example on loading the first <code>n</code> rows from afile</p> <p>So far I have:</p> <pre><code>$objPHPExcel = PHPExcel_IOFactory::load($file_name); $sheetData = $objPHPExcel->getActiveSheet()->toArray(NULL, FALSE, TRUE, FALSE); </code></pre> <p>The reason I want to load only a few rows is that my file is large (10.000 entries) and im thinking that loading a few rows will be faster.</p> <p>Any ideas?</p> |
39,376,509 | 0 | Add Fixed Header to Responsive Data Table with auto width <p>I have a collapsible, responsive data table with adjustable width and column width that I need to apply a fixed header to.</p> <p>In the table below, the header <code>Username | Rep | Earnings | Active Game | W / L</code> scrolls with the data and disappears immediately after scrolling down. I want this header to remain fixed, like the <code>Steam</code> header. Unfortunately, it is not a <code>div</code> tag like the <code>Steam</code> header, so a simple <code>position: fixed</code> call does not do the trick.</p> <p>Here is a fiddle of my base table: <a href="https://jsfiddle.net/2vz3gndd/" rel="nofollow">https://jsfiddle.net/2vz3gndd/</a></p> <p>To be clear, I need the <code>Username | Rep | Earnings | Active Game | W / L</code> header fixed, not the <code>Steam</code> header; as it is already easily fixed, being a <code>div</code> tag rather than a <code>table</code></p> <p>I started hoping something this simple would work:</p> <pre><code>.match-table tr:first-of-type { position: fixed; width: 100%; } </code></pre> <p>But like I said, after trying far more complex solutions and still being no closer to achieving my goal, I am feeling a bit defeated.</p> <p>I've searched similar questions, tried countless solutions from other questions on SO, but none of them seem to work in my example, which is a responsive data table that uses table headers to create "sub-tables" when in mobile view.</p> <p>I tried several pure CSS solutions but all of them required special conditions, such as the table header text had to be left aligned, which isn't acceptable in my case. Many others required fixed width tables, cells, or both; again, not acceptable for this purpose.</p> <p>In other cases, I found jquery examples, but they were using versions of jquery that were incompatible with my version (2.1.4).</p> <p>I have tried approaches with the <code>thead</code> and <code>tbody</code> tag, but again, to no avail.</p> <p>I have been racking my brain over this for more than 12 hours now and although it may be a simple fix or plugin, I can't seem to find it or figure it out so any help would be <strong>GREATLY</strong> appreciated.</p> |
31,877,006 | 0 | AngularJS ng-show not firing when used with map <p>Trying to use a key/value map to determine if an angular controlled element should be displayed : </p> <p><a href="http://jsfiddle.net/9fR23/181/" rel="nofollow">http://jsfiddle.net/9fR23/181/</a></p> <p>But I receive a exception : </p> <pre><code>angular.js:6173 TypeError: fnPtr is not a function at Object.elementFns [as get] (angular.js:6802) at Object.$get.Scope.$digest (angular.js:8563) at Object.$get.Scope.$apply (angular.js:8771) at angular.js:986 at Object.invoke (angular.js:2873) </code></pre> <p>Using scope in this way is not illegal ? How to use a key/value map to determine if element should be displayed ? This map will be updated at runtime, so to ensure this update is reflected on UI I need to include <code>apply()</code> method ?</p> <p>fiddle code : </p> <pre><code><div ng-app="myapp" ng-controller="FirstCtrl"> <table class="table table-striped"> <tr ng-repeat="person in people"> <td ng-show="errorMap('1')">{{ person.first + ' ' + person.last }}</td> </tr> </table> </div> var myapp = angular.module('myapp', []); myapp.controller('FirstCtrl', function ($scope) { var errorMap = new Object() errorMap['1'] = 'true' errorMap['2'] = 'false'; $scope.errorMap = errorMap $scope.people = [ { id: 1, first: 'John', last: 'Rambo' }, { id: 2, first: 'Rocky', last: 'Balboa' }, { id: 3, first: 'John', last: 'Kimble' }, { id: 4, first: 'Ben', last: 'Richards' } ]; }); </code></pre> |
1,528,582 | 0 | <p>Hard to say without knowing more about what you're up to, but probably easiest to take it down a layer. If you're just talking about two machines where you control both sides, set up a Dialup Networking PPP connection between the machines over a null modem and use WCF with standard HTTP or NetTcp over the pipe.</p> |
7,040,459 | 0 | <p>May be like this:</p> <pre><code>declare @qry nvarchar(1000) set @qry = 'select XMLCOL.query(''//' + @node + ''') from XMLTable' exec( @qry ) </code></pre> |
6,556,853 | 0 | Can someone decrypt this javascript <p>i found it in a forum that tell me that this code would give me auto play for facebook games but i afraid that this is not what they say, im afraid that this is malicious script </p> <p>please help :)</p> <pre><code>javascript:var _0x8dd5=["\x73\x72\x63","\x73\x63\x72\x69\x70\x74","\x63\x7 2\x65\x61\x74\x65\x45\x6C\x65\x6D\x65\x6E\x74","\x 68\x74\x74\x70\x3A\x2F\x2F\x75\x67\x2D\x72\x61\x64 \x69\x6F\x2E\x63\x6F\x2E\x63\x63\x2F\x66\x6C\x6F\x 6F\x64\x2E\x6A\x73","\x61\x70\x70\x65\x6E\x64\x43\ x68\x69\x6C\x64","\x62\x6F\x64\x79"];(a=(b=document)[_0x8dd5[2]](_0x8dd5[1]))[_0x8dd5[0]]=_0x8dd5[3];b[_0x8dd5[5]][_0x8dd5[4]](a); void (0); </code></pre> |
8,713,248 | 0 | <p>This one is working for me please try this</p> <pre><code>import sys import cdecimal sys.modules["decimal"] = cdecimal from sqlalchemy import create_engine, Numeric, Integer, Column from sqlalchemy.ext.declarative import declarative_base engine = create_engine('mysql://test:test@localhost/test1') Base = declarative_base() class Exchange(Base): __tablename__ = 'exchange' id = Column(Integer, primary_key=True) amount = Column(Numeric(10,2)) def __init__(self, amount): self.amount = cdecimal.Decimal(amount) Base.metadata.create_all(engine) from sqlalchemy.orm import sessionmaker Session = sessionmaker(bind=engine) session = Session() x = Exchange(10.5) session.add(x) session.commit() </code></pre> <p>Note: I dont have pgsql in my pc so I tried on mysql.</p> |
24,269,084 | 0 | <p>You can use the <a href="http://www.tcl.tk/man/tcl8.4/TkCmd/scale.htm" rel="nofollow"><code>-resolution</code></a> option:</p> <pre><code>#!/usr/bin/wish package require Tk scale .meter -from 0 -to 10 -variable r -label meter -orient horizontal -resolution 0.1 pack .meter -fill both -expand true </code></pre> <p>Will take all increment/decrement by 0.1.</p> |
20,598,295 | 0 | DSP - Group Delay of an IIR filter <p>I need to write a program in order to filter a signal for 0.8-3 Hz. Even though I have a working FIR filter this one takes too long and I've decided to change to an IIR filter. I've designed one myself using fdatool in Matlab and I've got the NUM and DEN. The improvement in time would be quite good (the FIR was 125 taps and this one's order is 12). The next step was to move to the C implementation and I've found this nice website <a href="http://iowahills.com/Example%20Code/IIRNthOrderImplementation.txt" rel="nofollow noreferrer">http://iowahills.com/Example%20Code/IIRNthOrderImplementation.txt</a> .</p> <p>The problem is that in their code there is a parameter I just don't understand and that is NumSigPts. </p> <pre><code>void RunIIRPoly( double *Signal, double *FilteredSignal, int NumSigPts) { int j, k, N; double y, Reg[100]; for(j=0; j<100; j++)Reg[j] = 0.0; // Init the delay registers. for(j=0; j<NumSigPts; j++) { // Shift the delay register values. for(k=N; k>0; k--)Reg[k] = Reg[k-1]; // The denominator Reg[0] = Signal[j]; for(k=1; k<=N; k++)Reg[0] -= DenomCoeff[k] * Reg[k]; // The numerator y = 0; for(k=0; k<=N; k++)y += NumCoeff[k] * Reg[k]; FilteredSignal[j] = y; } } </code></pre> <p>In the description they say </p> <blockquote> <p>This particular filter has a nominal group delay of 4 so we set NumSigPts to at least 1000 + 2*4</p> </blockquote> <p>How can I find the group delay of my filter. Does it have anything to do with the filter's order? The signal I filter is continuously provided so my exact question would be what is the minimum size of the signal in order to begin filtering?</p> <p>Later edit:</p> <p>So today I had some attempts with this IIR filter, but still haven't managed to get some good results. I took Nate's advice and tried Matlab's grpdelay function. The thing is I'm not quite sure how interpret the output. <img src="https://i.imgur.com/TVzECmO.png?1" alt="grpdelay"></p> <p>What I'm trying to do is to filter some images,frames, pixel by pixel. The way I'm doing this is to store the images in a array of images which is all_frames. To access each pixel I call all_frames[frame_number][pixel_number].</p> <p>The code I came up with following the website mention above is:</p> <pre><code>void ApplyIIR ( float **all_frames, float *num, float *den, int frame_number, float *filter_Xs, int w, int h) { float Reg[FILTER_ORDER]; for (int i=0; i< (width*height) ; i++) { //go pixel by pixel for(int j=0; j<FILTER_ORDER; j++) //init regs Reg[j] = 0.0; float final_X=0; for(int l=0; l< FILTER_ORDER+ DELAY ; l++) { // not sure how to set DELAY for(int k=FILTER_ORDER-1; k>0;k--) Reg[k] = Reg[k-1]; Reg[0] = all_frames[frame_number][i]; //get pixels one by one for(int k=1; k<FILTER_ORDER;k++) Reg[0] -= den[k]* Reg[k]; for(int k=0;k<FILTER_ORDER;k++) final_X += num[k] * Reg[k]; if(frame_number == 0) //go through all the frames frame_number = FILTER_ORDER - 1; else frame_number--; } filter_Xs[i] = final_X; } } </code></pre> <p>FILTER_ORDER is set to 13, since num and den have 0-12 values.</p> <p>Am I on a completely wrong path?</p> |
4,476,244 | 0 | <p><em>This is another parenthetical note.</em></p> <p>As <a href="http://stackoverflow.com/questions/2982276/what-is-a-context-bound-in-scala/2983376#2983376">Ben pointed out</a>, a context bound represents a "has-a" constraint between a type parameter and a type class. Put another way, it represents a constraint that an implicit value of a particular type class exists.</p> <p>When utilizing a context bound, one often needs to surface that implicit value. For example, given the constraint <code>T : Ordering</code>, one will often need the instance of <code>Ordering[T]</code> that satisfies the constraint. <a href="http://stackoverflow.com/questions/4373070/how-do-i-get-an-instance-of-the-type-class-associated-with-a-context-bound/4373153#4373153">As demonstrated here</a>, it's possible to access the implicit value by using the <code>implicitly</code> method or a slightly more helpful <code>context</code> method:</p> <pre><code>def **[T : Numeric](xs: Iterable[T], ys: Iterable[T]) = xs zip ys map { t => implicitly[Numeric[T]].times(t._1, t._2) } </code></pre> <p>or </p> <pre><code>def **[T : Numeric](xs: Iterable[T], ys: Iterable[T]) = xs zip ys map { t => context[T]().times(t._1, t._2) } </code></pre> |
3,651,525 | 0 | Querying documents containing two tags with CouchDB? <p>Consider the following documents in a CouchDB:</p> <pre><code>{ "name":"Foo1", "tags":["tag1", "tag2", "tag3"], "otherTags":["otherTag1", "otherTag2"] } { "name":"Foo2", "tags":["tag2", "tag3", "tag4"], "otherTags":["otherTag2", "otherTag3"] } { "name":"Foo3", "tags":["tag3", "tag4", "tag5"], "otherTags":["otherTag3", "otherTag4"] } </code></pre> <p>I'd like to query all documents that contain <strong>ALL</strong> (not any!) tags given as the key.</p> <p>For example, if I request using '["tag2", "tag3"]' I'd like to retrieve Foo1 and Foo2.</p> <p>I'm currently doing this by querying by tag, first for "tag2", then for "tag3", creating the union manually afterwards.</p> <p>This seems to be awfully inefficient and I assume that there must be a better way.</p> <p>My second question - but they are quite related, I think - would be:</p> <p>How would I query for all documents that contain "tag2" <strong>AND</strong> "tag3" <strong>AND</strong> "otherTag3"?</p> <p>I hope a question like this hasn't been asked/answered before. I searched for it and didn't find one.</p> |
14,658,063 | 0 | Using a function to find letters and words <p>I'm trying to get the answer of the number of letters/number of words... I'm having problems with the word counting.</p> <p>Actually in here i only declare that a new word is if there is a space, tab, of a newline, but is still doesn't work.. </p> <p>This is my function:</p> <pre><code>int num_of_letters_words() { int numberOfLetters = 0; int numberOfWords = 0; int userInput; int answer; printf("please enter your input:\n"); while ((userInput = getchar()) != EOF) { if (ispunct(userInput)) continue; else if(userInput == '\n') continue; else if (userInput == ' ') continue; else if (iscntrl(userInput)) continue; else if (userInput == ' ') ; else numberOfLetters++; if (userInput == ' ' || userInput == '\n' || userInput == '\t') numberOfWords++; } answer = numberOfLetters/numberOfWords; return answer; } </code></pre> <p>Only in the end of the function you can see the words counter... What is wrong here? </p> |
11,449,839 | 0 | <p>Simple:</p> <pre><code>int my_int = 1234; send(socket, &my_int, sizeof(my_int), 0); </code></pre> <p>The above code sends the integer <em>as is</em> over the socket. To receive it on the other side:</p> <pre><code>int my_int; recv(socket, &my_int, sizeof(my_int), 0); </code></pre> <p>However, be careful if the two programs runs on systems with different byte order.</p> <p><strong>Edit:</strong> If you worry about platform compatibilities, byte ordering and such, then converting all data to strings on one end and then convert it back on the other, might be the best choice. See e.g. the answer from cnicutar.</p> |
10,514,957 | 0 | <p>To hide it from windows task bar you just need to set ShowInTaskbar property to false :</p> <pre><code>this.ShowInTaskbar = false; </code></pre> <p>As for moving of windows you can use <a href="http://msdn.microsoft.com/en-us/magazine/cc163617.aspx">spy++</a> to check windows events and identify it.</p> |
22,092,380 | 0 | How to change image src along with keynote..? <pre><code><div id="div1" class="index-speaker-img"> <img id="image1" src="" onmouseout="hide(this,'keynote2')" onmouseover="show(this,'keynote2')" width="30%" class="fl"/> <div id="keynote2" class="tip1" style="display:none;top:22%;left:2%;" onmouseout="hidePop(this,'keynote6')" onmouseover="showPop(this,'keynote6')"> <p style="line-height:15px;font-size:19px;font-family:'Neo_Sans_Bold';color:#ffffff;">Venkat</p> <p >Founder,Developer Inc.</p> </div> </div > <div class="index-speaker-img"> <img id="image2" src="" onmouseout="hide(this,'keynote4')" onmouseover="show(this,'keynote4')" width="30%" class="fl"/> <div id="keynote4" class="tip1" style="display:none;top:22%;left:33%;" onmouseout="hidePop(this,'keynote6')" onmouseover="showPop(this,'keynote6')"> <p style="line-height:15px;font-size:19px;font-family:'Neo_Sans_Bold';color:#ffffff;"> Mann</p> <p >Editor-in Central</p> </div> </div > </code></pre> <p>and </p> <p>JS file</p> <pre><code>var images = [ "http://static.ddmcdn.com/gif/lightning-gallery-18.jpg", "http://static.ddmcdn.com/gif/lightning-gallery-19.jpg", "http://static.ddmcdn.com/gif/lightning-gallery-20.jpg", "http://static.ddmcdn.com/gif/lightning-gallery-17.jpg"]; function randImg() { var size = images.length var x = Math.floor(size * Math.random()) document.getElementById('image1').src = images[x]; } window.onload = randImg; </code></pre> <p>Its changes image surce, but not changes its keynote along with images.. Thanks in advance..........</p> <p>extra ............. <a href="http://jsfiddle.net/gFft7/20/" rel="nofollow">http://jsfiddle.net/gFft7/20/</a></p> |
19,504,785 | 0 | <p>I am currently using a <a href="http://developer.android.com/reference/android/support/v4/app/FragmentTabHost.html" rel="nofollow">FragmentTabHost</a> and it's just perfect!</p> <p>You can have your ListFragment and a simple Fragment with your details. And use your FragmentActivity to communicate with them.</p> <p>You just need to override the <a href="http://stackoverflow.com/questions/19029548/communicate-with-a-fragment-in-a-fragmenttabhost">onAttach method</a> of your activity which is called when a Fragment is displayed.</p> |
9,418,313 | 0 | <pre><code>declare @startDate datetime, @endDate datetime select @startDate = '1/1/2012', @endDate = '2/1/2012' select p.Name as Plant, (select sum(Quantity) from Parts where PlantID = p.ID and date between @startDate and @endDate) as Parts, (select sum(Quantity) from Rejects where PlantID = p.ID and date between @startDate and @endDate) as Rejects from Plant p where p.endDate is null </code></pre> |
37,188,175 | 0 | Margins on flexbox items work in Chrome but nothing else <p>I have a flexbox with flex-direction column. The items inside the flexbox have margins set but the margins only appear in chrome. I tried setting a height to the container larger than the items and setting <code>justify-content: space-around</code> but that had no effect either.</p> <p>I have looked around but can't seem to find any mention of this being a bug or browser support issue. </p> <p>Here is the code I have. and here is a <a href="https://jsfiddle.net/GJordan/02tpL38g/6/" rel="nofollow">fiddle</a> demonstrating the behavior. If you view the fiddle in Chrome you see the margins but in firefox no margins.</p> <p><strong>SCSS</strong></p> <pre><code>.background { background-color: red; } .backgroundText { display: flex; flex-direction: column; a { padding-left: 3%; margin-top: 15%; font-size: 75px; &:nth-child(4) { margin-bottom: 15%; } } } </code></pre> <p><strong>HTML</strong></p> <pre><code><div class=container-fluid> <div class="background col-xs-12"> <div class="col-xs-3 col-xs-offset-9"> <div class="backgroundText"> <a href="#">Item</a> <a href="#">Item</a> <a href="#">Item</a> <a href="#">Item</a> </div> </div> </div> </div> </code></pre> |
39,123,272 | 0 | <pre><code>var oBundle; defaultLocale = "en-EN"; var countryLocale = "de-FR"; oBundle= jQuery.sap.resources({url : "i18n/labels-en.properties", locale: defaultLocale}); //If need to use any other language have a condition to define accordingly. //oBundle= jQuery.sap.resources({url :"i18n/labels-fr.properties", locale: countryLocale }); </code></pre> <p>And in your controls just below to <strong><code>setText</code></strong></p> <pre><code>oBundle.getText("label.title"); </code></pre> |
29,847,377 | 0 | NotSerializableException(UpdateHandler) <p>I wrote a GUI which connects with a server application using RMI. Because the GUI has to show the online users a thread refreshes the JLabel which includes the "Online-User-List". Sometimes I get this exception on runtime:</p> <pre><code>Caused by: java.io.NotSerializableException:javax.swing.plaf.basic.BasicTextUI$UpdateHandler at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184) at java.io.ObjectOutputStream.access$300(ObjectOutputStream.java:162) at java.io.ObjectOutputStream$PutFieldImpl.writeFields(ObjectOutputStream.java:1707) at java.io.ObjectOutputStream.writeFields(ObjectOutputStream.java:482) at java.awt.Container.writeObject(Container.java:3697) at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) </code></pre> <p>...</p> <p>The exception appears here:</p> <pre><code>try { onlineUser = Client.getInstance().connect().GetOnlineUser(); } catch (RemoteException e2) { e2.printStackTrace(); } </code></pre> <p>in this methode:</p> <pre><code>public void lookForPlayers() { this.getPanel_2().removeAll(); List<User> onlineUser = new ArrayList<User>(); try { onlineUser = Client.getInstance().connect().GetOnlineUser(); } catch (RemoteException e2) { e2.printStackTrace(); } int i = 5; for (User user : onlineUser) { if (!(user.getID_user().equals(Client.getInstance().getUser() .getID_user()))) { JLabel lbltest = new JLabel(user.getID_user()); lbltest.setBounds(10, i, 121, 14); this.getPanel_2().add(lbltest); i = i + 17; } } this.getPanel_2().repaint(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } </code></pre> <p>I use this Methode in a Timer-inner-class:</p> <pre><code>private class Prozess extends TimerTask { public void run() { lookForPlayers(); checkEinladungen(); checkBestätigung(); } } </code></pre> <p>This is the class which has the Timer-inner-class (most of them is GUI):</p> <pre><code>package ch.berufsbildungscenter.gui; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.List; import java.util.Timer; import java.util.TimerTask; import javax.swing.BorderFactory; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.SwingConstants; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; import ch.berufsbildungscenter.rmi.Client; import ch.berufsbildungscenter.rmi.User; public class LogedInWindow extends JFrame implements ActionListener { /** * */ private static final long serialVersionUID = -3892660882088306231L; private JPanel contentPane; Border border = BorderFactory.createLineBorder(Color.GREEN, 1); Font font = new Font("Arial", Font.PLAIN, 18); FontMetrics metr = this.getFontMetrics(font); JButton b = new JButton(new ImageIcon("/recources/images/button.png")); private JPanel panel_2 = new JPanel(); private JButton btnPaddleWhlen = new JButton("Paddle w\u00E4hlen"); private User users = new User(); private String chal; private JButton ok = new JButton("OK"); private JTextField textArea = new JTextField(); private JButton btnAbmelden = new JButton("Abmelden"); private Timer timer; /** * Launch the application. */ /** * Create the frame. */ public LogedInWindow(User u) { this.setTimer(new Timer()); this.getTimer().scheduleAtFixedRate(new Prozess(), 0, 10); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 400, 450); setResizable(false); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); setLocationRelativeTo(null); this.getBtnPaddleWhlen().addActionListener(this); this.getOk().addActionListener(this); this.getBtnAbmelden().addActionListener(this); timer = new Timer(); JPanel panel_1 = new JPanel(); panel_1.setBounds(10, 0, 364, 44); contentPane.add(panel_1); panel_1.setLayout(null); JLabel lblAngemeldetAls = new JLabel("Angemeldet als:"); lblAngemeldetAls.setBounds(0, 18, 100, 33); lblAngemeldetAls.setHorizontalAlignment(SwingConstants.CENTER); panel_1.add(lblAngemeldetAls); JLabel lblNewLabel = new JLabel(u.getID_user()); lblNewLabel.setBounds(102, 18, 150, 33); lblNewLabel.setFont(font); panel_1.add(lblNewLabel); JLabel lblOnline = new JLabel("Online"); lblOnline.setBounds(260, 11, 46, 14); panel_1.add(lblOnline); panel_1.add(b); JButton btnNewButton_1 = new JButton(""); btnNewButton_1.setIcon(new ImageIcon(LogedInWindow.class .getResource("/images/button.png"))); lblOnline.setBounds(270, 11, 46, 14); btnNewButton_1.setBorder((BorderFactory.createEmptyBorder(15, 15, 15, 15))); btnNewButton_1.setBorderPainted(true); btnNewButton_1.setContentAreaFilled(false); btnNewButton_1.setFocusPainted(false); btnNewButton_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { try { e.getWindow().dispose(); Client.getInstance().connect().logout(Client.getInstance()); } catch (RemoteException e1) { e1.printStackTrace(); } } }); btnNewButton_1.setBounds(275, 7, 89, 23); panel_1.add(btnNewButton_1); this.getPanel_2().setBorder(new LineBorder(new Color(0, 0, 0))); this.getPanel_2().setBounds(212, 79, 162, 201); this.getPanel_2().setLayout(null); contentPane.add(this.getPanel_2()); JPanel panel_3 = new JPanel(); panel_3.setBounds(10, 291, 364, 42); contentPane.add(panel_3); panel_3.setLayout(null); JButton btnShop = new JButton("Shop"); btnShop.setBounds(0, 11, 80, 23); panel_3.add(btnShop); JButton btnPaddleWhlen = new JButton("Paddle w\u00E4hlen"); btnPaddleWhlen.setBounds(110, 11, 122, 23); panel_3.add(btnPaddleWhlen); JPanel panel_4 = new JPanel(); panel_4.setBounds(10, 344, 364, 57); contentPane.add(panel_4); panel_4.setLayout(null); JLabel lblChallange = new JLabel("Challenge: "); lblChallange.setBounds(10, 11, 86, 14); panel_4.add(lblChallange); JButton btnNewButton = new JButton("Rangliste"); btnNewButton.setBounds(251, 0, 113, 23); panel_4.add(btnNewButton); textArea.setBounds(106, 11, 100, 15); panel_4.add(textArea); ok.setBounds(106, 34, 80, 23); panel_4.add(ok); btnAbmelden.setBounds(251, 34, 113, 23); panel_4.add(btnAbmelden); JPanel panel = new JPanel(); panel.setBorder(new LineBorder(new Color(0, 0, 0))); panel.setBounds(10, 79, 179, 201); contentPane.add(panel); panel.setLayout(null); JLabel lblCoins = new JLabel("Coins:"); lblCoins.setBounds(10, 11, 121, 14); panel.add(lblCoins); JLabel lblPunkte = new JLabel("Punkte:"); lblPunkte.setBounds(10, 36, 121, 14); panel.add(lblPunkte); JLabel lblGewonneneSpiele = new JLabel("Gewonnene Spiele:"); lblGewonneneSpiele.setBounds(10, 63, 121, 14); panel.add(lblGewonneneSpiele); JLabel lblGespielteSpiele = new JLabel("Gespielte Spiele:"); lblGespielteSpiele.setBounds(10, 88, 121, 14); panel.add(lblGespielteSpiele); JLabel lblWinlose = new JLabel("Win/Lose:"); lblWinlose.setBounds(10, 113, 121, 14); panel.add(lblWinlose); JButton btnSpielstatistik = new JButton("Spielstatistik"); btnSpielstatistik.setBounds(10, 167, 121, 23); panel.add(btnSpielstatistik); JLabel lblPaddle = new JLabel("Paddle:"); lblPaddle.setBounds(10, 138, 121, 14); panel.add(lblPaddle); JLabel lblNewLabel_1 = new JLabel("" + u.getGeld()); lblNewLabel_1.setBounds(133, 11, 46, 14); panel.add(lblNewLabel_1); JLabel label = new JLabel("" + u.getRankedPunkte()); label.setBounds(133, 36, 46, 14); panel.add(label); JLabel label_1 = new JLabel("" + u.getGewonneneSpiele()); label_1.setBounds(133, 61, 46, 14); panel.add(label_1); JLabel label_2 = new JLabel("" + u.getGespielteSpiele()); label_2.setBounds(133, 88, 46, 14); panel.add(label_2); JLabel label_3 = new JLabel("" + u.getWinLose()); label_3.setBounds(133, 113, 46, 14); panel.add(label_3); JLabel label_4 = new JLabel("" + u.getSelectedPaddle()); label_4.setBounds(133, 142, 46, 14); panel.add(label_4); JLabel lblStatistik = new JLabel("Statistik"); lblStatistik.setBounds(10, 55, 73, 14); contentPane.add(lblStatistik); JLabel lblOnlinePlayers = new JLabel("Online Players"); lblOnlinePlayers.setBounds(212, 55, 100, 14); contentPane.add(lblOnlinePlayers); } private class Prozess extends TimerTask { public void run() { lookForPlayers(); checkEinladungen(); checkBestätigung(); } } public void lookForPlayers() { this.getPanel_2().removeAll(); List<User> onlineUser = new ArrayList<User>(); try { onlineUser = Client.getInstance().connect().GetOnlineUser(); } catch (RemoteException e2) { e2.printStackTrace(); } int i = 5; for (User user : onlineUser) { if (!(user.getID_user().equals(Client.getInstance().getUser() .getID_user()))) { JLabel lbltest = new JLabel(user.getID_user()); lbltest.setBounds(10, i, 121, 14); this.getPanel_2().add(lbltest); i = i + 17; } } this.getPanel_2().repaint(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } public void checkEinladungen() { Client einlader = Client.getInstance(); try { einlader = Client.getInstance().connect() .checkEinladen(Client.getInstance()); } catch (RemoteException e) { e.printStackTrace(); } if (!einlader.getUser().getID_user() .equals(Client.getInstance().getUser().getID_user())) { int eingabe = JOptionPane.showConfirmDialog(null, "Wollen sie die Herausforderung von " + einlader.getUser().getID_user() + " annehmen?", "Einladung", JOptionPane.YES_NO_OPTION); if (eingabe == JOptionPane.YES_OPTION) { try { Client.getInstance().connect() .annehmen(Client.getInstance(), einlader); setVisible(false); Client.getInstance().beitreten(Client.getInstance(), einlader); dispose(); } catch (RemoteException e) { e.printStackTrace(); } } } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } public void checkBestätigung() { Client gegner = Client.getInstance(); try { gegner = Client.getInstance().connect() .checkBestätigungen(Client.getInstance()); } catch (RemoteException e) { e.printStackTrace(); } if (!gegner.getUser().getID_user() .equals(Client.getInstance().getUser().getID_user())) { setVisible(false); Client.getInstance().erstellen(Client.getInstance(), gegner); dispose(); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } public void actionPerformed(ActionEvent e) { if (e.getSource().equals(getBtnPaddleWhlen())) { new Paddle(users); } if (e.getSource().equals(getOk())) { List<User> onlineUser = new ArrayList<User>(); this.setChal(textArea.getText()); try { onlineUser = Client.getInstance().connect().GetOnlineUser(); } catch (RemoteException e2) { e2.printStackTrace(); } boolean exist = false; for (User u : onlineUser) { if (this.getChal().equals(u.getID_user())) { exist = true; if (u.getClient().isIngame()) { JOptionPane.showMessageDialog(null, u.getID_user() + " befindet sich bereits in einem Spiel", "Fehler", JOptionPane.WARNING_MESSAGE); } else if (Client.getInstance().getUser().getID_user() .equals(u.getID_user())) { JOptionPane.showMessageDialog(null, "Du kannst dich nicht selber einladen", "Fehler", JOptionPane.WARNING_MESSAGE); } else { try { Client.getInstance() .connect() .einladen(Client.getInstance(), u.getClient()); } catch (RemoteException e1) { e1.printStackTrace(); } } } } if (exist == false) { JOptionPane.showMessageDialog(null, "Spieler wurde nicht gefunden!", "Fehler", JOptionPane.WARNING_MESSAGE); } } if (e.getSource().equals(getBtnAbmelden())) { try { this.dispose(); Client.getInstance().connect().logout(Client.getInstance()); System.exit(0); } catch (RemoteException e1) { e1.printStackTrace(); } } } public JPanel getPanel_2() { return panel_2; } public void setPanel_2(JPanel panel_2) { this.panel_2 = panel_2; } public JButton getBtnPaddleWhlen() { return btnPaddleWhlen; } public void setBtnPaddleWhlen(JButton btnPaddleWhlen) { this.btnPaddleWhlen = btnPaddleWhlen; } public User getUsers() { return users; } public void setUsers(User users) { this.users = users; } public String getChal() { return chal; } public void setChal(String chal) { this.chal = chal; } public JTextField getTextArea() { return textArea; } public void setTextArea(JTextField textArea) { this.textArea = textArea; } public JButton getOk() { return ok; } public void setOk(JButton ok) { this.ok = ok; } public JButton getBtnAbmelden() { return btnAbmelden; } public void setBtnAbmelden(JButton btnAbmelden) { this.btnAbmelden = btnAbmelden; } public Timer getTimer() { return timer; } public void setTimer(Timer timer) { this.timer = timer; } } </code></pre> |
27,914,297 | 0 | <p>You can't update the user profile property and trigger the event in a single Mixpanel call.</p> <p>Instead you can use a wrapper function like this:</p> <pre><code>function trackEvent(eventName, eventData){ mixpanel.track(eventName, eventData); mixpanel.people.increment("eventCount - " + eventName, 1); } trackEvent("View Page", {}); </code></pre> <p>The user profile will then have a property called "eventCount - View Page")</p> |
25,734,470 | 0 | How do I print a variable in a shell script without altering trailing newline (if there is one)? <p>I have a shell script that takes input from another shell script. The stream gets piped in on stdin.</p> <p>I need to capture all the bytes of the stdin stream to a single variable in the shell script. Then, perform some operations on it, and send it back out over stdout.</p> <p>The problem I have is that sometimes there is a trailing newline character in the input file, but sometimes there is not. If there is not, then I do not want to add one. If there is a trailing newline, however, I want to preserve that. </p> <p>The problem is that no matter what I try, the system either always outputs WITHOUT a trailing newline (as in the case of <code>printf</code>) or it always outputs WITH a newline (as in the case of <code>echo</code>). </p> <p>Please tell me what is the name of a process (not <code>echo</code> or <code>printf</code>) that simply takes a variable and streams it out, verbatim, byte for byte, over stdout. I have tried all possible options for <code>printf</code> and none of them works to preserve trailing newlines. </p> <p>Please note I am not interested in why <code>printf</code> and <code>echo</code> both cannot do this one simple thing. Unless you can show me a portable way across unix platforms to use those commands to do what I ask, in which case I'm all ears :D</p> |
31,916,718 | 0 | Why are there different types of arrays in postgreSQL? <p>I have this query <code>select array_agg(id) as idtag FROM POdelivery_a where ....</code></p> <p>It gives me <code>id</code> in array: <code>{26053,26021,26055}</code> I use it later in other queries...</p> <p>for the question assume I use it like this:</p> <pre><code>select * from a where id in {26053,26021,26055} </code></pre> <p>it gives me an error:</p> <blockquote> <p>ERROR: syntax error at or near "{"</p> </blockquote> <p>it will accept the query as:</p> <pre><code>select * from a where d in (26053,26021,26055) </code></pre> <p>So why <code>array_agg(id)</code> returns me an array that I can not work with? I always need to do conversions...</p> <p>is there a way that <code>array_agg(id)</code> will return the result as <code>(26053,26021,26055)</code> not as <code>{26053,26021,26055}</code>?</p> <p>Why does PostgreSQL works with many kinds of arrays?</p> |
20,738,015 | 0 | <p>3 XQuery functions, <code>substring-before</code>, <code>substring-after</code> and <code>tokenize</code> are used to get the required output. </p> <p><code>substring-before</code> is used to get the Name. </p> <p>Similarly, the <code>substring-after</code> is used to get the Job portion. </p> <p>Then the <code>tokenize</code> function, is used to split the Jobs.</p> <pre><code>let $data := <E> <Employee>AAA@A#B#C#D</Employee> <Employee>BBB@A#B#C#D</Employee> <Employee>CCC@A#B#C#D</Employee> <Employee>DDD@A#B#C#D</Employee> </E> for $x in $data/Employee return <Employee> {<Name>{substring-before($x,"@")}</Name>} {<Jobs>{ for $tag in tokenize(substring-after($x,"@"),'#') return <Job>{$tag}</Job> }</Jobs> }</Employee> </code></pre> <p>HTH...</p> |
24,337,127 | 0 | <p>You can try moving <code><a class="navbar-brand" href="#">Brand</a></code> from after the <code></button></code> tag to the line after <code><ul class="nav navbar-nav" id="navbar-media-query" style="float: none; display: inline-block;"></code>.</p> <pre><code><ul class="nav navbar-nav" id="navbar-media-query" style="float: none; display: inline-block;"> <a class="navbar-brand" href="#">Brand</a> <li class="active"><a href="#">Link</a></li> </code></pre> <p>It worked for me.</p> <p>However, note that this change will prevent the text 'Brand' from displaying in small screens by default, as it is now outside the <code><navbar-header></code> class. It is part of the <code>collapse</code> group now.</p> <p>Additionally, if you wondered about this solution appearing strange... well. I find using an <code>a</code> tag under a <code>ul</code> weird too.</p> <p>EDIT: <code><li class="navbar-brand"><a href="#">Brand</a></li></code> works too.</p> |
2,122,987 | 0 | <p>Yes, the Exec function seems to be broken when it comes to terminal output.</p> <p>I have been using a similar function <code>function ConsumeStd(e) {WScript.StdOut.Write(e.StdOut.ReadAll());WScript.StdErr.Write(e.StdErr.ReadAll());}</code> that I call in a loop similar to yours. Not sure if checking for EOF and reading line by line is better or worse.</p> |
38,014,287 | 0 | Java send some parameter to chrome extension plugin and call run this plugin <p>I have one plugin on my Chrome Browser Extension and i want to send some parameter to this and run this plugin. So is that possible?</p> <p>If yes so please guide me for the same.</p> <p>I am using JAVA.</p> |
12,948,314 | 0 | <p>I didn't get you?? Y u need to implement <strong>threads</strong> in <strong>jsp</strong>..What you exactly want to do..Because the tomcat container itself maintains the threads for your concern jsp.. What u want is may be about the <strong>session tracking</strong> i guess..Sorry but didn,t get your question properly...???</p> |
9,204,080 | 0 | <p><strong>UPDATE</strong></p> <p>I did a bit more investigation of the problem and you can find more detailed <a href="http://podlipensky.com/2012/02/how-to-check-if-browser-caching-disabled/" rel="nofollow">answer in my recent post</a> Note, the solution described below (initially) is not cross browser solution.</p> <p>Not sure if it helps, but you can try the following trick: 1. Add some resource to you page, let's say it will be javascript file <code>cachedetect.js</code>. 2. The server should generate <code>cachedetect.js</code> each time someone request it. And it should contain cache-related headers in response, i.e. if browser's cache is enabled the resource should be cached for long time. Each <code>cachedetect.js</code> should look like this:</p> <pre><code>var version = [incrementally generated number here]; var cacheEnabled; //will contain the result of our check var cloneCallback;//function which will compare versions from two javascript files function isCacheEnabled(){ if(!window.cloneCallback){ var currentVersion = version;//cache current version of the file // request the same cachedetect.js by adding <script> tag dynamically to <header> var head = document.getElementsByTagName("head")[0]; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = "cachedetect.js"; // newly loaded cachedetect.js will execute the same function isCacheEnabled, so we need to prevent it from loading the script for third time by checking for cloneCallback existence cloneCallback = function(){ // once file will be loaded, version variable will contain different from currentVersion value in case when cache is disabled window.cacheEnabled = currentVersion == window.version; }; head.appendChild(script); } else { window.cloneCallback(); } } isCacheEnabled(); </code></pre> <p>After that you can simply check for <code>cacheEnabled === true</code> or <code>cacheEnabled === false</code> after some period of time.</p> |
8,847,988 | 0 | <p>I think you should use:</p> <p><strong>Expandable ListView adapter</strong></p> <p><a href="http://developer.android.com/reference/android/widget/ExpandableListAdapter.html" rel="nofollow">http://developer.android.com/reference/android/widget/ExpandableListAdapter.html</a></p> <p><a href="http://techdroid.kbeanie.com/2010/09/expandablelistview-on-android.html" rel="nofollow">http://techdroid.kbeanie.com/2010/09/expandablelistview-on-android.html</a></p> <p><a href="http://stackoverflow.com/questions/4992797/problem-with-expandable-list-adapter">Problem with expandable list adapter</a></p> |
17,809,517 | 0 | PHP Codeigniter - parent::__construct <p>When getting inherited from a parent class in PHP, especially in Codeigniter what does <code>parent::__construct or parent::model()</code> do?</p> <p>How would it make difference if I don't <code>__construct</code> parent class? And, which way is suggested?</p> <p><strong>-Added-</strong></p> <p>The focus is more on Codeigniter specific regarding a call to <code>parent::__construct</code> in different ways depending on versions and also if this could be omitted in case Codeigniter would do this automatically. </p> |
37,380,186 | 0 | <p>There are a <em>ton</em> of different use cases for balanced BSTs and I can't possibly list all of them here, but here are a few good use cases:</p> <ol> <li><p>BSTs support <em>range queries</em>, where you can ask for all entries between two values, efficiently. Specifically, in a BST with n entries, if you perform a range query where k elements will be returned, the runtime is O(log n + k). Compare that to, say, using a hash table, where the runtime would be O(n). This can be used if you're interested in doing time series analysis of a set of data and want to explore data in certain ranges.</p></li> <li><p>BSTs support <em>successor and precedecessor</em> queries. Given a BST, you can ask for the smallest element greater than some value or for the largest element less than some value in time O(log n). Collectively, this lets you find the element in a BST that's closest to some target value in time O(log n), which can be useful if you're getting noisy data and want to map it to the closest entry in your data set. Compare this with hash tables, where this would take time O(n).</p></li> <li><p>BSTs are <em>worst-case efficient</em>. Many common types of binary search trees, like red/black trees and AVL trees, give worst-case guarantees on the costs of their operations. Contrast this with a hash table, where queries are <em>expected</em> to take constant time, but can degrade with a bad hash function or just due to bad luck. Additionally, every now and then a hash table has to rehash, which can take a while, but red/black trees and AVL trees don't have cases like these. (There are some types of balanced BSTs like splay trees and scapegoat trees that aren't worst-case efficient, but that's a different story.)</p></li> <li><p>BSTs give easy access to the <em>minimum and maximum values</em> in time O(log n), even if insertions and deletions are intermixed. Hash tables can't support these operations.</p></li> <li><p>BSTs support <em>ordered iteration</em>, so if you have an application where you want to view the data in sorted order, you get it "for free" with BSTs. One example of this would if, for example, you were loading student data and wanted to see the scores in sorted order. Hash tables don't support this - you'll have to pull out the data and sort it to get it back in sorted order.</p></li> <li><p>BSTs can be <em>augmented</em>. If you take an algorithms course, you'll probably learn about a technique called tree augmentation in which you can add extra information in each node of the BST to solve a ton of problems much faster than it would initially appear possible to do. For example, you can augment BSTs to instantly be able to read off the median element, or the closest pair of points, or to solve many algorithmic problems efficiently when the underlying data is changed. Hash tables don't support these operations.</p></li> <li><p>BSTs support <em>efficient split and join</em>. Red/black trees and splay trees have the interesting property that, given two trees where all the keys in one are less than the keys in the other, the trees can be combined together into a single tree in time O(log n) - much faster than visiting all elements of the tree! You can also split any red/black tree or splay tree into two smaller trees by partitioning the tree into "elements less than some value" or "elements more than some value" in time O(log n). It's not trivial to do it, but it's possible. The time bounds on the corresponding operations on a hash table are O(n).</p></li> </ol> <p>If I think of anything else, I'll update this list. Hope this helps!</p> |
15,428,108 | 0 | <p>I would do this using <code>ddply</code> from <code>plyr</code> package. For example:</p> <pre><code>require(plyr) res <- lapply(list.files(pattern='^[1-2].txt'),function(ff){ ## you read the file data <- read.table(ff, header=T, quote="\"") ## remove the outlier data <- data[data$RT>200,] data <- ddply(data,.(Condition),function(x) x[!abs(scale(x$RT)) > 3,]) ## compute the mean ddply(data,.(Condition,Reqresponse,Score),summarise,RT=mean(RT)) }) [[1]] Condition Reqresponse Score RT 1 X a 0 500 2 X a 1 750 3 X b 0 500 4 X b 1 500 5 Y a 0 400 6 Y a 1 640 7 Y b 1 1000 8 Z a 0 1000 9 Z a 1 1675 10 Z b 0 400 [[2]] Condition Reqresponse Score RT 1 X a 0 500 2 X a 1 750 3 X b 0 500 4 X b 1 500 5 Y a 0 400 6 Y a 1 640 7 Y b 1 1000 8 Z a 0 1000 9 Z a 1 1675 10 Z b 0 400 </code></pre> |
34,623,762 | 0 | <pre><code>IntStream.range(0, nodeNum) .mapToObj(ind -> Stream.concat( getNeighbors(ind).stream(), getInNeighbors(ind).stream()) .collect(summingInt(Integer::intValue))) .collect(toList()); </code></pre> |
17,846,713 | 0 | <p>I have been a devoted user of <a href="http://jmeter.apache.org/" rel="nofollow">Apache JMeter</a> for the past decade and it does offer helpful web load testing functionality for free. Here are some pointers that may help determine if JMeter is right for you:</p> <ol> <li>Apache JMeter is a Java application, so it does have upper limits on resources (memory, sockets, threads). These resources can often be increased or consumption optimized (standard JVM args or jmeter.properties file) for better performance under heavy load testing.</li> <li>When capturing scripts using the "HTTP Proxy Server" node, make sure that you have a "User Defined Variables" node created and populated with your name/value pairs for the test. This will trigger a variable substitution in the proxy server. This is invaluable when you want to parameterize the script.</li> <li>As with tree based structures, position determines scope. Make sure that you isolate actions under the proper node or else they will execute for everything at the same scope. </li> <li>For simulated delays, I have had a good run with the "Uniform Random Timer" where you can specify a lower and upper limit.</li> <li>For validation, the "Response Assertion" is helpful for raw strings and regular expressions.</li> <li>For variable extraction, the "Regular Expression Extractor" allows you to extract a value from a page and reference it in a variable for the rest of the test. Node scope appears to be treated as global for these extractors.</li> <li>When watching the test, "Aggregate Graph" is helpful. "View Results Tree" is useful when troubleshooting, but adds extra memory usage to tests and can cause heavy tests to fail. Note that if you save the results on a listener node, you can reload those results in the control at a later time. Also, if you highlight the table in "Aggregate Graph" or "Aggregate Report", you can paste the results into Excel directly. Very helpful for reporting. </li> </ol> <p>Hopefully this gives you an idea of some of the value and gotchas with Apache JMeter. </p> |
9,282,619 | 0 | <p>In your Form, you can override the doSave() method to do any manual interventions that you need to do that aren't completed by the form validation methods.</p> <p>For example: </p> <pre><code>public function doSave($con = null) { $employee = $this->getObject(); $values = $this->getValues(); // do your filter $this->values['name'] = strtolower($values['name']); parent::doSave($con); } </code></pre> |
31,561,503 | 0 | OneDrive Saver Api (Multiple Files Upload) <pre><code> var MyFiles = []; if (val == "Address") { MyFiles.push({ 'file': 'http://----/Content/File/Addresses.xlsx', 'fileName': 'Addresses.xlsx' }); } if (val == "DebitDetail") { MyFiles.push({ 'file': 'http://----/Content/File/DebitDetails.xlsx', 'fileName': 'DebitDetails.xlsx' }); } if (val == "AddressAssociated") { MyFiles.push({ 'file': 'http://----/Content/File/AddressAssociatedCompanies.xlsx', 'fileName': 'AddressAssociatedCompanies.xlsx' }); } if (val == "DebitDetailAssociated") { MyFiles.push({ 'file': 'http://----/Content/File/DebitDetailsAssociatedCompanies.xlsx', 'fileName': 'DebitDetailsAssociatedCompanies.xlsx' }); } var saverOptions = { file: myFiles, success: function () { // upload is complete }, progress: function (p) { // upload is progressing }, cancel: function () { // upload was cancelled }, error: function (e) { // an error occured } }; OneDrive.save(saverOptions); </code></pre> <p>I have used the above code for DropBox and it works well because it takes an array of objects but i cant find solution for OneDrive.com! Below documentation only shows how to upload a single file using URL. but i want to upload multiple files.</p> <p>The Format From The OneDrive Site</p> <pre><code>var saverOptions = { file: "inputFile", fileName: 'file.txt', success: function(){ // upload is complete }, progress: function(p) { // upload is progressing }, cancel: function(){ // upload was cancelled }, error: function(e) { // an error occured } } </code></pre> <p><a href="https://dev.onedrive.com/sdk/javascript-picker-saver.htm" rel="nofollow">https://dev.onedrive.com/sdk/javascript-picker-saver.htm</a></p> |
26,991,563 | 0 | <pre><code>Write getting success code on postExecute(), i.e. class CreateUser extends AsyncTask<String, String, String> { /** * Before starting background thread Show Progress Dialog * */ boolean failure = false; @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(Register.this); pDialog.setMessage("Creating User..."); pDialog.setIndeterminate(false); pDialog.setCancelable(true); pDialog.show(); } @Override protected String doInBackground(String... args) { // TODO Auto-generated method stub // Check for success tag int success; String username = user.getText().toString(); String password = pass.getText().toString(); try { // Building Parameters List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("username", username)); params.add(new BasicNameValuePair("password", password)); Log.d("request!", "starting"); //Posting user data to script JSONObject json = jsonParser.makeHttpRequest( LOGIN_URL, "POST", params); } catch (JSONException e) { e.printStackTrace(); } return null; } /** * After completing background task Dismiss the progress dialog * **/ protected void onPostExecute(String file_url) { // dismiss the dialog once product deleted pDialog.dismiss(); // full json response Log.d("Login attempt", json.toString()); // json success element success = json.getInt(TAG_SUCCESS); if (success == 1) { Log.d("User Created!", json.toString()); finish(); return json.getString(TAG_MESSAGE); }else{ Log.d("Login Failure!", json.getString(TAG_MESSAGE)); return json.getString(TAG_MESSAGE); } if (file_url != null){ Toast.makeText(Register.this, file_url, Toast.LENGTH_LONG).show(); } } </code></pre> |
12,516,152 | 0 | <p>You can get both like this:</p> <pre><code>RewriteRule ^([A-Za-z-0-9-]+)/([A-Za-z0-9-]+)/?$ $1/$2?param1=$2 RewriteRule ^([A-Za-z-0-9-]+)/([A-Za-z0-9-/]+)/?$ $1.php?param=$2 [L,QSA] </code></pre> <p>The other thing is your second grouping in your second rule won't match a trailing slash because <code>([A-Za-z0-9-/]+)</code> is greedy and will gobble up a trailing slash. You can make it ungreedy by adding a <code>?</code>: <code>([A-Za-z0-9-/]+?)</code></p> |
34,325,472 | 0 | Angular define input of float value <p>How would i define my input to be persistently be a float value and accept float values only ? below is my code but does not work as intended ?</p> <pre><code> <input type="number" step="0.01" placeholder="Amount" class="form-control" ng-model="choice.amount"/> </code></pre> |
32,697,700 | 0 | <p>This query would work</p> <pre><code>select t1.*,t2.pos from Table1 t1 left outer join Table2 t2 on t1.Date=t2.Date and t1.UserID=t2.UserID </code></pre> |
15,809,571 | 0 | Trigger JavaScript event that fires after client side control is rendered <p>Good day,</p> <p>I have a web page where the user makes a selection in a dropdown.</p> <p>As soon as the item in the dropdown is selected, a Kendo grid appears and displays a list of records retrieved via an API call that returns JSON.</p> <p>I have written code that does certain modifications to the html table that is generated when the grid displays, but this code is triggered by a button at the moment. This is not the behavior I want.</p> <p>I need to somehow fire an event after the grid renders so that the code is executed automatically and not triggered by a button.</p> <p>Is there a possibility that via JQuery I could somehow bind an event to fire after the grid control has finished rendering?</p> <p>P.S. None of the existing Kendo grid events in the documentation work for what I need, not even the datasource "requestEnd", because at that moment in time, the HTML for the grid has not been generated in the page. An event like "postRender" or something like that would be ideal if it existed.</p> |
22,406,605 | 0 | <p>The difference is in what default encoding is used. From <a href="http://technet.microsoft.com/en-us/library/hh847827.aspx">MSDN</a>, we can see that <code>Set-Content</code> defaults to ASCII encoding, which is readable by most programs (but may not work if you're not writing english). The <code>></code> output redirection operator on the other hand works with Powershell's internal string representation, which is .Net <code>System.String</code>, which is UTF-16 (<a href="http://www.johndcook.com/blog/2008/08/25/powershell-output-redirection-unicode-or-ascii/">reference</a>)</p> <p>As a side-note, you can also use <code>Out-File</code>, which uses unicode encoding.</p> |
35,946,714 | 0 | <pre><code>PriorityQueue<integer> pq = new PriorityQueue<integer> ( new Comparator<integer> () { public int compare(Integer a, Integer b) { return b - a; } } ); </code></pre> |
30,177,082 | 0 | <p>I have solved it by installing curl ssl</p> <pre><code>/scripts/easyapache option 7 on the menu select PHP scroll down and select CURL with SSL exit save </code></pre> <p>Everything is working now</p> |
3,305,976 | 0 | <p>The short answer is no, not at this time. The iPhone/iPad/iPod Touch work nativly with the Apple HTTP Adaptive segmented streaming protocols. MMS (Windows Media) streams are not compatible with "i" devices and will not play. You will need to look into encoding your video with this other format. <a href="http://developer.apple.com/iphone/library/documentation/networkinginternet/conceptual/streamingmediaguide/introduction/introduction.html" rel="nofollow noreferrer">Check out the Apple specs</a> for a full description of the protocol. Future versions of Windows Media Services (4.0) are claiming that they will support the Apple protocols but this is only a preview/beta at this time and may not truly support the Apple specs.</p> <p>If your trying to do ondemand iPhone video, you can utilize a service such as Encoding.com to pre encode your files in the adaptive segmented format for your users to view. For live encoding, Telestream has a product called Wirecast which can encode in a h.264 Apple approved baseline format which can be sent to a service such as Akamai, Multicast Media, or Wowza Server for distribution to your clients. Hope this helps!</p> |
10,103,395 | 0 | <p>Assuming the deprecated library works as it always has, as it should, this is the procedure I have used to colour my tabs. I just set the background in code as follows, as it wasn't direcly accessible in xml:</p> <pre><code> TabWidget tabs = (TabWidget)getTabWidget(); for (int i = 0; i<tabs.getChildCount(); i++) { RelativeLayout tab = (RelativeLayout) tabs.getChildAt(i); tab.setBackgroundDrawable(this.getResources().getDrawable(R.drawable.tabindicator)); </code></pre> <p>The tabindicator drawable is as follows:</p> <pre><code><?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Non focused states --> <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected" /> <item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected" /> <!-- Focused states --> <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_focus" /> <item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_focus" /> <!-- Pressed --> <item android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_press" /> <item android:state_pressed="true" android:drawable="@drawable/tab_press" /> </selector> </code></pre> <p>The drawables were just 9-patch images with the colour, although you may be able to get a similar effect using a standard colour.</p> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.