w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Generalized `fold` or how to perform `fold` and `map` at a time
As f and g are functors, a natural transformation is what you're looking for (see also You Could Have Defined Natural Transformations). So a transformation like f :~> g = forall a. f a -> g a is needed to create xmap which is then just xmap :: (a -> b) -> (f :~> g) -> (f a -> g b) xmap f n = map f . n You still need to define types of (f :~> g), but there' not a general way of doing that.

Categories : Haskell

open file txt by notepad++ default java code
Right click on that txt file and go properties and change open with to notepad++. Now run your code and you can see now that file open in notepad++. First case your computer use notepad as default text editor and by doing above steps it will change to notepad++

Categories : Java

What would be the fold expression in Vim to fold unittests when using D?
Are you looking for a "foldexpression" or for a "fold command"? Supposing your cursor is on unittest, you can do zf/{/e to create a fold. Make it a mapping for more speed.

Categories : Vim

change default editor (core.editor) to notepad over SSH
It is not possible to launch a GUI program in Windows over a typical ssh session. If you would like to switch the default editor to a different terminal editor such as nano, you can do that with: git config --global core.editor "nano" Source

Categories : GIT

LocationManager region monitor is not what I expected. The region boundary looks bigger than my settings
My experience is that this is normal behavior. I've been using region monitoring for about 2.5 years now and since iOS 6, the -didExitRegion delegate takes much longer to trigger than the -didEnterRegion. I also had this behavior confirmed by an Apple Engineer during WWDC 2013. It doesn't sound as if they plan to improve the accuracy, rather delay, in the exit events. According to the engineer, the OS takes a lot longer to decipher that you've left because it has to completely get out of range of known Wifi networks and to new cell towers. It is much easier to determine you've arrived than it is to determine you've left. If it is only taking 300M or so to trigger your geofence (outside the 300M radius), I'd say you are probably within the operating limits of the geofence. If you need prec

Categories : IOS

How to disable a region when a child window pops up in another region in prism mef wpf
You can bind your viewModel's main content's attribute IsEnabled to a boolean property IsPopupGone. In the constructor of your toolbar subscribe EventAggregator to an event PopupWindowStateChanged and payload as a boolean. Then when your popup window(s) display, publish this event with True, and when closed publish as False. private bool isPopupGone = true; // default/original state assumed to be no childs showing public bool IsPopupGone { get { return isPopupGone; } set { isPopupGone = value; /* implement notifypropertychanged */ } } public ToolbarViewModel(IEventAggregator eventAggregator) { EventAggregator = eventAggregator; EventAggregator.GetEvent<PopupWindowStateChanged>().Subscribe(UpdateEnabledState); } public void UpdateEnabledState(bool isPopupShowing

Categories : Wpf

HBase region over region servers load not balanced
Are you using sequential rowkeys, like timestamp?If that is the case you might end up with RegionServer Hotspotting, putting uneven load on the servers. Avoid using sequential keys, if you can. If it is not possible create pre-splitted tables.

Categories : Hadoop

Emacs: select a region and type to delete the region
I don't think it does it out of the box, it looks like you have to turn on delete-selection-mode as per this article on EmacsWiki. So, basically put the following line into your .emacs: (delete-selection-mode 1)

Categories : Emacs

Fold up to the fold start, instead of the indent start
Chapters 48 and 49 of Learn Vimscript the Hard Way talk about how to do that, using foldmethod=expr instead of indent. Basically you need to make a custom ftplugin and put a folding script in it; the script contains functions used to determine what fold level different lines should have. As luck would have it, the example code given in those two chapters is for the Potion language which, like Python, is whitespace-sensitive, so it should be pretty easy to adapt it to Python. Since Vim already comes with a Python ftplugin, I think you can put the folding script described on the site into .vim/after/ftplugin/python instead of .vim/ftplugin/potion.

Categories : Vim

How can I get the country and region code using geolocation instead of full country and region names
You should use the short_name value for the country, which is the two-digit country code. These are ISO standard codes and should be the basis for your database lookup, not the localized country name.

Categories : Javascript

Combining Getters into a Fold
This is also possible with the Monoid instance posted in this answer: Getting multiple results from map with lens import Data.Monoid import Control.Lens instance Monoid r => Monoid (Accessor r a) where mempty = Accessor mempty mappend (Accessor a) (Accessor b) = Accessor $ a <> b Test: *Control.Lens Data.Monoid> ('a','b','c','d') ^.. (_1 <> _2 <> _3) "abc" "abc" is just ['a','b','c'], so this does what you want.

Categories : Haskell

JS/JQ Fix for Son of Suckerfish extending below fold?
In the end, I couldn't find an answer, so made a solution myself. The following is the code I used (requires jQuery): var winHeight = $(window).height(); $navULs = $('#nav ul'); $navULs.find('ul').each(function(i,v) { $this = $(v); var ulHeight = $this.height(); var parentHeight = $this.closest('li').height(); var parentTop = $this.offset().top; var parentBottom = parentTop + parentHeight; if ((winHeight - parentTop) &lt; ulHeight) { if (parentBottom &lt; ulHeight) { $this.css({ 'margin-top': '0px', // remove margin-top (added by suckerfish css) as it screws up the calculations 'top': '-' + (parentTop) + 'px' // move the menu up by the amount of px available above the parent's top });

Categories : Jquery

Above the fold screenshots using watir-webdriver
There is no way to get only visible part of the page using watir-webdriver, because selenium, which is used in this library does not provide such functionality. So one of possible solutions is crop a screenshot after its creation

Categories : Ruby

Haskell sqlite-simple fold IO
main :: IO () main = do conn <- open "C:\project.DB" theSum <- fold_ conn "SELECT rserial from conitr1" 0 ( ot (Only val) -> return $ (val::Int) + tot ) close conn I found an example here https://github.com/nurpax/db-bench/blob/master/haskell/Sqlite.hs#L24 and it works the same! Reading a type signature is the best place to start, but sometimes its not enough.

Categories : Haskell

Raphael SVG element overflows below the fold sometimes
Can you examine the generated source code while it's happening (I use the Web Developer tool and there's an option in there to view the generated source code — and am sure there0s something similar in Chrome) to see if there isn't an element being inserted before it (or that something in your program logic is causing the canvas to be duplicated). I once had some very strange behaviour with Raphael and found that it was linked to my inadvertently loading the same script twice on the page. I could always suggest absolute positioning too in CSS but that doesn't sound like it would fix the underlying problem. Good luck and a hope that helps.

