Skip to content

Instantly share code, notes, and snippets.

View narwanimonish's full-sized avatar

Monish Narwani narwanimonish

View GitHub Profile
@narwanimonish
narwanimonish / import_package.py
Last active August 28, 2019 11:44
Function to check if package exist then import or else install package & import
package = 'sentry-sdk'
package_module = package.replace('-', '_')
def import_package(package_name, module_name):
try:
__import__(module_name)
except ImportError:
import pip
if hasattr(pip, 'main'):
pip.main(['install', package_name])
sudo apt-get update
sudo apt install software-properties-common
sudo apt-get install python3.7
cd /usr/bin/
sudo ln -s python3 python
sudo apt-get -y install python3-pip
sudo ln -s /usr/bin/pip3 /usr/bin/pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py
pip3 install Django
@narwanimonish
narwanimonish / span-input.html
Created June 18, 2019 10:22
Replace span tag with input to edit value & then value appear in span tag
<div class="span-input">
<span class="span-el">1234 ms</span>
<input type="text" class="hide">
</div>
<div class="span-input">
<span data-append=" ms" class="span-el">1234 ms</span>
<input type="text" class="hide">
</div>
<?php
//Simple Usage
/**
* Encrypt a message
*
* @param string $message - message to encrypt
* @param string $key - encryption key
* @return string
*/
@narwanimonish
narwanimonish / CSVHelper.php
Created October 6, 2018 05:33
CSV Helper to parse CSV file contents into php Array with headers
<?php
class CSVHelper
{
// Build wonderful things
public static function parseCSV($fileName)
{
$extractData = [];
$csvArray = [];