Skip to content

Instantly share code, notes, and snippets.

Avatar
🌀
Fluttering

Sangam Kumar Shrestha 2shrestha22

🌀
Fluttering
View GitHub Profile
@2shrestha22
2shrestha22 / magisk_flash.sh
Last active March 6, 2023 16:11
Helper script to flash Magisk for non A/B device.
View magisk_flash.sh
#!/bin/bash
# To run this:
# bash <(curl -sL https://gist.githubusercontent.com/2shrestha22/b2f15066c1627085e0913ac52d243d62/raw/2c477da35d44b77a510783a1d1494cc90feb9217/magisk_flash.sh)
BOOT_IMAGE_FILE_NAME="boot.img"
BOOT_IMAGE_FILE_PATH="./$BOOT_IMAGE_FILE_NAME"
echo -e "Helper srcipt to flash Magisk patched boot.img for non A/B device...\n"
if adb shell getprop ro.build.ab_update | grep -q true; then
View GlobalMenu KDE GTK Electron
libdbusmenu-glib
libdbusmenu (for Fedora)
View 30-touchpad.conf
Section "InputClass"
Identifier "touchpad"
Driver "libinput"
MatchIsTouchpad "on"
Option "Tapping" "on"
Option "NaturalScrolling" "true"
EndSection
View TLP-1.4-Test_Battery-Care_Lenovo.md
@2shrestha22
2shrestha22 / freezed_snippet.code-snippets
Last active July 31, 2022 21:08
Freezed Snippet for VS Code. ctrl+shift+p - configure user snippet - add new global snippet - paste this
View freezed_snippet.code-snippets
// by ResoCoder
// https://github.com/rrousselGit/freezed/issues/85#issuecomment-593908291
{
"Part statement": {
"prefix": "pts",
"body": [
"part '${TM_FILENAME_BASE}.g.dart';",
],
"description": "Creates a filled-in part statement"
},
@2shrestha22
2shrestha22 / wp.conf
Created July 13, 2021 16:45
WordPress nginx config
View wp.conf
# /etc/nginx/snippets/wp.conf
# include inside server block
index index.php;
location / {
# try to serve static file if not found then directory then php
# include the "?$args" part so non-default permalinks doesn't break when usi>
try_files $uri $uri/ /index.php?$args;
}
@2shrestha22
2shrestha22 / _common.conf
Created June 29, 2021 01:01 — forked from Daniel15/_common.conf
WordPress config with WP Super Cache for Nginx
View _common.conf
# /etc/nginx/snippets/wordpress/common.conf
index index.php;
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
}
# Block PHP files in uploads, content, and includes directory.
location ~* /(?:uploads|files|wp-content|wp-includes)/.*\.php$ {
@2shrestha22
2shrestha22 / .md
Created May 14, 2021 16:10 — forked from joepie91/.md
Running a Node.js application using nvm as a systemd service
View .md

Read this first!

Hi there! Since this post was originally written, nvm has gained some new tools, and some people have suggested alternative (and potentially better) approaches for modern systems. Make sure to have a look at the comments to this article, before following this guide!


The original article

Trickier than it seems.

View repeatingAdInsideListview.dart
//where _kAdIndex is an int and after each -kAdIndex in the listView Ad is displayed
ListView.builder(
controller: _scrollController,
cacheExtent: 20,
itemCount: data.layoutList.length +
(data.layoutList.length ~/ _kAdIndex),
itemBuilder: (BuildContext context, int index) {
if (index != 0 && (index + 1) % (_kAdIndex + 1) == 0) {
print(index);
View regular_expressions.dart
class RegX {
static final RegExp _emailRegExp = RegExp(
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9\-\_]+(\.[a-zA-Z]+)*$");
static final RegExp _nonDigitsExp = RegExp(r'[^\d]');
static final RegExp _anyLetter = RegExp(r'[A-Za-z]');
static final RegExp _phoneRegExp = RegExp(r'^\d{7,15}$');
static final RegExp _ipv4RegExp = RegExp(
r'^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$');
static final RegExp _ipv6RegExp = RegExp(
r'^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[