This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
More recent resolution: | |
1. cd ~/../../etc (go to etc folder in WSL). | |
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line). | |
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line). | |
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian). | |
5. cd ~/../../etc (go to etc folder in WSL). | |
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file). | |
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and | |
secondary. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create backing field for live date (ex. in ViewModel) | |
private val _$VARIABLE_NAME$ = MutableLiveData<$VARIABLE_TYPE$>() | |
val $VARIABLE_NAME$: LiveData<$VARIABLE_TYPE$> = _$VARIABLE_NAME$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has | |
* already been handled. | |
* | |
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled. | |
*/ | |
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> { | |
override fun onChanged(event: Event<T>?) { | |
event?.getContentIfNotHandled()?.let { value -> | |
onEventUnhandledContent(value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Used as a wrapper for data that is exposed via a LiveData that represents an event. | |
*/ | |
open class Event<out T>(private val content: T) { | |
var hasBeenHandled = false | |
private set // Allow external read but not write | |
/** | |
* Returns the content and prevents its use again. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
// code | |
// Clear focus for EditText on click outside | |
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean { | |
if (ev?.action == MotionEvent.ACTION_DOWN) { | |
(currentFocus as? EditText)?.let { et -> | |
Rect().also { rect -> | |
et.getGlobalVisibleRect(rect) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
now=`date +%Y%m%d-%H%M%S` | |
day_ago=7 | |
db_name="DB_NAME" | |
base_path="BASE_PATH" | |
dump_fpath="$base_path/backup_db-$now.sql.gz" | |
sudo -u postgres pg_dump $db_name | gzip -9 > $dump_fpath |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Files to ignore in a LaTeX project | |
syntax: glob | |
# General files to ignore | |
*~ | |
*.bak | |
# Mac os | |
.DS_Store |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import forms | |
from django.utils.translation import ugettext_lazy as _ | |
from django.core import validators | |
from django.core.validators import EMPTY_VALUES | |
from django.forms.fields import Field | |
# Same as https://djangosnippets.org/snippets/3012/ but compatible with Django 1.6 | |
class CommaSeparatedEmailField(Field): | |
description = _(u"E-mail address(es)") |