Skip to content

Instantly share code, notes, and snippets.

View devmnj's full-sized avatar
💭
Exploring Algos

Manoj AP devmnj

💭
Exploring Algos
View GitHub Profile
Commands to remove a directory in Linux
There are two command to delete a folder in Linux:
rmdir command – Deletes the specified empty directories and folders in Linux.
rm command – Delete the file including sub-directories. You can delete non-empty directories with rmdir command in Linux.
Let us see some examples and usage in details.
rmdir command syntax to delete directory in Linux
https://chromedriver.storage.googleapis.com/index.html?path=76.0.3809.68/
@devmnj
devmnj / SeralizeHelper.cs
Created June 5, 2020 17:45
Serialize Helper class for encrypt and serialize any object collection in C#
public static class SerializeHelper
{
static byte[] key = { 1, 2, 3, 4, 5, 6, 7, 8 };
static byte[] iv = { 1, 2, 3, 4, 5, 6, 7, 8 };
static DESCryptoServiceProvider des = new DESCryptoServiceProvider();
public static void SerialiZe<T>(T data, string path)
{
using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write))
@devmnj
devmnj / autocreate_dir.cs
Created June 7, 2020 17:57
Create folder/directory automatically in C#.Net
using System.IO;
public static void AutoCreateDirectory(string dpath)
{
try
{
if (!Directory.Exists(dpath))
{
Directory.CreateDirectory(dpath);
}
}
@devmnj
devmnj / sqlhelper.cs
Last active October 24, 2023 07:17
SQLHelper class for performing Database operations in C#.Net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using System.Data;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Windows.Input;
using System.Collections.ObjectModel;
using System.IO;
@devmnj
devmnj / covid19-livedata.py
Last active June 13, 2020 12:46
Create a covid-19 live status using API in Python
import urllib2
import json
from datetime import datetime, timedelta
def printData(data):
jsonData = json.loads(data)
print('Printing Json Data....')
for d in jsonData:
s = str(d["date"])
dt=datetime(year=int(s[0:4]), month=int(s[4:6]), day=int(s[6:8]))
@devmnj
devmnj / SQLfunctionCkeck
Created July 14, 2020 15:55
Check a function exist or not in MS SQL Server
IF EXISTS (
SELECT * FROM sysobjects WHERE id = object_id(N'function_name')
AND xtype IN (N'FN', N'IF', N'TF')
)
DROP FUNCTION function_name
GO
If you want to avoid the sys* tables, you could instead do (from here in example A):
IF object_id(N'function_name', N'FN') IS NOT NULL
DROP FUNCTION function_name
@devmnj
devmnj / ViewModelBase.cs
Last active August 8, 2020 04:56
ViewModelBase class which implements INotifyPropertyChanged in C#
public abstract class ViewModelBase : INotifyPropertyChanged
{
/// <summary>
/// Multicast event for property change notifications.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Checks if a property already matches a desired value. Sets the property and
/// notifies listeners only when necessary.
@devmnj
devmnj / observableStringDictionary.cs
Last active September 17, 2020 04:04
C# WPF - An Observable String Dictionary class, which can be useful for storing and binding values as (key, value) pair
// The orginal class was obtained from official site, then I made some desirable changes such as `UpdateOrAdd`,
// which I think usefull for others
//
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
namespace mynamespace
{
@devmnj
devmnj / geturlPrameter.js
Created December 24, 2020 05:57
Get URL parameters from a given url such as query string in JavaScript
function getAllUrlParams(url) {
// get query string from url (optional) or window
var queryString = url ? url.split("?")[1] : window.location.search.slice(1);
// we'll store the parameters here
var obj = {};
// if query string exists
if (queryString) {
// stuff after # is not part of query string, so get rid of it