Skip to content

Instantly share code, notes, and snippets.

🎯
work smarter (but not sure)

Anton Vlasov whalemare

🎯
work smarter (but not sure)
Block or report user

Report or block whalemare

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybindings.json
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "cmd+q",
"command": "editor.action.showHover",
"when": "editorTextFocus"
},
{
"key": "cmd+w",
"command": "editor.action.smartSelect.expand",
@whalemare
whalemare / eslint-install.sh
Created Jul 28, 2019
Fast install ESLint and Prettier
View eslint-install.sh
#!/bin/bash
file="package.json"
if [ -f "$file" ]
then
# all is ok
echo ""
else
cd ..
if [ -f "$file" ]
@whalemare
whalemare / index.js
Created Jul 15, 2019
Simple .sortBy implementation for JS
View index.js
function compare(x, y) {
return x > y
}
/**
* @param {any[]} array list of items
* @param {() => boolean} f function selector
*/
function sortBy(array, f) {
return array.sort((x, y) => compare(f(x), f(y)))
View Fragment.kt
class ProfileFragment : Fragment() {
val viewModel: ProfileViewModel by viewModel()
}
@whalemare
whalemare / doctor.sh
Created Apr 29, 2019
React Native doctor that can solve your problems
View doctor.sh
#!/usr/bin/env bash
# If you dont know what happened just start this script for automatically trying solve your problem.
# Clear all your build folders and dependencies.
# Install dependencies again
platform=$1
platform=$(echo "$platform" | tr '[:upper:]' '[:lower:]') # to lower string
echo "Moving to the root project folder"
@whalemare
whalemare / remote_url.md
Created Apr 15, 2019 — forked from hofnerb/remote_url.md
git remote set-url
View remote_url.md

Review and Change Remote URL

git remote -v
# View existing remotes

git remote set-url origin https://github.com/user/repo2.git
# Change the 'origin' remote's URL

git remote add origin https://github.com/user/repo2.git
@whalemare
whalemare / IxKotlin.kt
Created Feb 14, 2019 — forked from acrylic-origami/IxKotlin.kt
Rx operator implementations from the five major classes outlined in https://lam.io/writing/ReactiveX using Kotlin reactive channels
View IxKotlin.kt
import kotlin.collections.*
import org.reactivestreams.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.reactive.*
import kotlinx.coroutines.*
import kotlin.coroutines.*
@ExperimentalCoroutinesApi
fun <T, U> Publisher<T>.debounce(timeout: Long, ctx: CoroutineContext) = GlobalScope.publish(ctx) {
var idx = 0;
View TextViewExt.kt
fun TextView.onTextChanged(handler: (text: CharSequence) -> Unit): TextWatcher {
val watcher = object : TextWatcher {
override fun afterTextChanged(editable: Editable?) {
}
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
}
override fun onTextChanged(text: CharSequence?, p1: Int, p2: Int, p3: Int) {
View NaiveActivity.kt
editSearch.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(editable: Editable?) {
}
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
}
override fun onTextChanged(charSequence: CharSequence?, p1: Int, p2: Int, p3: Int) {
val text = charSequence?.toString() ?: ""
@whalemare
whalemare / WindowExt.kt
Created Oct 9, 2018
Android set status bar light
View WindowExt.kt
@TargetApi(Build.VERSION_CODES.M)
fun Window.setLightStatusBar(light: Boolean) {
var flags = decorView.systemUiVisibility
if (light && (flags and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR == View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)) {
return
} else if (!light && (flags and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) {
return
}
You can’t perform that action at this time.