qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
25,055,712
`Dataframe.resample()` works only with timeseries data. I cannot find a way of getting every nth row from non-timeseries data. What is the best method?
2014/07/31
[ "https://Stackoverflow.com/questions/25055712", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1014352/" ]
I'd use `iloc`, which takes a row/column slice, both based on integer position and following normal python syntax. If you want every 5th row: ``` df.iloc[::5, :] ```
Though @chrisb's accepted answer does answer the question, I would like to add to it the following. A simple method I use to get the `nth` data or drop the `nth` row is the following: ``` df1 = df[df.index % 3 != 0] # Excludes every 3rd row starting from 0 df2 = df[df.index % 3 == 0] # Selects every 3rd raw starting from 0 ``` This arithmetic based sampling has the ability to enable even more complex row-selections. This **assumes**, of course, that you have an `index` column of *ordered, consecutive, integers* starting at 0.
24,415,148
I have a page that references an external javascript file, and when I tell it run a function onload, it is giving me errors (I assume because it is firing before the page is loaded.) "Cannot set property 'innerHTML' of null" What do I need to do here to fire run() after the page is loaded? HTML ``` <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test</title> <script type="text/javascript" src="js/test.js"></script> </head> <body> <div id="test"></div> </body> </html> ``` JS ``` window.onload = run(); function run() { document.getElementById("test").innerHTML = "found it"; } ```
2014/06/25
[ "https://Stackoverflow.com/questions/24415148", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1229571/" ]
Your Rails -v and Ruby -v are correct for this tutorial. I can also see from the input that your `gemfile` has `gem 'sqlite3', '1.3.8'` in it. 1: Have you bundled? -------------------- When was the last time you ran `bundle update` or `bundle install`? How did you go about uninstalling sqlite3? Did you use `$ gem uninstall sqlite3`? Try uninstalling and then reinstalling the gem. 2: - What version manager? -------------------------- Did you use rvm, rbenv or homebrew to install? Using different version managers for different pieces can create communication issues. 3: Did you install Xcode? ------------------------- This is taken from <http://www.railstutorial.org>: --- "As a prerequisite, OS X users may need to install the Xcode developer tools. To avoid the (huge) full installation, I recommend the much smaller Command Line Tools for Xcode. --- To install Xcode (my recommendation), look it up in the AppStore. To install Command Line Tools (MHartl's recommendation) - <https://developer.apple.com/downloads/> 4: Are you using `bundle exec`? ------------------------------- Try `bundle exec rails c` and `bundle exec rails s` 5: Try 'refreshing' your bundle directory ----------------------------------------- If `bundle exec` doesn't work Remove the .bundle/ directory and re-bundle with ``` rm -rf .bundle/ && bundle ```
I experienced the same issue, I just switched to a different ruby version e.g; ``` rvm use 1.9.3-p484 ``` and then bundle again.
589,001
1) Assume that there exist homomorphisms $f:\mathbb{Z} \rightarrow S\_{3}$ where $\ker(f)\neq \mathbb{Z}$? What are the possible kernels? Explain. 2) Lest at least two non-trivial homomorphisms $f:\mathbb{Z} \rightarrow S\_{3}$ whose kernel are not $\mathbb{Z}$.
2013/12/02
[ "https://math.stackexchange.com/questions/589001", "https://math.stackexchange.com", "https://math.stackexchange.com/users/112778/" ]
Note that if $\ker(f) \neq \mathbb{Z}$, then $f(1) \neq e$ ($e$ referring to the identity of $S\_3$). Why? With the above established, we have two possibilities: either the order of $f(1)$ is $2$, or the order of $f(1)$ is $3$. In the first case, we have $f(2k) = f(2)^k = e^k = e$, so that $\ker(f) = 2\mathbb{Z}$. Similarly, in the second case, we have $\ker(f) = 3\mathbb{Z}$. **Examples:** * $f:\mathbb{Z}\to S\_3, f(k) = (1\quad 2)^k$ * $f:\mathbb{Z}\to S\_3, f(k) = (1\quad 2\quad 3)^k$
Hint : $\mathbb{Z}\_2$ and $\mathbb{Z}\_3$ are subgroups of $S\_3$ (of course upto isomorphism) .
40,454,714
I'm dying to solve my problem with autogenerated input in a span. I'm using the Wordpress plugin Contact Form 7 on my website and I want so animate the label while the user in using the input field. When the input-field is on focus or something is typed in it, the class active should appear in the div with the class "grid-3". I tried to get the javascript myself but it doesnt works: ``` $('.wpcf7-form-control-wrap').each(function() { //console.log($(this)); $(this).on('focus', function() { $(this).parent().parent().addClass('active'); }); $(this).on('blur', function() { if ($(this).val().length == 0) { $(this).parent().parent().removeClass('active'); } }); if ($(this).val() != '') $(this).parent('.grid-3').addClass('active'); }); ``` The HTML: ``` <div class="grid-3"> <label for="schenkel2">Schenkel 2 in mm</label> <span class="wpcf7-form-control-wrap schenkel2"> <input type="text" name="schenkel2" value="" size="40" class="wpcf7-form-control wpcf7-text" id="schenkel2" aria-invalid="false"> </span> </div> ```
2016/11/06
[ "https://Stackoverflow.com/questions/40454714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6291344/" ]
Your logic looks fine, although instead walking up two parent nodes, I'd suggest crawling up the DOM tree until you find the class you're looking for. That way it is less likely to break with changes to the DOM. In vanilla javascript something like the following should do the job. Note that it uses [classList](http://caniuse.com/#search=classlist) which you may need to polyfill for older versions of IE. ```js /** * Walk up DOM tree to get parent element with the matching class * @param {Element} Element to search from * @param {string} The class name to identify target parent * @return {Element} The parent element with targetClass or null of we reach the top of the DOM tree **/ function getTargetParent(elem, targetClass) { var currElem = elem; while( currElem && !currElem.classList.contains(targetClass) ) { currElem = currElem.parentNode; } return currElem; } /** * Add a focus event listener to an element to add "focus" class on the parent identified by targetClass **/ function addFocusListener(elem, targetClass) { var targetParent = getTargetParent(elem, targetClass); if(targetParent) { elem.addEventListener('focus', function() { targetParent.classList.add('focus'); }); elem.addEventListener('blur', function() { targetParent.classList.remove('focus'); }); } } var inputs = document.getElementsByClassName('wpcf7-form-control'); for(var i = 0; i < inputs.length; i++) { addFocusListener(inputs[i], 'grid-3'); } ``` ```css .focus { color: red; } ``` ```html <div class="grid-3"> <label for="schenkel2">Schenkel 2 in mm</label> <span class="wpcf7-form-control-wrap schenkel2"> <input type="text" name="schenkel2" value="" size="40" class="wpcf7-form-control wpcf7-text" id="schenkel2" aria-invalid="false"> </span> </div> ```
Do you use CSS for this ? I think u can achieve it easily with CSS3 ``` <div class="grid-3"> <label for="schenkel2">Schenkel 2 in mm</label> <span class="wpcf7-form-control-wrap schenkel2"> <input type="text" name="schenkel2" value="" size="40" class="wpcf7-form-control wpcf7-text inputHover" id="schenkel2" aria-invalid="false"> ``` ``` input[type=text], textarea { -webkit-transition: all 0.30s ease-in-out; -moz-transition: all 0.30s ease-in-out; -ms-transition: all 0.30s ease-in-out; -o-transition: all 0.30s ease-in-out; outline: none; padding: 3px 0px 3px 3px; margin: 5px 1px 3px 0px; border: 1px solid #DDDDDD; } #inputHover:focus { box-shadow: 0 0 5px #EC8937; padding: 3px 0px 3px 3px; margin: 5px 1px 3px 0px; border: 1px solid #EC8937; } ``` above first one is to add the default styles for a text area and second CSS is to get the on focus effect add the inputHover class into your Input tag and check
59,384,333
I have some text that i am trying to change the styling on based on route name.I have set up 2 route names, ads and webs and have set up a watcher to watch the routes. If the route name is either ads or webs i want the text to have `color:white;background-color:orange`. But i am not sure how to do it. ```js new Vue({ el: '#app', data() { return { styleClass: null } }, watch: { '$route' (to, from) { if (to.name == 'ads' || to.name == 'webs') { } } } }) ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script> <div id="app"> <span><h1>Hello!!!</h1></span> </div> ```
2019/12/18
[ "https://Stackoverflow.com/questions/59384333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11505813/" ]
I'd create a computed property to represent if the current route matches your criteria. ```js computed: { highlight () { return this.$route.matched.some(({ name }) => /^(ad|web)s$/.test(name)) } } ``` Then you can use that in a `class` binding expression. ```html <span :class="{ highlight }">Text goes here</span> ``` and in your CSS ```css .highlight { color: white; background-color: orange; } ``` See <https://router.vuejs.org/api/#route-object-properties> for info on the `matched` property.
I guess you are missing the route vuejs plugin and name your application into the route name too. Here the full example. Hope you get what you want ```js const Foo = { template: '<div>foo</div>' } const Bar = { template: '<div>bar</div>' } const routes = [ { path: '/foo', component: Foo, name: 'ads' }, { path: '/bar', component: Bar, name: 'nowebs' } ] const router = new VueRouter({ routes }) const app = new Vue({ router, data() { return { styleClass: null } }, watch: { '$route' (to, from) { if (to.name == 'ads' || to.name == 'webs') { this.styleClass = "color:white;background-color:orange" } else { this.styleClass = "" } } } }).$mount('#app') ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script> <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script> <script src="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js"></script> <div id="app"> <span><h1 :style="styleClass">Hello!!!</h1></span> <p> <router-link to="/foo">Go to Foo</router-link> <router-link to="/bar">Go to Bar</router-link> </p> <router-view></router-view> </div> ```
42,499
Simon Blackburn is describing the Poetic Interpretation of ascending from Plato's Cave: > > Part of the charm of Plato is the sense of being in a world in which these fractures did not exist. Ours may be a world in which there is a division between fact on the one hand, and value on the other. But his world is, in the phrase of the godfather of modern sociology, Max Weber, an enchanted world, in which ideas like proportion and harmony efface any such division. Beauty makes both goodness and truth manifest, so its perception and the love it engenders together give us the first step out of the Cave. Beauty is the first erasure of the distinction between fact and value. It is borne in upon us, in erotic experience, like facts. But it is intrinsically or essentially connected with the values of pleasure and love. And just as it erases the fact-value distinction, so beauty erases the tyranny of the self. In loving something or someone for beauty’s sake we are, as Iris Murdoch says, ‘unselfed’. **Selfish desire has no place in the pure aesthetic experience.** > > > Does it mean that purity comes with the consequence of selflessness? That if one is clean and pure they must be selfless?
2017/05/18
[ "https://philosophy.stackexchange.com/questions/42499", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/4506/" ]
"Does [Selfish desire has no place in the pure aesthetic experience] mean that purity comes with the consequence of selflessness? That if one is clean and pure they must be selfless?" No, no, no. the causal relationship is the other way around. It is not the selflessness that allows you to experience purity, but it is the purity of (aesthetic) experience that allows you to become self-less. Purity of (aesthetic) experience happens, when you read a great poem or watch an awesome movie, and you lose you spatio-temporal self and become the person in the poem or the movie. When I finally understood Robert Francis' Pitcher, I lost myself and became the Pitcher for a moment (the poem provided at the end of this post). Selflessness, for Blackburn, is not meant to be the opposite to selfishness. Rather it is the sublime self who is able to see things for their intrinsic values, no longer interpreting everything as an instrument to further one's needs and desires. By this way, the sublime self can also experience other values like the goodness. The hitherto self-interested self comes to understand that experiencing (doing) the good is intrinsically valuable, just as experiencing the beauty. In other words, the selflessness activated by the aesthetic experience is transmitted into the moral self (other-regarding self). This is why some argue that aesthetics is the mother of ethics (e.g., Marcia Eaton) The possibility of self-lessness through the aesthetic experience is important to Blackburn since such a possibility allows him to elaborate his projection theory. According to him, the reason that this world is a moral world, despite the absence of moral facts in this world (so-called the analytic world, world inhabited by brute facts), is that our moral values, just like aesthetic values, acquired through language games, are projected (or spread) onto the analytic world. Pitcher ------- His art is eccentricity, his aim How not to hit the mark he seems to aim at, --- His passion how to avoid the obvious, His technique how to vary the avoidance. --- The others throw to be comprehended. He Throws to be a moment misunderstood. --- Yet not too much. Not errant, arrant, wild, But every seeming aberration willed. --- Not to, yet still, still to communicate Making the batter understand too late.
I believe that the phrase explains that beauty in aesthetics is an a priori knowledge that is simultaneously the highest positive value and personification of truth. Aesthetics is an experiential phenomena that is external to ourselves and, ostensibly, is an appreciation for the truth of beauty (which is perceived as a universal concept in the author's theory). It is not related to one's person satisfaction, but an a priori truth and value accessed through this appreciation. Therefore, it is intrinsically "unselfed". > > Does it mean that purity comes with the consequence of selflessness? That if one is clean and pure they must be selfless? > > > I believe that the author's intent is that the practice of aesthetics -*appreciation of true beauty* - is itself unselfish - neither the beautiful thing, nor the actor, is unselfish. It is more descriptive of the person's experiencing the beauty (in that moment), rather than the beautiful thing in-itself.
2,073,574
I am using the [python-ldap](http://www.python-ldap.org/) module to (amongst other things) search for groups, and am running into the server's size limit and getting a `SIZELIMIT_EXCEEDED` exception. I have tried both synchronous and asynchronous searches and hit the problem both ways. You are supposed to be able to work round this by setting a paging control on the search, but according to the python-ldap docs these controls are not yet implemented for `search_ext()`. Is there a way to do this in Python? If the `python-ldap` library does not support it, is there another Python library that does?
2010/01/15
[ "https://Stackoverflow.com/questions/2073574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/206417/" ]
Here are some links related to paging in python-ldap. * Documentation: <http://www.python-ldap.org/doc/html/ldap-controls.html#ldap.controls.SimplePagedResultsControl> * Example code using paging: <http://www.novell.com/coolsolutions/tip/18274.html> * More example code: <http://google-apps-for-your-domain-ldap-sync.googlecode.com/svn/trunk/ldap_ctxt.py>
After some discussion on the python-ldap-dev mailing list, I can answer my own question. Page controls ARE supported by the Python lDAP module, but the docs had not been updated for search\_ext to show that. The [example linked by Gorgapor](http://www.novell.com/coolsolutions/tip/18274.html) shows how to use the ldap.controls.SimplePagedResultsControl to read the results in pages. However there is a gotcha. This will work with Microsoft Active Directory servers, but not with OpenLDAP servers (and possibly others, such as Sun's). The [LDAP controls RFC](http://www.ietf.org/rfc/rfc2696.txt) is ambiguous as to whether paged controls should be allowed to override the server's sizelimit setting. On ActiveDirectory servers they can by default while on OpenLDAP they cannot, but I think there is a server setting that will allow them to. So even if you implement the paged control, there is still no guarantee that it will get all the objects that you want. *Sigh* Also paged controls are only available with LDAP v3, but I doubt that there are many v2 servers in use.
49,423,221
My date range is ``` var currDay = Jan.1 var birthday = Feb.15 ``` I know that to find the difference in number of weeks is ``` currDay.diff(birthday, 'week') ``` However, is there a way to find the full weeks and the remaining days?
2018/03/22
[ "https://Stackoverflow.com/questions/49423221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2394970/" ]
You can make use of [`duration`](http://momentjs.com/docs/#/durations/). You can get the years, months (excludes years) and days (excludes years and months) using this. Only problem is weeks are calculated using the value of days so you'd still have to get the remainder on days if you're getting the number of weeks. From [momentjs docs](https://momentjs.com/docs/#/durations/weeks/): > > Pay attention that unlike the other getters for duration, weeks are > counted as a subset of the days, and are not taken off the days count. > > > Note: If you want the total number of weeks use `asWeeks()` instead of `weeks()` ```js var currDay = moment("2018-01-01"); var birthday = moment("2018-02-16"); var diff = moment.duration(birthday.diff(currDay)); console.log(diff.months() + " months, " + diff.weeks() + " weeks, " + diff.days()%7 + " days."); console.log(Math.floor(diff.asWeeks()) + " weeks, " + diff.days()%7 + " days."); ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.21.0/moment.min.js"></script> ```
```js var currDay = moment("Jan.1","MMM.DD"); var birthday = moment("Feb.15","MMM.DD"); var diff = moment.duration(birthday.diff(currDay)); console.log(diff.weeks() +" weeks & "+ diff.days()%7 +" days to go for birthday"); ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.21.0/moment.min.js"></script> ```
45,434,944
I made a sample form validation using only plain javascript. Everything was ok until I decided to store the two functions inside an event callback function. I did it so my javascript file can only have lesser lines of code. The callback function can only execute one function. ```js var query = document.querySelector.bind(document); function isBlank(element) { var isblank = (!element.value) ? true : false; element.setAttribute('data-error', isblank); return isblank; } function isInvalid(element, regex) { var invalidValue = (!element.value.match(regex)) ? true : false; element.setAttribute('data-error', invalidValue); return invalidValue; } function checkInput(e) { var $this = e.target; return [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ]; } query('#name').addEventListener('blur', checkInput); ``` ```css form input[name] { border: 1px solid #ccc; } form input[data-error="true"] { border-color: red; } form input[data-error="false"] { border-color: #ccc; } ``` ```html <form action="" method="post"> <input type="text" name="name" id="name" placeholder="Name" data-error=""><span class="message"></span><br> <input type="submit" value="Submit"> </form> ``` I also tried the following two options, but it didn't work either: ``` function checkInput(e) { var $this = e.target; return { execute: [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ] }; } function checkInput(e) { var $this = e.target; isBlank($this); isInvalid($this, /^[a-zA-Z ]*$/); } ``` How can I fix it but make the code cleaner and more organized?
2017/08/01
[ "https://Stackoverflow.com/questions/45434944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You should do this as a two-step process: First you parse out the `CompatibleVersions` attribute, and then you split out those version numbers. Otherwise you will have difficulties finding the version numbers individually without likely finding otheer version-like numbers. ``` $s = '[assembly: CompatibleVersions("1.7.1.0","1.7.1.1","1.2.2.3")]' $versions = ($s | Select-String -Pattern 'CompatibleVersions\(([^)]+)\)' | % { $_.Matches }).Groups[1].Value $versions.Split(',') | % { $_.Trim('"') } | Write-Host # 1.7.1.0 # 1.7.1.1 # 1.2.2.3 ```
You may use ``` $s | select-string -pattern "\d+(?:\.\d+)+" -AllMatches | Foreach {$_.Matches} | ForEach-Object {$_.Value} ``` The `\d+(?:\.\d+)+` pattern will match: * `\d+` - 1 or more digits * `(?:\.\d+)+` - 1 or more sequences of a `.` and 1+ digits. [![enter image description here](https://i.stack.imgur.com/VTSSk.png)](https://i.stack.imgur.com/VTSSk.png) See the [**regex demo on RegexStorm**](http://regexstorm.net/tester?p=%5Cd%2B%28%3F%3A%5C.%5Cd%2B%29%2B&i=%5Bassembly%3A%20CompatibleVersions%28%221.7.1.0%22%2C%221.7.1.1%22%2C%221.2.2.3%22%29%5D).
45,434,944
I made a sample form validation using only plain javascript. Everything was ok until I decided to store the two functions inside an event callback function. I did it so my javascript file can only have lesser lines of code. The callback function can only execute one function. ```js var query = document.querySelector.bind(document); function isBlank(element) { var isblank = (!element.value) ? true : false; element.setAttribute('data-error', isblank); return isblank; } function isInvalid(element, regex) { var invalidValue = (!element.value.match(regex)) ? true : false; element.setAttribute('data-error', invalidValue); return invalidValue; } function checkInput(e) { var $this = e.target; return [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ]; } query('#name').addEventListener('blur', checkInput); ``` ```css form input[name] { border: 1px solid #ccc; } form input[data-error="true"] { border-color: red; } form input[data-error="false"] { border-color: #ccc; } ``` ```html <form action="" method="post"> <input type="text" name="name" id="name" placeholder="Name" data-error=""><span class="message"></span><br> <input type="submit" value="Submit"> </form> ``` I also tried the following two options, but it didn't work either: ``` function checkInput(e) { var $this = e.target; return { execute: [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ] }; } function checkInput(e) { var $this = e.target; isBlank($this); isInvalid($this, /^[a-zA-Z ]*$/); } ``` How can I fix it but make the code cleaner and more organized?
2017/08/01
[ "https://Stackoverflow.com/questions/45434944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You may use ``` $s | select-string -pattern "\d+(?:\.\d+)+" -AllMatches | Foreach {$_.Matches} | ForEach-Object {$_.Value} ``` The `\d+(?:\.\d+)+` pattern will match: * `\d+` - 1 or more digits * `(?:\.\d+)+` - 1 or more sequences of a `.` and 1+ digits. [![enter image description here](https://i.stack.imgur.com/VTSSk.png)](https://i.stack.imgur.com/VTSSk.png) See the [**regex demo on RegexStorm**](http://regexstorm.net/tester?p=%5Cd%2B%28%3F%3A%5C.%5Cd%2B%29%2B&i=%5Bassembly%3A%20CompatibleVersions%28%221.7.1.0%22%2C%221.7.1.1%22%2C%221.2.2.3%22%29%5D).
`'"([.\d]+)"'` will match any substring composed of dots and digits (`\d`) and comprised into double quotes (") [Try it here](https://regex101.com/r/lh4cv1/1)
45,434,944
I made a sample form validation using only plain javascript. Everything was ok until I decided to store the two functions inside an event callback function. I did it so my javascript file can only have lesser lines of code. The callback function can only execute one function. ```js var query = document.querySelector.bind(document); function isBlank(element) { var isblank = (!element.value) ? true : false; element.setAttribute('data-error', isblank); return isblank; } function isInvalid(element, regex) { var invalidValue = (!element.value.match(regex)) ? true : false; element.setAttribute('data-error', invalidValue); return invalidValue; } function checkInput(e) { var $this = e.target; return [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ]; } query('#name').addEventListener('blur', checkInput); ``` ```css form input[name] { border: 1px solid #ccc; } form input[data-error="true"] { border-color: red; } form input[data-error="false"] { border-color: #ccc; } ``` ```html <form action="" method="post"> <input type="text" name="name" id="name" placeholder="Name" data-error=""><span class="message"></span><br> <input type="submit" value="Submit"> </form> ``` I also tried the following two options, but it didn't work either: ``` function checkInput(e) { var $this = e.target; return { execute: [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ] }; } function checkInput(e) { var $this = e.target; isBlank($this); isInvalid($this, /^[a-zA-Z ]*$/); } ``` How can I fix it but make the code cleaner and more organized?
2017/08/01
[ "https://Stackoverflow.com/questions/45434944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You may use ``` $s | select-string -pattern "\d+(?:\.\d+)+" -AllMatches | Foreach {$_.Matches} | ForEach-Object {$_.Value} ``` The `\d+(?:\.\d+)+` pattern will match: * `\d+` - 1 or more digits * `(?:\.\d+)+` - 1 or more sequences of a `.` and 1+ digits. [![enter image description here](https://i.stack.imgur.com/VTSSk.png)](https://i.stack.imgur.com/VTSSk.png) See the [**regex demo on RegexStorm**](http://regexstorm.net/tester?p=%5Cd%2B%28%3F%3A%5C.%5Cd%2B%29%2B&i=%5Bassembly%3A%20CompatibleVersions%28%221.7.1.0%22%2C%221.7.1.1%22%2C%221.2.2.3%22%29%5D).
A number between .. can be 0, but cannot be 00, 01 or similar. Pay attention to the starting [ This is a regex for the check: ``` ^\[assembly: CompatibleVersions\("(?:[1-9]\d*|0)(?:\.(?:[1-9]\d*|0)){3}"(?:,"(?:[1-9]\d*|0)(?:\.(?:[1-9]\d*|0)){3}")*\)]$ ``` [Here](https://regex101.com/r/wEcCk3/2) is the regex with tests. But if you are reading a list, you should use instead: ``` ^\[assembly: CompatibleVersions\("((?:[1-9]\d*|0)(?:\.(?:[1-9]\d*|0)){3}"(?:,"(?:[1-9]\d*|0)(?:\.(?:[1-9]\d*|0)){3}")*)\)]$ ``` By it you will extract the "...","..."... consequence from the inner parenthesis. After that split the result string by '","' into a list and remove last " from the last element and the first " from the first element. Now you have list of correct versions Strings. Alas, regex cannot create a list without split() function.
45,434,944
I made a sample form validation using only plain javascript. Everything was ok until I decided to store the two functions inside an event callback function. I did it so my javascript file can only have lesser lines of code. The callback function can only execute one function. ```js var query = document.querySelector.bind(document); function isBlank(element) { var isblank = (!element.value) ? true : false; element.setAttribute('data-error', isblank); return isblank; } function isInvalid(element, regex) { var invalidValue = (!element.value.match(regex)) ? true : false; element.setAttribute('data-error', invalidValue); return invalidValue; } function checkInput(e) { var $this = e.target; return [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ]; } query('#name').addEventListener('blur', checkInput); ``` ```css form input[name] { border: 1px solid #ccc; } form input[data-error="true"] { border-color: red; } form input[data-error="false"] { border-color: #ccc; } ``` ```html <form action="" method="post"> <input type="text" name="name" id="name" placeholder="Name" data-error=""><span class="message"></span><br> <input type="submit" value="Submit"> </form> ``` I also tried the following two options, but it didn't work either: ``` function checkInput(e) { var $this = e.target; return { execute: [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ] }; } function checkInput(e) { var $this = e.target; isBlank($this); isInvalid($this, /^[a-zA-Z ]*$/); } ``` How can I fix it but make the code cleaner and more organized?
2017/08/01
[ "https://Stackoverflow.com/questions/45434944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You should do this as a two-step process: First you parse out the `CompatibleVersions` attribute, and then you split out those version numbers. Otherwise you will have difficulties finding the version numbers individually without likely finding otheer version-like numbers. ``` $s = '[assembly: CompatibleVersions("1.7.1.0","1.7.1.1","1.2.2.3")]' $versions = ($s | Select-String -Pattern 'CompatibleVersions\(([^)]+)\)' | % { $_.Matches }).Groups[1].Value $versions.Split(',') | % { $_.Trim('"') } | Write-Host # 1.7.1.0 # 1.7.1.1 # 1.2.2.3 ```
Start by grabbing the parentheses pair and everything inside: ``` $string = '[assembly: CompatibleVersions("1.7.1.0","1.7.1.1","1.2.2.3")]' if($string -match '\(([^)]+)\)'){ # Remove the parentheses themselves, split by comma and then trim the " $versionList = $Matches[0].Trim("()") -split ',' |ForEach-Object Trim '"' } ```
45,434,944
I made a sample form validation using only plain javascript. Everything was ok until I decided to store the two functions inside an event callback function. I did it so my javascript file can only have lesser lines of code. The callback function can only execute one function. ```js var query = document.querySelector.bind(document); function isBlank(element) { var isblank = (!element.value) ? true : false; element.setAttribute('data-error', isblank); return isblank; } function isInvalid(element, regex) { var invalidValue = (!element.value.match(regex)) ? true : false; element.setAttribute('data-error', invalidValue); return invalidValue; } function checkInput(e) { var $this = e.target; return [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ]; } query('#name').addEventListener('blur', checkInput); ``` ```css form input[name] { border: 1px solid #ccc; } form input[data-error="true"] { border-color: red; } form input[data-error="false"] { border-color: #ccc; } ``` ```html <form action="" method="post"> <input type="text" name="name" id="name" placeholder="Name" data-error=""><span class="message"></span><br> <input type="submit" value="Submit"> </form> ``` I also tried the following two options, but it didn't work either: ``` function checkInput(e) { var $this = e.target; return { execute: [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ] }; } function checkInput(e) { var $this = e.target; isBlank($this); isInvalid($this, /^[a-zA-Z ]*$/); } ``` How can I fix it but make the code cleaner and more organized?
2017/08/01
[ "https://Stackoverflow.com/questions/45434944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Start by grabbing the parentheses pair and everything inside: ``` $string = '[assembly: CompatibleVersions("1.7.1.0","1.7.1.1","1.2.2.3")]' if($string -match '\(([^)]+)\)'){ # Remove the parentheses themselves, split by comma and then trim the " $versionList = $Matches[0].Trim("()") -split ',' |ForEach-Object Trim '"' } ```
`'"([.\d]+)"'` will match any substring composed of dots and digits (`\d`) and comprised into double quotes (") [Try it here](https://regex101.com/r/lh4cv1/1)
45,434,944
I made a sample form validation using only plain javascript. Everything was ok until I decided to store the two functions inside an event callback function. I did it so my javascript file can only have lesser lines of code. The callback function can only execute one function. ```js var query = document.querySelector.bind(document); function isBlank(element) { var isblank = (!element.value) ? true : false; element.setAttribute('data-error', isblank); return isblank; } function isInvalid(element, regex) { var invalidValue = (!element.value.match(regex)) ? true : false; element.setAttribute('data-error', invalidValue); return invalidValue; } function checkInput(e) { var $this = e.target; return [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ]; } query('#name').addEventListener('blur', checkInput); ``` ```css form input[name] { border: 1px solid #ccc; } form input[data-error="true"] { border-color: red; } form input[data-error="false"] { border-color: #ccc; } ``` ```html <form action="" method="post"> <input type="text" name="name" id="name" placeholder="Name" data-error=""><span class="message"></span><br> <input type="submit" value="Submit"> </form> ``` I also tried the following two options, but it didn't work either: ``` function checkInput(e) { var $this = e.target; return { execute: [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ] }; } function checkInput(e) { var $this = e.target; isBlank($this); isInvalid($this, /^[a-zA-Z ]*$/); } ``` How can I fix it but make the code cleaner and more organized?
2017/08/01
[ "https://Stackoverflow.com/questions/45434944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Start by grabbing the parentheses pair and everything inside: ``` $string = '[assembly: CompatibleVersions("1.7.1.0","1.7.1.1","1.2.2.3")]' if($string -match '\(([^)]+)\)'){ # Remove the parentheses themselves, split by comma and then trim the " $versionList = $Matches[0].Trim("()") -split ',' |ForEach-Object Trim '"' } ```
A number between .. can be 0, but cannot be 00, 01 or similar. Pay attention to the starting [ This is a regex for the check: ``` ^\[assembly: CompatibleVersions\("(?:[1-9]\d*|0)(?:\.(?:[1-9]\d*|0)){3}"(?:,"(?:[1-9]\d*|0)(?:\.(?:[1-9]\d*|0)){3}")*\)]$ ``` [Here](https://regex101.com/r/wEcCk3/2) is the regex with tests. But if you are reading a list, you should use instead: ``` ^\[assembly: CompatibleVersions\("((?:[1-9]\d*|0)(?:\.(?:[1-9]\d*|0)){3}"(?:,"(?:[1-9]\d*|0)(?:\.(?:[1-9]\d*|0)){3}")*)\)]$ ``` By it you will extract the "...","..."... consequence from the inner parenthesis. After that split the result string by '","' into a list and remove last " from the last element and the first " from the first element. Now you have list of correct versions Strings. Alas, regex cannot create a list without split() function.
45,434,944
I made a sample form validation using only plain javascript. Everything was ok until I decided to store the two functions inside an event callback function. I did it so my javascript file can only have lesser lines of code. The callback function can only execute one function. ```js var query = document.querySelector.bind(document); function isBlank(element) { var isblank = (!element.value) ? true : false; element.setAttribute('data-error', isblank); return isblank; } function isInvalid(element, regex) { var invalidValue = (!element.value.match(regex)) ? true : false; element.setAttribute('data-error', invalidValue); return invalidValue; } function checkInput(e) { var $this = e.target; return [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ]; } query('#name').addEventListener('blur', checkInput); ``` ```css form input[name] { border: 1px solid #ccc; } form input[data-error="true"] { border-color: red; } form input[data-error="false"] { border-color: #ccc; } ``` ```html <form action="" method="post"> <input type="text" name="name" id="name" placeholder="Name" data-error=""><span class="message"></span><br> <input type="submit" value="Submit"> </form> ``` I also tried the following two options, but it didn't work either: ``` function checkInput(e) { var $this = e.target; return { execute: [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ] }; } function checkInput(e) { var $this = e.target; isBlank($this); isInvalid($this, /^[a-zA-Z ]*$/); } ``` How can I fix it but make the code cleaner and more organized?
2017/08/01
[ "https://Stackoverflow.com/questions/45434944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You should do this as a two-step process: First you parse out the `CompatibleVersions` attribute, and then you split out those version numbers. Otherwise you will have difficulties finding the version numbers individually without likely finding otheer version-like numbers. ``` $s = '[assembly: CompatibleVersions("1.7.1.0","1.7.1.1","1.2.2.3")]' $versions = ($s | Select-String -Pattern 'CompatibleVersions\(([^)]+)\)' | % { $_.Matches }).Groups[1].Value $versions.Split(',') | % { $_.Trim('"') } | Write-Host # 1.7.1.0 # 1.7.1.1 # 1.2.2.3 ```
`'"([.\d]+)"'` will match any substring composed of dots and digits (`\d`) and comprised into double quotes (") [Try it here](https://regex101.com/r/lh4cv1/1)
45,434,944
I made a sample form validation using only plain javascript. Everything was ok until I decided to store the two functions inside an event callback function. I did it so my javascript file can only have lesser lines of code. The callback function can only execute one function. ```js var query = document.querySelector.bind(document); function isBlank(element) { var isblank = (!element.value) ? true : false; element.setAttribute('data-error', isblank); return isblank; } function isInvalid(element, regex) { var invalidValue = (!element.value.match(regex)) ? true : false; element.setAttribute('data-error', invalidValue); return invalidValue; } function checkInput(e) { var $this = e.target; return [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ]; } query('#name').addEventListener('blur', checkInput); ``` ```css form input[name] { border: 1px solid #ccc; } form input[data-error="true"] { border-color: red; } form input[data-error="false"] { border-color: #ccc; } ``` ```html <form action="" method="post"> <input type="text" name="name" id="name" placeholder="Name" data-error=""><span class="message"></span><br> <input type="submit" value="Submit"> </form> ``` I also tried the following two options, but it didn't work either: ``` function checkInput(e) { var $this = e.target; return { execute: [ isBlank($this), isInvalid($this, /^[a-zA-Z ]*$/) ] }; } function checkInput(e) { var $this = e.target; isBlank($this); isInvalid($this, /^[a-zA-Z ]*$/); } ``` How can I fix it but make the code cleaner and more organized?
2017/08/01
[ "https://Stackoverflow.com/questions/45434944", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You should do this as a two-step process: First you parse out the `CompatibleVersions` attribute, and then you split out those version numbers. Otherwise you will have difficulties finding the version numbers individually without likely finding otheer version-like numbers. ``` $s = '[assembly: CompatibleVersions("1.7.1.0","1.7.1.1","1.2.2.3")]' $versions = ($s | Select-String -Pattern 'CompatibleVersions\(([^)]+)\)' | % { $_.Matches }).Groups[1].Value $versions.Split(',') | % { $_.Trim('"') } | Write-Host # 1.7.1.0 # 1.7.1.1 # 1.2.2.3 ```
A number between .. can be 0, but cannot be 00, 01 or similar. Pay attention to the starting [ This is a regex for the check: ``` ^\[assembly: CompatibleVersions\("(?:[1-9]\d*|0)(?:\.(?:[1-9]\d*|0)){3}"(?:,"(?:[1-9]\d*|0)(?:\.(?:[1-9]\d*|0)){3}")*\)]$ ``` [Here](https://regex101.com/r/wEcCk3/2) is the regex with tests. But if you are reading a list, you should use instead: ``` ^\[assembly: CompatibleVersions\("((?:[1-9]\d*|0)(?:\.(?:[1-9]\d*|0)){3}"(?:,"(?:[1-9]\d*|0)(?:\.(?:[1-9]\d*|0)){3}")*)\)]$ ``` By it you will extract the "...","..."... consequence from the inner parenthesis. After that split the result string by '","' into a list and remove last " from the last element and the first " from the first element. Now you have list of correct versions Strings. Alas, regex cannot create a list without split() function.
9,295
So I'm trying to find a way to download a report from salesforce programmatically, to a local machine. so, I've found the XMLStreamWriter class, and am writing the XML just fine... I'm just wondering if it is possible to save this XML string to a file and then downloading it. Has anyone done something similar to this before? Any pointers/examples would be awesome!
2013/03/06
[ "https://salesforce.stackexchange.com/questions/9295", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/2273/" ]
I've worked on this multiple times recently for a client who needs to output various fixed width file formats - not quite the same situation as you, but once you've got yourself down to a string it's a piece of cake. Check out this Gist for some boilerplate to get you going: <https://gist.github.com/Oblongmana/78c2807c91903bfe22b9> So say you have a String called 'txt': ``` Blob txtBlob = Blob.valueOf(txt); //Convert it to a blob Attachment attach = new Attachment(); //Make an attachment attach.Name ='text.xml'; attach.Body = txtBlob; attach.ContentType= 'application/xml'; //Signal what the file's MIME type is attach.ParentID = [parentIDGoesHere]; insert attach; ``` You can then serve this file up like so: ``` <a href="/servlet/servlet.FileDownload?file=' + attach.ID +'">Download me!</a> ```
Although the above answer is the better solution IMO (and I have upvoted), this is an alternative solution I helped create a few years back. The scenario was similar, a fixed-width file needed to be generated and extracted twice a day. The solution was to build a custom object where each record stored a line of the file - seems odd but the file could be of varying sizes and there were different 'types' of line so the ordering was important too. Twice a day a batch file (it had to be a Windows box unfortunately) would fire up dataloader to pull out the lines in the correct order and then it'd use a command line substitution tool (similar to `sed`) to do a bit of cleanup (removing the CSV parts) before moving the file into another directory where it was needed. The batch would then use the success log to update the downloaded records setting a checkbox to true, and those would subsequently be deleted from the system by a scheduled batch apex job.
7,956,631
I am trying to call a php function from .net. I tried to a webrequest method but I am not sure how to specify the function to call in the url. A link below shows the method I am trying to call. Thanks in advance for any help <http://codex.wordpress.org/Function_Reference/wp_hash_password>
2011/10/31
[ "https://Stackoverflow.com/questions/7956631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/686715/" ]
You would first need to create a webpage on the PHP server that calls the function you want, and returns the results (ideally in SOAP or XML format). Then, you can GET that webpage through the .NET WebRequest mechanism as you pointed out.
To call the function from C# you have to create a PHP file that executes the function, for example `http://www.somesite.com/ScriptWithTheFunction.php` with the content: ``` <?php //your includes here //You can set the value of $password from a $_GET parameter echo wp_hash_password( $password ); ``` and with C# you use `WebRequest` to get the output of the function (The same response you get from visiting `http://www.somesite.com/ScriptWithTheFunction.php` with your web browser)
69,482,458
I'm working on an implementation of EfficientNet in Tensorflow. My model is overfitting and predicting all three classes as just a single class. My training and validation accuracy is in the 99% after a few epochs and my loss is <0.5. I have 32,000 images between the three classes (12, 8, 12). My hypothesis is that it has to do with the way I input the data and one hot coded the labels. Perhaps it is due to everything being labeled the same accidentally, but I can't figure out where. ```py # Load Data train_ds = tf.keras.utils.image_dataset_from_directory( train_dir, labels='inferred', seed=42, image_size=(height, width), batch_size=batch_size ) val_ds = tf.keras.utils.image_dataset_from_directory( val_dir, labels='inferred', seed=42, image_size=(height, width), batch_size=batch_size ) class_names = train_ds.class_names num_classes = len(class_names) print('There are ' + str(num_classes) + ' classes:\n' + str(class_names)) # Resize images train_ds = train_ds.map(lambda image, label: ( tf.image.resize(image, (height, width)), label)) val_ds = val_ds.map(lambda image, label: ( tf.image.resize(image, (height, width)), label)) ``` This provides a sample of the correct images and class labels: ```py # # Visualization of samples # plt.figure(figsize=(10, 10)) # for images, labels in train_ds.take(1): # for i in range(9): # ax = plt.subplot(3, 3, i + 1) # plt.imshow(images[i].numpy().astype("uint8")) # plt.title(class_names[labels[i]]) # plt.axis("off") ``` Could this be causing an issue with labels? ```py # Prepare inputs # One-hot / categorical encoding def input_preprocess(image, label): label = tf.one_hot(label, num_classes) return image, label train_ds = train_ds.map(input_preprocess, num_parallel_calls=tf.data.AUTOTUNE) train_ds = train_ds.prefetch(tf.data.AUTOTUNE) val_ds = val_ds.map(input_preprocess) ``` My network: ```py def build_model(num_classes): inputs = Input(shape=(height, width, 3)) x = img_augmentation(inputs) model = EfficientNetB0( include_top=False, input_tensor=x, weights="imagenet") # Freeze the pretrained weights model.trainable = False # Rebuild top x = layers.GlobalAveragePooling2D(name="avg_pool")(model.output) x = layers.BatchNormalization()(x) top_dropout_rate = 0.4 x = layers.Dropout(top_dropout_rate, name="top_dropout")(x) outputs = layers.Dense(num_classes, activation="softmax", name="pred")(x) # Compile model = tf.keras.Model(inputs, outputs, name="EfficientNet") optimizer = tf.keras.optimizers.Adam(learning_rate=1e-3) model.compile( optimizer=optimizer, loss="categorical_crossentropy", metrics=["accuracy"] ) return model with strategy.scope(): model = build_model(num_classes=num_classes) epochs = 40 hist = model.fit(train_ds, epochs=epochs, validation_data=val_ds, workers=6, verbose=1, callbacks=callback) plot_hist(hist) ```
2021/10/07
[ "https://Stackoverflow.com/questions/69482458", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14059931/" ]
Well first off you are writing more code than you need to. In train\_ds and val\_ds you did not specify the parameter label\_mode. By default it is set to 'int'. Which means your labels will be integers. This is fine if your compile your model using loss=tf.keras.losses.SparseCategoricalCrossentropy. If you had set ``` label_mode= 'categorical' then you can use loss=tf.keras.losses.CategoricalCrossentropy ``` You did convert you labels to one-hot-encoded and that appears to have been done correctly. But you could have avoided having to do that by setting the label mode to categorical as mentioned. You also wrote code to resize the images. This is not necessary since tf.keras.utils.image\_dataset\_from\_directory resized the images for you. I had trouble getting your model to run probably because I don't have the code for x = img\_augmentation(inputs). you have the code ``` model = EfficientNetB0( include_top=False, input_tensor=x, weights="imagenet") ``` Since you are using the model API I think this should be ``` model = EfficientNetB0( include_top=False, weights="imagenet", pooling='max')(x) ``` NOTE I included pooliing='max' so efficientnet produces a one dimensional tensor output and thus you do not need the layer ``` x = layers.GlobalAveragePooling2D(name="avg_pool")(model.output) ``` I also modified your code to produce a test\_ds so I could test the accuracy of the model. Of course I used a different dataset but the results were fine. My complete code is shown below ``` train_dir=r'../input/beauty-detection-data-set/train' val_dir=r'../input/beauty-detection-data-set/valid' batch_size=32 height=224 width=224 train_ds = tf.keras.preprocessing.image_dataset_from_directory( train_dir, labels='inferred', validation_split=0.1, subset="training", label_mode='categorical', seed=42, image_size=(height, width), batch_size=batch_size ) test_ds = tf.keras.preprocessing.image_dataset_from_directory( train_dir, labels='inferred', validation_split=0.1, subset="validation", label_mode='categorical', seed=42, image_size=(height, width), batch_size=batch_size) val_ds = tf.keras.preprocessing.image_dataset_from_directory( val_dir, labels='inferred', seed=42, label_mode='categorical', image_size=(height, width), batch_size=batch_size ) class_names = train_ds.class_names num_classes = len(class_names) print('There are ' + str(num_classes) + ' classes:\n' + str(class_names)) img_shape=(224,224,3) base_model=tf.keras.applications.EfficientNetB3(include_top=False, weights="imagenet",input_shape=img_shape, pooling='max') x=base_model.output x=keras.layers.BatchNormalization(axis=-1, momentum=0.99, epsilon=0.001 )(x) x = Dense(256, kernel_regularizer = regularizers.l2(l = 0.016),activity_regularizer=regularizers.l1(0.006), bias_regularizer=regularizers.l1(0.006) ,activation='relu')(x) x=Dropout(rate=.45, seed=123)(x) output=Dense(num_classes, activation='softmax')(x) model=Model(inputs=base_model.input, outputs=output) model.compile(Adamax(lr=.001), loss='categorical_crossentropy', metrics=['accuracy']) epochs =5 hist = model.fit(train_ds, epochs=epochs, validation_data=val_ds, verbose=1) accuracy =model.evaluate(test_ds, verbose=1)[1] print (accuracy) ``` ```
If you use `labels='inferred'`, you should also specify `class_names` which will be the name of the three folders you're getting images from.
3,108,987
My tempdb size is growing too much, as we are doing too many transactions in the database. Can someone let me know how to shrink this tempdb without restarting the server. I have tried DBCC SHRINKDATABASE and it didn't help Thanks in advance
2010/06/24
[ "https://Stackoverflow.com/questions/3108987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/375115/" ]
Your tempdb is the size it needs to be... It will just grow again, just even more fragmented on disk and possibly blocking while it grows too. More seriously, I'd set the size of tempdb to soemthing sensible and slightly larger than now, shut down SQL, delete the old files to be 110% sure, start SQL Server up again...
Shrink the data files. From tempdb: ``` dbcc shrinkfile ('tempdev') dbcc shrinkfile ('templog') ``` If you have other data files for tempdb you may need to shrink them also. You can see this from the system data dictionary. Look in the 'name' column. ``` select * from sys.database_files ```
3,108,987
My tempdb size is growing too much, as we are doing too many transactions in the database. Can someone let me know how to shrink this tempdb without restarting the server. I have tried DBCC SHRINKDATABASE and it didn't help Thanks in advance
2010/06/24
[ "https://Stackoverflow.com/questions/3108987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/375115/" ]
I have found shrinking the tempdb to often be a troublesome task. The solution I have used previously is to set the initial size of the tempdb database to be the actual desired size of the database. Restarting the SQL Server Service will then re-create the tempdb database to this sepcified size. You may also find the following Microsoft reference to be useful reading: <http://support.microsoft.com/kb/307487/en-gb>
Shrink the data files. From tempdb: ``` dbcc shrinkfile ('tempdev') dbcc shrinkfile ('templog') ``` If you have other data files for tempdb you may need to shrink them also. You can see this from the system data dictionary. Look in the 'name' column. ``` select * from sys.database_files ```
3,108,987
My tempdb size is growing too much, as we are doing too many transactions in the database. Can someone let me know how to shrink this tempdb without restarting the server. I have tried DBCC SHRINKDATABASE and it didn't help Thanks in advance
2010/06/24
[ "https://Stackoverflow.com/questions/3108987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/375115/" ]
Your tempdb is the size it needs to be... It will just grow again, just even more fragmented on disk and possibly blocking while it grows too. More seriously, I'd set the size of tempdb to soemthing sensible and slightly larger than now, shut down SQL, delete the old files to be 110% sure, start SQL Server up again...
Even with "DBCC SHRINKFILE" you can receive warning like "DBCC SHRINKFILE: Page 1:878039 could not be moved because it is a work file page." that lead to no shrinking. I found a blog that explain well that situation and tell how to workaround and how to successfully shrink tempdb without restarting SQL: <http://adventuresinsql.com/2009/12/how-to-shrink-tempdb-in-sql-2005/> So here is an exemple from that blog: ``` DBCC FREEPROCCACHE GO USE [tempdb] GO DBCC SHRINKFILE (N'tempdev') GO DBCC SHRINKDATABASE(N'tempdb') GO ```
3,108,987
My tempdb size is growing too much, as we are doing too many transactions in the database. Can someone let me know how to shrink this tempdb without restarting the server. I have tried DBCC SHRINKDATABASE and it didn't help Thanks in advance
2010/06/24
[ "https://Stackoverflow.com/questions/3108987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/375115/" ]
I have found shrinking the tempdb to often be a troublesome task. The solution I have used previously is to set the initial size of the tempdb database to be the actual desired size of the database. Restarting the SQL Server Service will then re-create the tempdb database to this sepcified size. You may also find the following Microsoft reference to be useful reading: <http://support.microsoft.com/kb/307487/en-gb>
Even with "DBCC SHRINKFILE" you can receive warning like "DBCC SHRINKFILE: Page 1:878039 could not be moved because it is a work file page." that lead to no shrinking. I found a blog that explain well that situation and tell how to workaround and how to successfully shrink tempdb without restarting SQL: <http://adventuresinsql.com/2009/12/how-to-shrink-tempdb-in-sql-2005/> So here is an exemple from that blog: ``` DBCC FREEPROCCACHE GO USE [tempdb] GO DBCC SHRINKFILE (N'tempdev') GO DBCC SHRINKDATABASE(N'tempdb') GO ```
34,014,790
I am making a custom adapter extending ArrayAdapter. When I extend BaseAdapter, it works fine, but when I use ArrayAdapter, it shows error on super(). My Adapter code: CustomAdapter.java ``` public class CustomAdapter extends ArrayAdapter { private final Context context; private List<String> Title=new ArrayList<String>(); private List<String> Dis=new ArrayList<String>(); private List<String> Desc=new ArrayList<String>(); public static TextView title; public CustomAdapter(Context context,List<String>title,List<String>dis,List<String> desc) { super(); //ERROR HERE this.context = context; this.Title=title; this.Dis=dis; this.Desc=desc; } @Override public int getCount() { return Title.size(); } @Override public Object getItem(int position) { return null; } @Override public long getItemId(int position) { return 0; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.custom_adapter,parent, false); title = (TextView)v.findViewById(R.id.helloText); final TextView dis = (TextView)v.findViewById(R.id.dis); final TextView descr = (TextView)v.findViewById(R.id.descr); title.setText(Title.get(position)); dis.setText(Dis.get(position)); descr.setText(Desc.get(position)); return v; } } ``` And I want to call it as: ``` CustomAdapter ad=new CustomAdapter(this,titles,dis,desc); ``` Where titles, dis,desc are lists.
2015/12/01
[ "https://Stackoverflow.com/questions/34014790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4810235/" ]
take a look at java basics for explanation. This is an extract: "You don't have to provide any `constructors` for your class, but you must be careful when doing this. The compiler automatically provides a no-argument, default `constructor` for any class without `constructors`. This default `constructor` will call the no-argument constructor of the superclass. In this situation, the compiler will complain if the superclass doesn't have a no-argument constructor so you must verify that it does. If your class has no explicit superclass, then it has an implicit superclass of Object, which does have a no-argument constructor." You could read the whole article [here](https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html) And further you could take a look at `ArrayAdapter` source as 0X0nosugar suggested.
You need to pass parameter to super(), replace **super()** with following ``` super(context,title,dis,desc); ```
23,385,325
How to change an image to the next one in the array using a for loop, once a button has been clicked. At present I have this in my on click method. ``` int[] Pics = {R.drawable.pic1, R.drawable.pic2, R.drawable.pic3}; for (int i=0; i<Pics.length; i++){ mainpic.setImageResource(Pics[i]); } ``` The problem is when the next button is clicked, it only stays at the first image or goes straight through to the last image.
2014/04/30
[ "https://Stackoverflow.com/questions/23385325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3535866/" ]
the answer is they all get separated by slashes as shown below ``` <HttpGet()> _ <Route("getsinglerangeprojection/symboltype/{symboltype:int}/symbol/{symbol}/requestdate/{requestDate:datetime}")> _ Public Function GetSingleRangeProjection(ByVal symboltype As Integer, ByVal symbol As String, ByVal requestDate As String) As ProjectedRange ...code here End Function ```
You should create a model to represent your data like this ``` public class MyData { public string symboltype { get; set; } public string symbol { get; set; } public DateTime requestData { get; set; } } ``` And change your method to use the model or **JObject** as the parameter. Finally, post the whole json object as a string data:JSON.stringify({ "symboltype": symboltype, "symbol": symb, "requestDate": dDate}); Hope this help.
3,432,389
The original question: If we have a sequence of real numbers and on that, we define a sequence of $n^{th}$ rational numbers and another of irrational numbers, then they are both subsequences of the original sequence of real numbers? In other words, can a rational sequence be a complementary subsequence of an irrational sequence? That is can there exist a sequence of real numbers which has both a rational subsequence and an irrational subsequence?
2019/11/12
[ "https://math.stackexchange.com/questions/3432389", "https://math.stackexchange.com", "https://math.stackexchange.com/users/700226/" ]
Consider $(a\_n)$ given by $a\_{2n}= \frac{\sqrt{2}}{2n}$ and $a\_{2n-1}= \frac{1}{2n-1}.$
Consider the sequence $$1, 1.4, 1.41, 1.414, 1.4142\ldots$$ that converges to $\sqrt 2$, and the sequence $$\sqrt 2,\sqrt 2,\sqrt 2,\sqrt 2\ldots$$ that also converges to $\sqrt 2$.
3,432,389
The original question: If we have a sequence of real numbers and on that, we define a sequence of $n^{th}$ rational numbers and another of irrational numbers, then they are both subsequences of the original sequence of real numbers? In other words, can a rational sequence be a complementary subsequence of an irrational sequence? That is can there exist a sequence of real numbers which has both a rational subsequence and an irrational subsequence?
2019/11/12
[ "https://math.stackexchange.com/questions/3432389", "https://math.stackexchange.com", "https://math.stackexchange.com/users/700226/" ]
> > Can a rational sequence and an irrational sequence have same limit? > > > Yes. Take the sequence of irrational numbers $\frac{1}{\sqrt{p}}$ as $p\rightarrow \infty$, which converges to zero. Now consider the sequence of rational numbers $\frac{1}{p}$, as $p\rightarrow \infty$, which converges to zero. > > Can there exist a sequence of real numbers which has both a rational subsequence and an irrational subsequence? > > > Sure. When constructing sequences, you have great freedom. As an exercise, do a $\delta - \epsilon$ proof that the sequence ${\frac{1}{p\_1}, \frac{1}{\sqrt{p\_1}}, \frac{1}{p\_2}, \frac{1}{\sqrt{p\_2}},...}$ converges to zero. Then show each "compliment" sub-sequence converges to zero. Here's another thing you could maybe think about playing with, the AM-GM inequality: $$\frac{a\_1 + a\_2 + a\_3 + \cdots + a\_n}{n} \geq \sqrt[n]{a\_1\cdot a\_2 \cdot a\_3 \cdot \cdots \cdot a\_n} $$
Consider the sequence $$1, 1.4, 1.41, 1.414, 1.4142\ldots$$ that converges to $\sqrt 2$, and the sequence $$\sqrt 2,\sqrt 2,\sqrt 2,\sqrt 2\ldots$$ that also converges to $\sqrt 2$.
3,432,389
The original question: If we have a sequence of real numbers and on that, we define a sequence of $n^{th}$ rational numbers and another of irrational numbers, then they are both subsequences of the original sequence of real numbers? In other words, can a rational sequence be a complementary subsequence of an irrational sequence? That is can there exist a sequence of real numbers which has both a rational subsequence and an irrational subsequence?
2019/11/12
[ "https://math.stackexchange.com/questions/3432389", "https://math.stackexchange.com", "https://math.stackexchange.com/users/700226/" ]
Just to give a simple example with a single formula, let $$a\_n={(1+(-1)^n)\sqrt2\over n}$$ The sequence is $$0,\sqrt2,0,{\sqrt2\over2},0,{\sqrt2\over3},0,{\sqrt2\over4},\ldots$$ which clearly has both a rational and an irrational subsequence, each converging to the same limit, namely $0$.
Consider the sequence $$1, 1.4, 1.41, 1.414, 1.4142\ldots$$ that converges to $\sqrt 2$, and the sequence $$\sqrt 2,\sqrt 2,\sqrt 2,\sqrt 2\ldots$$ that also converges to $\sqrt 2$.
7,664,080
I have been trying to figure this one out for the last 2 days. I feel like I'm really close, but just can't get it. I've gotten my c# program to successfully send an email with all the required information in it, but I can't change the sender's name and email address. Here is my code so far: ``` Outlook.Application oApp = new Outlook.Application(); string emailrecipient = (Convert.ToString(txtAdmin1.Text) + "@domain.com"); Outlook.MailItem email = (Outlook.MailItem)(oApp.CreateItem(Outlook.OlItemType.olMailItem)); email.Recipients.Add(emailrecipient); email.Subject = "Your Recent Admin Rights Request"; email.Body = "Your admin rights request has been processed. The user " + txtAdmin1.Text + " has been added as an administrator on computer " + txtName.Text + ". Please reboot your computer for these changes to take effect."; email.Send(); ``` any advice would be amazing. I've searched all over the place, and haven't found anything that has worked so far.
2011/10/05
[ "https://Stackoverflow.com/questions/7664080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/980678/" ]
I had the same issue (adding theme worked but it produces ugly warnings). I fixed it by explicitly referencing the theme's CSS file by: 1. Add the following to your flexmojos configuration: ``` <themes> <theme>spark-theme-${flex.sdk.version}.css</theme> </themes> ``` 2. Add the theme as a dependency: ``` <dependency> <groupId>com.adobe.flex.framework</groupId> <artifactId>spark-theme</artifactId> <version>${flex.sdk.version}</version> <type>css</type> </dependency> ``` 3. pull the dependency in to your output directory. There are several ways to do this, including a simple ant copy. I chose to use the maven dependency plugin: ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-theme-file</id> <phase>process-resources</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.outputDirectory}</outputDirectory> <includeArtifactIds>spark-theme</includeArtifactIds> </configuration> </execution> </executions> </plugin> ``` Following these steps copies the spark-theme's CSS file to the output directory (/target/classes in most cases) and explicitly refers to the CSS file in in the flexmojos configuration. This completely got rid of all theme warnings for me. I hope this helps someone.
I am using Flex-Mojos 4.1-beta, and themes "just work" ™ I cannot vouch for earlier versions. Taking an example, pull in the spark theme (part of the SDK): ``` <dependency> <groupId>com.adobe.flex.framework</groupId> <artifactId>spark</artifactId> <version>${flex.version}</version> <scope>theme</scope> <type>swc</type> </dependency> ``` Now, pull in the theme which I've earlier, myself defined: ``` <dependency> <groupId>ie.hunt</groupId> <artifactId>theme-library</artifactId> <version>1.0-SNAPSHOT</version> <type>swc</type> <scope>theme</scope> </dependency> ``` And the 'spark' theme is applied, then overridden by the rules I've defined in my own theme swc. Nothing else to do. Using the 'themes' subsection of 'plugin'->'configuration' creates unhelpful Null Pointer Exceptions, e.g: ``` <configuration> <themes> <theme>spark.css</theme> <themes> ... </configuration> ``` Error output: ``` [ERROR] Failed to execute goal org.sonatype.flexmojos:flexmojos-maven-plugin:4.1-beta:compile-swc (default-compile-swc) on project theme-library: java.lang.NullPointerException -> [Help 1] ```
7,664,080
I have been trying to figure this one out for the last 2 days. I feel like I'm really close, but just can't get it. I've gotten my c# program to successfully send an email with all the required information in it, but I can't change the sender's name and email address. Here is my code so far: ``` Outlook.Application oApp = new Outlook.Application(); string emailrecipient = (Convert.ToString(txtAdmin1.Text) + "@domain.com"); Outlook.MailItem email = (Outlook.MailItem)(oApp.CreateItem(Outlook.OlItemType.olMailItem)); email.Recipients.Add(emailrecipient); email.Subject = "Your Recent Admin Rights Request"; email.Body = "Your admin rights request has been processed. The user " + txtAdmin1.Text + " has been added as an administrator on computer " + txtName.Text + ". Please reboot your computer for these changes to take effect."; email.Send(); ``` any advice would be amazing. I've searched all over the place, and haven't found anything that has worked so far.
2011/10/05
[ "https://Stackoverflow.com/questions/7664080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/980678/" ]
I had the same issue (adding theme worked but it produces ugly warnings). I fixed it by explicitly referencing the theme's CSS file by: 1. Add the following to your flexmojos configuration: ``` <themes> <theme>spark-theme-${flex.sdk.version}.css</theme> </themes> ``` 2. Add the theme as a dependency: ``` <dependency> <groupId>com.adobe.flex.framework</groupId> <artifactId>spark-theme</artifactId> <version>${flex.sdk.version}</version> <type>css</type> </dependency> ``` 3. pull the dependency in to your output directory. There are several ways to do this, including a simple ant copy. I chose to use the maven dependency plugin: ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-theme-file</id> <phase>process-resources</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.outputDirectory}</outputDirectory> <includeArtifactIds>spark-theme</includeArtifactIds> </configuration> </execution> </executions> </plugin> ``` Following these steps copies the spark-theme's CSS file to the output directory (/target/classes in most cases) and explicitly refers to the CSS file in in the flexmojos configuration. This completely got rid of all theme warnings for me. I hope this helps someone.
Or, more simple [with this answer](https://stackoverflow.com/a/5043813/244911) (just think to declare it in your *dependencyManagement* and *dependencies* tags of your pom
10,415,040
Now I want to try this program (link: <http://www.cogno-sys.com/azure-cloud-management/azure-cloud-director-single-click-azure-deployment/> ) because I have some problem to deploy my app to Azure. So I downloaded it and it requires first to add a subscription ID. But after I fill all field I click the button OK but nothing happening...(I added the certification path and password, too) No error message, nothing else. This pop-up window is on the screen still (the problem is the same when I ad the Certhumprint and then clikc to Check, but nothing again. If I click the OK button now the error messages show to click to check button first) Are you using this? Do you have the same problem with it?
2012/05/02
[ "https://Stackoverflow.com/questions/10415040", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1304813/" ]
`:whatever` is a symbol, you've got that part right. When you're using a hash, this was how you used to define it in 1.8x ruby: ``` {:key => value, :another_key => another_value} ``` This is known as the hashrocket syntax. In ruby 1.9x, this changed to: ``` {key: value, another_key: another_value} ``` There is backward compatibility that will still load the hashrocket syntax... But, in 1.9, 'key:' is a symbol
the `{:key => value}` is the old hash syntax in ruby, now we have a new hash syntax that is more like json so ``` {:key => value} ``` is the same as ``` {key: value} ``` The old one, we’re all familiar with is: ``` old_hash = {:simon => "Talek", :lorem => "Ipsum"} ``` This is all nice and dandy, but it could be simpler and cleaner. Check out the Ruby 1.9 style, it sort of resembles JSON: ``` new_hash = {simon: "Talek", lorem: "Ipsum"} ``` But now you look closer and ask, “But previously the key was a symbol explicitly, what’s with this now?”. Well you’re right, the new notation is sort of a syntactic sugar for the most common style of hashes out there, the so called symbol to object hash. If you do this in the irb, you’ll see ruby returning the old school hash, with the symbols used as keys: ``` > new_hash = {simon: "Talek", lorem: "Ipsum"} => {:simon=>"Talek", :lorem=>"Ipsum"} ``` If you need to have arbitrary objects as your hash keys, you’ll still have to do it old school. ref:<http://breakthebit.org/post/8453341914/ruby-1-9-and-the-new-hash-syntax>
224,709
I'm looking at writing a simple app indicator and I need it to update it's information whenever it's clicked on to open the menu. Is there any kind of on\_click action thing? Let me rephrase it then: How to perform an action (any action) when the user clicks on the appindicator to open its menu?
2012/12/02
[ "https://askubuntu.com/questions/224709", "https://askubuntu.com", "https://askubuntu.com/users/101066/" ]
An app indicator can only open its menu. It can't perform any other action and your program doesn't get notified when the menu is displayed. You could either include some kind of "Update" menu item or find other events that trigger the update.
I have used the middle mouse click in one of my indicators to perform an action, so I think you could do the same... See related [answer](https://askubuntu.com/a/501050/67335). *Note it only seems to work on Ubuntu (not Lubuntu/Xubuntu).*
224,709
I'm looking at writing a simple app indicator and I need it to update it's information whenever it's clicked on to open the menu. Is there any kind of on\_click action thing? Let me rephrase it then: How to perform an action (any action) when the user clicks on the appindicator to open its menu?
2012/12/02
[ "https://askubuntu.com/questions/224709", "https://askubuntu.com", "https://askubuntu.com/users/101066/" ]
An app indicator can only open its menu. It can't perform any other action and your program doesn't get notified when the menu is displayed. You could either include some kind of "Update" menu item or find other events that trigger the update.
Indeed, you may notice that some indicators (like volume or keyboard language ones) support middle mouse click. It can be done with `set_secondary_activate_target(menu_item)`. My code snippet for pyGtk/pyGI: ``` menu_items = Gtk.MenuItem("Toggle Floater") menu.append(menu_items) menu_items.connect("activate", self.toggleWindow) self.ind.set_secondary_activate_target(menu_items) ``` I found it [here](https://developer.ubuntu.com/api/devel/ubuntu-13.10/python/AppIndicator3-0.1.html), but it's not described, I just tried it on chance, and it worked.
66,932,125
so I have a coded a simple function in python and called it `Lag()`. The folder I am saving the python script at is `C:\Users\yo4226ka\Work Folders\Desktop\...\Code` and I call the file `2.5`. I am trying to do something like this: `from 2.5 import Lag` I am not quite sure how I could use the folder location to import the function I coded in another script. Any help is appreciated :)! Y
2021/04/03
[ "https://Stackoverflow.com/questions/66932125", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14127938/" ]
You can save the code as a package and import it later on and use it like regular python packages. This might help you: <https://www.tutorialsteacher.com/python/python-package>
did your main script file and 2.5 file exist same folder? if its condition is true, it is simple. you just write code below. ``` from Lag import 2.5 ```
10,425,694
In web page designing i am using css files and js files and these css files and javascript files are called in jsp page as follows: ``` <script type="text/javascript" src="datepick.js"></script> <link rel="stylesheet" type="text/css" href="datepick.css" /> ``` If somebody views page source then he can know `css files` as well as `js files`, but how can i prevent it? in index.jsp ``` <html> <head> <script type="text/javascript" src="datepick.js"/> <link rel="stylesheet" type="text/css" href="datepick.css"/> </head> <body> .............. .............. </body> </html> ``` If somebody views page source then immediately he can view `datepick.css` and `datepick.js` , which i do n't want. How can i prevent him from viewing these css and javascript files?
2012/05/03
[ "https://Stackoverflow.com/questions/10425694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1232355/" ]
You cannot **hide** CSS or JS as the are client-side scripts. The best you can do is to [obfuscate your JavaScript](https://stackoverflow.com/questions/194397/how-can-i-obfuscate-javascript) and [compress your CSS](https://www.google.com/search?q=compress%20css).
You can't. You have to give the browser the CSS and JS so that it can parse them. Anything you give to the browser you also give to the user.
10,425,694
In web page designing i am using css files and js files and these css files and javascript files are called in jsp page as follows: ``` <script type="text/javascript" src="datepick.js"></script> <link rel="stylesheet" type="text/css" href="datepick.css" /> ``` If somebody views page source then he can know `css files` as well as `js files`, but how can i prevent it? in index.jsp ``` <html> <head> <script type="text/javascript" src="datepick.js"/> <link rel="stylesheet" type="text/css" href="datepick.css"/> </head> <body> .............. .............. </body> </html> ``` If somebody views page source then immediately he can view `datepick.css` and `datepick.js` , which i do n't want. How can i prevent him from viewing these css and javascript files?
2012/05/03
[ "https://Stackoverflow.com/questions/10425694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1232355/" ]
You cannot **hide** CSS or JS as the are client-side scripts. The best you can do is to [obfuscate your JavaScript](https://stackoverflow.com/questions/194397/how-can-i-obfuscate-javascript) and [compress your CSS](https://www.google.com/search?q=compress%20css).
Short Answer: **NO**. Whatever tricks may you used to hide your css and js, users can able to track it easily. Because there are lot of Developer tools available in the market. Better leave this idea for hiding your files...
10,425,694
In web page designing i am using css files and js files and these css files and javascript files are called in jsp page as follows: ``` <script type="text/javascript" src="datepick.js"></script> <link rel="stylesheet" type="text/css" href="datepick.css" /> ``` If somebody views page source then he can know `css files` as well as `js files`, but how can i prevent it? in index.jsp ``` <html> <head> <script type="text/javascript" src="datepick.js"/> <link rel="stylesheet" type="text/css" href="datepick.css"/> </head> <body> .............. .............. </body> </html> ``` If somebody views page source then immediately he can view `datepick.css` and `datepick.js` , which i do n't want. How can i prevent him from viewing these css and javascript files?
2012/05/03
[ "https://Stackoverflow.com/questions/10425694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1232355/" ]
You cannot **hide** CSS or JS as the are client-side scripts. The best you can do is to [obfuscate your JavaScript](https://stackoverflow.com/questions/194397/how-can-i-obfuscate-javascript) and [compress your CSS](https://www.google.com/search?q=compress%20css).
In HTML, if you can see it, you can get it. JS runs in web browser. JSP runs in JSP container.
15,565,783
How to auto delete file from Git cache when I deleted it by hand in sublime text 2? Is there a plugin to do so?
2013/03/22
[ "https://Stackoverflow.com/questions/15565783", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1401708/" ]
**This is the way you can remove file/folders from `git cache` manually.** Remove tracking of file/folder - but keep them on disk - using ``` $ git rm --cached ``` Now they do not show up as "changed" but still show as untracked files in ``` $ git status -u ``` Add them to `.gitignore` Use ``` $ git config --global core.editor ```
Remove the definite file which you want to ignore, rather than removing all files in cache, it will reduce risk. 1. add to `.gitignore`; 2. delete the file/files `git rm cached <file>`
152,421
What do you call the V-shaped figure one uses to check a checkbox? How about the X-shaped figure?
2014/02/17
[ "https://english.stackexchange.com/questions/152421", "https://english.stackexchange.com", "https://english.stackexchange.com/users/11268/" ]
You might be looking for "check" or "tick", or "check mark" or "tick mark".
Do you mean a check mark (also called a tick)? <http://en.wikipedia.org/wiki/Check_mark> The x-shaped mark can be called simply an x or a cross.<http://en.wikipedia.org/wiki/X_mark>
152,421
What do you call the V-shaped figure one uses to check a checkbox? How about the X-shaped figure?
2014/02/17
[ "https://english.stackexchange.com/questions/152421", "https://english.stackexchange.com", "https://english.stackexchange.com/users/11268/" ]
You might be looking for "check" or "tick", or "check mark" or "tick mark".
In the UK we were usually told to put [a tick or a cross](https://books.google.com/ngrams/graph?content=a%20tick%20or%20a%20cross&year_start=1930&year_end=2000&corpus=15&smoothing=3&share=&direct_url=t1;,a%20tick%20or%20a%20cross;,c0) in the appropriate box... ![enter image description here](https://i.stack.imgur.com/kKZUh.png) ...but if you follow the link and switch between British and American corpuses, you'll see that the "relative prevalence" (number of instances per 100M words) for BrE is about 8 times higher than that for AmE. --- Just a guess, but I wonder if maybe the (historically) higher proportion of immigrants less familiar with English (for reading the instructions on filling out the form) might mean that US forms were always more likely to expect just a single mark (tick ***or*** cross) to mean "this is the one that applies". Some years ago a friend who helped out counting the ballot papers after a General Election told me she was amazed at how many were classed as "spoiled" because the voter had put a tick against their preferred candidate, and a cross against each of the others. The intended vote was obvious, but they weren't allowed to count it. We both thought this probably caused disproportionate (hopefully, *unintended*) disenfranchisement of recent immigrants who might not understand the instructions.
30,790,855
Here is my current layout configuration: ``` <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ListView android:id="@+id/list_1" android:layout_width="match_parent" android:layout_height="match_parent" android:cacheColorHint="@android:color/transparent" android:drawSelectorOnTop="false" android:dividerHeight="0dp" android:divider="@null" android:scrollbars="none" /> <ListView android:id="@+id/list_2" android:layout_width="match_parent" android:layout_height="match_parent" android:cacheColorHint="@android:color/transparent" android:drawSelectorOnTop="false" android:dividerHeight="0dp" android:divider="@null" android:scrollbars="none" /> </FrameLayout> ``` The top listview is basically a scrolling overlay for the base listview: list\_1, they must have the same height. The overlay is not visible on idle but when dragging it has some alpha, and displays list\_1 current section. I made it so that we have list 1 and list 2 have the same content height, but they have DIFFERENT LAYOUT for their own list item. Knowing that list\_2 here will catch touch events here, I want to sync both listview scroll offset. I have partly managed it with this example: ``` mListView2.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { View c = mListViewMonths.getChildAt(0); int scrolly = -c.getTop() + mListViewMonths.getFirstVisiblePosition() * c.getHeight(); mListViewWeeks.setScrollY(scrolly); } }); ``` At the exception that listview1 gets scrolled, but when going down no list items of listview1 are drawn. What am I missing here? Or perhaps better, dispatch the touch event to both listview, instead of all those scrolling techniques. Thoughts?
2015/06/11
[ "https://Stackoverflow.com/questions/30790855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1763767/" ]
Remember this is MVC. The request goes to the controller, where an action is performed and the result is shown in a view. You created a new view file, but there is no reference in the controller. The default routing mechanism looks for a controller and then an action in the controller to fulfill a request. You should create an action named R3, with the same code as the action Details and try again.
It doesn't sound like you have an action responsible for populating the model requred for `R3` to display. If you copy the `Details` action and rename it `R3`, it should work.
30,790,855
Here is my current layout configuration: ``` <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ListView android:id="@+id/list_1" android:layout_width="match_parent" android:layout_height="match_parent" android:cacheColorHint="@android:color/transparent" android:drawSelectorOnTop="false" android:dividerHeight="0dp" android:divider="@null" android:scrollbars="none" /> <ListView android:id="@+id/list_2" android:layout_width="match_parent" android:layout_height="match_parent" android:cacheColorHint="@android:color/transparent" android:drawSelectorOnTop="false" android:dividerHeight="0dp" android:divider="@null" android:scrollbars="none" /> </FrameLayout> ``` The top listview is basically a scrolling overlay for the base listview: list\_1, they must have the same height. The overlay is not visible on idle but when dragging it has some alpha, and displays list\_1 current section. I made it so that we have list 1 and list 2 have the same content height, but they have DIFFERENT LAYOUT for their own list item. Knowing that list\_2 here will catch touch events here, I want to sync both listview scroll offset. I have partly managed it with this example: ``` mListView2.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { View c = mListViewMonths.getChildAt(0); int scrolly = -c.getTop() + mListViewMonths.getFirstVisiblePosition() * c.getHeight(); mListViewWeeks.setScrollY(scrolly); } }); ``` At the exception that listview1 gets scrolled, but when going down no list items of listview1 are drawn. What am I missing here? Or perhaps better, dispatch the touch event to both listview, instead of all those scrolling techniques. Thoughts?
2015/06/11
[ "https://Stackoverflow.com/questions/30790855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1763767/" ]
It doesn't sound like you have an action responsible for populating the model requred for `R3` to display. If you copy the `Details` action and rename it `R3`, it should work.
jfeston helped me out a bit. However, I had the method in my controller BUT I had [HttpPost] as part of the method header. I needed to create another method with [HttpPost] to accept requests from the new view. So... ``` [AllowAnonymous] // this is a login page; there is no auth yet public ActionResult Login() { // do stuff here } [AllowAnonymous] [HttpPost] // this accepts the request from the view public ActionResult Login(User user, string returnURL) { // do stuff here } ```
30,790,855
Here is my current layout configuration: ``` <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <ListView android:id="@+id/list_1" android:layout_width="match_parent" android:layout_height="match_parent" android:cacheColorHint="@android:color/transparent" android:drawSelectorOnTop="false" android:dividerHeight="0dp" android:divider="@null" android:scrollbars="none" /> <ListView android:id="@+id/list_2" android:layout_width="match_parent" android:layout_height="match_parent" android:cacheColorHint="@android:color/transparent" android:drawSelectorOnTop="false" android:dividerHeight="0dp" android:divider="@null" android:scrollbars="none" /> </FrameLayout> ``` The top listview is basically a scrolling overlay for the base listview: list\_1, they must have the same height. The overlay is not visible on idle but when dragging it has some alpha, and displays list\_1 current section. I made it so that we have list 1 and list 2 have the same content height, but they have DIFFERENT LAYOUT for their own list item. Knowing that list\_2 here will catch touch events here, I want to sync both listview scroll offset. I have partly managed it with this example: ``` mListView2.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { View c = mListViewMonths.getChildAt(0); int scrolly = -c.getTop() + mListViewMonths.getFirstVisiblePosition() * c.getHeight(); mListViewWeeks.setScrollY(scrolly); } }); ``` At the exception that listview1 gets scrolled, but when going down no list items of listview1 are drawn. What am I missing here? Or perhaps better, dispatch the touch event to both listview, instead of all those scrolling techniques. Thoughts?
2015/06/11
[ "https://Stackoverflow.com/questions/30790855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1763767/" ]
Remember this is MVC. The request goes to the controller, where an action is performed and the result is shown in a view. You created a new view file, but there is no reference in the controller. The default routing mechanism looks for a controller and then an action in the controller to fulfill a request. You should create an action named R3, with the same code as the action Details and try again.
jfeston helped me out a bit. However, I had the method in my controller BUT I had [HttpPost] as part of the method header. I needed to create another method with [HttpPost] to accept requests from the new view. So... ``` [AllowAnonymous] // this is a login page; there is no auth yet public ActionResult Login() { // do stuff here } [AllowAnonymous] [HttpPost] // this accepts the request from the view public ActionResult Login(User user, string returnURL) { // do stuff here } ```
20,632,401
I have a clientid and username and i want them both send with the socket. ``` client.userid = userid; client.username = username; client.emit('onconnected', { id: client.userid, name: client.username }); ``` i tried this for example but it doesn't seem to work
2013/12/17
[ "https://Stackoverflow.com/questions/20632401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3086742/" ]
You can try this ``` io.sockets.on('connection', function (socket) { socket.on('event_name', function(data) { // you can try one of these three options // this is used to send to all connecting sockets io.sockets.emit('eventToClient', { id: userid, name: username }); // this is used to send to all connecting sockets except the sending one socket.broadcast.emit('eventToClient',{ id: userid, name: username }); // this is used to the sending one socket.emit('eventToClient',{ id: userid, name: username }); } } ``` and on the client ``` socket.on('eventToClient',function(data) { // do something with data var id = data.id var name = data.name // here, it should be data.name instead of data.username }); ```
Try sending the object as a whole: ``` $('form').submit(function(){ var loginDetails={ userid : userid, username : username }; client.emit('sentMsg',loginDetails); } ```
20,632,401
I have a clientid and username and i want them both send with the socket. ``` client.userid = userid; client.username = username; client.emit('onconnected', { id: client.userid, name: client.username }); ``` i tried this for example but it doesn't seem to work
2013/12/17
[ "https://Stackoverflow.com/questions/20632401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3086742/" ]
You can try this ``` io.sockets.on('connection', function (socket) { socket.on('event_name', function(data) { // you can try one of these three options // this is used to send to all connecting sockets io.sockets.emit('eventToClient', { id: userid, name: username }); // this is used to send to all connecting sockets except the sending one socket.broadcast.emit('eventToClient',{ id: userid, name: username }); // this is used to the sending one socket.emit('eventToClient',{ id: userid, name: username }); } } ``` and on the client ``` socket.on('eventToClient',function(data) { // do something with data var id = data.id var name = data.name // here, it should be data.name instead of data.username }); ```
You should pass an object to socket event. In server-side: ``` socket.emit('your-event', { name: 'Whatever', age: 18 }) ``` In client-side: ``` socket.on('your-event', ({ name, age }) => { // name: Whatever // age: 18 }) ```
6,253,173
My Android project has a few jar libraries as dependencies. Alone, it compiles and works well. I wrote a little test project but running it I don't get any result (no tests passed or failed) nor any error, but in the logcat's output there are warnings like this: ``` 06-06 14:55:43.533: INFO/dalvikvm(7049): Failed resolving Lcom/adwhirl/adapters/InMobiAdapter; interface 315 'Lcom/inmobi/androidsdk/InMobiAdDelegate;' 06-06 14:55:43.533: WARN/dalvikvm(7049): Link of class 'Lcom/adwhirl/adapters/InMobiAdapter;' failed 06-06 14:55:43.533: INFO/dalvikvm(7049): Failed resolving Lcom/adwhirl/adapters/InMobiAdapter; interface 407 'Lcom/inmobi/androidsdk/InMobiAdDelegate;' 06-06 14:55:43.533: WARN/dalvikvm(7049): Link of class 'Lcom/adwhirl/adapters/InMobiAdapter;' failed 06-06 14:55:43.553: DEBUG/dalvikvm(7049): GC_CONCURRENT freed 471K, 51% free 2880K/5831K, external 0K/0K, paused 2ms+4ms 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): Cannot load class. Make sure it is in your apk. Class name: 'com.adwhirl.adapters.InMobiAdapter'. Message: com.adwhirl.adapters.InMobiAdapter 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): java.lang.ClassNotFoundException: com.adwhirl.adapters.InMobiAdapter 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.Class.classForName(Native Method) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.Class.forName(Class.java:234) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:89) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:40) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:51) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:48) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.SimpleCache.get(SimpleCache.java:31) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:73) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:154) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:115) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:103) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:360) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3398) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.app.ActivityThread.access$2200(ActivityThread.java:123) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:977) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.os.Handler.dispatchMessage(Handler.java:99) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.os.Looper.loop(Looper.java:130) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.app.ActivityThread.main(ActivityThread.java:3835) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.reflect.Method.invokeNative(Native Method) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.reflect.Method.invoke(Method.java:507) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at dalvik.system.NativeStart.main(Native Method) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): Caused by: java.lang.NoClassDefFoundError: com.adwhirl.adapters.InMobiAdapter 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): ... 26 more 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): Caused by: java.lang.ClassNotFoundException: com.adwhirl.adapters.InMobiAdapter in loader dalvik.system.PathClassLoader[/system/framework/android.test.runner.jar:/data/app/com.mypackage.test-1.apk:/data/app/com.mypackage-2.apk] 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): ... 26 more ``` As you can see seems that there are problem exporting the libraries, infact I get an error like that for every library. I read [in this blog post](http://dtmilano.blogspot.com/2009/12/android-testing-external-libraries.html) that to get it to work, it should be enough to export all the libraries in the main project, but for me didn't works. Any other idea?
2011/06/06
[ "https://Stackoverflow.com/questions/6253173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/321354/" ]
Go to your project that uses .jar files (i.e. project under test). Click right button -> Properties-> Java Build Path -> Order and Export -> check libraries there ![enter image description here](https://i.stack.imgur.com/4hX1s.png)
Have you tried to put the jars in libs intead than lib ? <http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17>
6,253,173
My Android project has a few jar libraries as dependencies. Alone, it compiles and works well. I wrote a little test project but running it I don't get any result (no tests passed or failed) nor any error, but in the logcat's output there are warnings like this: ``` 06-06 14:55:43.533: INFO/dalvikvm(7049): Failed resolving Lcom/adwhirl/adapters/InMobiAdapter; interface 315 'Lcom/inmobi/androidsdk/InMobiAdDelegate;' 06-06 14:55:43.533: WARN/dalvikvm(7049): Link of class 'Lcom/adwhirl/adapters/InMobiAdapter;' failed 06-06 14:55:43.533: INFO/dalvikvm(7049): Failed resolving Lcom/adwhirl/adapters/InMobiAdapter; interface 407 'Lcom/inmobi/androidsdk/InMobiAdDelegate;' 06-06 14:55:43.533: WARN/dalvikvm(7049): Link of class 'Lcom/adwhirl/adapters/InMobiAdapter;' failed 06-06 14:55:43.553: DEBUG/dalvikvm(7049): GC_CONCURRENT freed 471K, 51% free 2880K/5831K, external 0K/0K, paused 2ms+4ms 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): Cannot load class. Make sure it is in your apk. Class name: 'com.adwhirl.adapters.InMobiAdapter'. Message: com.adwhirl.adapters.InMobiAdapter 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): java.lang.ClassNotFoundException: com.adwhirl.adapters.InMobiAdapter 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.Class.classForName(Native Method) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.Class.forName(Class.java:234) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:89) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:40) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:51) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:48) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.SimpleCache.get(SimpleCache.java:31) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:73) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:154) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:115) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:103) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:360) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3398) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.app.ActivityThread.access$2200(ActivityThread.java:123) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:977) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.os.Handler.dispatchMessage(Handler.java:99) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.os.Looper.loop(Looper.java:130) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.app.ActivityThread.main(ActivityThread.java:3835) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.reflect.Method.invokeNative(Native Method) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.reflect.Method.invoke(Method.java:507) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at dalvik.system.NativeStart.main(Native Method) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): Caused by: java.lang.NoClassDefFoundError: com.adwhirl.adapters.InMobiAdapter 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): ... 26 more 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): Caused by: java.lang.ClassNotFoundException: com.adwhirl.adapters.InMobiAdapter in loader dalvik.system.PathClassLoader[/system/framework/android.test.runner.jar:/data/app/com.mypackage.test-1.apk:/data/app/com.mypackage-2.apk] 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): ... 26 more ``` As you can see seems that there are problem exporting the libraries, infact I get an error like that for every library. I read [in this blog post](http://dtmilano.blogspot.com/2009/12/android-testing-external-libraries.html) that to get it to work, it should be enough to export all the libraries in the main project, but for me didn't works. Any other idea?
2011/06/06
[ "https://Stackoverflow.com/questions/6253173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/321354/" ]
Go to your project that uses .jar files (i.e. project under test). Click right button -> Properties-> Java Build Path -> Order and Export -> check libraries there ![enter image description here](https://i.stack.imgur.com/4hX1s.png)
what worked for me was - in 'Order and Import' section bringing my jar file up
6,253,173
My Android project has a few jar libraries as dependencies. Alone, it compiles and works well. I wrote a little test project but running it I don't get any result (no tests passed or failed) nor any error, but in the logcat's output there are warnings like this: ``` 06-06 14:55:43.533: INFO/dalvikvm(7049): Failed resolving Lcom/adwhirl/adapters/InMobiAdapter; interface 315 'Lcom/inmobi/androidsdk/InMobiAdDelegate;' 06-06 14:55:43.533: WARN/dalvikvm(7049): Link of class 'Lcom/adwhirl/adapters/InMobiAdapter;' failed 06-06 14:55:43.533: INFO/dalvikvm(7049): Failed resolving Lcom/adwhirl/adapters/InMobiAdapter; interface 407 'Lcom/inmobi/androidsdk/InMobiAdDelegate;' 06-06 14:55:43.533: WARN/dalvikvm(7049): Link of class 'Lcom/adwhirl/adapters/InMobiAdapter;' failed 06-06 14:55:43.553: DEBUG/dalvikvm(7049): GC_CONCURRENT freed 471K, 51% free 2880K/5831K, external 0K/0K, paused 2ms+4ms 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): Cannot load class. Make sure it is in your apk. Class name: 'com.adwhirl.adapters.InMobiAdapter'. Message: com.adwhirl.adapters.InMobiAdapter 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): java.lang.ClassNotFoundException: com.adwhirl.adapters.InMobiAdapter 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.Class.classForName(Native Method) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.Class.forName(Class.java:234) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:89) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:40) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:51) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:48) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.SimpleCache.get(SimpleCache.java:31) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:73) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:154) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:115) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:103) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:360) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3398) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.app.ActivityThread.access$2200(ActivityThread.java:123) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:977) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.os.Handler.dispatchMessage(Handler.java:99) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.os.Looper.loop(Looper.java:130) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at android.app.ActivityThread.main(ActivityThread.java:3835) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.reflect.Method.invokeNative(Native Method) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.reflect.Method.invoke(Method.java:507) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at dalvik.system.NativeStart.main(Native Method) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): Caused by: java.lang.NoClassDefFoundError: com.adwhirl.adapters.InMobiAdapter 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): ... 26 more 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): Caused by: java.lang.ClassNotFoundException: com.adwhirl.adapters.InMobiAdapter in loader dalvik.system.PathClassLoader[/system/framework/android.test.runner.jar:/data/app/com.mypackage.test-1.apk:/data/app/com.mypackage-2.apk] 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 06-06 14:55:43.553: WARN/ClassPathPackageInfoSource(7049): ... 26 more ``` As you can see seems that there are problem exporting the libraries, infact I get an error like that for every library. I read [in this blog post](http://dtmilano.blogspot.com/2009/12/android-testing-external-libraries.html) that to get it to work, it should be enough to export all the libraries in the main project, but for me didn't works. Any other idea?
2011/06/06
[ "https://Stackoverflow.com/questions/6253173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/321354/" ]
what worked for me was - in 'Order and Import' section bringing my jar file up
Have you tried to put the jars in libs intead than lib ? <http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17>
46,199,583
I want to display all customers who placed an order during 2010. When I display "customerid" and "orderdate" from the custorder table, the format looks like this: ``` C-300064 06-DEC-10 ``` Basically I need to figure out how to get it to display only customerid where the last 2 digits of orderdate are 10. Can someone help me out please?
2017/09/13
[ "https://Stackoverflow.com/questions/46199583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8332686/" ]
> > I'm wanting to display all customers who placed an order during 2010. > > > As simple as: ``` SELECT customerid , orderdate FROM your_table WHERE orderdate >= DATE '2010-01-01' AND orderdate < DATE '2011-01-01'; ``` If orderdate is `DATE` column then how it is displayed doesn't matter. `DATE 'YYYY-MM-DD'` literal does not depend on your session `NLS_DATE_FORMAT`.
Since you are using Oracle, this will work. ``` SELECT customerid , orderdate FROM yourtable WHERE EXTRACT(YEAR FROM orderdate) = 2010; ```
46,199,583
I want to display all customers who placed an order during 2010. When I display "customerid" and "orderdate" from the custorder table, the format looks like this: ``` C-300064 06-DEC-10 ``` Basically I need to figure out how to get it to display only customerid where the last 2 digits of orderdate are 10. Can someone help me out please?
2017/09/13
[ "https://Stackoverflow.com/questions/46199583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8332686/" ]
> > I'm wanting to display all customers who placed an order during 2010. > > > As simple as: ``` SELECT customerid , orderdate FROM your_table WHERE orderdate >= DATE '2010-01-01' AND orderdate < DATE '2011-01-01'; ``` If orderdate is `DATE` column then how it is displayed doesn't matter. `DATE 'YYYY-MM-DD'` literal does not depend on your session `NLS_DATE_FORMAT`.
If you are using Oracle, you have several ways to achieve this using a WHERE clause on the "orderdate" column. However, when using Oracle SQL, you may need some additional code to account for different date formats. I believe these examples should work for you: ```sql SELECT t1.customerid, t1.orderdate FROM some_table t1 WHERE t1.orderdate BETWEEN '2017-01-01' AND '2017-12-31'; SELECT t1.customerid, t1.orderdate FROM some_table t1 WEHRE t1.orderdate > '2016-12-31' AND t1.orderdate < '2018-01-01'; SELECT t1.customerid, t1.orderdate FROM some_table t1 WHERE NOT ('2017-01-01' > t1.orderdate OR '2017-12-31' < t1.orderdate); ``` The BETWEEN method takes a little longer to process, so I would recommend the bottom two options (WHERE and WHERE NOT). I've built a fiddle that shows these three examples: <http://sqlfiddle.com/#!9/38063/1> Good luck!
46,199,583
I want to display all customers who placed an order during 2010. When I display "customerid" and "orderdate" from the custorder table, the format looks like this: ``` C-300064 06-DEC-10 ``` Basically I need to figure out how to get it to display only customerid where the last 2 digits of orderdate are 10. Can someone help me out please?
2017/09/13
[ "https://Stackoverflow.com/questions/46199583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8332686/" ]
Since you are using Oracle, this will work. ``` SELECT customerid , orderdate FROM yourtable WHERE EXTRACT(YEAR FROM orderdate) = 2010; ```
If you are using Oracle, you have several ways to achieve this using a WHERE clause on the "orderdate" column. However, when using Oracle SQL, you may need some additional code to account for different date formats. I believe these examples should work for you: ```sql SELECT t1.customerid, t1.orderdate FROM some_table t1 WHERE t1.orderdate BETWEEN '2017-01-01' AND '2017-12-31'; SELECT t1.customerid, t1.orderdate FROM some_table t1 WEHRE t1.orderdate > '2016-12-31' AND t1.orderdate < '2018-01-01'; SELECT t1.customerid, t1.orderdate FROM some_table t1 WHERE NOT ('2017-01-01' > t1.orderdate OR '2017-12-31' < t1.orderdate); ``` The BETWEEN method takes a little longer to process, so I would recommend the bottom two options (WHERE and WHERE NOT). I've built a fiddle that shows these three examples: <http://sqlfiddle.com/#!9/38063/1> Good luck!
55,739,464
if I try to `import tkinter` in my project, pycharm underlines **tkinter** as being a missing library. When I try to install the library, pycharm suggests to import the '**future**' library instead of the **tkinter** library. I don't know why. If I go to the project interpreter window, I cannot find the **tkinter** library after clicking on the install packages button. On the pycharm terminal, if I try to `pip install tkinter` it returns: *Could not find a version that satisfies the requirement tkinter (from versions: ) No matching distribution found for tkinter* I get the same result when trying `pip install python-tk`, `pip install python3-tk`, `and pip install tk`. Does anyone know why this is? I imported the project from windows into Ubuntu Mint 19.1, I am using interpreter Python 3.7.2. Please let me know if I can add any more useful info.
2019/04/18
[ "https://Stackoverflow.com/questions/55739464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7736693/" ]
Install it via apt. ``` sudo apt-get update && sudo apt install python3-tk ``` Works for me.
**tkinter** is a built in library in python. install this package :'**future**' using this command : ``` pip install future ``` now import '**tkinter**' in your project : ``` import tkinter ```
55,739,464
if I try to `import tkinter` in my project, pycharm underlines **tkinter** as being a missing library. When I try to install the library, pycharm suggests to import the '**future**' library instead of the **tkinter** library. I don't know why. If I go to the project interpreter window, I cannot find the **tkinter** library after clicking on the install packages button. On the pycharm terminal, if I try to `pip install tkinter` it returns: *Could not find a version that satisfies the requirement tkinter (from versions: ) No matching distribution found for tkinter* I get the same result when trying `pip install python-tk`, `pip install python3-tk`, `and pip install tk`. Does anyone know why this is? I imported the project from windows into Ubuntu Mint 19.1, I am using interpreter Python 3.7.2. Please let me know if I can add any more useful info.
2019/04/18
[ "https://Stackoverflow.com/questions/55739464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7736693/" ]
I fixed the issue by uninstalling PyCharm, and reinstalling it from the command line. The previous version I had installed it through the Linux Mint 19.1 Software Manager, and the version installed behaved in very strange ways; for instance it showed a completely different file tree to the one in my machine when trying to setup interpreters. Here is the command I used, as per JetBrains recommendation: `sudo snap install [pycharm-professional|pycharm-community] --classic` Note: I had to install snap first :)
**tkinter** is a built in library in python. install this package :'**future**' using this command : ``` pip install future ``` now import '**tkinter**' in your project : ``` import tkinter ```
177,858
I have a Hewlett Packard DV6. I connected to the access point. I receive an IP address/default gateway/DNS,etc(DHCP). I cannot ping my gateway. DNS lookups fails. There is just no connectivity. My driver is listed as being IWLWIFI. An lspci shows my card to be a Realtek RTL8101E/RTL8102E. I can't ping myself from another computer. ``` eth0 Link encap:Ethernet HWaddr c8:0a:a9:0c:a7:45 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:41 Base address:0xe000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:561 errors:0 dropped:0 overruns:0 frame:0 TX packets:561 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:42164 (42.1 KB) TX bytes:42164 (42.1 KB) wlan0 Link encap:Ethernet HWaddr 00:26:c7:04:97:c0 inet addr:192.168.1.109 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::226:c7ff:fe04:97c0/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:12 errors:0 dropped:0 overruns:0 frame:0 TX packets:71 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2035 (2.0 KB) TX bytes:12371 (12.3 KB) ```
2012/08/19
[ "https://askubuntu.com/questions/177858", "https://askubuntu.com", "https://askubuntu.com/users/32933/" ]
***No, this settings can't be changed in default setup***. Krunner and Kickoff are designed to display search suggestion after at least 3 letters in input. So, you can't change them because there is not configuration option to do so. * [See this Wikipedia Article](http://en.wikipedia.org/wiki/KDE_Plasma_Workspaces#KRunner) about Krunner. * Also see [this documentation in userbase.kde.org](http://userbase.kde.org/Plasma/Krunner) which says, krunner requires at least 3 letters to be typed to match for a partial search. [A bug report was filed](https://bugs.kde.org/show_bug.cgi?id=252675) against this behavior in <https://bugs.kde.org>, though it's status is still (7-9-2012) unconfirmed, the first response was > > As Plasma developers (somehow understandable) won‘t remove the 3 letters restricton, at least make it more obvious that it won‘t search bevore you‘ve entered at least 3 letters > > > So, it seems KDE developers are not willing to change this behavior. I think the only option is to change it yourself and then re-compile. Note that, both Krunner and Kickoff was designed in this way
Unlike Synapse, which tries to match items based on any input, Kickoff and Krunner are designed to match after you've inserted enough information to match with. My suggestion would be to report a bug against the two as a wishlist item, since there are currently no options (that I know of), that allow you to change this.
24,921,650
I am trying to do an elasticsearch query in the following way: * search for query * function score queries - one of which is on location that is nested, and another one to boost the scores of documents matching a particular type * document must match `{ verified: true }` I have an index called `users`, and within that index there are two types - `type1` and `type2`, each with exactly the same mappings. An example document in the `users` index would be this: ``` { name: 'Brian Fantana', location: { coordinates: { lat: 22.266858, lon: 114.152069 }, country: 'United States', city: 'New York' }, verified: true } ``` and the mapping: ``` { name: { type: 'string' }, location: { properties: { coordinates: { type: 'geo_point', lat_lon: true } } }, verified: { type: 'boolean' } } ``` I have tried the following: ``` { query: { bool: { must: { match: { verified: true } } }, query_string: { query: <query_string> }, function_score: { functions: [{ script_score: "doc['_type'].value == 'type1' ? _score * 100 : _score" }] }, nested: { path: 'location', query: { function_score: { functions: [{ gauss: { 'location.coordinates': <location>, scale: '50km' } }] } } } }] } } ``` Clearly, I have no idea how you would combine queries like this. Sorry for being an idiot.
2014/07/23
[ "https://Stackoverflow.com/questions/24921650", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2205763/" ]
Here's what I came up with. This is run against ES v1.2.2 - which is important, because earlier versions don't have the \_type field exposed for the script like this. In 1.3.0, dynamic scripting is deprecated. You can see I'm indexing several documents to demonstrate the successful application of the scoring functions. ``` #!/bin/sh echo "--- delete index" curl -X DELETE 'http://localhost:9200/so_multi_search/' echo "--- create index and put mapping into place" curl -XPUT "http://localhost:9200/so_multi_search/?pretty=true" -d '{ "mappings": { "type1": { "properties": { "group": { "type": "integer" }, "verified": { "type": "boolean" }, "name": { "type": "string" }, "location": { "properties": { "coordinates": { "type": "geo_point", "lat_lon": true } } } } }, "type2": { "properties": { "group": { "type": "integer" }, "verified": { "type": "boolean" }, "name": { "type": "string" }, "location": { "properties": { "coordinates": { "type": "geo_point", "lat_lon": true } } } } } }, "settings" : { "number_of_shards" : 1, "number_of_replicas" : 0 } }' echo "--- index users by POSTing" curl -XPOST "http://localhost:9200/so_multi_search/type1" -d '{ "name": "Brian Fantana", "location": { "coordinates": { "lat": 40.712784, "lon": -74.005941 }, "country": "United States", "city": "New York" }, "group": 1, "verified": true }' curl -XPOST "http://localhost:9200/so_multi_search/type2" -d '{ "name": "Brian Fantana", "location": { "coordinates": { "lat": 40.712784, "lon": -74.005941 }, "country": "United States", "city": "New York" }, "group": 2, "verified": true }' curl -XPOST "http://localhost:9200/so_multi_search/type2" -d '{ "name": "Anna Fantana", "location": { "coordinates": { "lat": 40.82, "lon": -73.5 }, "country": "United States", "city": "New York" }, "group": 2, "verified": true }' echo "--- flush index" curl -XPOST 'http://localhost:9200/_flush' echo "--- search the users" curl -XGET "http://localhost:9200/so_multi_search/_search?pretty=true" -d '{ "query": { "filtered": { "query": { "function_score": { "functions": [ { "filter": { "query": { "query_string": { "default_field": "name", "query": "Fantana" } } }, "script_score": { "script": "doc[\"_type\"].value == \"type1\" ? _score * 100 : _score" } }, { "gauss": { "location.coordinates": { "origin": "40.712784, -74.005941", "scale": "50km" } } } ] } }, "filter": { "query": { "bool": { "must": { "match": { "verified": true } } } } } } } }' ``` Output: ``` --- delete index {"acknowledged":true}--- create index and put mapping into place { "acknowledged" : true } --- index users by POSTing {"_index":"so_multi_search","_type":"type1","_id":"bAPnG5KfQXu_QIgGvY1mmA","_version":1,"created":true}{"_index":"so_multi_search","_type":"type2","_id":"XtCC8L6QRKueCdPsncAOpg","_version":1,"created":true}{"_index":"so_multi_search","_type":"type2","_id":"qlXiyXpQTySCLdMcL-DILw","_version":1,"created":true}--- flush index {"_shards":{"total":8,"successful":8,"failed":0}}--- search the users { "took" : 4, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "failed" : 0 }, "hits" : { "total" : 3, "max_score" : 100.0, "hits" : [ { "_index" : "so_multi_search", "_type" : "type1", "_id" : "bAPnG5KfQXu_QIgGvY1mmA", "_score" : 100.0, "_source":{ "name": "Brian Fantana", "location": { "coordinates": { "lat": 40.712784, "lon": -74.005941 }, "country": "United States", "city": "New York" }, "group": 1, "verified": true } }, { "_index" : "so_multi_search", "_type" : "type2", "_id" : "XtCC8L6QRKueCdPsncAOpg", "_score" : 1.0, "_source":{ "name": "Brian Fantana", "location": { "coordinates": { "lat": 40.712784, "lon": -74.005941 }, "country": "United States", "city": "New York" }, "group": 2, "verified": true } }, { "_index" : "so_multi_search", "_type" : "type2", "_id" : "qlXiyXpQTySCLdMcL-DILw", "_score" : 0.5813293, "_source":{ "name": "Anna Fantana", "location": { "coordinates": { "lat": 40.82, "lon": -73.5 }, "country": "United States", "city": "New York" }, "group": 2, "verified": true } } ] } } ```
Ok, after reading more into the query DSL, here is my solution: ``` query: { function_score: { query: { query_string: { query: query + '*' }, }, filter: { term: { verified: true } }, functions: [{ script_score: { script: "doc['_type'].value == 'type1' ? _score * 1000 : _score" }, gauss: { 'location.coordinates': { origin: [location.latitude, location.longitude], scale: '20km' } } }] } } ```
27,771,595
[This code](http://jsfiddle.net/we67Lp6o/1/) leaves this weirdly shaped border *(it's the active link border)* when you click the image, like so: ![enter image description here](https://i.stack.imgur.com/tIJ3X.jpg) And when we [put an orange background on the `<a>` element](http://jsfiddle.net/Lg5a0ksg/2/) we see that there's an orange area underneath the image. So, `<a>` wraps around the image, but also around an area underneath it. Why does `<a>` do that?
2015/01/04
[ "https://Stackoverflow.com/questions/27771595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3763850/" ]
First, by default element has an 'outline' decoration, to disable it use the following css rule: ``` a { outline: 0 } ``` Second, the area is created by another css property you apply on the image itself: 'margin', which is the margin between the image to the elements around it, in this case it affects the element which wraps it, to fix that change the following rules: ``` .socialBtn { /* Removed margin here so there won't be space around image */ height: 2.5em; width: 2.5em; } a { height: 2.5em; /* Gave it width like the image */ width: 2.5em; /* Gave it height like the image */ display: inline-block; /* Made it inline-block so it can have width and height */ } ``` <http://jsfiddle.net/we67Lp6o/6/> **UPDATE:** Changing source to understand how the display property: [block vs inline-block vs inline](https://stackoverflow.com/questions/9189810/css-display-inline-vs-inline-block). Removed "outline: 0" from a selector, it is a bad practice, read why [here](http://outlinenone.com/).
It's actually not spacing underneath at all. It's because your `a` tag is collapsed due to the default setting of `display:inline`. Adding `display: inline-block` to those `a`s will fix that issue: [**FIDDLE**](http://jsfiddle.net/Lg5a0ksg/3/) [Alohci offers a great explanation on why this happens](https://stackoverflow.com/a/18586297/3763850) **UPDATE** The extra spacing is the `margin` on the `img`: ``` .social a { display: inline-block; background-color: orange; padding: 0; margin: 0; vertical-align: top; } .socialBtn{ height: 2.5em; width: 2.5em; padding: 0; margin: 0; vertical-align: inherit; } ``` [**NEW FIDDLE**](http://jsfiddle.net/we67Lp6o/7/) [The spacing answer can be provided here](https://stackoverflow.com/a/3197613/3113558)
27,771,595
[This code](http://jsfiddle.net/we67Lp6o/1/) leaves this weirdly shaped border *(it's the active link border)* when you click the image, like so: ![enter image description here](https://i.stack.imgur.com/tIJ3X.jpg) And when we [put an orange background on the `<a>` element](http://jsfiddle.net/Lg5a0ksg/2/) we see that there's an orange area underneath the image. So, `<a>` wraps around the image, but also around an area underneath it. Why does `<a>` do that?
2015/01/04
[ "https://Stackoverflow.com/questions/27771595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3763850/" ]
It's actually not spacing underneath at all. It's because your `a` tag is collapsed due to the default setting of `display:inline`. Adding `display: inline-block` to those `a`s will fix that issue: [**FIDDLE**](http://jsfiddle.net/Lg5a0ksg/3/) [Alohci offers a great explanation on why this happens](https://stackoverflow.com/a/18586297/3763850) **UPDATE** The extra spacing is the `margin` on the `img`: ``` .social a { display: inline-block; background-color: orange; padding: 0; margin: 0; vertical-align: top; } .socialBtn{ height: 2.5em; width: 2.5em; padding: 0; margin: 0; vertical-align: inherit; } ``` [**NEW FIDDLE**](http://jsfiddle.net/we67Lp6o/7/) [The spacing answer can be provided here](https://stackoverflow.com/a/3197613/3113558)
Set your images to `display: block` (or alternatively, to `vertical-align: bottom`) to remove the default space at the bottom. (By default, images align to the `baseline` of any potential text next to them, and they leave that space there even if there's no text beside them.)
27,771,595
[This code](http://jsfiddle.net/we67Lp6o/1/) leaves this weirdly shaped border *(it's the active link border)* when you click the image, like so: ![enter image description here](https://i.stack.imgur.com/tIJ3X.jpg) And when we [put an orange background on the `<a>` element](http://jsfiddle.net/Lg5a0ksg/2/) we see that there's an orange area underneath the image. So, `<a>` wraps around the image, but also around an area underneath it. Why does `<a>` do that?
2015/01/04
[ "https://Stackoverflow.com/questions/27771595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3763850/" ]
It's actually not spacing underneath at all. It's because your `a` tag is collapsed due to the default setting of `display:inline`. Adding `display: inline-block` to those `a`s will fix that issue: [**FIDDLE**](http://jsfiddle.net/Lg5a0ksg/3/) [Alohci offers a great explanation on why this happens](https://stackoverflow.com/a/18586297/3763850) **UPDATE** The extra spacing is the `margin` on the `img`: ``` .social a { display: inline-block; background-color: orange; padding: 0; margin: 0; vertical-align: top; } .socialBtn{ height: 2.5em; width: 2.5em; padding: 0; margin: 0; vertical-align: inherit; } ``` [**NEW FIDDLE**](http://jsfiddle.net/we67Lp6o/7/) [The spacing answer can be provided here](https://stackoverflow.com/a/3197613/3113558)
`inline-block`is the property you need for the `<a>` elements. For the spacing issues, the margins need to be removed. The reason for the strangely shaped border, is of the `outline` property on `<a>`. It's showing you the area of your link, but due to the `display` and `margin` properties it is a different size than your `img`. Here is the new CSS: ``` .header { width: 650px; height: 150px; clear: left; margin: 0px auto; background-color: #efefef; position: relative; border-radius: 4em 4em 0 0; } .social{ padding: 1em 2em 0 0; display: inline-block; position: absolute; right: 0; } .socialBtn{ height: 2.5em; width: 2.5em; } img { display: block; } a { display: inline-block; background-color: orange; } ``` <http://jsfiddle.net/Lg5a0ksg/4/>
27,771,595
[This code](http://jsfiddle.net/we67Lp6o/1/) leaves this weirdly shaped border *(it's the active link border)* when you click the image, like so: ![enter image description here](https://i.stack.imgur.com/tIJ3X.jpg) And when we [put an orange background on the `<a>` element](http://jsfiddle.net/Lg5a0ksg/2/) we see that there's an orange area underneath the image. So, `<a>` wraps around the image, but also around an area underneath it. Why does `<a>` do that?
2015/01/04
[ "https://Stackoverflow.com/questions/27771595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3763850/" ]
First, by default element has an 'outline' decoration, to disable it use the following css rule: ``` a { outline: 0 } ``` Second, the area is created by another css property you apply on the image itself: 'margin', which is the margin between the image to the elements around it, in this case it affects the element which wraps it, to fix that change the following rules: ``` .socialBtn { /* Removed margin here so there won't be space around image */ height: 2.5em; width: 2.5em; } a { height: 2.5em; /* Gave it width like the image */ width: 2.5em; /* Gave it height like the image */ display: inline-block; /* Made it inline-block so it can have width and height */ } ``` <http://jsfiddle.net/we67Lp6o/6/> **UPDATE:** Changing source to understand how the display property: [block vs inline-block vs inline](https://stackoverflow.com/questions/9189810/css-display-inline-vs-inline-block). Removed "outline: 0" from a selector, it is a bad practice, read why [here](http://outlinenone.com/).
Set your images to `display: block` (or alternatively, to `vertical-align: bottom`) to remove the default space at the bottom. (By default, images align to the `baseline` of any potential text next to them, and they leave that space there even if there's no text beside them.)
27,771,595
[This code](http://jsfiddle.net/we67Lp6o/1/) leaves this weirdly shaped border *(it's the active link border)* when you click the image, like so: ![enter image description here](https://i.stack.imgur.com/tIJ3X.jpg) And when we [put an orange background on the `<a>` element](http://jsfiddle.net/Lg5a0ksg/2/) we see that there's an orange area underneath the image. So, `<a>` wraps around the image, but also around an area underneath it. Why does `<a>` do that?
2015/01/04
[ "https://Stackoverflow.com/questions/27771595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3763850/" ]
First, by default element has an 'outline' decoration, to disable it use the following css rule: ``` a { outline: 0 } ``` Second, the area is created by another css property you apply on the image itself: 'margin', which is the margin between the image to the elements around it, in this case it affects the element which wraps it, to fix that change the following rules: ``` .socialBtn { /* Removed margin here so there won't be space around image */ height: 2.5em; width: 2.5em; } a { height: 2.5em; /* Gave it width like the image */ width: 2.5em; /* Gave it height like the image */ display: inline-block; /* Made it inline-block so it can have width and height */ } ``` <http://jsfiddle.net/we67Lp6o/6/> **UPDATE:** Changing source to understand how the display property: [block vs inline-block vs inline](https://stackoverflow.com/questions/9189810/css-display-inline-vs-inline-block). Removed "outline: 0" from a selector, it is a bad practice, read why [here](http://outlinenone.com/).
`inline-block`is the property you need for the `<a>` elements. For the spacing issues, the margins need to be removed. The reason for the strangely shaped border, is of the `outline` property on `<a>`. It's showing you the area of your link, but due to the `display` and `margin` properties it is a different size than your `img`. Here is the new CSS: ``` .header { width: 650px; height: 150px; clear: left; margin: 0px auto; background-color: #efefef; position: relative; border-radius: 4em 4em 0 0; } .social{ padding: 1em 2em 0 0; display: inline-block; position: absolute; right: 0; } .socialBtn{ height: 2.5em; width: 2.5em; } img { display: block; } a { display: inline-block; background-color: orange; } ``` <http://jsfiddle.net/Lg5a0ksg/4/>
27,771,595
[This code](http://jsfiddle.net/we67Lp6o/1/) leaves this weirdly shaped border *(it's the active link border)* when you click the image, like so: ![enter image description here](https://i.stack.imgur.com/tIJ3X.jpg) And when we [put an orange background on the `<a>` element](http://jsfiddle.net/Lg5a0ksg/2/) we see that there's an orange area underneath the image. So, `<a>` wraps around the image, but also around an area underneath it. Why does `<a>` do that?
2015/01/04
[ "https://Stackoverflow.com/questions/27771595", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3763850/" ]
`inline-block`is the property you need for the `<a>` elements. For the spacing issues, the margins need to be removed. The reason for the strangely shaped border, is of the `outline` property on `<a>`. It's showing you the area of your link, but due to the `display` and `margin` properties it is a different size than your `img`. Here is the new CSS: ``` .header { width: 650px; height: 150px; clear: left; margin: 0px auto; background-color: #efefef; position: relative; border-radius: 4em 4em 0 0; } .social{ padding: 1em 2em 0 0; display: inline-block; position: absolute; right: 0; } .socialBtn{ height: 2.5em; width: 2.5em; } img { display: block; } a { display: inline-block; background-color: orange; } ``` <http://jsfiddle.net/Lg5a0ksg/4/>
Set your images to `display: block` (or alternatively, to `vertical-align: bottom`) to remove the default space at the bottom. (By default, images align to the `baseline` of any potential text next to them, and they leave that space there even if there's no text beside them.)
16,802,325
I want to decrement a database table value if the field value is greater than or equal to 1 (`>= 1`). Otherwise (if it IS less than 1) then I want to delete that whole database record, My code decrements the value continuously but does not delete the record when it reaches less than 1. I think the `$Check` variable does not hold the `Quantity` field value but I'm not sure: Using MySQL Here is my code: ``` $Check = "SELECT Quantity FROM Cart WHERE ItemCode = '1'"; if($Check >= '1') { $Query = "UPDATE Cart SET Quantity = Quantity - 1 WHERE ItemCode = '1'"; mysql_query($Query); } else { $DeleteRow = "DELETE FROM Cart WHERE ItemCode = '1'"; mysql_query($DeleteRow); } mysql_close(); ```
2013/05/28
[ "https://Stackoverflow.com/questions/16802325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2296715/" ]
If you're running under iOS 6 then `shouldAutorotateToInterfaceOrientation` has been deprecated. You should use `supportedInterfaceOrientationsForWindow:` and `shouldAutorotate` methods. Have a look at the iOS 6 release notes [here](https://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/index.html) under the UIKit heading.
It's `supportedInterfaceOrientations` on `UIViewController` you want to implement for iOS6 rather than `shouldAutorotateToInterfaceOrientation`.
10,272,950
I want to make it clear that I have no prior experience programming, I only have experience in HTML and SQL, everyone seems to be like "Look like the documentation" well yes that sure helps me! *sniff* \*sniff\* is there a book that could be recommendable or a series of webcasts?
2012/04/22
[ "https://Stackoverflow.com/questions/10272950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/519753/" ]
Welcome to the wonderful world of node.js! I myself have also just started learning Node.js and often asked myself "what is express?" "Why use express over node?" etc. Express is a fantastic web framework so you can develop robust applications with having a lot of the hard stuff done for you :) I highly recommend reading through his examples to have a feel how it all gets put together: <https://github.com/visionmedia/express/tree/master/examples> I found this screen cast very helpful in myself learning the basics: <http://vimeo.com/38136668> Proloser goes through explaining how to start a new express application, how to connect it to mongodb and explains how and why everything works :) He's created it for new noders. Us noders hang out on irc.freenode.net in the #node.js channel. Come and ask any questions you have and we will help set you on track :)
* I want to make it clear that I have no prior experience programming, * I only have experience in HTML and SQL Based on these two points, first you should learn programming. You want to learn NodeJS+Express+MongoDB which 3 of them are completely different things from what you already know. 1. First start with Javascript. This is more than enough: <http://www.w3schools.com/js/> * Write your scripts to a file named `try.js` and execute them with `node try.js` and see the results! 2. Then try to learn how a web application is built. Two basics for you: * You request something from server via HTTP, <http://myapp.com/users/all> * Server processes requests, and sends you a result in HTML * Your browser displays it. * More information at: <http://www.slideshare.net/nbrier/how-to-build-a-web-app-for-nonprogrammers> * Look the ExpressJS web site, and go step by step, and TRY EVERYTHING there 3. Then learn MongoDB, this is not SQL database, it's a NoSQL database, I do not know why you want to learn it, however, experimenting with <http://www.mongodb.org/display/DOCS/Tutorial> will definetely help. But all you have to do is looking in to examples. To use MongoDB from Node, you can use Mongoose.
10,272,950
I want to make it clear that I have no prior experience programming, I only have experience in HTML and SQL, everyone seems to be like "Look like the documentation" well yes that sure helps me! *sniff* \*sniff\* is there a book that could be recommendable or a series of webcasts?
2012/04/22
[ "https://Stackoverflow.com/questions/10272950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/519753/" ]
Welcome to the wonderful world of node.js! I myself have also just started learning Node.js and often asked myself "what is express?" "Why use express over node?" etc. Express is a fantastic web framework so you can develop robust applications with having a lot of the hard stuff done for you :) I highly recommend reading through his examples to have a feel how it all gets put together: <https://github.com/visionmedia/express/tree/master/examples> I found this screen cast very helpful in myself learning the basics: <http://vimeo.com/38136668> Proloser goes through explaining how to start a new express application, how to connect it to mongodb and explains how and why everything works :) He's created it for new noders. Us noders hang out on irc.freenode.net in the #node.js channel. Come and ask any questions you have and we will help set you on track :)
I think you should learn the basics of a programming language before getting deep into the frameworks. [**Code Year**](http://codeyear.com/) has a series of interactive programming lessons to learn JavaScript. You learn the language step by step from the ground up. When you have grasped JavaScript you can start using express and mongo and other frameworks.
10,272,950
I want to make it clear that I have no prior experience programming, I only have experience in HTML and SQL, everyone seems to be like "Look like the documentation" well yes that sure helps me! *sniff* \*sniff\* is there a book that could be recommendable or a series of webcasts?
2012/04/22
[ "https://Stackoverflow.com/questions/10272950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/519753/" ]
Welcome to the wonderful world of node.js! I myself have also just started learning Node.js and often asked myself "what is express?" "Why use express over node?" etc. Express is a fantastic web framework so you can develop robust applications with having a lot of the hard stuff done for you :) I highly recommend reading through his examples to have a feel how it all gets put together: <https://github.com/visionmedia/express/tree/master/examples> I found this screen cast very helpful in myself learning the basics: <http://vimeo.com/38136668> Proloser goes through explaining how to start a new express application, how to connect it to mongodb and explains how and why everything works :) He's created it for new noders. Us noders hang out on irc.freenode.net in the #node.js channel. Come and ask any questions you have and we will help set you on track :)
You have a long way to go, if you only know HTML/CSS. Take a look at <http://howtonode.org/express-mongodb> You have to have an advanced understanding of how to code modular JavaScript, JSON, Databases (especially NoSQL databases ). Cheers!
10,272,950
I want to make it clear that I have no prior experience programming, I only have experience in HTML and SQL, everyone seems to be like "Look like the documentation" well yes that sure helps me! *sniff* \*sniff\* is there a book that could be recommendable or a series of webcasts?
2012/04/22
[ "https://Stackoverflow.com/questions/10272950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/519753/" ]
* I want to make it clear that I have no prior experience programming, * I only have experience in HTML and SQL Based on these two points, first you should learn programming. You want to learn NodeJS+Express+MongoDB which 3 of them are completely different things from what you already know. 1. First start with Javascript. This is more than enough: <http://www.w3schools.com/js/> * Write your scripts to a file named `try.js` and execute them with `node try.js` and see the results! 2. Then try to learn how a web application is built. Two basics for you: * You request something from server via HTTP, <http://myapp.com/users/all> * Server processes requests, and sends you a result in HTML * Your browser displays it. * More information at: <http://www.slideshare.net/nbrier/how-to-build-a-web-app-for-nonprogrammers> * Look the ExpressJS web site, and go step by step, and TRY EVERYTHING there 3. Then learn MongoDB, this is not SQL database, it's a NoSQL database, I do not know why you want to learn it, however, experimenting with <http://www.mongodb.org/display/DOCS/Tutorial> will definetely help. But all you have to do is looking in to examples. To use MongoDB from Node, you can use Mongoose.
I think you should learn the basics of a programming language before getting deep into the frameworks. [**Code Year**](http://codeyear.com/) has a series of interactive programming lessons to learn JavaScript. You learn the language step by step from the ground up. When you have grasped JavaScript you can start using express and mongo and other frameworks.
10,272,950
I want to make it clear that I have no prior experience programming, I only have experience in HTML and SQL, everyone seems to be like "Look like the documentation" well yes that sure helps me! *sniff* \*sniff\* is there a book that could be recommendable or a series of webcasts?
2012/04/22
[ "https://Stackoverflow.com/questions/10272950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/519753/" ]
* I want to make it clear that I have no prior experience programming, * I only have experience in HTML and SQL Based on these two points, first you should learn programming. You want to learn NodeJS+Express+MongoDB which 3 of them are completely different things from what you already know. 1. First start with Javascript. This is more than enough: <http://www.w3schools.com/js/> * Write your scripts to a file named `try.js` and execute them with `node try.js` and see the results! 2. Then try to learn how a web application is built. Two basics for you: * You request something from server via HTTP, <http://myapp.com/users/all> * Server processes requests, and sends you a result in HTML * Your browser displays it. * More information at: <http://www.slideshare.net/nbrier/how-to-build-a-web-app-for-nonprogrammers> * Look the ExpressJS web site, and go step by step, and TRY EVERYTHING there 3. Then learn MongoDB, this is not SQL database, it's a NoSQL database, I do not know why you want to learn it, however, experimenting with <http://www.mongodb.org/display/DOCS/Tutorial> will definetely help. But all you have to do is looking in to examples. To use MongoDB from Node, you can use Mongoose.
You have a long way to go, if you only know HTML/CSS. Take a look at <http://howtonode.org/express-mongodb> You have to have an advanced understanding of how to code modular JavaScript, JSON, Databases (especially NoSQL databases ). Cheers!
10,525,890
How do I add a text to the right of the figure? I want to resize the plot to leave some empty space on the right and add some information there. Thanks!!
2012/05/10
[ "https://Stackoverflow.com/questions/10525890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1083320/" ]
If you want to put that text inside of a legend you can do: ``` legend('Some quick information','location','EastOutside') ``` That is easiest. For more control though, you can put a text box inside the figure window: ``` MyBox = uicontrol('style','text') set(MyBox,'String','Here is a lot more information') ``` and move it around with: ``` set(MyBox,'Position',[xpos,ypos,xsize,ysize]) ```
Try this for short text: ``` plot(1:5); text(5.05, 2.5, 'outside', 'clipping', 'off'); ``` Or this solution for more complex annotations: <http://radio.feld.cvut.cz/matlab/techdoc/creating_plots/chaxes6.html>
333,467
OK, I have an Alienware M14X and the keyboard backlight is always on and I can't turn it off... Google didn't me much. I want to turn it off because it's disturbing sometimes I uninstalled Windows OS from my laptop so I can't really disable it from there
2013/08/16
[ "https://askubuntu.com/questions/333467", "https://askubuntu.com", "https://askubuntu.com/users/180793/" ]
Change the color to black and it will be off.
For GNU-Linux systems you can use [alienware-kbl](http://rsm.imap.cc/software/gnu-linux/software/alienware-kbl). With that program you can control the lights of alienware computers.
71,669,133
``` df = pd.read_sql_query(query, con, parse_dates=["time"]).set_index("time") type(df_aq.index) ``` Why does this set index as DatetimeIndex (pandas.core.indexes.datetimes.DatetimeIndex) while the code below returns a RangeIndex (pandas.core.indexes.range.RangeIndex): ``` df = pd.read_sql_query(query, con, parse_dates=["time"]) df.set_index("time") type(df_aq.index) ```
2022/03/29
[ "https://Stackoverflow.com/questions/71669133", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16106459/" ]
You can use MIN to not allow the value to become greater than `0` ``` =MIN(SUM(A1,A2),0) ``` This will make any positive number `0` because `0` is lower than any positive number.
Something like this? ``` =IF(SUM(J87+K87)>0,0,J87+K87) ``` [![enter image description here](https://i.stack.imgur.com/qnory.png)](https://i.stack.imgur.com/qnory.png) [![enter image description here](https://i.stack.imgur.com/7QOfs.png)](https://i.stack.imgur.com/7QOfs.png)
42
One thing that we are starting to see are variations of the question of "what martial art should I practice." For example: * [Is aikido a good addition to Karate? Or shoud I go for jiu-jitsu?](https://martialarts.stackexchange.com/questions/94/is-aikido-a-good-addition-to-karate-or-shoud-i-go-for-jiu-jitsu) * [Which martial arts focus on self defense?](https://martialarts.stackexchange.com/questions/159/which-martial-arts-focus-on-self-defense) I would argue that we should consider these questions, unless they are very specific in scope, to be *off topic* in general, for many of the same reasons that [Board Games.SE](https://boardgames.meta.stackexchange.com/questions/656/should-we-ban-game-recommendation-questions-done) and [Gaming.SE](https://gaming.meta.stackexchange.com/questions/997/handling-game-recommendations-how-can-we-solve-these-two-problems-of-quality) have banned game recommendation questions: They are not a good fit for a Q&A format. There are just too many answers and too many of those answered are grounded in personal opinions or for which the reasons one art may be a better selection than another are highly debatable. There are, of course, going to be edge cases and recommendations that might fit better with the format (e.g., [What characteristics should I look for in a sensei?](https://martialarts.stackexchange.com/questions/160/what-characteristics-should-i-look-for-in-a-sensei)), but particularly when it comes down to the arts themselves I'd go with declaring such questions as off topic.
2012/02/02
[ "https://martialarts.meta.stackexchange.com/questions/42", "https://martialarts.meta.stackexchange.com", "https://martialarts.meta.stackexchange.com/users/11/" ]
**"What martial arts focus on x?" -style questions** Where x is "grappling" or "self-defense" or "high kicks" or "joint manipulation" seem perfectly valid to me. Some arts *do* focus on certain areas more than others. It seems plausible that the answers to these types of questions could provide valid, factual responses beyond mere opinion or anecdote. And if simple opinions of the style "my art is best" are offered, then it seems natural to avoid voting these up or to vote them down if they don't offer clear references as to why these arts are suited for the given requirement. Another approach is not to recommend individual arts, but instead to explain how to evaluate arts and schools for whatever requirement is given. In the closed ["What martial arts focus on self-defense?"](https://martialarts.stackexchange.com/questions/159/which-martial-arts-focus-on-self-defense) question, I attempted to provide an answer that didn't champion a particular art, but rather offered advice about what elements make a school better set up for teaching self-defense. **"What martial arts are suitable for y" -style questions** Where y is "blind and partially sighted people" or "children under five" or "amputees" are equally valid in my opinion. Again, this is likely to solicit opinion, but provided that opinions are backed by solid explanations, they're likely to offer useful information for the asker and future visitors. ### Avoiding the word "best" I think the key might be to avoid loaded words like "best" that will encourage arguments. Questions adopting this format should be edited to use "suitable" and "focus on" instead. ### Using "martial arts" instead of "martial art" Again, I think it's less contentious to ask "what martial *arts* are suitable" than it is to say "what martial *art* is suitable...". The plural form shows that the asker accepts that there's not necessarily one "best" art and is looking for three or four to evaluate. It may also be less likely to encourage "my art is best" -style responses. ### Choosing a martial art is difficult; we can help Finally, choosing a martial art to study is a common question because it's very difficult for beginners to evaluate individual arts and schools. There is no site on the web presently that attempts to do this from a neutral standpoint. I think we should accept it as a challenge and do our best to help. It might be valuable to have a "How to choose a martial art and martial arts school" wiki for a general overview. But I don't think it worth closing more specific questions about suitability for a particular area or person -- instead, we can simply rewrite questions where necessary to solicit facts rather than opinion.
I agree. The problem with these questions is that they are both subjective and too localised - the question of what martial art to practice depends on too many factors (age, location, past experience). Possibly a question "**How do I choose** what martial art to practice?" would be useful. Something like this would stand the best chance of answering these sorts of questions and would provide a suitable question for closing duplicates and possibly linking in the FAQ.
42
One thing that we are starting to see are variations of the question of "what martial art should I practice." For example: * [Is aikido a good addition to Karate? Or shoud I go for jiu-jitsu?](https://martialarts.stackexchange.com/questions/94/is-aikido-a-good-addition-to-karate-or-shoud-i-go-for-jiu-jitsu) * [Which martial arts focus on self defense?](https://martialarts.stackexchange.com/questions/159/which-martial-arts-focus-on-self-defense) I would argue that we should consider these questions, unless they are very specific in scope, to be *off topic* in general, for many of the same reasons that [Board Games.SE](https://boardgames.meta.stackexchange.com/questions/656/should-we-ban-game-recommendation-questions-done) and [Gaming.SE](https://gaming.meta.stackexchange.com/questions/997/handling-game-recommendations-how-can-we-solve-these-two-problems-of-quality) have banned game recommendation questions: They are not a good fit for a Q&A format. There are just too many answers and too many of those answered are grounded in personal opinions or for which the reasons one art may be a better selection than another are highly debatable. There are, of course, going to be edge cases and recommendations that might fit better with the format (e.g., [What characteristics should I look for in a sensei?](https://martialarts.stackexchange.com/questions/160/what-characteristics-should-i-look-for-in-a-sensei)), but particularly when it comes down to the arts themselves I'd go with declaring such questions as off topic.
2012/02/02
[ "https://martialarts.meta.stackexchange.com/questions/42", "https://martialarts.meta.stackexchange.com", "https://martialarts.meta.stackexchange.com/users/11/" ]
**"What martial arts focus on x?" -style questions** Where x is "grappling" or "self-defense" or "high kicks" or "joint manipulation" seem perfectly valid to me. Some arts *do* focus on certain areas more than others. It seems plausible that the answers to these types of questions could provide valid, factual responses beyond mere opinion or anecdote. And if simple opinions of the style "my art is best" are offered, then it seems natural to avoid voting these up or to vote them down if they don't offer clear references as to why these arts are suited for the given requirement. Another approach is not to recommend individual arts, but instead to explain how to evaluate arts and schools for whatever requirement is given. In the closed ["What martial arts focus on self-defense?"](https://martialarts.stackexchange.com/questions/159/which-martial-arts-focus-on-self-defense) question, I attempted to provide an answer that didn't champion a particular art, but rather offered advice about what elements make a school better set up for teaching self-defense. **"What martial arts are suitable for y" -style questions** Where y is "blind and partially sighted people" or "children under five" or "amputees" are equally valid in my opinion. Again, this is likely to solicit opinion, but provided that opinions are backed by solid explanations, they're likely to offer useful information for the asker and future visitors. ### Avoiding the word "best" I think the key might be to avoid loaded words like "best" that will encourage arguments. Questions adopting this format should be edited to use "suitable" and "focus on" instead. ### Using "martial arts" instead of "martial art" Again, I think it's less contentious to ask "what martial *arts* are suitable" than it is to say "what martial *art* is suitable...". The plural form shows that the asker accepts that there's not necessarily one "best" art and is looking for three or four to evaluate. It may also be less likely to encourage "my art is best" -style responses. ### Choosing a martial art is difficult; we can help Finally, choosing a martial art to study is a common question because it's very difficult for beginners to evaluate individual arts and schools. There is no site on the web presently that attempts to do this from a neutral standpoint. I think we should accept it as a challenge and do our best to help. It might be valuable to have a "How to choose a martial art and martial arts school" wiki for a general overview. But I don't think it worth closing more specific questions about suitability for a particular area or person -- instead, we can simply rewrite questions where necessary to solicit facts rather than opinion.
'What martial arts should I practice' is off-topic, because too personal - but this question comes up often, so the community should probably examine the possibility of a community wiki and/or a series of questions that can help someone decide. Not being able to offer insight into this question would be, I feel, a flaw. Of course, the answer, in *my* head, is "It depends on where you are, what's available to you, and who the teachers are", but that's just me - and I'm not the community :)
389,902
In languages such as C or Java we have the concepts of the Stack and the Heap. Are these abstractions the particular language runtime/compiler creates over the plain-old RAM? Or are these concepts inherent to the OS? In other words, do the Stack and Heap "physically" generally exist in any application regardless of the programming language or technology it was built with? Or are these abstractions managed by e.g. the C language compiler/runtime, and may not actually exist in other language implementations?
2019/04/06
[ "https://softwareengineering.stackexchange.com/questions/389902", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/121368/" ]
All of the above. It's complicated. Some CPU architectures, especially x86, include a dedicated stack pointer register and instructions that allow you to easily push/pop values on that stack. The Java Virtual Machine is a specification that defines the operations of the JVM in terms of a stack. Most instructions push and pop operands on that stack. Actual implementations must implement these instructions, but they don't actually have to use a stack here. Instead, a JIT-compiling JVM will typically place operands in registers as far as possible. Systems/platforms define an ABI (application binary interface). This includes things such as calling conventions. A calling convention covers details such as: * which registers must be saved before the call * which registers have to be preserved by the called function * where arguments are placed (usually: first arguments in registers, other arguments on the stack) * in which order arguments are placed on a stack * where return values are placed * where execution shall continue after the call completes (usually: a return address is saved on the stack by the caller) The calling convention depends on many factors: * First and foremost, the calling convention depends on the CPU architecture because the architecture dictates which registers are available. Often, a processor vendor will suggest a calling convention in the ISA manual. * The operating system typically defines an ABI. Strictly speaking the only mandatory part of the ABI is the part about system calls. However, operating systems are more than a kernel. If you want to use libraries installed on a system, you need to use the same calling convention they were compiled with. * The compiler defines an ABI. As an extension of the above point, software should generally be compiled with the same compiler as the libraries it wants to link. Calling conventions necessarily involve implementation-specific features such as dealing with multiple return values, or managing exceptions. * Some languages define an ABI for that language which fosters interoperability. This is still CPU-dependent, of course. * Some languages/compilers make it possible to select an ABI/calling convention on a per-function basis. This is sometimes called a “foreign function interface”. The system's C calling convention is generally understood by everyone. For example, if I want to write a library in C++ but want to allow anyone to link it without having to support my compiler's C++ ABI, I might declare the functions as `extern "C"`. Most calling conventions use a stack, because stacks are extremely convenient: special CPU instructions make them very efficient, they are a super easy and fast way to allocate small amounts of temporary memory, and the lifetime of the allocated memory matches the nested invocation of functions. A system that doesn't use pre-compiled binaries does not need a defined ABI: the calling convention is just an implementation detail. For example, an interpreter might use data structures in the host language to represent function calls. This might still be a stack, but it's generally not identical with the host system's stack. The Perl and CPython interpreters use C data structures as the “stack”. Some programming languages are not a good fit for a call stack model because functions do not have that clear hierarchy that a called function terminates before the calling function, or that the lifetime of data on the call stack is identical with the time that the function is active. In particular: * closures/inner functions may extend the lifetime of data that would usually be stored on the stack * coroutines are called and suspended multiple times while keeping consistent state + (each “thread” needs its own stack, and pre-allocating space for the whole stack may use too much memory) * continuations mean that a function doesn't necessarily return to the calling function, which makes cleanup of the calling function's stack frame difficult These problems generally require that instead of a single, simple call stack, the stack data is divided into multiple parts that are linked with pointers, and garbage-collected where necessary. For example, closures and coroutines are closely related to OOP objects. So yes, the stack does depend on the operating system and generally exists for real in memory, but some languages might not really use that stack, and how the stack is used differs, and there might be multiple stacks, and the stack might be fragmented into multiple parts, and no stack might exist in any recognizable form. The “heap” refers to other memory that a program can manage freely. The operating system doesn't know about the heap, it just knows about virtual address space that's mapped into a process. The language runtime manages this memory, for example `malloc()` in C. However, there are many different memory management techniques and not all of them should be described as a “heap” with its implied problems like memory fragmentation. In particular, arena allocators allow fixed-sized objects to be allocated efficiently. With compacting garbage collectors, memory allocation can be as fast as stack allocation and no memory fragmentation issues arise, but the GC algorithm implies a runtime overhead. Some parts of the virtual address space are neither stack nor heap, but e.g. data segments, program memory, `mmap()`ed files or shared memory, or memory that represents other resources (like a frame buffer). While writing normal software (anything other than compilers, linkers, and operating systems), and when not debugging arcane memory corruption issues in unsafe languages like C++, it is best to treat the presence or absence of a stack or heap as an implementation detail. It is sufficient to know that “compiled” implementations can typically allocate space for temporary/local variables very cheaply. In C/C++ there are also considerations about object lifetimes (e.g. don't return a pointer to an automatic variable).
In principle, you don't need a stack in some high-level programming languages, whose implementation have a [garbage collector](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)). At the low level (assembly, OS, ....) a stack is often needed (e.g. for [interrupts](https://en.wikipedia.org/wiki/Interrupt)). Details are architecture specific (different on x86-64, ARM 32 bits, PowerPC, etc...) You may want to read the following books and papers: * Andrew Appel's [book](https://rads.stackoverflow.com/amzn/click/com/0521416957) (green cover): *Compiling with continuations* ISBN-13: 978-0521416955 * Richard Jones, Antony Hosking, Eliot Moss [book](https://gchandbook.org/) (blue cover) : *Garbage Collection handbook* * Jacques Pitrat [book](https://rads.stackoverflow.com/amzn/click/com/1848211015) (yellow cover): *Artificial Beings, the conscience of a conscious machine*. * Appel's old [paper](https://www.cs.princeton.edu/%7Eappel/papers/45.pdf): *garbage collection can be faster than stack allocation* * Butenhof book (white and blue cover) *programming with POSIX threads* ISBN 0-201-63392-2 * Queinnec's [book](https://pages.lip6.fr/Christian.Queinnec/WWW/LiSP.html): *Lisp In Small Pieces* : the original French version is white-grey; *principes d'implantation de Scheme et Lisp* * blue book by Fisher, Faraboschi, Young: *Embedded Computing* ISBN 1-55860-766-8 * the [Dragon](https://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools) Book. In practice, recent programming languages or multi-threaded systems (e.g. [RefPerSys](http://refpersys.org/) or most [JVM](https://en.wikipedia.org/wiki/Java_virtual_machine)s) have *several* call stacks (one per thread). See (for Linux) [pthreads(7)](https://man7.org/linux/man-pages/man7/pthreads.7.html), [signal(7)](https://man7.org/linux/man-pages/man7/signal.7.html), [sigaltstack(2)](https://man7.org/linux/man-pages/man2/sigaltstack.2.html), [clone(2)](https://man7.org/linux/man-pages/man2/clone.2.html), [mmap(2)](https://man7.org/linux/man-pages/man2/mmap.2.html) and arguments passed to [pthread\_create(3)](https://man7.org/linux/man-pages/man3/pthread_create.3.html) and how [GNU libc](https://www.gnu.org/software/libc/) or [musl-libc](https://musl.libc.org/) implements it. Study also the open source implementation of [Go](https://golang.org/), or [SBCL](https://sbcl.org/) (an implementation of Common Lisp), or [Bigloo](https://github.com/manuel-serrano/bigloo), [GNU lightning](https://www.gnu.org/software/lightning/), [GNU bash](https://www.gnu.org/software/bash/), [Lua](https://www.lua.org/). Feel free to contact me by email.
389,902
In languages such as C or Java we have the concepts of the Stack and the Heap. Are these abstractions the particular language runtime/compiler creates over the plain-old RAM? Or are these concepts inherent to the OS? In other words, do the Stack and Heap "physically" generally exist in any application regardless of the programming language or technology it was built with? Or are these abstractions managed by e.g. the C language compiler/runtime, and may not actually exist in other language implementations?
2019/04/06
[ "https://softwareengineering.stackexchange.com/questions/389902", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/121368/" ]
All of the above. It's complicated. Some CPU architectures, especially x86, include a dedicated stack pointer register and instructions that allow you to easily push/pop values on that stack. The Java Virtual Machine is a specification that defines the operations of the JVM in terms of a stack. Most instructions push and pop operands on that stack. Actual implementations must implement these instructions, but they don't actually have to use a stack here. Instead, a JIT-compiling JVM will typically place operands in registers as far as possible. Systems/platforms define an ABI (application binary interface). This includes things such as calling conventions. A calling convention covers details such as: * which registers must be saved before the call * which registers have to be preserved by the called function * where arguments are placed (usually: first arguments in registers, other arguments on the stack) * in which order arguments are placed on a stack * where return values are placed * where execution shall continue after the call completes (usually: a return address is saved on the stack by the caller) The calling convention depends on many factors: * First and foremost, the calling convention depends on the CPU architecture because the architecture dictates which registers are available. Often, a processor vendor will suggest a calling convention in the ISA manual. * The operating system typically defines an ABI. Strictly speaking the only mandatory part of the ABI is the part about system calls. However, operating systems are more than a kernel. If you want to use libraries installed on a system, you need to use the same calling convention they were compiled with. * The compiler defines an ABI. As an extension of the above point, software should generally be compiled with the same compiler as the libraries it wants to link. Calling conventions necessarily involve implementation-specific features such as dealing with multiple return values, or managing exceptions. * Some languages define an ABI for that language which fosters interoperability. This is still CPU-dependent, of course. * Some languages/compilers make it possible to select an ABI/calling convention on a per-function basis. This is sometimes called a “foreign function interface”. The system's C calling convention is generally understood by everyone. For example, if I want to write a library in C++ but want to allow anyone to link it without having to support my compiler's C++ ABI, I might declare the functions as `extern "C"`. Most calling conventions use a stack, because stacks are extremely convenient: special CPU instructions make them very efficient, they are a super easy and fast way to allocate small amounts of temporary memory, and the lifetime of the allocated memory matches the nested invocation of functions. A system that doesn't use pre-compiled binaries does not need a defined ABI: the calling convention is just an implementation detail. For example, an interpreter might use data structures in the host language to represent function calls. This might still be a stack, but it's generally not identical with the host system's stack. The Perl and CPython interpreters use C data structures as the “stack”. Some programming languages are not a good fit for a call stack model because functions do not have that clear hierarchy that a called function terminates before the calling function, or that the lifetime of data on the call stack is identical with the time that the function is active. In particular: * closures/inner functions may extend the lifetime of data that would usually be stored on the stack * coroutines are called and suspended multiple times while keeping consistent state + (each “thread” needs its own stack, and pre-allocating space for the whole stack may use too much memory) * continuations mean that a function doesn't necessarily return to the calling function, which makes cleanup of the calling function's stack frame difficult These problems generally require that instead of a single, simple call stack, the stack data is divided into multiple parts that are linked with pointers, and garbage-collected where necessary. For example, closures and coroutines are closely related to OOP objects. So yes, the stack does depend on the operating system and generally exists for real in memory, but some languages might not really use that stack, and how the stack is used differs, and there might be multiple stacks, and the stack might be fragmented into multiple parts, and no stack might exist in any recognizable form. The “heap” refers to other memory that a program can manage freely. The operating system doesn't know about the heap, it just knows about virtual address space that's mapped into a process. The language runtime manages this memory, for example `malloc()` in C. However, there are many different memory management techniques and not all of them should be described as a “heap” with its implied problems like memory fragmentation. In particular, arena allocators allow fixed-sized objects to be allocated efficiently. With compacting garbage collectors, memory allocation can be as fast as stack allocation and no memory fragmentation issues arise, but the GC algorithm implies a runtime overhead. Some parts of the virtual address space are neither stack nor heap, but e.g. data segments, program memory, `mmap()`ed files or shared memory, or memory that represents other resources (like a frame buffer). While writing normal software (anything other than compilers, linkers, and operating systems), and when not debugging arcane memory corruption issues in unsafe languages like C++, it is best to treat the presence or absence of a stack or heap as an implementation detail. It is sufficient to know that “compiled” implementations can typically allocate space for temporary/local variables very cheaply. In C/C++ there are also considerations about object lifetimes (e.g. don't return a pointer to an automatic variable).
Stack and heap are more or less general concepts to organize computer memory. Usually the heap is just a big block of memory controlled by the operating system to care, that programs do not use the same memory range. A program or compiler has to ask for heap memory to use it. In most cases a stack ist controlled by the compiler to store return adresses from function calls, but you can easily create your own stack for whatever you want. Every array in Javascript can act as a stack, as you can use push and pull to add elements. The compiler stack often ist called a "return stack", as it is used mainly to store return adresses from function calls. Hope this helps.
5,997,677
I am trying to mix video, coming from the camera with a static image (watermarking). I have checked around questions/answers here and some examples, including WWDC AVEditDemo from Apple and ended with the following code. Unfortunately, the exported video does not contain the layer with the image. Any ideas? ``` - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { /// incoming video NSURL *videoURL = [info valueForKey:UIImagePickerControllerMediaURL]; /// UIImage into CALayer UIImage *myImage = [UIImage imageNamed:@"m1h.png"]; CALayer *aLayer = [CALayer layer]; aLayer.contents = (id)myImage.CGImage; AVURLAsset* url = [AVURLAsset URLAssetWithURL:videoURL options:nil]; AVMutableComposition *videoComposition = [AVMutableComposition composition]; NSError *error; NSFileManager *fileManager = [NSFileManager defaultManager]; AVMutableCompositionTrack *compositionVideoTrack = [videoComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; AVAssetTrack *clipVideoTrack = [[url tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; [compositionVideoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, [url duration]) ofTrack:clipVideoTrack atTime:kCMTimeZero error:&error]; AVMutableVideoComposition* videoComp = [[AVMutableVideoComposition videoComposition] retain]; videoComp.renderSize = CGSizeMake(640, 480); videoComp.frameDuration = CMTimeMake(1, 30); videoComp.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithAdditionalLayer:aLayer asTrackID:2]; /// instruction AVMutableVideoCompositionInstruction *instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; instruction.timeRange = CMTimeRangeMake(kCMTimeZero, CMTimeMakeWithSeconds(60, 30) ); AVMutableVideoCompositionLayerInstruction* layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:clipVideoTrack]; instruction.layerInstructions = [NSArray arrayWithObject:layerInstruction]; videoComp.instructions = [NSArray arrayWithObject: instruction]; /// outputs NSString *filePath = nil; filePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; filePath = [filePath stringByAppendingPathComponent:@"temp.mov"]; NSLog(@"exporting to: %@", filePath); if ([fileManager fileExistsAtPath:filePath]) { BOOL success = [fileManager removeItemAtPath:filePath error:&error]; if (!success) NSLog(@"FM error: %@", [error localizedDescription]); } /// exporting AVAssetExportSession *exporter; exporter = [[AVAssetExportSession alloc] initWithAsset:videoComposition presetName:AVAssetExportPresetHighestQuality] ; exporter.videoComposition = videoComp; exporter.outputURL=[NSURL fileURLWithPath:filePath]; exporter.outputFileType=AVFileTypeQuickTimeMovie; [statusLabel setText:@"processing..."]; [exporter exportAsynchronouslyWithCompletionHandler:^(void){ switch (exporter.status) { case AVAssetExportSessionStatusFailed: NSLog(@"exporting failed"); break; case AVAssetExportSessionStatusCompleted: NSLog(@"exporting completed"); UISaveVideoAtPathToSavedPhotosAlbum(filePath, self, @selector(video:didFinishSavingWithError:contextInfo:), NULL); break; case AVAssetExportSessionStatusCancelled: NSLog(@"export cancelled"); break; } }]; ``` }
2011/05/13
[ "https://Stackoverflow.com/questions/5997677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/726927/" ]
After playing around I ended up with something like this in a addition to the above code, also changing the used method to videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer: ``` CALayer *parentLayer = [CALayer layer]; CALayer *videoLayer = [CALayer layer]; parentLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); videoLayer.frame = CGRectMake(0, 0, videoSize.width, videoSize.height); [parentLayer addSublayer:videoLayer]; [parentLayer addSublayer:aLayer]; videoComp.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer]; ``` Hope it helps somebody.
i got this to work! heres the code! i didn't write most of it, i just tweaked some, but the only issue is the video itself is rotated for landscape in portrait mode? and then in landscape its portrait video, but the image is right side up! ``` CALayer *aLayer = [CALayer layer]; aLayer.frame = CGRectMake(5, 0, 320, 480); aLayer.bounds = CGRectMake(5, 0, 320, 480); aLayer.contents = (id) [UIImage imageNamed:@"image.png"].CGImage; aLayer.opacity = 0.5; aLayer.backgroundColor = [UIColor clearColor].CGColor; NSURL *url = [NSURL fileURLWithPath:[urlsOfVideos objectAtIndex:self.pageControl.currentPage]]; AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil]; cmp = [AVMutableComposition composition]; AVMutableCompositionTrack *trackA = [cmp addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid]; AVAssetTrack *sourceVideoTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; [trackA insertTimeRange:CMTimeRangeMake(kCMTimeZero, [asset duration]) ofTrack:sourceVideoTrack atTime:kCMTimeZero error:nil] ; animComp = [AVMutableVideoComposition videoComposition]; animComp.renderSize = CGSizeMake(320, 480); animComp.frameDuration = CMTimeMake(1,30); CALayer *parentLayer = [CALayer layer]; CALayer *videoLayer = [CALayer layer]; parentLayer.frame = CGRectMake(0, 0, 320, 480); videoLayer.frame = CGRectMake(0, 0, 320, 480); [parentLayer addSublayer:videoLayer]; [parentLayer addSublayer:aLayer]; animComp.animationTool = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer]; AVMutableVideoCompositionInstruction *instruction = [AVMutableVideoCompositionInstruction videoCompositionInstruction]; instruction.timeRange = CMTimeRangeMake(kCMTimeZero, [asset duration]); AVMutableVideoCompositionLayerInstruction *layerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:trackA]; //[layerInstruction setTrackID:2]; [layerInstruction setOpacity:1.0 atTime:kCMTimeZero]; instruction.layerInstructions = [NSArray arrayWithObject:layerInstruction] ; animComp.instructions = [NSArray arrayWithObject:instruction]; [self exportMovie:self]; ``` and here is the exporting code ``` -(IBAction) exportMovie:(id)sender{ NSArray *docPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *tempPath = [docPaths objectAtIndex:0]; NSLog(@"Temp Path: %@",tempPath); NSString *fileName = [NSString stringWithFormat:@"%@/output-anot.MOV",tempPath]; NSFileManager *fileManager = [NSFileManager defaultManager] ; if([fileManager fileExistsAtPath:fileName ]){ //NSError *ferror = nil ; //BOOL success = [fileManager removeItemAtPath:fileName error:&ferror]; } NSURL *exportURL = [NSURL fileURLWithPath:fileName]; AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:cmp presetName:AVAssetExportPresetHighestQuality] ; exporter.outputURL = exportURL; exporter.videoComposition = animComp; exporter.outputFileType= AVFileTypeQuickTimeMovie; [exporter exportAsynchronouslyWithCompletionHandler:^(void){ switch (exporter.status) { case AVAssetExportSessionStatusFailed:{ NSLog(@"Fail"); break; } case AVAssetExportSessionStatusCompleted:{ NSLog(@"Success"); break; } default: break; } }]; ``` }
61,873,574
I have looked at some threads here but could not find the solution to my question. I have a data.frame with 1284 columns (214 countries by 6 parameters) and I would like to reorder those. The principle is like the one in the example below. ``` # Reorder [A1 A2 A3 B1 B2 B3] to [A1 B1 A2 B2 A3 B3] x <- data.frame("A1"=1, "A2"=2, "A3"=3, "B1"=1, "B2"=2, "B3"=3) y <- x[,c(1, 4, 2, 5, 3, 6)] > x A1 A2 A3 B1 B2 B3 1 1 2 3 1 2 3 > y A1 B1 A2 B2 A3 B3 1 1 1 2 2 3 3 ``` That works very well but my data.frame has more columns and when I try the same idea I get an error, probably because the line is too long. ``` dfx<-dfy[,c(1,215,429,643,857,1071,2,216,430,644,858,1072,3,217,431,645,859,1073,4,218,432,646,860,1074,5,219,433,647,861,1075,6,220,434,648,862,1076,7,221,435,649,863,1077,8,222,436,650,864,1078,9,223,437,651,865,1079,10,224,438,652,866,1080,11,225,439,653,867,1081,12,226,440,654,868,1082,13,227,441,655,869,1083,14,228,442,656,870,1084,15,229,443,657,871,1085,16,230,444,658,872,1086,17,231,445,659,873,1087,18,232,446,660,874,1088,19,233,447,661,875,1089,20,234,448,662,876,1090,21,235,449,663,877,1091,22,236,450,664,878,1092,23,237,451,665,879,1093,24,238,452,666,880,1094,25,239,453,667,881,1095,26,240,454,668,882,1096,27,241,455,669,883,1097,28,242,456,670,884,1098,29,243,457,671,885,1099,30,244,458,672,886,1100,31,245,459,673,887,1101,32,246,460,674,888,1102,33,247,461,675,889,1103,34,248,462,676,890,1104,35,249,463,677,891,1105,36,250,464,678,892,1106,37,251,465,679,893,1107,38,252,466,680,894,1108,39,253,467,681,895,1109,40,254,468,682,896,1110,41,255,469,683,897,1111,42,256,470,684,898,1112,43,257,471,685,899,1113,44,258,472,686,900,1114,45,259,473,687,901,1115,46,260,474,688,902,1116,47,261,475,689,903,1117,48,262,476,690,904,1118,49,263,477,691,905,1119,50,264,478,692,906,1120,51,265,479,693,907,1121,52,266,480,694,908,1122,53,267,481,695,909,1123,54,268,482,696,910,1124,55,269,483,697,911,1125,56,270,484,698,912,1126,57,271,485,699,913,1127,58,272,486,700,914,1128,59,273,487,701,915,1129,60,274,488,702,916,1130,61,275,489,703,917,1131,62,276,490,704,918,1132,63,277,491,705,919,1133,64,278,492,706,920,1134,65,279,493,707,921,1135,66,280,494,708,922,1136,67,281,495,709,923,1137,68,282,496,710,924,1138,69,283,497,711,925,1139,70,284,498,712,926,1140,71,285,499,713,927,1141,72,286,500,714,928,1142,73,287,501,715,929,1143,74,288,502,716,930,1144,75,289,503,717,931,1145,76,290,504,718,932,1146,77,291,505,719,933,1147,78,292,506,720,934,1148,79,293,507,721,935,1149,80,294,508,722,936,1150,81,295,509,723,937,1151,82,296,510,724,938,1152,83,297,511,725,939,1153,84,298,512,726,940,1154,85,299,513,727,941,1155,86,300,514,728,942,1156,87,301,515,729,943,1157,88,302,516,730,944,1158,89,303,517,731,945,1159,90,304,518,732,946,1160,91,305,519,733,947,1161,92,306,520,734,948,1162,93,307,521,735,949,1163,94,308,522,736,950,1164,95,309,523,737,951,1165,96,310,524,738,952,1166,97,311,525,739,953,1167,98,312,526,740,954,1168,99,313,527,741,955,1169,100,314,528,742,956,1170,101,315,529,743,957,1171,102,316,530,744,958,1172,103,317,531,745,959,1173,104,318,532,746,960,1174,105,319,533,747,961,1175,106,320,534,748,962,1176,107,321,535,749,963,1177,108,322,536,750,964,1178,109,323,537,751,965,1179,110,324,538,752,966,1180,111,325,539,753,967,1181,112,326,540,754,968,1182,113,327,541,755,969,1183,114,328,542,756,970,1184,115,329,543,757,971,1185,116,330,544,758,972,1186,117,331,545,759,973,1187,118,332,546,760,974,1188,119,333,547,761,975,1189,120,334,548,762,976,1190,121,335,549,763,977,1191,122,336,550,764,978,1192,123,337,551,765,979,1193,124,338,552,766,980,1194,125,339,553,767,981,1195,126,340,554,768,982,1196,127,341,555,769,983,1197,128,342,556,770,984,1198,129,343,557,771,985,1199,130,344,558,772,986,1200,131,345,559,773,987,1201,132,346,560,774,988,1202,133,347,561,775,989,1203,134,348,562,776,990,1204,135,349,563,777,991,1205,136,350,564,778,992,1206,137,351,565,779,993,1207,138,352,566,780,994,1208,139,353,567,781,995,1209,140,354,568,782,996,1210,141,355,569,783,997,1211,142,356,570,784,998,1212,143,357,571,785,999,1213,144,358,572,786,1000,1214,145,359,573,787,1001,1215,146,360,574,788,1002,1216,147,361,575,789,1003,1217,148,362,576,790,1004,1218,149,363,577,791,1005,1219,150,364,578,792,1006,1220,151,365,579,793,1007,1221,152,366,580,794,1008,1222,153,367,581,795,1009,1223,154,368,582,796,1010,1224,155,369,583,797,1011,1225,156,370,584,798,1012,1226,157,371,585,799,1013,1227,158,372,586,800,1014,1228,159,373,587,801,1015,1229,160,374,588,802,1016,1230,161,375,589,803,1017,1231,162,376,590,804,1018,1232,163,377,591,805,1019,1233,164,378,592,806,1020,1234,165,379,593,807,1021,1235,166,380,594,808,1022,1236,167,381,595,809,1023,1237,168,382,596,810,1024,1238,169,383,597,811,1025,1239,170,384,598,812,1026,1240,171,385,599,813,1027,1241,172,386,600,814,1028,1242,173,387,601,815,1029,1243,174,388,602,816,1030,1244,175,389,603,817,1031,1245,176,390,604,818,1032,1246,177,391,605,819,1033,1247,178,392,606,820,1034,1248,179,393,607,821,1035,1249,180,394,608,822,1036,1250,181,395,609,823,1037,1251,182,396,610,824,1038,1252,183,397,611,825,1039,1253,184,398,612,826,1040,1254,185,399,613,827,1041,1255,186,400,614,828,1042,1256,187,401,615,829,1043,1257,188,402,616,830,1044,1258,189,403,617,831,1045,1259,190,404,618,832,1046,1260,191,405,619,833,1047,1261,192,406,620,834,1048,1262,193,407,621,835,1049,1263,194,408,622,836,1050,1264,195,409,623,837,1051,1265,196,410,624,838,1052,1266,197,411,625,839,1053,1267,198,412,626,840,1054,1268,199,413,627,841,1055,1269,200,414,628,842,1056,1270,201,415,629,843,1057,1271,202,416,630,844,1058,1272,203,417,631,845,1059,1273,204,418,632,846,1060,1274,205,419,633,847,1061,1275,206,420,634,848,1062,1276,207,421,635,849,1063,1277,208,422,636,850,1064,1278,209,423,637,851,1065,1279,210,424,638,852,1066,1280,211,425,639,853,1067,1281,212,426,640,854,1068,1282,213,427,641,855,1069,1283,214,428,642,856,1070,1284)] ``` Maybe there is a way to get it done manually but a more elegant solution would be nice.
2020/05/18
[ "https://Stackoverflow.com/questions/61873574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4213982/" ]
You can use Biostrings : ``` library(Biostrings) data = data.frame(Sequence=c("AGGATC","GTCCCA")) dinucleotideFrequency(DNAStringSet(as.character(data$Sequence))) AA AC AG AT CA CC CG CT GA GC GG GT TA TC TG TT [1,] 0 0 1 1 0 0 0 0 1 0 1 0 0 1 0 0 [2,] 0 0 0 0 1 2 0 0 0 0 0 1 0 1 0 0 ```
This one gives you a count for each cell of `data$Sequence`. ``` require(stringr) data <- data.frame(Sequence = c("AAGGATA", "TAAGCAA")) Couples <- paste0(rep(c("A", "C", "G", "T"),4), rep(c("A", "C", "G", "T"), each=4)) sapply(Couples, function(x) str_count(data$Sequence, x)) ``` For a total count add ``` colSums( sapply(Couples, function(x) str_count(data$Sequence, x)) ) ```
16,041,379
I'm doing some research for a new project, for which the constraints and specifications have yet to be set. One thing that is wanted is a large number of paths, directly under the root domain. This could ramp up to millions of paths. The paths don't have a common structure or unique parts, so I have to look for exact matches. Now I know it's more efficient to break up those paths, which would also help in the path lookup. However I'm researching the possibility here, so bear with me. I'm evaluating methods to accomplish this, while maintaining excellent performance. I thought of the following methods: * Storing the paths in an SQL database and doing a lookup on every request. This seems like the worst option and will definitely not be used. * Storing the paths in a key-value store like Redis. This would be a lot better, and perform quite well I think (have to benchmark it though). * Doing string/regex matching - like many frameworks do out of the box - for this amount of possible matches is nuts and thus not really an option. But I could see how doing some sort of algorithm where you compare letter-by-letter, in combination with some smart optimizations, could work. But maybe there are tools/methods I don't know about that are far more suited for this type of problem. I could use any tips on how to accomplish this though. Oh and in case anyone is wondering, no this isn't homework. --- **UPDATE** I've tested the Redis approach. Based on two sets of keywords, I got 150 million paths. I've added each of them using the `set` command, with the value being a serialized string of id's I can use to identify the actual keywords in the request. (`SET 'keyword1-keyword2' '<serialized_string>'`) A quick test in a local VM with a data set of one million records returned promising results: benchmarking 1000 requests took 2ms on average. And this was on my laptop, which runs tons of other stuff. Next I did a complete test on a VPS with 4 cores and 8GB of RAM, with the complete set of 150 million records. This yielded a database of 3.1G in file size, and around 9GB in memory. Since the database could not be loaded in memory entirely, Redis started swapping, which caused terrible results: around 100ms on average. Obviously this will not work and scale nice. Either each web server needs to have a enormous amount of RAM for this, or we'll have to use a dedicated Redis-routing server. I've read [an article](http://instagram-engineering.tumblr.com/post/12202313862/storing-hundreds-of-millions-of-simple-key-value-pairs) from the engineers at Instagram, who came up with a trick to decrease the database size dramatically, but I haven't tried this yet. Either way, this does not seem the right way to do this. Back to the drawing board.
2013/04/16
[ "https://Stackoverflow.com/questions/16041379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/339122/" ]
Redis is your best bet I think. SQL would be slow and regular expressions from my experience are always painfully slow in queries. I would do the following steps to test Redis: 1. Fire up a Redis instance either with a local VM or in the cloud on something like EC2. 2. Download a dictionary or two and pump this data into Redis. For example something from here: <http://wordlist.sourceforge.net/> Make sure you normalize the data. For example, always lower case the strings and remove white space at the start/end of the string, etc. 3. I would ignore the hash. I don't see the reason you need to hash the URL? It would be impossible to read later if you wanted to debug things and it doesn't seem to "buy" you anything. I went to <http://www.sha1-online.com/>, and entered `ryan` and got `ea3cd978650417470535f3a4725b6b5042a6ab59` as the hash. The original text would be much smaller to put in RAM which will help Redis. Obviously for longer paths, the hash would be better, but your examples were very small. =) 4. Write a tool to read from Redis and see how well it performs. 5. Profit! Keep in mind that Redis needs to keep the entire data set in RAM, so plan accordingly.
I would suggest using some kind of key-value store (i.e. a hashing store), possibly along with hashing the key so it is shorter (something like SHA-1 would be OK IMHO).
16,041,379
I'm doing some research for a new project, for which the constraints and specifications have yet to be set. One thing that is wanted is a large number of paths, directly under the root domain. This could ramp up to millions of paths. The paths don't have a common structure or unique parts, so I have to look for exact matches. Now I know it's more efficient to break up those paths, which would also help in the path lookup. However I'm researching the possibility here, so bear with me. I'm evaluating methods to accomplish this, while maintaining excellent performance. I thought of the following methods: * Storing the paths in an SQL database and doing a lookup on every request. This seems like the worst option and will definitely not be used. * Storing the paths in a key-value store like Redis. This would be a lot better, and perform quite well I think (have to benchmark it though). * Doing string/regex matching - like many frameworks do out of the box - for this amount of possible matches is nuts and thus not really an option. But I could see how doing some sort of algorithm where you compare letter-by-letter, in combination with some smart optimizations, could work. But maybe there are tools/methods I don't know about that are far more suited for this type of problem. I could use any tips on how to accomplish this though. Oh and in case anyone is wondering, no this isn't homework. --- **UPDATE** I've tested the Redis approach. Based on two sets of keywords, I got 150 million paths. I've added each of them using the `set` command, with the value being a serialized string of id's I can use to identify the actual keywords in the request. (`SET 'keyword1-keyword2' '<serialized_string>'`) A quick test in a local VM with a data set of one million records returned promising results: benchmarking 1000 requests took 2ms on average. And this was on my laptop, which runs tons of other stuff. Next I did a complete test on a VPS with 4 cores and 8GB of RAM, with the complete set of 150 million records. This yielded a database of 3.1G in file size, and around 9GB in memory. Since the database could not be loaded in memory entirely, Redis started swapping, which caused terrible results: around 100ms on average. Obviously this will not work and scale nice. Either each web server needs to have a enormous amount of RAM for this, or we'll have to use a dedicated Redis-routing server. I've read [an article](http://instagram-engineering.tumblr.com/post/12202313862/storing-hundreds-of-millions-of-simple-key-value-pairs) from the engineers at Instagram, who came up with a trick to decrease the database size dramatically, but I haven't tried this yet. Either way, this does not seem the right way to do this. Back to the drawing board.
2013/04/16
[ "https://Stackoverflow.com/questions/16041379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/339122/" ]
> > Storing the paths in an SQL database and doing a lookup on every request. This seems like the worst option and will definitely not be used. > > > You're probably underestimating what a database can do. Can I invite you to reconsider your position there? For Postgres (or MySQL w/ InnoDB), a million entries is a notch above tiny. Store the whole path in a field, add an index on it, vacuum, analyze. Don't do nutty joins until you've identified the ID of your key object, and you'll be fine in terms of lookup speeds. Say a few ms when running your query from psql. Your real issue will be the bottleneck related to disk IO if you get material amounts of traffic. The operating motto here is: the less, the better. Besides the basics such as installing APC on your php server, using Passenger if you're using Ruby, etc: 1. Make sure the server has plenty of RAM to fit that index. 2. Cache a reference to the object related to each path in memcached. 3. If you can categorize all routes in a dozen or so regex, they might help by allowing the use of smaller, more targeted indexes that are easier to keep in memory. If not, just stick to storing the (possibly trailing-slashed) entire path and move on. 4. Worry about misses. If you've a non-canonical URL that redirects to a canonical one, store the redirect in memcached without any expiration date and begone with it. 5. Did I mention lots of RAM and memcached? 6. Oh, and don't overrate that ORM you're using, either. Chances are it's taking more time to build your query than your data store is taking to parse, retrieve and return the results. 7. RAM... Memcached... To be very honest, Reddis isn't so different from a SQL + memcached option, except when it comes to memory management (as you found out), sharding, replication, and syntax. And familiarity, of course. Your key decision point (besides excluding iterating over more than a few regex) ought to be how your data is structured. If it's highly structured with critical needs for atomicity, SQL + memcached ought to be your preferred option. If you've custom fields all over and obese EAV tables, then playing with Reddis or CouchDB or another NoSQL store ought to be on your radar. In either case, it'll help to have *lots* of RAM to keep those indexes in memory, and a memcached cluster in front of the whole thing will never hurt if you need to scale.
I would suggest using some kind of key-value store (i.e. a hashing store), possibly along with hashing the key so it is shorter (something like SHA-1 would be OK IMHO).
16,041,379
I'm doing some research for a new project, for which the constraints and specifications have yet to be set. One thing that is wanted is a large number of paths, directly under the root domain. This could ramp up to millions of paths. The paths don't have a common structure or unique parts, so I have to look for exact matches. Now I know it's more efficient to break up those paths, which would also help in the path lookup. However I'm researching the possibility here, so bear with me. I'm evaluating methods to accomplish this, while maintaining excellent performance. I thought of the following methods: * Storing the paths in an SQL database and doing a lookup on every request. This seems like the worst option and will definitely not be used. * Storing the paths in a key-value store like Redis. This would be a lot better, and perform quite well I think (have to benchmark it though). * Doing string/regex matching - like many frameworks do out of the box - for this amount of possible matches is nuts and thus not really an option. But I could see how doing some sort of algorithm where you compare letter-by-letter, in combination with some smart optimizations, could work. But maybe there are tools/methods I don't know about that are far more suited for this type of problem. I could use any tips on how to accomplish this though. Oh and in case anyone is wondering, no this isn't homework. --- **UPDATE** I've tested the Redis approach. Based on two sets of keywords, I got 150 million paths. I've added each of them using the `set` command, with the value being a serialized string of id's I can use to identify the actual keywords in the request. (`SET 'keyword1-keyword2' '<serialized_string>'`) A quick test in a local VM with a data set of one million records returned promising results: benchmarking 1000 requests took 2ms on average. And this was on my laptop, which runs tons of other stuff. Next I did a complete test on a VPS with 4 cores and 8GB of RAM, with the complete set of 150 million records. This yielded a database of 3.1G in file size, and around 9GB in memory. Since the database could not be loaded in memory entirely, Redis started swapping, which caused terrible results: around 100ms on average. Obviously this will not work and scale nice. Either each web server needs to have a enormous amount of RAM for this, or we'll have to use a dedicated Redis-routing server. I've read [an article](http://instagram-engineering.tumblr.com/post/12202313862/storing-hundreds-of-millions-of-simple-key-value-pairs) from the engineers at Instagram, who came up with a trick to decrease the database size dramatically, but I haven't tried this yet. Either way, this does not seem the right way to do this. Back to the drawing board.
2013/04/16
[ "https://Stackoverflow.com/questions/16041379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/339122/" ]
> > Storing the paths in an SQL database and doing a lookup on every request. This seems like the worst option and will definitely not be used. > > > You're probably underestimating what a database can do. Can I invite you to reconsider your position there? For Postgres (or MySQL w/ InnoDB), a million entries is a notch above tiny. Store the whole path in a field, add an index on it, vacuum, analyze. Don't do nutty joins until you've identified the ID of your key object, and you'll be fine in terms of lookup speeds. Say a few ms when running your query from psql. Your real issue will be the bottleneck related to disk IO if you get material amounts of traffic. The operating motto here is: the less, the better. Besides the basics such as installing APC on your php server, using Passenger if you're using Ruby, etc: 1. Make sure the server has plenty of RAM to fit that index. 2. Cache a reference to the object related to each path in memcached. 3. If you can categorize all routes in a dozen or so regex, they might help by allowing the use of smaller, more targeted indexes that are easier to keep in memory. If not, just stick to storing the (possibly trailing-slashed) entire path and move on. 4. Worry about misses. If you've a non-canonical URL that redirects to a canonical one, store the redirect in memcached without any expiration date and begone with it. 5. Did I mention lots of RAM and memcached? 6. Oh, and don't overrate that ORM you're using, either. Chances are it's taking more time to build your query than your data store is taking to parse, retrieve and return the results. 7. RAM... Memcached... To be very honest, Reddis isn't so different from a SQL + memcached option, except when it comes to memory management (as you found out), sharding, replication, and syntax. And familiarity, of course. Your key decision point (besides excluding iterating over more than a few regex) ought to be how your data is structured. If it's highly structured with critical needs for atomicity, SQL + memcached ought to be your preferred option. If you've custom fields all over and obese EAV tables, then playing with Reddis or CouchDB or another NoSQL store ought to be on your radar. In either case, it'll help to have *lots* of RAM to keep those indexes in memory, and a memcached cluster in front of the whole thing will never hurt if you need to scale.
Redis is your best bet I think. SQL would be slow and regular expressions from my experience are always painfully slow in queries. I would do the following steps to test Redis: 1. Fire up a Redis instance either with a local VM or in the cloud on something like EC2. 2. Download a dictionary or two and pump this data into Redis. For example something from here: <http://wordlist.sourceforge.net/> Make sure you normalize the data. For example, always lower case the strings and remove white space at the start/end of the string, etc. 3. I would ignore the hash. I don't see the reason you need to hash the URL? It would be impossible to read later if you wanted to debug things and it doesn't seem to "buy" you anything. I went to <http://www.sha1-online.com/>, and entered `ryan` and got `ea3cd978650417470535f3a4725b6b5042a6ab59` as the hash. The original text would be much smaller to put in RAM which will help Redis. Obviously for longer paths, the hash would be better, but your examples were very small. =) 4. Write a tool to read from Redis and see how well it performs. 5. Profit! Keep in mind that Redis needs to keep the entire data set in RAM, so plan accordingly.
25,377,610
Hi i am new to wordpress , I am trying to validate a value. So each time the page loads the function must execute, is it possible to write it in my functions.php? ``` function checknewusr() { //My Code; } add_action('????', 'checknewusr'); ``` I am not aware of the action hook to give on that area so that my function will execute every time i load a page.
2014/08/19
[ "https://Stackoverflow.com/questions/25377610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2938305/" ]
`add_action()` adds a function when a certain situation occurs, `add_action('init','checknewusr');` should do it. There is quite an extensive array of actions, each targeting certain functions. It would probably be better to call `add_action()` on the most appropriate scenario rather than the `init` hook but this will work in most situations. **Reading Material:** [Codex - Add Action](http://codex.wordpress.org/Function_Reference/add_action) [Codex - Plugin API/Action Reference](http://codex.wordpress.org/Plugin_API/Action_Reference)
Use like this in functions.php: ``` function checknewusr() { //My Code; } if ( ! is_admin() ) { checknewusr(); } ``` This will execute every time any page loads in frontend.
1,214,107
. my steps assume $d=2$ and $n=1$, then $2$ divides $1 = 1/2$ if d does not divide $(n +1)$ then $2/1+1 = 1$ $1/2$ is not equal to $1$ hence it is false!
2015/03/31
[ "https://math.stackexchange.com/questions/1214107", "https://math.stackexchange.com", "https://math.stackexchange.com/users/227220/" ]
Let $d$ divide $n$. Therefore, for some natural $c$, $n=cd$. Assume $d$ also divides $n+1$, and therefore, for some natural $f$, $n+1=fd$. Since $n+1>n$ it follows $f>c$ so $f=c+g$ for some natural $g$. From this it follows $n+1=d(c+g)=cd+gd$. However $cd=n$ so we have $n+1=n+gd \Rightarrow 1=gd$. This is a contradiction! We are given $d>1$ and we have defined $g$ as a natural number, so $gd>1$, which contradicts our result $gd=1$. Thus, for all $d>1$ and natural $n$ if $d$ divides $n$ then $d$ does not divide $n+1$.
If $d$ divides $n+1$ as well $d$ must divide $1\cdot(n+1)+(-1)\cdot n$
1,214,107
. my steps assume $d=2$ and $n=1$, then $2$ divides $1 = 1/2$ if d does not divide $(n +1)$ then $2/1+1 = 1$ $1/2$ is not equal to $1$ hence it is false!
2015/03/31
[ "https://math.stackexchange.com/questions/1214107", "https://math.stackexchange.com", "https://math.stackexchange.com/users/227220/" ]
Let $d$ divide $n$. Therefore, for some natural $c$, $n=cd$. Assume $d$ also divides $n+1$, and therefore, for some natural $f$, $n+1=fd$. Since $n+1>n$ it follows $f>c$ so $f=c+g$ for some natural $g$. From this it follows $n+1=d(c+g)=cd+gd$. However $cd=n$ so we have $n+1=n+gd \Rightarrow 1=gd$. This is a contradiction! We are given $d>1$ and we have defined $g$ as a natural number, so $gd>1$, which contradicts our result $gd=1$. Thus, for all $d>1$ and natural $n$ if $d$ divides $n$ then $d$ does not divide $n+1$.
Assume $d|n$, and let $n=\alpha d$. Also assume $d|(n+1)$ and let $(n+1)=\beta d$. So $\alpha d + 1=\beta d$, and so $d(\beta-\alpha)=1$. But as $d\gt1$, this is impossible.
788,991
I wish to move files in a hadoop dir in a timely manner. The hadoop dir contains 1000 files with the same extension. I wish to move 100 of them every 10 minutes. I can setup a cron job to move the files every 10 minutes but I don't know how to specify the number of files to be moved. ``` hdfs dfs -ls /src/ | tail -100 | xargs hdfs dfs -mv {} / dest/ ``` Any command to use? Thanks in advance.
2016/06/19
[ "https://askubuntu.com/questions/788991", "https://askubuntu.com", "https://askubuntu.com/users/558859/" ]
You can use mv like this: mv -t target file1 file2 file3 ... ``` ls | head -n 100 | xargs mv -t destination ```
For the future generations: ``` hdfs dfs -mv `hdfs dfs -ls -C {your_src_hdfs_path} | head -{number_of_files}` {your_dest_hdfs_path} ```
788,991
I wish to move files in a hadoop dir in a timely manner. The hadoop dir contains 1000 files with the same extension. I wish to move 100 of them every 10 minutes. I can setup a cron job to move the files every 10 minutes but I don't know how to specify the number of files to be moved. ``` hdfs dfs -ls /src/ | tail -100 | xargs hdfs dfs -mv {} / dest/ ``` Any command to use? Thanks in advance.
2016/06/19
[ "https://askubuntu.com/questions/788991", "https://askubuntu.com", "https://askubuntu.com/users/558859/" ]
What about using a script like this: ``` #!/bin/bash Source="/where/they/are/now/*" Destination="/where/they/will/go" while true; do count=0 for file in $Source; do if [ $((count++)) -eq 100 ];then break else mv "$file" "$Destination" fi done sleep 10m done ```
For the future generations: ``` hdfs dfs -mv `hdfs dfs -ls -C {your_src_hdfs_path} | head -{number_of_files}` {your_dest_hdfs_path} ```
49,271
Watching films of Miles Davis performing in the 50's and 60's I noticed that whenever his solo was done he would take his index finger and press it beneath his right ear. Sometimes he would also shake his head as if it were painful to do so. I'm not sure if he did this later in his career or not. He acted very differently on stage in the 70's and later. Is the pressure from blowing the horn forcing air into someplace it shouldn't? Why only his right ear? Is this common among trumpet players? Here are a few stills of him doing this: [![enter image description here](https://i.stack.imgur.com/VEcSMm.jpg)](https://i.stack.imgur.com/VEcSMm.jpg) [![enter image description here](https://i.stack.imgur.com/syMChm.jpg)](https://i.stack.imgur.com/syMChm.jpg) [![enter image description here](https://i.stack.imgur.com/POFuAm.jpg)](https://i.stack.imgur.com/POFuAm.jpg)
2016/10/03
[ "https://music.stackexchange.com/questions/49271", "https://music.stackexchange.com", "https://music.stackexchange.com/users/23661/" ]
I believe it was to complaint to the band of some other aspect of the performance(intonation,rhythm, etc) he did not like. I do not have any specific source to back this at the moment, though I know that he was extremely sensitive of musicians playing slightly out of tune.
I always interpreted it as he was asking the band to "listen" - pay close attention to what is happening.
49,271
Watching films of Miles Davis performing in the 50's and 60's I noticed that whenever his solo was done he would take his index finger and press it beneath his right ear. Sometimes he would also shake his head as if it were painful to do so. I'm not sure if he did this later in his career or not. He acted very differently on stage in the 70's and later. Is the pressure from blowing the horn forcing air into someplace it shouldn't? Why only his right ear? Is this common among trumpet players? Here are a few stills of him doing this: [![enter image description here](https://i.stack.imgur.com/VEcSMm.jpg)](https://i.stack.imgur.com/VEcSMm.jpg) [![enter image description here](https://i.stack.imgur.com/syMChm.jpg)](https://i.stack.imgur.com/syMChm.jpg) [![enter image description here](https://i.stack.imgur.com/POFuAm.jpg)](https://i.stack.imgur.com/POFuAm.jpg)
2016/10/03
[ "https://music.stackexchange.com/questions/49271", "https://music.stackexchange.com", "https://music.stackexchange.com/users/23661/" ]
I believe it was to complaint to the band of some other aspect of the performance(intonation,rhythm, etc) he did not like. I do not have any specific source to back this at the moment, though I know that he was extremely sensitive of musicians playing slightly out of tune.
I would suspect that he had temporo-mandibular joint dysfunction and pain below the ear. It’s only a guess, but common to press or rub the muscles around that joint where the lower jaw (mandible) articulates with upper jaw.
49,271
Watching films of Miles Davis performing in the 50's and 60's I noticed that whenever his solo was done he would take his index finger and press it beneath his right ear. Sometimes he would also shake his head as if it were painful to do so. I'm not sure if he did this later in his career or not. He acted very differently on stage in the 70's and later. Is the pressure from blowing the horn forcing air into someplace it shouldn't? Why only his right ear? Is this common among trumpet players? Here are a few stills of him doing this: [![enter image description here](https://i.stack.imgur.com/VEcSMm.jpg)](https://i.stack.imgur.com/VEcSMm.jpg) [![enter image description here](https://i.stack.imgur.com/syMChm.jpg)](https://i.stack.imgur.com/syMChm.jpg) [![enter image description here](https://i.stack.imgur.com/POFuAm.jpg)](https://i.stack.imgur.com/POFuAm.jpg)
2016/10/03
[ "https://music.stackexchange.com/questions/49271", "https://music.stackexchange.com", "https://music.stackexchange.com/users/23661/" ]
Watching the Tonight Show from 1964, it seems he was angry about some aspect of the sound balance. When he does it during the blues, he changes where he's playing on the mic, putting his bell way past it, so maybe he thought he was way too hot and not balanced with the rest of the band. During So What, when he does it, he completely walks away from the mic and plays without any amplification.
I always interpreted it as he was asking the band to "listen" - pay close attention to what is happening.
49,271
Watching films of Miles Davis performing in the 50's and 60's I noticed that whenever his solo was done he would take his index finger and press it beneath his right ear. Sometimes he would also shake his head as if it were painful to do so. I'm not sure if he did this later in his career or not. He acted very differently on stage in the 70's and later. Is the pressure from blowing the horn forcing air into someplace it shouldn't? Why only his right ear? Is this common among trumpet players? Here are a few stills of him doing this: [![enter image description here](https://i.stack.imgur.com/VEcSMm.jpg)](https://i.stack.imgur.com/VEcSMm.jpg) [![enter image description here](https://i.stack.imgur.com/syMChm.jpg)](https://i.stack.imgur.com/syMChm.jpg) [![enter image description here](https://i.stack.imgur.com/POFuAm.jpg)](https://i.stack.imgur.com/POFuAm.jpg)
2016/10/03
[ "https://music.stackexchange.com/questions/49271", "https://music.stackexchange.com", "https://music.stackexchange.com/users/23661/" ]
I've seen him do this countless times and I believe it's either some tick, OR it's something he consciously does on purpose simply to add to the mysteriousness that of which is... Miles Davis.
I always interpreted it as he was asking the band to "listen" - pay close attention to what is happening.
49,271
Watching films of Miles Davis performing in the 50's and 60's I noticed that whenever his solo was done he would take his index finger and press it beneath his right ear. Sometimes he would also shake his head as if it were painful to do so. I'm not sure if he did this later in his career or not. He acted very differently on stage in the 70's and later. Is the pressure from blowing the horn forcing air into someplace it shouldn't? Why only his right ear? Is this common among trumpet players? Here are a few stills of him doing this: [![enter image description here](https://i.stack.imgur.com/VEcSMm.jpg)](https://i.stack.imgur.com/VEcSMm.jpg) [![enter image description here](https://i.stack.imgur.com/syMChm.jpg)](https://i.stack.imgur.com/syMChm.jpg) [![enter image description here](https://i.stack.imgur.com/POFuAm.jpg)](https://i.stack.imgur.com/POFuAm.jpg)
2016/10/03
[ "https://music.stackexchange.com/questions/49271", "https://music.stackexchange.com", "https://music.stackexchange.com/users/23661/" ]
The best I found via lmgtfy was these: From [reddit](https://www.reddit.com/r/Jazz/comments/2kqxly/miles_davis_plugging_his_ears_during_a_lester/?st=itved15t&sh=8636e34b) > > I always heard Miles would cover his ears to hear the other soloist > better. > > > OTOH, an [interview](http://hepcat1950.com/mdiv_sy.html) side note suggests it's purely a habit: > > "Had to drink some water 'cause I get dehydrated," Miles explained. > "Loretta knows. Sometimes I'll say, 'Loretta, something's funny about > me. What is it?' And she'll look at me and say, 'Fix your hair. It's > sticking out over there.'" > > > Miles touches his hair behind the right ear. > > > "You know, Sy, chicks just know about you. Cicely [Tyson] knows when I > don't feel good, and she'll call me up and say, 'What's the matter, > Miles?'" > > > As does [this review](http://www.nytimes.com/2001/05/13/arts/miles-davis-the-chameleon-of-cool-a-jazz-genius-in-the-guise-of-a-hustler.html?_r=0): > > Every gesture seems choreographed but effortless, the way he > nonchalantly walks onstage, rubs just behind his ear, puts his > impeccably manicured fingers to his lips just before bringing the horn > to his mouth. > > >
I would suspect that he had temporo-mandibular joint dysfunction and pain below the ear. It’s only a guess, but common to press or rub the muscles around that joint where the lower jaw (mandible) articulates with upper jaw.
49,271
Watching films of Miles Davis performing in the 50's and 60's I noticed that whenever his solo was done he would take his index finger and press it beneath his right ear. Sometimes he would also shake his head as if it were painful to do so. I'm not sure if he did this later in his career or not. He acted very differently on stage in the 70's and later. Is the pressure from blowing the horn forcing air into someplace it shouldn't? Why only his right ear? Is this common among trumpet players? Here are a few stills of him doing this: [![enter image description here](https://i.stack.imgur.com/VEcSMm.jpg)](https://i.stack.imgur.com/VEcSMm.jpg) [![enter image description here](https://i.stack.imgur.com/syMChm.jpg)](https://i.stack.imgur.com/syMChm.jpg) [![enter image description here](https://i.stack.imgur.com/POFuAm.jpg)](https://i.stack.imgur.com/POFuAm.jpg)
2016/10/03
[ "https://music.stackexchange.com/questions/49271", "https://music.stackexchange.com", "https://music.stackexchange.com/users/23661/" ]
The best I found via lmgtfy was these: From [reddit](https://www.reddit.com/r/Jazz/comments/2kqxly/miles_davis_plugging_his_ears_during_a_lester/?st=itved15t&sh=8636e34b) > > I always heard Miles would cover his ears to hear the other soloist > better. > > > OTOH, an [interview](http://hepcat1950.com/mdiv_sy.html) side note suggests it's purely a habit: > > "Had to drink some water 'cause I get dehydrated," Miles explained. > "Loretta knows. Sometimes I'll say, 'Loretta, something's funny about > me. What is it?' And she'll look at me and say, 'Fix your hair. It's > sticking out over there.'" > > > Miles touches his hair behind the right ear. > > > "You know, Sy, chicks just know about you. Cicely [Tyson] knows when I > don't feel good, and she'll call me up and say, 'What's the matter, > Miles?'" > > > As does [this review](http://www.nytimes.com/2001/05/13/arts/miles-davis-the-chameleon-of-cool-a-jazz-genius-in-the-guise-of-a-hustler.html?_r=0): > > Every gesture seems choreographed but effortless, the way he > nonchalantly walks onstage, rubs just behind his ear, puts his > impeccably manicured fingers to his lips just before bringing the horn > to his mouth. > > >
I always interpreted it as he was asking the band to "listen" - pay close attention to what is happening.
49,271
Watching films of Miles Davis performing in the 50's and 60's I noticed that whenever his solo was done he would take his index finger and press it beneath his right ear. Sometimes he would also shake his head as if it were painful to do so. I'm not sure if he did this later in his career or not. He acted very differently on stage in the 70's and later. Is the pressure from blowing the horn forcing air into someplace it shouldn't? Why only his right ear? Is this common among trumpet players? Here are a few stills of him doing this: [![enter image description here](https://i.stack.imgur.com/VEcSMm.jpg)](https://i.stack.imgur.com/VEcSMm.jpg) [![enter image description here](https://i.stack.imgur.com/syMChm.jpg)](https://i.stack.imgur.com/syMChm.jpg) [![enter image description here](https://i.stack.imgur.com/POFuAm.jpg)](https://i.stack.imgur.com/POFuAm.jpg)
2016/10/03
[ "https://music.stackexchange.com/questions/49271", "https://music.stackexchange.com", "https://music.stackexchange.com/users/23661/" ]
Watching the Tonight Show from 1964, it seems he was angry about some aspect of the sound balance. When he does it during the blues, he changes where he's playing on the mic, putting his bell way past it, so maybe he thought he was way too hot and not balanced with the rest of the band. During So What, when he does it, he completely walks away from the mic and plays without any amplification.
I believe it was to complaint to the band of some other aspect of the performance(intonation,rhythm, etc) he did not like. I do not have any specific source to back this at the moment, though I know that he was extremely sensitive of musicians playing slightly out of tune.
49,271
Watching films of Miles Davis performing in the 50's and 60's I noticed that whenever his solo was done he would take his index finger and press it beneath his right ear. Sometimes he would also shake his head as if it were painful to do so. I'm not sure if he did this later in his career or not. He acted very differently on stage in the 70's and later. Is the pressure from blowing the horn forcing air into someplace it shouldn't? Why only his right ear? Is this common among trumpet players? Here are a few stills of him doing this: [![enter image description here](https://i.stack.imgur.com/VEcSMm.jpg)](https://i.stack.imgur.com/VEcSMm.jpg) [![enter image description here](https://i.stack.imgur.com/syMChm.jpg)](https://i.stack.imgur.com/syMChm.jpg) [![enter image description here](https://i.stack.imgur.com/POFuAm.jpg)](https://i.stack.imgur.com/POFuAm.jpg)
2016/10/03
[ "https://music.stackexchange.com/questions/49271", "https://music.stackexchange.com", "https://music.stackexchange.com/users/23661/" ]
I've seen him do this countless times and I believe it's either some tick, OR it's something he consciously does on purpose simply to add to the mysteriousness that of which is... Miles Davis.
I would suspect that he had temporo-mandibular joint dysfunction and pain below the ear. It’s only a guess, but common to press or rub the muscles around that joint where the lower jaw (mandible) articulates with upper jaw.
49,271
Watching films of Miles Davis performing in the 50's and 60's I noticed that whenever his solo was done he would take his index finger and press it beneath his right ear. Sometimes he would also shake his head as if it were painful to do so. I'm not sure if he did this later in his career or not. He acted very differently on stage in the 70's and later. Is the pressure from blowing the horn forcing air into someplace it shouldn't? Why only his right ear? Is this common among trumpet players? Here are a few stills of him doing this: [![enter image description here](https://i.stack.imgur.com/VEcSMm.jpg)](https://i.stack.imgur.com/VEcSMm.jpg) [![enter image description here](https://i.stack.imgur.com/syMChm.jpg)](https://i.stack.imgur.com/syMChm.jpg) [![enter image description here](https://i.stack.imgur.com/POFuAm.jpg)](https://i.stack.imgur.com/POFuAm.jpg)
2016/10/03
[ "https://music.stackexchange.com/questions/49271", "https://music.stackexchange.com", "https://music.stackexchange.com/users/23661/" ]
Watching the Tonight Show from 1964, it seems he was angry about some aspect of the sound balance. When he does it during the blues, he changes where he's playing on the mic, putting his bell way past it, so maybe he thought he was way too hot and not balanced with the rest of the band. During So What, when he does it, he completely walks away from the mic and plays without any amplification.
I've seen him do this countless times and I believe it's either some tick, OR it's something he consciously does on purpose simply to add to the mysteriousness that of which is... Miles Davis.
49,271
Watching films of Miles Davis performing in the 50's and 60's I noticed that whenever his solo was done he would take his index finger and press it beneath his right ear. Sometimes he would also shake his head as if it were painful to do so. I'm not sure if he did this later in his career or not. He acted very differently on stage in the 70's and later. Is the pressure from blowing the horn forcing air into someplace it shouldn't? Why only his right ear? Is this common among trumpet players? Here are a few stills of him doing this: [![enter image description here](https://i.stack.imgur.com/VEcSMm.jpg)](https://i.stack.imgur.com/VEcSMm.jpg) [![enter image description here](https://i.stack.imgur.com/syMChm.jpg)](https://i.stack.imgur.com/syMChm.jpg) [![enter image description here](https://i.stack.imgur.com/POFuAm.jpg)](https://i.stack.imgur.com/POFuAm.jpg)
2016/10/03
[ "https://music.stackexchange.com/questions/49271", "https://music.stackexchange.com", "https://music.stackexchange.com/users/23661/" ]
Watching the Tonight Show from 1964, it seems he was angry about some aspect of the sound balance. When he does it during the blues, he changes where he's playing on the mic, putting his bell way past it, so maybe he thought he was way too hot and not balanced with the rest of the band. During So What, when he does it, he completely walks away from the mic and plays without any amplification.
I would suspect that he had temporo-mandibular joint dysfunction and pain below the ear. It’s only a guess, but common to press or rub the muscles around that joint where the lower jaw (mandible) articulates with upper jaw.
48,334,725
``` OleDbConn.ole = "SELECT InvoiceDate,InvoiceNo,Customer,SalesPerson,TotalAmount" +" FROM Invoice WHERE InvoiceDate BETWEEN " + startDate.ToString("yyyy-MM-dd") + " AND " + endDate.ToString("yyyy-MM-dd") + " AND (InvoiceNo LIKE '%" + txtSearch.Text + "%' OR SalesPerson LIKE '%"+ txtSearch.Text + "%' OR Customer LIKE '%" + txtSearch.Text + "%') GROUP BY InvoiceNo,InvoiceDate,Customer,SalesPerson,TotalAmount " +"ORDER BY InvoiceDate, InvoiceNo DESC"; //here is my search query dgw.Rows.Add( Convert.ToDateTime(OleDbConn.dr[0]).ToString("MM/dd/yyyy"), OleDbConn.dr[1].ToString(),OleDbConn.dr[2].ToString(), OleDbConn.dr[3].ToString(), Strings.FormatNumber(OleDbConn.dr[4]).ToString(), Strings.FormatNumber(OleDbConn.dr[4]).ToString()); //adding data to gridview ``` when a user selects the dates between its supposed to show data in gridview but its not, code works well in sql but its failing in ms-access
2018/01/19
[ "https://Stackoverflow.com/questions/48334725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9238419/" ]
First save your input value to some variables using onChangeText ``` <TextInput value= {this.state.userName} onChangeText = {(text)=>{ this.setState({userName:text}); } /> ``` Then you can pass the value , ``` <Button onPress={() => navigate('HomePage',{"userName":this.state.userName})} // you can pass objects title="Login" /> ```
``` class Login extends Component { constructor(props) { super(props); this.state = { userName:"", password:"" }; } updateUserName = (name) =>{ this.setState({ userName:name, }) } updatePwd = (pwd) =>{ this.setState({ password:pwd, }) } render() { const { navigate } = this.props.navigation return ( <View style={{ flex: 1 }}> <View style={styles.container}> <View style={styles.container1}> <TextInput style={{ width: 190, color: 'white' }} placeholder="User Name" placeholderTextColor="#f9f9f9" underlineColorAndroid="#f9f9f9" onChangeText={(name) => this.updateUserName(name)} value={this.state.userName} /> <TextInput placeholder="Password" secureTextEntry returnKeyType="go" ref={input => (this.passwordInput = input)} style={{ width: 190, color: 'white' }} placeholderTextColor="#f9f9f9" underlineColorAndroid="#f9f9f9" onChangeText={(pwd) => this.updatePwd(pwd)} value={this.state.password} /> <TouchableOpacity style={{ top: 10 }}> <Button color="#314561" onPress={() => navigate('HomePage',{userName:this.state.userName})} title="Login" /> </TouchableOpacity> </View> </View> </View> ) } } export default Login ``` file : homePage.js ``` constructor(props) { super(props); const { params } = this.props.navigation.state; var data = params.userName; this.state = { userName : data }; } ```
48,334,725
``` OleDbConn.ole = "SELECT InvoiceDate,InvoiceNo,Customer,SalesPerson,TotalAmount" +" FROM Invoice WHERE InvoiceDate BETWEEN " + startDate.ToString("yyyy-MM-dd") + " AND " + endDate.ToString("yyyy-MM-dd") + " AND (InvoiceNo LIKE '%" + txtSearch.Text + "%' OR SalesPerson LIKE '%"+ txtSearch.Text + "%' OR Customer LIKE '%" + txtSearch.Text + "%') GROUP BY InvoiceNo,InvoiceDate,Customer,SalesPerson,TotalAmount " +"ORDER BY InvoiceDate, InvoiceNo DESC"; //here is my search query dgw.Rows.Add( Convert.ToDateTime(OleDbConn.dr[0]).ToString("MM/dd/yyyy"), OleDbConn.dr[1].ToString(),OleDbConn.dr[2].ToString(), OleDbConn.dr[3].ToString(), Strings.FormatNumber(OleDbConn.dr[4]).ToString(), Strings.FormatNumber(OleDbConn.dr[4]).ToString()); //adding data to gridview ``` when a user selects the dates between its supposed to show data in gridview but its not, code works well in sql but its failing in ms-access
2018/01/19
[ "https://Stackoverflow.com/questions/48334725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9238419/" ]
First save your input value to some variables using onChangeText ``` <TextInput value= {this.state.userName} onChangeText = {(text)=>{ this.setState({userName:text}); } /> ``` Then you can pass the value , ``` <Button onPress={() => navigate('HomePage',{"userName":this.state.userName})} // you can pass objects title="Login" /> ```
Do the following changes : In Login component : **Username Field** ``` <TextInput style={{width:190,color:'white'}} placeholder="User Name" placeholderTextColor="#f9f9f9" underlineColorAndroid='#f9f9f9' onChangeText= {(username)=>this.setState({username})} /> ``` **Button :** ``` <TouchableOpacity style={{top:10}}> <Button color="#314561" onPress={() => navigate('HomePage'), { username: this.state.username }} title="Login"/> </TouchableOpacity> ``` In Home component: e.g. `render method` ``` render(){ const {state} = this.props.navigation; console.og(state.params.username) } ``` **Update :** In login constructor,initialise `state` ``` constructor(){ super(); this.state = {}; } ```
34,382,612
I am using the following code to save a spark DataFrame to JSON file ``` unzipJSON.write.mode("append").json("/home/eranw/Workspace/JSON/output/unCompressedJson.json") ``` the output result is: ``` part-r-00000-704b5725-15ea-4705-b347-285a4b0e7fd8 .part-r-00000-704b5725-15ea-4705-b347-285a4b0e7fd8.crc part-r-00001-704b5725-15ea-4705-b347-285a4b0e7fd8 .part-r-00001-704b5725-15ea-4705-b347-285a4b0e7fd8.crc _SUCCESS ._SUCCESS.crc ``` 1. How do I generate a single JSON file and not a file per line? 2. How can I avoid the \*crc files? 3. How can I avoid the SUCCESS file?
2015/12/20
[ "https://Stackoverflow.com/questions/34382612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3401244/" ]
If you want a single file, you need to do a `coalesce` to a single partition before calling write, so: ``` unzipJSON.coalesce(1).write.mode("append").json("/home/eranw/Workspace/JSON/output/unCompressedJson.json") ``` Personally, I find it rather annoying that the number of output files depend on number of partitions you have before calling `write` - especially if you do a `write` with a `partitionBy` - but as far as I know, there are currently no other way. I don't know if there is a way to disable the .crc files - I don't know of one - but you can disable the \_SUCCESS file by setting the following on the hadoop configuration of the Spark context. ``` sc.hadoopConfiguration.set("mapreduce.fileoutputcommitter.marksuccessfuljobs", "false") ``` Note, that you may also want to disable generation of the metadata files with: ``` sc.hadoopConfiguration.set("parquet.enable.summary-metadata", "false") ``` Apparently, generating the metadata files takes some time (see [this blog post](https://www.appsflyer.com/blog/the-bleeding-edge-spark-parquet-and-s3/)) but aren't actually that important (according to [this](http://search-hadoop.com/m/q3RTtrwSwe2hVzCu&subj=Re+Parquet+writing+gets+progressively+slower)). Personally, I always disable them and I have had no issues.
Just a little update in above answer. To disable crc and SUCCESS file, simply set property in spark session as follows(example) ``` spark = SparkSession \ .builder \ .appName("Python Spark SQL Hive integration example") \ .config("spark.sql.warehouse.dir", warehouse_location) \ .enableHiveSupport() \ .getOrCreate() spark.conf.set("mapreduce.fileoutputcommitter.marksuccessfuljobs", "false") ```
34,382,612
I am using the following code to save a spark DataFrame to JSON file ``` unzipJSON.write.mode("append").json("/home/eranw/Workspace/JSON/output/unCompressedJson.json") ``` the output result is: ``` part-r-00000-704b5725-15ea-4705-b347-285a4b0e7fd8 .part-r-00000-704b5725-15ea-4705-b347-285a4b0e7fd8.crc part-r-00001-704b5725-15ea-4705-b347-285a4b0e7fd8 .part-r-00001-704b5725-15ea-4705-b347-285a4b0e7fd8.crc _SUCCESS ._SUCCESS.crc ``` 1. How do I generate a single JSON file and not a file per line? 2. How can I avoid the \*crc files? 3. How can I avoid the SUCCESS file?
2015/12/20
[ "https://Stackoverflow.com/questions/34382612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3401244/" ]
If you want a single file, you need to do a `coalesce` to a single partition before calling write, so: ``` unzipJSON.coalesce(1).write.mode("append").json("/home/eranw/Workspace/JSON/output/unCompressedJson.json") ``` Personally, I find it rather annoying that the number of output files depend on number of partitions you have before calling `write` - especially if you do a `write` with a `partitionBy` - but as far as I know, there are currently no other way. I don't know if there is a way to disable the .crc files - I don't know of one - but you can disable the \_SUCCESS file by setting the following on the hadoop configuration of the Spark context. ``` sc.hadoopConfiguration.set("mapreduce.fileoutputcommitter.marksuccessfuljobs", "false") ``` Note, that you may also want to disable generation of the metadata files with: ``` sc.hadoopConfiguration.set("parquet.enable.summary-metadata", "false") ``` Apparently, generating the metadata files takes some time (see [this blog post](https://www.appsflyer.com/blog/the-bleeding-edge-spark-parquet-and-s3/)) but aren't actually that important (according to [this](http://search-hadoop.com/m/q3RTtrwSwe2hVzCu&subj=Re+Parquet+writing+gets+progressively+slower)). Personally, I always disable them and I have had no issues.
Ignore crc files on .write ``` val hadoopConf = spark.sparkContext.hadoopConfiguration val fs = org.apache.hadoop.fs.FileSystem.get(hadoopConf) fs.setWriteChecksum(false) ```
34,382,612
I am using the following code to save a spark DataFrame to JSON file ``` unzipJSON.write.mode("append").json("/home/eranw/Workspace/JSON/output/unCompressedJson.json") ``` the output result is: ``` part-r-00000-704b5725-15ea-4705-b347-285a4b0e7fd8 .part-r-00000-704b5725-15ea-4705-b347-285a4b0e7fd8.crc part-r-00001-704b5725-15ea-4705-b347-285a4b0e7fd8 .part-r-00001-704b5725-15ea-4705-b347-285a4b0e7fd8.crc _SUCCESS ._SUCCESS.crc ``` 1. How do I generate a single JSON file and not a file per line? 2. How can I avoid the \*crc files? 3. How can I avoid the SUCCESS file?
2015/12/20
[ "https://Stackoverflow.com/questions/34382612", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3401244/" ]
Just a little update in above answer. To disable crc and SUCCESS file, simply set property in spark session as follows(example) ``` spark = SparkSession \ .builder \ .appName("Python Spark SQL Hive integration example") \ .config("spark.sql.warehouse.dir", warehouse_location) \ .enableHiveSupport() \ .getOrCreate() spark.conf.set("mapreduce.fileoutputcommitter.marksuccessfuljobs", "false") ```
Ignore crc files on .write ``` val hadoopConf = spark.sparkContext.hadoopConfiguration val fs = org.apache.hadoop.fs.FileSystem.get(hadoopConf) fs.setWriteChecksum(false) ```
510,518
Install 14.04 through live usb to external-hdd on ASUS 105E-DS02, currently running 12.04 with broken wifi. The 8GB live usb and 3 dvds from PRIZX will provide the software. Have read through many answers and web sites, did note the need for internet connection which is not available until thats fixed. Hoping that wifi Atheros ath9k, internal, external Ralink and external rt2800usb Realtek rtl8192 are included in the software. The wifi issue is a seperate question (awaiting answers). Either way I wish to fix 12.04 and install 14.04 on external-hdd. The external-hdd is recognised in 12.04 , and there appears to the ability to boot external drive (recognised WD passport (750 GB) as such in BIOS) and to boot bootable (live) usb (also in BIOS) Any additional help will be much appreciated. Sure miss my now gone linux/bsd library and four servers.
2014/08/12
[ "https://askubuntu.com/questions/510518", "https://askubuntu.com", "https://askubuntu.com/users/315054/" ]
Overall just start the installation but when it gets to the page where it asks you to select install location and such select "something else" then set the bootloader install location to the external hdd and the / mount point on it as well.
Examples: Does not hightlight changing boot loader to sdb, if external drive, but shows other install screen shots: [How to Install Ubuntu on separate hard drive in a dual boot?](https://askubuntu.com/questions/312782/how-to-install-ubuntu-on-separate-hard-drive-in-a-dual-boot) [Install on Second Hard Drive with startup boot option?](https://askubuntu.com/questions/274371/install-on-second-hard-drive-with-startup-boot-option)