Skip to content

Instantly share code, notes, and snippets.

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

Vinay Aggarwal vinaydotblog

🏠
Working from home
View GitHub Profile
@vinaydotblog
vinaydotblog / composer-install.sh
Last active April 17, 2023 11:08
Installing composer using curl
# Goto a directory you can write to:
cd ~
#get composer:
curl -s https://getcomposer.org/installer | php
# move composer into a bin directory you control:
sudo mv composer.phar /usr/local/bin/composer
# double check composer works
composer about
@vinaydotblog
vinaydotblog / google_form_email.js
Created November 15, 2014 04:47
Send Google Form Submission to an Email address
/* Send Google Form by Email v2.1 */
/* For customization, contact the developer at amit@labnol.org */
/* Tutorial: http://www.labnol.org/?p=20884 */
function Initialize() {
var triggers = ScriptApp.getProjectTriggers();
@vinaydotblog
vinaydotblog / gist:3216713
Last active February 5, 2019 05:02
Will this php script work? and what will be the output if yes?
<?=
_::
o_O
()
;
class _{ static
@vinaydotblog
vinaydotblog / composelist.sh
Created June 28, 2018 16:29 — forked from mortenson/composelist.sh
List all Docker Compose projects currently running
#!/bin/bash
docker ps --filter "label=com.docker.compose.project" -q | xargs docker inspect --format='{{index .Config.Labels "com.docker.compose.project"}}'| uniq
@vinaydotblog
vinaydotblog / bookmarklet-speech-input.js
Last active February 24, 2018 07:40
A bookmarklet to input text using speech to document's active element.
(function(Recognition,c){
var recognition = new Recognition;
recognition.lang = 'en-US';
recognition.interimResults = false;
recognition.maxAlternatives = 5;
recognition.start();
c.log('listening now');
function triggerEvent(elem, Event, type) {
var event = new Event(type, {'bubbles': true, 'cancelable': true });
@vinaydotblog
vinaydotblog / php-server.sh
Created November 18, 2017 17:49
PHP Local Server
## Usage Example: serv home.html 5050
## 2nd and 3rd arguments are optional
serv() {
open -a "Google Chrome" http://localhost:${2:-2020}/${1:-}
/usr/bin/php -S localhost:${2:-2020} -t .
}
@vinaydotblog
vinaydotblog / latlng_to_city.js
Last active November 18, 2017 16:34
Gives back City Name based on given latitude/longitude values.
/*
* Pass it your string of latlong and it'll return a promise to come back with the locality, city.
*
* getCity('12.9715987,77.5945627').done(function(cityName){
* $elem.val( cityName )
* });
*
* Info: jQuery is required for $.Deferred() and $.getJSON to work!
* Regardless of everything modify it as per your convenience :)
*/
@vinaydotblog
vinaydotblog / composer.json
Created July 23, 2017 11:24 — forked from andyshinn/composer.json
Docker Compose PHP Composer Example
{
"require": {
"mfacenet/hello-world": "v1.*"
}
}
@vinaydotblog
vinaydotblog / laravel_query_log.php
Created June 5, 2017 10:32
Clean query log for laravel
<?php
DB::listen(function ($sql) {
$log = vsprintf('[SQL] - ' . str_replace('?', '"%s"', $sql->sql), $sql->bindings);
if( App::runningInConsole() ) {
print($log);
} else {
\Log::info($log);
}
@vinaydotblog
vinaydotblog / gist:4070899
Created November 14, 2012 07:59
Detect and show message if javascript is disabled.
<!DOCTYPE HTML>
<html lang="en-US" class="no-js">
<head>
<meta charset="UTF-8">
<script type="text/javascript">(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
<title></title>
<style type="text/css"> .no-js span.disabledjavascript{ display:block; } .js span.disabledjavascript{ display:none; } </style>
</head>
<body>
<h2>Regular Page</h2>