Skip to content

Instantly share code, notes, and snippets.

View vrkansagara's full-sized avatar
😀
Coding :-)

Vallabh Kansagara vrkansagara

😀
Coding :-)
View GitHub Profile
var url = 'https://vrkansagara.in'
documentLinks = document.links
var isHostIsUp = false;
function doesConnectionExist() {
var xhr = new XMLHttpRequest();
var host = url;
xhr.open('HEAD', host, true);
xhr.send();
xhr.addEventListener('readystatechange', processRequest, false);
@vrkansagara
vrkansagara / Laravel-Container.md
Created April 7, 2018 13:06
Laravel's Dependency Injection Container in Depth

Laravel's Dependency Injection Container in Depth

Laravel has a powerful Inversion of Control (IoC) / Dependency Injection (DI) Container. Unfortunately the official documentation doesn't cover all of the available functionality, so I decided to experiment with it and document it for myself. The following is based on Laravel 5.4.26 - other versions may vary.

Introduction to Dependency Injection

I won't attempt to explain the principles behind DI / IoC here - if you're not familiar with them you might want to read What is Dependency Injection? by Fabien Potencier (creator of the Symfony framework).

Accessing the Container

@vrkansagara
vrkansagara / mac-apps.md
Created April 1, 2018 13:53 — forked from erikreagan/mac-apps.md
Mac developer must-haves

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik

STEPS

  • Click on Help menu

  • Select Enter License

  • Then paste given KEY given at bottom

  • Finally click on Use License

I use the first
—– BEGIN LICENSE —–
Michael Barnes
Single User License
EA7E-821385
8A353C41 872A0D5C DF9B2950 AFF6F667
C458EA6D 8EA3C286 98D1D650 131A97AB
AA919AEC EF20E143 B361B1E7 4C8B7F04
@vrkansagara
vrkansagara / gist:9bdf6f3bc93fc97dfa4503aa1b58e98a
Created March 15, 2018 19:36
Number to Word in INR string.
function INR(input) {
var a, b, c, d, e, output, outputA, outputB, outputC, outputD, outputE;
var ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
if (input === 0) { // Zero
output = "Rupees zero";
@vrkansagara
vrkansagara / linux_performance.md
Last active March 7, 2018 16:03 — forked from marianposaceanu/linux_performance.md
Linux simple performance tweaks

Linux simple performance tweaks

Change the I/O Scheduler

Open $ vim /etc/default/grub then add elevator=noop next to GRUB_CMDLINE_LINUX_DEFAULT. Run $ update-grub and $ cat /sys/block/sda/queue/scheduler to be sure that noop is being used:

$ vim /etc/default/grub
$ update-grub
$ cat /sys/block/sda/queue/scheduler

[noop] deadline cfq

@vrkansagara
vrkansagara / cleanUbuntu.sh
Last active January 28, 2018 18:53
Clean your unwanted repository from apt list.
#!/usr/bin/env bash
for f in /etc/apt/sources.list.d/*.list; do
grep -Po "(?<=^deb\s).*?(?=#|$)" "$f" | while read -r ENTRY ; do
echo "ENTRY: $ENTRY"
HOST=$(cut -d/ -f3 <<< "$ENTRY")
if [ "ppa.launchpad.net" = "$HOST" ]; then
USER=$(cut -d/ -f4 <<< "$ENTRY")
PPA=$(cut -d/ -f5 <<< "$ENTRY")
packageCount=$(awk '$1=="Package:" {if (a[$2]++ == 0) {system("dpkg -l "$2)}}' /var/lib/apt/lists/*"$USER"*"$PPA"*Packages 2>/dev/null | awk '/^ii/' | wc -l)
grep '\$_REQUEST\|$_GET\|$_POST\|$this->array' * -R --color
@vrkansagara
vrkansagara / ocp.php
Created December 5, 2017 05:19 — forked from ck-on/ocp.php
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)#ocp #php #opcache #opcode #cache #zend #optimizerplus #optimizer+
<?php
/*
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)
Author: _ck_ (with contributions by GK, stasilok)
Version: 0.1.7
Free for any kind of use or modification, I am not responsible for anything, please share your improvements
* revision history
0.1.7 2015-09-01 regex fix for PHP7 phpinfo
0.1.6 2013-04-12 moved meta to footer so graphs can be higher and reduce clutter