Skip to content

Instantly share code, notes, and snippets.

View pratheeshrussell's full-sized avatar

Pratheesh pratheeshrussell

  • Enjoying life and coding
  • India
View GitHub Profile
@pratheeshrussell
pratheeshrussell / .eslintrc.json
Last active May 23, 2023 06:12
Eslintrc for Angular
{
"root": true,
"ignorePatterns": ["projects/**/*"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"overrides": [
{
@pratheeshrussell
pratheeshrussell / deepcopy.js
Created May 18, 2023 04:49
A function to deepcopy in js
function deepCopy(obj) {
if (typeof obj !== 'object' || obj === null) {
return obj;
}
const isArray = Array.isArray(obj);
const copy = isArray ? [] : {};
const stack = [{ source: obj, target: copy }];
@pratheeshrussell
pratheeshrussell / .gitconfig
Created March 23, 2023 04:14
Git alias that I use for projects
[alias]
# Prints current branch
cbr=rev-parse --abbrev-ref HEAD
# prints the branches sorted by commit date and coloured
br=branch --sort=-committerdate --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]' --sort=-committerdate
@pratheeshrussell
pratheeshrussell / two-way-binder.directive.ts
Last active October 30, 2022 08:56
Two angular directives for 2 way binding without ngModel - make sure to declare in app module
// sample usage: https://stackblitz.com/edit/angular-ivy-lvhg5u?file=src%2Fapp%2Ftwo-way-binder.directive.ts
// <input type="text" id="sample" [(appTwoWayBinder)]="name" />
import {
Directive,
EventEmitter,
HostBinding,
HostListener,
Input,
OnChanges,
@pratheeshrussell
pratheeshrussell / XorEncoder.dart
Created August 23, 2022 09:11
An Xor String Encoder with Dart
/// Code based on https://stackoverflow.com/a/66938952
/// Usage Example
/// String text = "Hello World";
/// String salt = 'Pl!309R@dM';
///
/// XorEncoder encoder = XorEncoder(salt);
///
/// String encoded = encoder.encode(text);
/// String decoded = encoder.decode(encoded);
///
@pratheeshrussell
pratheeshrussell / webpack.config.js
Created July 30, 2022 17:18
Development webpack config
const path = require('path');
const cleanPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
mode: 'development',
entry: './src/main.ts',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
@pratheeshrussell
pratheeshrussell / drive_cypher.cql
Last active February 25, 2022 11:34
Sample cypher - for SO
CREATE (c:Computer {name: 'Andy',uid:'123'})
CREATE (d1:Drive {name: 'Drive1',capacity:"2gb",uid:'223'})
CREATE (d2:Drive {name: 'Drive2',capacity:"4gb",uid:'233'})
CREATE (f1:Folder {name: 'desktop',type:"special",uid:'323'})
CREATE (f2:Folder {name: 'mydocuments',type:"special",uid:'333'})
CREATE (f3:Folder {name: 'myprojects',type:"normal",uid:'343'})
CREATE (t1:File {name: 'text1',type:"txt",size:"1kb",uid:'423'})
CREATE (t2:File {name: 'text2',type:"txt",size:"1.5kb",uid:'433'})
CREATE (t3:File {name: 'text3',type:"txt",size:"2kb",uid:'443'})
@pratheeshrussell
pratheeshrussell / flutter_window.cpp
Created February 12, 2022 17:39
Flutter Platform channel windows class
flutter::FlutterEngine *newEngine = flutter_controller_->engine();
custom_channels::createChannelCalc x = custom_channels::createChannelCalc(newEngine);
@pratheeshrussell
pratheeshrussell / platform.channel.dart
Created February 12, 2022 17:30
Flutter platform channels dart
import 'package:flutter/services.dart';
class AppPlatformChannel{
static Future<String> add(int a, int b) async{
const MethodChannel channel = MethodChannel('calc_channel');
try{
var result = await channel.invokeMethod('add', {'a': a, 'b': b});
return(result);
}catch(e){
return(e.toString());