Skip to content

Instantly share code, notes, and snippets.

View mManishTrivedi's full-sized avatar
🏠
Working from home

Manish Trivedi mManishTrivedi

🏠
Working from home
View GitHub Profile
@mManishTrivedi
mManishTrivedi / index.html
Created June 30, 2023 07:02
Skeleton-View
<!DOCTYPE html>
<html>
<head>
<title>Body Skeleton</title>
<script>
/**
* The drawSkeleton() function takes an array of keypoints as an argument
* and draws the skeleton on the canvas.
*/
@mManishTrivedi
mManishTrivedi / log_chunk_length_over_4000_char.java
Created October 14, 2022 06:00 — forked from kiirpi/log_chunk_length_over_4000_char.java
if log message length over than 4000 char
if (sb.length() > 4000) {
Log.v(TAG, "sb.length = " + sb.length());
int chunkCount = sb.length() / 4000; // integer division
for (int i = 0; i <= chunkCount; i++) {
int max = 4000 * (i + 1);
if (max >= sb.length()) {
Log.v(TAG, "chunk " + i + " of " + chunkCount + ":" + sb.substring(4000 * i));
} else {
Log.v(TAG, "chunk " + i + " of " + chunkCount + ":" + sb.substring(4000 * i, max));
}
// kills long running ops in MongoDB (taking seconds as an arg to define "long")
// attempts to be a bit safer than killing all by excluding replication related operations
// and only targeting queries as opposed to commands etc.
killLongRunningOps = function(maxSecsRunning) {
currOp = db.currentOp();
for (oper in currOp.inprog) {
op = currOp.inprog[oper-0];
if (op.secs_running > maxSecsRunning && op.op == "query" && !op.ns.startsWith("local")) {
print("Killing opId: " + op.opid
@mManishTrivedi
mManishTrivedi / mongodb_collection_sizes.js
Created February 26, 2018 14:32 — forked from joeyAghion/mongodb_collection_sizes.js
List mongodb collections in descending order of size. Helpful for finding largest collections. First number is "size," second is "storageSize."
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
@mManishTrivedi
mManishTrivedi / bash.sh
Last active August 2, 2017 13:40
Basic Ubuntu Command
// Number of CPUs
nproc
// RAM size and Swap Size
free -m
// Disk Size
df -h
@mManishTrivedi
mManishTrivedi / mongo-import-export.sh
Last active August 12, 2016 11:39 — forked from nhoening/bongo.sh
Allowing to pass a query for exporting specific data. Added a LIMIT option to limit the number of returned results. Added a debug switch to see errors.
#!/bin/bash
# https://gist.github.com/mManishTrivedi/ba64d0423e8a4692c0687b9d0b2078a8
LOADING=false
DEBUG=/dev/null
usage()
{
cat << EOF
usage: $0 [options] <DBNAME>
/* Node.js */
var crypto = require('crypto'),
algorithm = 'aes-256-ctr';
data = "manish"
encryption_key = "VHUz1dxrhsowwEYGqUnPcE4wvAyz7Vmb";
encryption_data = _encrypt()
console.log('encrypted data :: ' + encryption_data);
@mManishTrivedi
mManishTrivedi / moment-js-examples.js
Last active August 25, 2017 06:32
Gist contain examples of moment.js lib
// Do experiment here "http://jsfiddle.net/FLhpq/1958/"
//Query : timestamp (second) to current date
moment.unix(1442555078).calendar();
// output : Today at 11:14 AM
//Query : Timestamp (second) to proper format
moment.unix(1442555078).format('LLLL');
// output : Friday, September 18 2015 11:14 AM
@mManishTrivedi
mManishTrivedi / Joomla_xius_overwrite_no_result_msg.php
Last active December 27, 2015 10:59
Overwrite no result Message in XiUS
<?php
// Follow these steps to achieve overwrite no result Message in XiUS result page
// 1# copy your default_profile.php file like your xius template is default
// copy file _SITE_ROOTS_/components/com_xius/templates/default/default_profile.php
// 2# Paste this file to following hierarchy
// _SITE_ROOTS_/templates/_CURRENT_SITE_TEMPLATE/html/com_xius/default_profile.php
// 3# paste following code to near the line 13-14
?>
<?php
# overwrite code start here
@mManishTrivedi
mManishTrivedi / php_get_class_var.php
Last active December 22, 2015 23:29
Return all class attribute name. Included Public, protected, Private and static.
<?php
/**
*
* Return all class attribute name. Included Public, protected, Private and static.
* It will filter base class attribute
*
* @param $className
*
* @return Attribute array
*/