code-cleanup

Why CKEditor ignores empty div or is it something else?

时光毁灭记忆、已成空白 提交于 2020-01-06 02:28:13
问题 I have written a plugin that adds bootstrap grid into the editor.However it seems that CKEditor deletes the whole wrapping col div when there is no content inside it. Plugin on github: https://github.com/radko26/CKEditor_layoutmanagerPlugin/tree/master/layoutmanager This is what is default inside the dom.When i delete the 'content', the editor removes the wrapping div-layout-column . <div class="container-fluid layout-container"> <div class="row layout-row"> <div class="col-xs-3 col-sm-3 col

Extracting relative paths from absolute paths

笑着哭i 提交于 2020-01-02 09:29:13
问题 This is a seemingly simple problem but I am having trouble doing it in a clean manner. I have a file path as follows: /this/is/an/absolute/path/to/the/location/of/my/file What I need is to extract /of/my/file from the above given path since that is my relative path. The way I am thinking of doing it is as follows: String absolutePath = "/this/is/an/absolute/path/to/the/location/of/my/file"; String[] tokenizedPaths = absolutePath.split("/"); int strLength = tokenizedPaths.length; String

Organizing code files/XML files for Android SDK

孤街醉人 提交于 2019-12-30 08:58:10
问题 Can someone provide some strategies as to organizing my project so that it is clean? Say I have a bunch of activities; is it good to place them all into a separate package, while putting other classes (such as custom Adapters) in another package to separate "logic" better? Also, when creating XML files for layouts, how would I separate the layout XML files logically if I have some layouts that are for certain activities and other XML layout files for custom "rows" (to use with an Adapter) I

How do I initialize classes with lots of fields in an elegant way?

二次信任 提交于 2019-12-29 11:35:29
问题 In my application, I have to instantiate many different types of objects. Each type contains some fields and needs to be added to a containing type. How can I do this in an elegant way? My current initialization step looks something like this: public void testRequest() { //All these below used classes are generated classes from xsd schema file. CheckRequest checkRequest = new CheckRequest(); Offers offers = new Offers(); Offer offer = new Offer(); HotelOnly hotelOnly = new HotelOnly(); Hotel

How do I initialize classes with lots of fields in an elegant way?

六眼飞鱼酱① 提交于 2019-12-29 11:35:23
问题 In my application, I have to instantiate many different types of objects. Each type contains some fields and needs to be added to a containing type. How can I do this in an elegant way? My current initialization step looks something like this: public void testRequest() { //All these below used classes are generated classes from xsd schema file. CheckRequest checkRequest = new CheckRequest(); Offers offers = new Offers(); Offer offer = new Offer(); HotelOnly hotelOnly = new HotelOnly(); Hotel

RxJS Refactor nested map statement

試著忘記壹切 提交于 2019-12-29 07:42:42
问题 I have a service which uses @angular/http to load data from an API. I want to create a projection of the retrieved data for my Components using this data. Therefore I wrote the following code: getById(id: string) { return this.http .get(`https://my-api.io/${id}`) .map(response => response.json()) .map(contracts => contracts.map(contract => # <- Nested map new Contract( contract['id'], contract['description'] ) ) ); } In the 6th line I have a nested map -Statement reducing the readability of

Cleaning up after all JUnit tests without explicit test suite classes declaration

人走茶凉 提交于 2019-12-25 07:27:40
问题 In Intelij and Eclipse IDEs (and probably some others too) it's possible to run all test classes from a package (or even all test classes in a project) without the need to put each of them explicitly in a test suite class (this is something I want to avoid). Just right click -> run all tests and voilà! I've got one problem with that approach to testing though. I want to do some cleaning up after all the tests are done, but no matter what I do, nothing seems to work. At first, I tried using

Is there a tool that can track unused code automatically

こ雲淡風輕ζ 提交于 2019-12-24 02:28:16
问题 I currently have 6 different flex applications (widgets) that run on a main page. They all depend on one common library project. I am currently cleaning up the codebase quite dramatically and it is hard to keep overview this way especially since I inherited the codebase. Does anyone know a tool that can automatically inform me of any dead code? Cheers 回答1: There are a few tools out there. I'd start with this one from Adobe; which I believe is written as an eclipse plugin. FlexPMD is another

Remove useless files, includes, global variables and functions in C++

痴心易碎 提交于 2019-12-21 18:07:14
问题 I modified a huge C++ project with lots of files and functions. The problem is, that now there are tons of useless files, includes, global variables and functions. Removing them by hand would be a pain. Is there a tool that analyzes the code like a compiler does and deletes all unused stuff? I would prefer a tool for unix. Also a way to remove only one or a few of the useless components named above would help. 回答1: There several posibilities of the GNU toolchain itself to optimize codesize,

Sublime Text 2: Trim trailing white space on demand

你离开我真会死。 提交于 2019-12-18 09:59:08
问题 I know that Sublime Text 2 can delete the trailing white space on files upon saving. When working in a team and commiting a change to a file this tends to produce huge diffs which make peer code review more cumbersome. For that reason I prefer to only do the white space cleaning when I'm commiting huge changes to a file anyway and leave whitespace as it is for the minor changes. I would like to know if there's any command for executing the trimming of the white space on demand on a file,