Skip to content

Instantly share code, notes, and snippets.

View shivdhwaj's full-sized avatar
🎯
Focusing

Shivdhwaj Pandey shivdhwaj

🎯
Focusing
View GitHub Profile
@shivdhwaj
shivdhwaj / removeJobsRedisDriver.php
Created February 11, 2021 08:32 — forked from derhansen/removeJobsRedisDriver.php
Laravel 5 - remove all jobs from a queue (redis driver)
Redis::connection()->del('queues:myqueue');
@shivdhwaj
shivdhwaj / short-number-format.php
Created December 18, 2020 20:14 — forked from RadGH/short-number-format.php
Short Number Formatter for PHP (1000 to 1k; 1m; 1b; 1t)
<?php
// Converts a number into a short version, eg: 1000 -> 1k
// Based on: http://stackoverflow.com/a/4371114
function number_format_short( $n, $precision = 1 ) {
if ($n < 900) {
// 0 - 900
$n_format = number_format($n, $precision);
$suffix = '';
} else if ($n < 900000) {
@shivdhwaj
shivdhwaj / redis_key_sizes.sh
Created June 29, 2020 12:30 — forked from epicserve/redis_key_sizes.sh
A simple script to print the size of all your Redis keys.
#!/usr/bin/env bash
# This script prints out all of your Redis keys and their size in a human readable format
# Copyright 2013 Brent O'Connor
# License: http://www.apache.org/licenses/LICENSE-2.0
human_size() {
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } '
}
@shivdhwaj
shivdhwaj / flow-error-icu4c-not-loaded.md
Created May 21, 2020 10:12 — forked from berkedel/flow-error-icu4c-not-loaded.md
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.60.dylib

How to solve dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.60.dylib

brew uninstall --ignore-dependencies node icu4c
brew install node

A handful of BigQuery SQL queries that you can use to analyze your own Google Analytics for Firebase data. To find out more about how they work, check out our presentation from Cloud Next 2018 (Video link to be added soon)

Please note that these scripts have been updated to make sure of the new Firebase schema, which was rolled out to Analytics products in July of 2018.

Note that none of these scripts will work out of the box -- you'll need to update the values in brackets with the names of your actual datasets, and you'll most likely also need to replace the names of events and event properties with ones that are appropriate for your app.

The contents of this gist are licensed under the Apache License, version 2.0

@shivdhwaj
shivdhwaj / sumOfFirst20EvenNumbers.php
Created March 2, 2020 16:55
Find the sum of first 20 even number in PHP Code
<?php
function evenSum($n) {
return ($n * ($n + 1));
}
$n = 20;
echo "Sum of first: ". $n." even numbers is: " . evenSum($n);
?>
<?php
/*
|--------------------------------------------------------------------------
| Excel To Array
|--------------------------------------------------------------------------
| Helper function to convert excel sheet to key value array
| Input: path to excel file, set wether excel first row are headers
| Dependencies: PHPExcel.php include needed
*/
function excelToArray($filePath, $header=true){
@shivdhwaj
shivdhwaj / greatestOfThreeNumbers.c
Last active July 10, 2019 12:59
The code in C Language to calculate the greate of three numbers.
#include <stdio.h>
int main()
{
int fNum, sNum, tNum, gNum;
printf("Enter three integer numbers: ");
scanf("%d %d %d", & fNum, & sNum, & tNum);
gNum = fNum>sNum?(fNum>tNum?fNum:tNum):(sNum>tNum?sNum:tNum);
printf("%d is the greatest number.", gNum);
return 0;
}
@shivdhwaj
shivdhwaj / prepare-commit-msg.sh
Created November 25, 2016 12:56 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
#!/bin/bash
# This way you can customize which branches should be skipped when
# prepending commit message.
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop test)
fi
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME="${BRANCH_NAME##*/}"
<?php
/* vars for export */
// database record to be exported
$db_record = 'XXXXXXXXX';
// optional where query
$where = 'WHERE 1 ORDER BY 1';
// filename for export
$csv_filename = 'db_export_'.$db_record.'_'.date('Y-m-d').'.csv';
// database variables