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
export const copyToClipboard = async (text) => { | |
if (!navigator.clipboard) | |
// Clipboard API not available | |
throw new Error('Your browser doesn\'t allow clipboard access') | |
try { | |
await navigator.clipboard.writeText(text) | |
} catch (e) { | |
log.error('Failed to copy', e) |
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
export const omit = (obj, fn) => Object.keys(obj) | |
.filter(it => fn(obj[it])) | |
.reduce((acc, it) => ({ ...acc, [it]: obj[it] }), {}) |
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
export const isNumeric = n => | |
!(isNaN(n)) && (typeof n !== 'object') && | |
(n != Number.POSITIVE_INFINITY) && (n != Number.NEGATIVE_INFINITY) |
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
export const selectText = el => { | |
if (!window.getSelection || !document.createRange) return | |
const sel = window.getSelection() | |
if (sel.toString() == '') | |
window.setTimeout(() => { | |
const range = document.createRange() | |
range.selectNodeContents(el) | |
sel.removeAllRanges() | |
sel.addRange(range) | |
}, 1) |
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
interface Observer<T> { | |
fun onChange(newValue: T?) | |
} | |
class Observable<T>(initialValue: T? = null) { | |
// List ov observers watching this value for changes | |
private val observers = mutableListOf<Observer<T>>() | |
// The real value of this observer |
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
import java.util.concurrent.ConcurrentLinkedQueue | |
interface IQueue { | |
val tasks: ConcurrentLinkedQueue<String> | |
val hasTasks: Boolean | |
var isRunning: Boolean | |
fun addTask(url: String) |
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
fun publicGetUniqueDevSet() : Vector<DevSet?>? { | |
val finder = DeviceFinder() | |
val uniqueDevSet: Vector<DevSet?> = Vector() | |
val devSets = if (Printer.getUserPrinterInfo() == null) { | |
finder.discoverDevice(false) | |
} else { | |
finder.discoverDevice(Printer.getUserPrinterInfo().enabledTethering) | |
} |
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
import android.content.SharedPreferences | |
import androidx.lifecycle.MutableLiveData | |
import androidx.preference.PreferenceManager | |
import com.orhanobut.hawk.Hawk | |
import com.splashthat.host.extensions.Plank | |
/** | |
* A [LiveData] implementation that reads and persists | |
* it's value using [SharedPreferences] via [Hawk] | |
*/ |
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
#!/usr/bin/env node | |
const shell = require('shelljs') | |
const inquirer = require('inquirer') | |
const chalk = require('chalk') | |
/** | |
* Gets a list of Git branches | |
* | |
* @return {Array[String]} |
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
import android.graphics.Canvas | |
import android.graphics.Color | |
import android.graphics.drawable.ColorDrawable | |
import android.graphics.drawable.Drawable | |
import androidx.recyclerview.widget.ItemTouchHelper | |
import androidx.recyclerview.widget.RecyclerView | |
import com.splashthat.host.R | |
import com.splashthat.host.api.Identifiable | |
import com.splashthat.host.extensions.getColorDrawable |