Skip to content

Instantly share code, notes, and snippets.

View vithalreddy's full-sized avatar
🔥

Vithal Reddy vithalreddy

🔥
View GitHub Profile
<b:if cond='data:blog.metaDescription != &quot;&quot;'>
<meta expr:content='data:blog.metaDescription' property='og:description'/>
<meta expr:content='data:blog.metaDescription' name='twitter:description'/>
<meta expr:content='data:blog.metaDescription' itemprop='description'/>
</b:if>
<b:if cond='data:blog.postImageUrl'>
<meta expr:content='data:blog.postImageUrl' property='og:image'/>
<meta expr:content='data:blog.postImageUrl' name='twitter:image'/>
<meta expr:content='data:blog.postImageUrl' itemprop='image'/>
<b:else/> <b:if cond='data:blog.postImageThumbnailUrl'>
function filterpagesinsearch($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts', 'filterpagesinsearch');
function formatFileSize(bytes,decimalPoint) {
if(bytes == 0) return '0 Bytes';
var k = 1000,
dm = decimalPoint || 2,
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
//You only need to use the formatFileSize() function in JavaScript to convert file size units.
@vithalreddy
vithalreddy / directives.js
Created October 29, 2017 13:34 — forked from elizabeth-young/directives.js
Some Angular validation directives
'use strict';
var directives = angular.module('app', []);
// override the default input to update on blur
directives.directive('input', function () {
return {
restrict: 'E',
require: 'ngModel',
link: function (scope, elm, attr, ngModelCtrl) {
if (attr.type === 'radio' || attr.type === 'checkbox') return;
@vithalreddy
vithalreddy / win10ShortcutKeys.json
Created November 19, 2017 16:44
Windows 10 PC Ultimates Shortcut keys List
[
["Windows key","Open or close Start Menu." ],
["Windows key + A","Open Action center." ],
["Windows key + C","Open Cortana in listening mode." ],
["Windows key + D","Display and hide the desktop." ],
["Windows key + E","Open File Explorer." ],
["Windows key + G","Open Game bar when a game is open." ],
["Windows key + H","Open the Share charm." ],
["Windows key + I","Open Settings." ],
["Windows key + K","Open the Connect quick action." ],
@vithalreddy
vithalreddy / roles_invesitgation.md
Created February 23, 2018 06:23 — forked from facultymatt/roles_invesitgation.md
Roles and permissions system for Nodejs
@vithalreddy
vithalreddy / mongo_db_recover_delete_record.py
Created May 7, 2018 09:13 — forked from egguy/mongo_db_recover_delete_record.py
Recover deleted data from mongo DB database
"""A little script to recover deleted recording of a mongoDB db file
There's no optimization but it work and has saved me
"""
import struct
import bson
import pymongo
import sys
@vithalreddy
vithalreddy / listFiles.js
Created June 30, 2018 13:46
list of all files in a directory in Node.js
//requiring path and fs modules
const path = require('path');
const fs = require('fs');
//joining path of directory
const directoryPath = path.join(__dirname, 'Documents');
//passsing directoryPath and callback function
fs.readdir(directoryPath, function (err, files) {
//handling error
if (err) {
return console.log('Unable to scan directory: ' + err);
@vithalreddy
vithalreddy / gd-drive-file-download.sh
Last active September 17, 2019 08:20
Shell Script To Download Google Drive Files from terminal
#!/bin/bash
read -p "Enter File Id: " fileid
read -e -p "Enter File Dir: " "path_to_download_dir" dir #replce with your download dir path ~/Downloads
cd ~/$dir
echo "File will be downloaded in dir: ~/{$dir}"
curl -c ./$fileid -s -L "https://drive.google.com/uc?export=download&id=${fileid}" > /dev/null
@vithalreddy
vithalreddy / pandas.py
Created August 4, 2019 05:52
Inverse of pandas json_normalize or json_denormalize – python pandas
# more at https://stackfame.com/inverse-of-pandas-json_normalize-or-json_denormalize-python-pandas
def make_formatted_dict(my_dict, key_arr, val):
"""
Set val at path in my_dict defined by the string (or serializable object) array key_arr
"""
current = my_dict
for i in range(len(key_arr)):
key = key_arr
if key not in current: