Skip to content

Instantly share code, notes, and snippets.

View 2shrestha22's full-sized avatar
๐Ÿ’™
Dart / Flutter

Sangam Shrestha 2shrestha22

๐Ÿ’™
Dart / Flutter
View GitHub Profile
#right-sidebar {
position: -webkit-sticky;
position: sticky;
top: 0;
}
.site-header, .inside-article,.sidebar .widget, .comments-area, .paging-navigation, .my-ad, .wp-block-image {
-webkit-box-shadow: 5px 5px 30px -10px rgba(46,46,46,0.5);
-moz-box-shadow: 5px 5px 30px -10px rgba(46,46,46,0.5);
// 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"
},
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[
//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);
@2shrestha22
2shrestha22 / .md
Created May 14, 2021 16:10 — forked from joepie91/.md
Running a Node.js application using nvm as a systemd service

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.

@2shrestha22
2shrestha22 / _common.conf
Created June 29, 2021 01:01 — forked from Daniel15/_common.conf
WordPress config with WP Super Cache for Nginx
# /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 / wp.conf
Created July 13, 2021 16:45
WordPress nginx config
# /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 / 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
// 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"
},

TLP 1.4 Test: Battery Care for Lenovo Laptops (non-ThinkPad series)

Read the overview document first.

Supported Features

Lenovo laptop series using the ideapad_laptop driver have a feature called 'battery conservation mode', basically a fixed stop charge threshold at 60%. The hardware behaviour is:

  1. Connected to the charger, charging stops when the charge level reaches the stop threshold
Section "InputClass"
Identifier "touchpad"
Driver "libinput"
MatchIsTouchpad "on"
Option "Tapping" "on"
Option "NaturalScrolling" "true"
EndSection