Categories : CSS

Combining vim's fold and conceal feature
In general, the foldtext and conceal could be combined. But this needs to be implemented by yourself, following the conceal logic. The option foldtext defines the text to display, when a fold was closed. The value of the option could be a vim function or expression. so we could do pretty much modification on the original text. Conceal. usually it does: when X pattern matched, display Y instead of X. So we could write a function, read the foldstart line, check the conceal syntax patterns, if the line matches any, if True, then remove those matched part, and display the cchar. We set this function as value of foldtext option. Of course only for certain file type. For highlighting, these two groups could be used for foldtext. Folded line used for closed folds FoldColumn 'foldcolum

Categories : Vim

relation between monadic filter and fold
Not sure that it has any sense (since it has that strange reverse), but at least it type checked well: myFilterM :: Monad m => (a -> m Bool) -> [a] -> m [a] myFilterM p l = foldM f [] (reverse l) where f y x = do p1 <- p x return $ if p1 then (x:y) else y

Categories : Haskell

is there any stl algorithm work for 2-fold loop?
First off, STL is not going to give you magic performance benefits. There already is a std::accumulate which is easier then building your own. Probably not faster, though. Similarly, there's std::generate_n which calls a generator (such as &rand) N times. You first populate c before you call index.push_back(c);. It may be cheaper to push an empty vector, and set std::vector<int>& c = index.back().

Categories : C++

What is "above-the-fold content" in Google Pagespeed?
This is because Google recently changed the page speed tool to better reflect an increasingly mobile web. Mobile data networks have different performance characteristics than wired or wifi so you need to do different things to optimize for them. Above-the-fold is simply the first screen's worth--anything you don't need to scroll to see. Obviously, this varies depending on the device and its orientation, so you may need to generalize and maybe find some workable common options, maybe one targeting smartphones, one for tablets, and one for larger desktops. As for what CSS they are talking about, they are really intending all CSS needed to fully style whatever content is displayed ATF. To determine the load time of your ATF content, they are going to take a screen shot of the final version

Categories : Javascript

fold settings seem to screw up vim's pwd in certain circumstances
What gets persisted is determined by the 'viewoptions' setting. Unfortunately, there's no separate configuration value for the local working directory. It seems that Vim always adds the :lcd command when you've set a local one. To work around this, either avoid creating views for windows that currently have a window-local directory, or you could post-process the generated view script to remove / comment out the :lcd line. The session.vim plugins uses that approach for session files.

Categories : Vim

