https://github.com/radarsh/til
Today I Learned
https://github.com/radarsh/til
Last synced: 3 months ago
JSON representation
Today I Learned
- Host: GitHub
- URL: https://github.com/radarsh/til
- Owner: radarsh
- Created: 2016-03-14T13:44:52.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-06-05T12:31:13.000Z (about 8 years ago)
- Last Synced: 2025-03-12T01:38:19.259Z (over 1 year ago)
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Today I Learned
A collection of TILs heavily inspired from [jbranchaud](https://github.com/jbranchaud/til).
## 5/6/2018 - IntelliJ constructor breakpoint
In IntelliJ, while debugging a Java application you can set breakpoints on constructors to track creation of objects. However, what would you do if the class doesn't declare any constructors (has only the implicit default constructor)? Just set a line breakpoint on the class declaration line `public class MyClass {` and it will be hit whenever an instance of this class is created.
## 20/07/2017 - IntelliJ Gradle dependency pasting
If you are looking to convert a Maven style dependency into Gradle style for use in your `build.gradle`, look no further. All you have to do copy something that looks like the below.
```xml
net.logstash.logback
logstash-logback-encoder
4.11
```
When you past it inside the `dependencies` block of your `build.gradle`, it gets automatically converted to the below format by intelligent IntelliJ.
```
compile 'net.logstash.logback:logstash-logback-encoder:4.11'
```
## 7/11/2016 - Bash readline arguments
I discovered this one by accident. Simply open Bash and type Alt + `digit` followed by any character and you'll find the character repeated `digit` times on your prompt.
More about this at http://stackoverflow.com/questions/562115/press-alt-numeric-in-bash-and-you-get-arg-numeric-what-is-that
## 14/03/2016 - CSS3 ch unit of measurement
This can be invaluable if you are trying to express the width of an element as a multiple of the character width.
The best part is that `ch` understands the changes in character width arising due to different font styles, sizes etc.
Example:
```css
.panel {
font-style: Consolas, monospace;
font-size: 12px;
}
.drawer {
width: 10ch;
}
```
```html
1234567890
```
The above will render both the `p` and the `div.drawer` elements at equal widths (provided the margins and paddings are set accordingly, of course).
What's more, the browser support for this is remarkably good too.
## 10/03/2016 - JavaScript input event
This is a robust way to handle changes to values of `input` and `textarea` elements. Browser support is excellent too.
Example:
```javascript
$("input.class-name").on("input", function(e) {
console.log("Value: ", $(this).val());
});
```
Before finding out about this, I was using the `keyup`, `keydown` and `keypress` events but each one comes with its own set of limitations. For instance, the `keyup` and `keydown` events don't filter out special keys such as `Ctrl` and `Alt`. The `keypress` isn't even a standard event and it gets tricky if you want to grab the value of a field after the key has been pressed.
## 26/02/2016 - Gradle offline mode
Extremely handy when you have to execute a Gradle task without connecting to the internet or remote repositories in situations such as when you're in a coffee shop or have no access to the network but have already downloaded all the dependencies.
Simply use the `--offline` switch in conjunction with your task commands.
Example:
```bash
$ gradle clean build --offline
```
Just keep in mind that it will only work if you have already downloaded all the required dependencies when you had access to the network.