Skip to content

Instantly share code, notes, and snippets.

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

Vallabh Kansagara vrkansagara

😀
Coding :-)
View GitHub Profile
@vrkansagara
vrkansagara / learning-JavaScript
Last active February 14, 2019 02:10
Path way to learn JavaScript
[16 JavaScript Concepts JavaScript Professionals Must Know Well ] (http://javascriptissexy.com/16-javascript-concepts-you-must-know-well/)
<?php
if (!function_exists('randcomString')) {
/**
* @param number
* @return string
*/
function randcomString($length = 16)
{
$capital = substr(str_shuffle('ABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 1);
$small = substr(str_shuffle('abcdefghijklmnopqrstuvwxyz'), 0, 1);
<?php
if (!function_exists('http_status_message')) {
/**
* @param int $code
* @return string
*/
function http_status_message($code)
{
/**
@vrkansagara
vrkansagara / gist:b83c04b48c8338879a51f4bb426b2d82
Created September 5, 2018 17:52 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@vrkansagara
vrkansagara / ngrxintro.md
Created July 29, 2018 02:01 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@vrkansagara
vrkansagara / setInterval.js
Created July 5, 2018 19:15 — forked from richardkundl/setInterval.js
An alternative to Javascript's evil setInterval: - Doesn't care whether the callback is still running or not - Ignores errors - Isn't that flexible Thanks: http://www.thecodeship.com/web-development/alternative-to-javascript-evil-setinterval/
function interval(func, wait, times){
var interv = function(w, t){
return function(){
if(typeof t === "undefined" || t-- > 0){
setTimeout(interv, w);
try{
func.call(null);
}
catch(e){
t = 0;
@vrkansagara
vrkansagara / README
Created July 5, 2018 18:51 — forked from joelambert/README
Drop in replacements for setTimeout()/setInterval() that makes use of requestAnimationFrame() where possible for better performance
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available
http://www.joelambert.co.uk
Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
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 / nginx-tuning.md
Created June 19, 2018 17:29 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@vrkansagara
vrkansagara / get-ip-address-optimized.php
Created June 14, 2018 16:40 — forked from cballou/get-ip-address-optimized.php
PHP - Advanced Method to Retrieve Client IP Address
<?php
function get_ip_address() {
$ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR');
foreach ($ip_keys as $key) {
if (array_key_exists($key, $_SERVER) === true) {
foreach (explode(',', $_SERVER[$key]) as $ip) {
// trim for safety measures
$ip = trim($ip);
// attempt to validate IP
if (validate_ip($ip)) {