Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Avinash Dalvi aviboy2006

🏠
Working from home
View GitHub Profile
@aviboy2006
aviboy2006 / php-guzzle-promise-function.php
Created Dec 4, 2020
Implement async call in PHP using guzzle promise
View php-guzzle-promise-function.php
<?php
use GuzzleHttp\Promise\Promise;
use GuzzleHttp\Promise\EachPromise;
function promiseFunction($sample_array,$index){ // index is optional params
$promise = new Promise(
function () use ($sample_array,$index,&$promise) {
$response = secondFunction($sample_array);
@aviboy2006
aviboy2006 / doc-pdf.py
Created Oct 15, 2020
Converting Doc to PDF
View doc-pdf.py
import subprocess
subprocess.check_call(
[‘/usr/bin/python3’, ‘/usr/bin/unoconv’, ‘-f’, ‘pdf’, ‘-o’, pdffilename, ‘-d’, ‘document’,
newfilename])
except subprocess.CalledProcessError as e:
print(‘CalledProcessError’, e)
@aviboy2006
aviboy2006 / tar-creation-s3-bucket.py
Created Oct 13, 2020
Create tar from S3 bucket files using boto3
View tar-creation-s3-bucket.py
import boto3
import tarfile
import os.path
s3Client = boto3.client('s3')
s3object = boto3.resource('s3')
def lambda_handler(event, context):
agtBucket = "angularbuildbucket"
key=""
@aviboy2006
aviboy2006 / Count lines in Git repo
Created Aug 11, 2020 — forked from mandiwise/Count lines in Git repo
A command to calculate lines of code in all tracked files in a Git repo
View Count lines in Git repo
// Reference: http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository
$ git ls-files | xargs wc -l
@aviboy2006
aviboy2006 / deployment_angular_s3_cloudfront.py
Created Jul 14, 2020
This include angular build creation, upload to S3 and clearing cloudfront cache.
View deployment_angular_s3_cloudfront.py
#!/usr/bin/env python
"""
File : deployment_angular_s3_cloudfront.py
Package :
Description :
Created by Avinash on 18/09/2019
"""
# git checkout production
# git fetch origin
@aviboy2006
aviboy2006 / search_subdirectory_s3_bucket.py
Created Jun 2, 2020
Search in each of the s3 bucket and see if the given folder exists
View search_subdirectory_s3_bucket.py
#Author : Avinash Dalvi
#Reference question : https://stackoverflow.com/questions/62158664/search-in-each-of-the-s3-bucket-and-see-if-the-given-folder-exists/62160218#62160218
import boto3
client = boto3.client('s3')
bucket_name = "bucket_name"
prefix = ""
s3 = boto3.client("s3")
@aviboy2006
aviboy2006 / gradle_help.txt
Created Apr 23, 2020
Fixing [ERROR] Failed to run dexer for SDK 7.4.0 titanium
View gradle_help.txt
# Open /Users/UserName/Library/Application\ Support/Titanium/mobilesdk/osx/7.4.0.GA/android/templates/gradle/gradle/wrapper/gradle-wrapper.properties
replace this
distributionUrl=http\://services.gradle.org/distributions/gradle-4.6-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
View check-for-duplicate-record-based-key.sql
select * from
(select callTime,callType,employee,phoneNumber,count(*) as n from table2 group by callTime,callType,employee,phoneNumber) x
where x.n > 1;
delete a
from leads a
LEFT JOIN
(
SELECT MIN(ID) ID,phone
@aviboy2006
aviboy2006 / nested-json-tree-based.py
Created Feb 5, 2020
This is to convert list of dictionary which will have child- parent relation to each other. This will convert to nested hierarchy
View nested-json-tree-based.py
data = [
{ "name" : "ABC", "parent":"DEF", },
{ "name" : "DEF", "parent":"null" },
{ "name" : "new_name", "parent":"ABC" },
{ "name" : "new_name2", "parent":"ABC" },
{ "name" : "Foo", "parent":"DEF"},
{ "name" : "Bar", "parent":"null"},
{ "name" : "Chandani", "parent":"new_name", "relation": "rel", "depth": 3 },
{ "name" : "Chandani333", "parent":"new_name", "relation": "rel", "depth": 3 }
]
@aviboy2006
aviboy2006 / non-ascii-removal.py
Created Jan 16, 2020
This to remove non ASCII characters from string
View non-ascii-removal.py
import re
ini_string = "'technews One lone dude awaits iPad 2 at Apple\x89Ûªs SXSW store"
res1 = " ".join(re.split("[^A-Za-z0-9]+", ini_string))
print(res1)
if re.match("[^\t\r\n\x20-\x7E]+", ini_string):
print("found")
result = ini_string.encode().decode('ascii', 'replace').replace(u'\ufffd', '`')
result2 = ini_string.encode().decode("utf-8").replace(u"\x89Ûª", "`").encode("utf-8")