Skip to content

Instantly share code, notes, and snippets.

@B0yma
B0yma / rename.ps1
Last active June 5, 2023 18:39
script for powershell to rename
# This script works by using the Get-ChildItem cmdlet to recursively search for all files and folders in the target directory. For each item, it checks whether its name contains the search string. If it does, it constructs the new name by replacing the search string with the replace string, and then renames the item using the Rename-Item cmdlet.
# Note that we're using the ToLower() method to convert the item name to lowercase before checking for the search string. This ensures that we catch variations of the search string that are spelled with different capitalization.
# Again, you should use this script with caution, especially when renaming directories that contain files, as it can cause issues with file paths and dependencies.
# To run this PowerShell script, save it with a .ps1 extension (e.g., rename_comments.ps1) and execute it from a PowerShell prompt by entering the file path, e.g.: .\rename_comments.ps1. You will then be prompted to enter the target directory path.
$searchString = "string1"
@B0yma
B0yma / YasivAddUserList.js
Last active August 18, 2020 18:32
YasivAddUserList
var items = [
'567',
'2346'
];
var i = 0;
function myLoop() {
setTimeout(function() {
@Root(name="Node")
class Node (
@field:Element(name = "title", required = false)
var title: String? = null
)
val n = Node("sad")
val serializer: Serializer = Persister()
val writer = StringWriter()
@B0yma
B0yma / BindingAdapter.kt
Created August 11, 2019 18:13
BindingChipGroup
@BindingAdapter("list", "layout")
fun <T> chips(view: ChipGroup, items: List<T>, layoutId: Int) {
view.removeAllViews()
val inflater = view.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
items.forEachIndexed { index, model ->
val binding = DataBindingUtil.inflate<ViewDataBinding>(inflater, layoutId, view, false)
binding.setVariable(BR.model, model)
(binding.root as Chip).id = index
view.addView(binding.root)
binding.executePendingBindings()
@B0yma
B0yma / BindingAdapters.java
Created July 21, 2019 20:09
CollapseAppBar
public class BindingAdapters {
@BindingAdapter({"app:setFlags"})
public static void setFlags(CollapsingToolbarLayout view, int flag) {
AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) view.getLayoutParams();
params.setScrollFlags(flag);
view.setLayoutParams(params);
}
}
@B0yma
B0yma / desc.js
Created June 15, 2019 19:27
Binding Adapter Creating
//in manifest
apply plugin: 'kotlin-kapt'
...
dataBinding { enabled = true }
//-------------------
//Binding adapter example in kotlin
@BindingAdapter("app:backgroundTintAdapt")
@B0yma
B0yma / activity.kt
Created May 26, 2019 11:29
AutoSizeOfGroupTextView
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.util.TypedValue
import android.widget.TextView
import androidx.core.widget.TextViewCompat
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
@B0yma
B0yma / activity.kt
Created April 26, 2019 18:50
Dynamically hiding a menu item in BottomNavigationView
bottomNavigationView.menu.removeItem(R.id.itemId)
@B0yma
B0yma / dialog.kt
Created April 24, 2019 07:33
GravityOfDialogFragmentWithMargin
private fun setDialogGravity(gravity: Int) {
val window = dialog?.window
val wlp = window?.attributes
wlp?.gravity = gravity
wlp?.y = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56f, resources.displayMetrics).toInt()
window?.attributes = wlp
}
@B0yma
B0yma / appbargrad.xml
Last active April 20, 2019 17:50
AppBarShadowDependency
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#34000000"
android:endColor="#00000000"
android:angle="-90"
android:useLevel="false"
android:type="linear"/>
</shape>