Reduce, fold or scan (Left/Right)?
In general, all 6 fold functions apply a binary operator to each element of a collection. The result of each step is passed on to the next step (as input to one of the binary operator's two arguments). This way we can cumulate a result. reduceLeft and reduceRight cumulate a single result. foldLeft and foldRight cumulate a single result using a start value. scanLeft and scanRight cumulate a collection of intermediate cumulative results using a start value. Accumulate From LEFT and forwards... With a collection of elements abc and a binary operator add we can explore what the different fold functions do when going forwards from the LEFT element of the collection (from A to C): val abc = List("A", "B", "C") def add(res: String, x: String) = { println(s"op: $res + $x = ${res + x}")

Categories : Scala

Fold the code only if file has more than 200 lines
You can get the number of lines in the buffer using the line function with a '$' parameter. For example, :echo line('$') will show the line count in the status bar. You should be able to use this in combination with BufRead to change your settings for each file you load based on its length.

Categories : Vim

Fold ribbon on MS CRM 2011 using JavaScript
I don't how supported this would be but something to look into is: Control + Shift + 5 is a keyboard shortcut which opens and closes the ribbon. Presumably there must be some event or function tided to that shortcut, so if you can dig around and find it you could try calling the code directly. Or you could try simulating the key press - Firing a Keyboard Event in JavaScript.

Categories : Javascript

how to write a function to fold certain patterns
Check if there's a plugin that does that. Read the help on how to write a custom folding function for the R filetype: :h 'foldexpr', :h fold-expr. Read the in-depth tutorial on custom folding in Learn Vim Script the Hard Way by Steve Losh: "Advanced Folding".

Categories : Vim

Fold highlighted text in eclipse
First, folding depends on the kind of editor your are using (Java, C/C++, JSP...). Anyway, to my knowledge, such a fine folding ability isn't available (in Juno) for the editors I have given as example. Here you can find a similar question and the answers that were given.

Categories : Eclipse

How do I case fold a string in Python 2?
There is a thread here which covers some of the issues (but may not resolve all), you can judge whether it is suitable for what you need. If this is no good then there are some useful tips for implementing case folding on the W3C site here.

Categories : Python

vim: open fold with remote-silent
Edit: The explanation below is slightly wrong but the method is sound. I missed that the --remote family takes an optional "init" command argument; it's part of the --remote-silent command not a new argument to gvim. The explanation below fits for if it was a new argument to gvim. The problem is that the Vim which runs to send the remote file will also run the +... command, rather than the Vim which actually edits the file. Try using --remote-send or --remote-expr after the --remote-silent, to send the commands you need to run after loading the file. I.e. something like: gvim --remote-silent myfile gvim --remote-send zv etc.

Categories : Vim

When to case fold and when to collate using Boost.Locale?
I think it depends on what you want to achieve. In the collation case (using collator_base::secondary), punctuation will be ignored as well. This is sometimes what you want, and sometimes not. So it's up to you to decide, which is to be preferred in a particular case. The documentations says: fold_case is generally a locale-independent operation, but it receives a locale as a parameter to determine the 8-bit encoding. For me generally means in this case, that fold_case is locale independent, and the locale is only used in order to determine the 8-bit encoding. (But I'm not an english native speaker...)

Categories : C++

leftnavigation animation doesnt fold in correcly
You should .stop() the animation queues in order to interrupt additional animations to build up: http://jsbin.com/oxisal/1/ $(".left-navigation ul li:not(.current)").hover(function( e ){ var mEnt = e.type=="mouseenter"; // boolean true/false $(this).stop().animate({width: mEnt?'95%':35}, mEnt?100:0, function() { $(this).find("span.nav-text").css({ display: mEnt? "inline-block" : "none" }); }); }); you should .stop() also on click

Categories : Jquery

"Eliminate render-blocking CSS in above-the-fold content"
A related question has been asked before: What is “above-the-fold content” in Google Pagespeed? Firstly you have to notice that this is all about 'mobile pages'. So when I interpreted your question and screenshot correctly, then this is not for your site! On the contrary - doing some of the things advised by Google in their guidelines will things make worse than better for 'normal' websites. And not everything that comes from Google is the "holy grail" just because it comes from Google. And they themselves are not a good role model if you have a look at their HTML markup. The best advice I could give you is: Set width and height on replaced elements in your CSS, so that the browser can layout the elements and doesn't have to wait for the replaced content! Additionally why do y

Categories : CSS

k-fold cross validation - how to get the prediction automatically?
As stated in the comments, caret makes cross-validation very easy. Just use the "glm" method, like so: > library(caret) > set.seed(2) > dat <- data.frame(label=round(runif(100,0,5)),v1=rnorm(100),v2=rnorm(100)) > tc <- trainControl("cv",10,savePred=T) > (fit <- train(label~.,data=dat,method="glm",trControl=tc,family=poisson(link = "log"))) 100 samples 2 predictors No pre-processing Resampling: Cross-Validation (10 fold) Summary of sample sizes: 90, 91, 91, 90, 90, 89, ... Resampling results RMSE Rsquared RMSE SD Rsquared SD 1.53 0.146 0.131 0.235 > fit$finalModel$family Family: poisson Link function: log > head(fit$pred) pred obs rowIndex .parameter Resample 1 2.684367 1 1 none Fold01 2 2.165246 1

