Skip to content

Instantly share code, notes, and snippets.

View nandeeshmp's full-sized avatar

Nandeesh Mp nandeeshmp

View GitHub Profile
@nandeeshmp
nandeeshmp / gist:8921179
Created February 10, 2014 18:11
register a command using service provider
public function register()
{
$this->app['command.hello'] = $this->app->share(function($app){
return new HelloCommand;
});
$this->commands('command.hello');
}
@nandeeshmp
nandeeshmp / read-file
Created February 20, 2014 01:06
read input from a file
$_fp = fopen("php://stdin", "r");
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
$count = fgets($_fp);
while ( $value = fgetcsv($_fp,0,' ')){
$cases[] = $value;
}
@nandeeshmp
nandeeshmp / linux-find
Created July 6, 2015 16:06
find example
// Sweeps out all the unwanted .svn files recursively from repo with one go
find myproject -name ".svn" -exec rm -rf "{}" \;
// finds all the files with word class in them recursively
// --with-filename option prints the file name
find myproject -exec grep --with-filename class {} \;
@nandeeshmp
nandeeshmp / example_form.php
Last active August 29, 2015 14:25
sample for form builder module
<?php
require 'vendor/autoload.php';
$form = new \Form\Builder();
$options_list = [0 => '-- Select --', 1 => 'Bachelor Degree', 2 => 'Master Degree'];
?>
<?php echo $form->open(['action' => '/form-handler']); ?>
<legend>Form Builder Example</legend>
<div class="form-group">
@nandeeshmp
nandeeshmp / load.pl
Created June 23, 2017 06:40
check cpu load and memory usage and fire an event
#!/usr/bin/perl
use Data::Dumper;
my $loadAvgLast15Minutes = `uptime | awk '{gsub(",",""); print \$9}'`;
my $memoryUsed = `free | awk '/Mem/ {print \$3}'`;
# Assume its 16 cores cpu and has 16gb ram
if ($loadAvgLast15Minutes > 14 && $memoryUsed > 11524884) {
print '5 minute load avarage is greater than 85% and memory usage is greater than 70%';