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
/** | |
implementation 'com.github.mik3y:usb-serial-for-android:3.4.6' | |
*/ | |
UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE); | |
UsbSerialProber prober = UsbSerialProber.getDefaultProber(); | |
List<UsbSerialDriver> availableDrivers = prober.findAllDrivers(usbManager); | |
if (availableDrivers.isEmpty()) { |
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
try { | |
val services = PrintServiceLookup.lookupPrintServices(null, null) | |
val printer = services.find { | |
it.name.lowercase().contains("star") | |
} ?: throw Exception("No printer") | |
val outputStream = ByteArrayOutputStream() | |
outputStream.write(byteArrayOf(27, 64)) // Initialize printer (ESC @) | |
outputStream.write("=== STRUK PEMBELIAN ===\n".toByteArray(charset("UTF-8"))) | |
outputStream.write("Item 1 x2 Rp10.000\n".toByteArray(charset("UTF-8"))) |
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 os | |
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "projectdir.settings") | |
import django | |
django.setup() | |
from django.contrib.auth.models import User |
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
# htdocs/ | |
# ├─ public/ | |
# │ └─.htaccess //second file | |
# │ | |
# ├─ src/ | |
# └─.htaccess //first file | |
# first .htaccess in root host folder | |
RewriteEngine On |
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
# For a symfony application to work properly, you MUST store this .htaccess in | |
# the same directory as your front controller, index.php, in a standard symfony | |
# web application is under the "public" project subdirectory. | |
# Use the front controller as index file. | |
DirectoryIndex index.php | |
# Uncomment the following line if you install assets as symlinks or if you | |
# experience problems related to symlinks when compiling LESS/Sass/CoffeScript. | |
# Options +FollowSymlinks |
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
/** | |
* Set this on a textview and then you can potentially open links locally if applicable | |
*/ | |
public class DefaultLinkMovementMethod extends LinkMovementMethod { | |
private OnLinkClickedListener mOnLinkClickedListener; | |
public DefaultLinkMovementMethod(OnLinkClickedListener onLinkClickedListener) { | |
mOnLinkClickedListener = onLinkClickedListener; | |
} |
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
//If you want to use a Compose in your XML file, you can add this to your layout file: | |
<androidx.compose.ui.platform.ComposeView | |
android:id="@+id/my_composable" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" /> | |
//and then, set the content: |
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 NVM_DIR=~/.nvm | |
export PATH=~/Library/Android/sdk/tools:$PATH | |
export PATH=~/Library/Android/sdk/platform-tools:$PATH | |
export PATH=/Library/flutter/bin:$PATH | |
source $(brew --prefix nvm)/nvm.sh |
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
RewriteBase / | |
RewriteCond %{REQUEST_URI} !^/(assets/?|$) | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteRule . /index.html [L] |
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 String.getSha256(): String { | |
val digest = MessageDigest.getInstance("SHA-256").apply { reset() } | |
val byteData: ByteArray = digest.digest(toByteArray()) | |
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | |
Base64.getEncoder().encodeToString(byteData) | |
} else { | |
String( | |
android.util.Base64.encode(byteData, android.util.Base64.DEFAULT), | |
StandardCharsets.UTF_8 | |
) |
NewerOlder