Categories : R

Attempting to fold functions results in incorrect type
The problem is that you want to pass a polymorphically typed function to foldr. Note that while foldr itself has a polymorphic type, it expects its argument to have a monomorphic type. For functions to take polymorphic functions as arguments (and in fact use those argument functions polymorphically), you need so-called higher-rank polymorphism. The good news is that GHC supports higher-ranked polymorphic types (use the RankNTypes extension); the bad news is that type inference is undecidable for them. Hence, you will need explicit type signatures in your code in order to convince the type checker that your code is correct. Then the question of course arises what would be the type signature that you need for your function intToSize'? And then there's more bad news: as the type of your func

Categories : Haskell

How to fold by a tag a group of selected (neighbor) tags with XSLT1?
In XSLT 1.0 the standard technique to handle this sort of thing is called Muenchian grouping, and involves the use of a key that defines how the nodes should be grouped and a trick using generate-id to extract just the first node in each group as a proxy for the group as a whole. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:strip-space elements="*" /> <xsl:output indent="yes" /> <xsl:key name="elementsByGr" match="*[@gr]" use="@gr" /> <xsl:template match="@*|node()" name="identity"> <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> </xsl:template> <!-- match the first element with each @gr value --> <xsl:template match="*[@gr][generate-id() = gen

Categories : Xslt

Can I use a monadic action to filter Fold from Control.Lens?
why not mapM_ actionM <=< filterM predM $ toListOf YOUR_LENS_HERE YOUR_OBJECT_HERE or just mapM_ actionM <=< filterM predM $ xs if you really only need to work on a list

Categories : Haskell

Eliminate external render-blocking Javascript and CSS in above-the-fold content
I found a fix for this. I think the problem was on the server side. . My website runs on Windows Server. Under IIS Setting on custom MIME types , i added .css set mime type to text/css and .js set mime type to text/javascript. Haven't tried on Apache.

Categories : CSS

Automatically collapse/fold getters and setters or use compact format in NetBeans?
You can configure this in Tools / Options / Editor / General There you have a few code collapse configuration options: Code Foldings / Collapse by Default

Categories : Java

How would I wrap a Scanner instance such that I get a stream of doubles I can .fold() on without reading everyting in memory?
Based on guidance from @om-nom-nom, I've come up with the following solution: val in = new java.util.Scanner(...) val doubles = Iterator .continually(if (in.hasNextDouble) Some(in.nextDouble) else None) .takeWhile(_ != None) .map(_.get) val sum = doubles.reduce(_ + _) ...but I'm not particularly happy about the fiddling around with the stream; I'd be really happy to accept a cleaner solution as the answer. Update: looks like Thomas W has found a good solution; I'm gonna post it here for completeness' sake: val in = new Scanner(file) val it = new Iterator[Double] { def hasNext = in.hasNextDouble; def next = in.nextDouble } val sum = it.foldLeft(_ + _)

Categories : Scala

RegEx Notepad++
I suggest a two step approach. First get all the lines with the STNO and a number. Second remove everything except the number. Select the Mark tab in the find dialogue. Ensure Bookmark line is ticked. In the Find what box enter STNO:s*d+ and then click Mark all. Access Menu => Search => Bookmark => Copy bookmarked lines. Then paste into another buffer. Alternatively, to work in the same file use Menu => Search => Bookmark => Remove unmarked lines. Now you should have all the wanted lines in a buffer. Do a regular expression search and replace setting Find what to be ^.*STNO:s*(d+).*$ and Replace with to 1. Then click Replace all. The above assumes that there is only one number to be found per line. ========================= As only the numbers are wanted, another method would be to p

Categories : Regex

Notepad++ Any Character
Turn on regular expression mode in Find, with ". matches newline" enabled: Search for: ID.s.*[ ]+Debt:s.*$ Older versions of Notepad++ have difficulty matching multi-line regexes, be sure to have version 6+ Notepad++ for this to work.

Categories : Search

Intellisense in notepad++
I don't know if this is exactly what you're looking for, but Notepad++ (current releases) have a form of this known as AutoComplete - go to Settings > Preferences > Auto-completion and tick the enable auto-completion for each input* button. As for the Firefox OS API specifically, I don't know if that works. But I know you can achieve the intellisense effect with languages themselves, anyway. Keep in mind the differences between "Function Completion" and "Word completion" inside auto-complete: Function Completion uses external cues to tell you exactly what you're trying to write in, as it autocompletes functions from an API. Word completion meanwhile may be more helpful in your case; If Firefox OS API can't be worked into NPP, you can at least auto-complete functions that you've already

Categories : Firefox



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.