Skip to content

Instantly share code, notes, and snippets.

View mohitt's full-sized avatar
🎯
Focusing

Mohit Thakral mohitt

🎯
Focusing
View GitHub Profile
export SENDGRID_API_KEY='YOUR_API_KEY'
curl --request POST \
--url https://api.sendgrid.com/v3/mail/send \
--header "Authorization: Bearer $SENDGRID_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"personalizations": [{"to": [{"email": "test@example.com"}]}],"from": {"email": "test@example.com"},"subject": "Sending with SendGrid is Fun","content": [{"type": "text/plain", "value": "and easy to do anywhere, even with cURL"}]}'
@mohitt
mohitt / Enable PS Remoting
Created August 11, 2019 17:01
Enable PS Remoting
Set-NetConnectionProfile -interfacealias "vEthernet (Default Switch)" -NetworkCategory Private
Enable-PSRemoting -Force
require('request-to-curl');
require('request-debug')(request, function(type, data, r) {
console.log(r.req.toCurl());
// put your request or response handling logic here
});
<?php
$servername = "cy-db-c";
$database = "cloudyogi_wp";
$username = "cloudyogi_wp";
$password = "localhost";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
(function() {
var _open = window.open;
window.open = function(str) {
console.log(JSON.stringify(arguments));
console.log(navigator.userAgent);
_open.apply(window, arguments);
};
})();
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
@mohitt
mohitt / temp
Last active February 3, 2018 14:41
input n
i=1
while ( i is not equal to n-1)
k = n/i
if ( k equal to 0)
output "number is not a prime"
i = i +1
output "number is a prime "

Keybase proof

I hereby claim:

  • I am codemerlin on github.
  • I am mohitt (https://keybase.io/mohitt) on keybase.
  • I have a public key ASB9WCt2mMmCnfKQNAHQtgVF3W1PxcJJz3Au3fPkNqzZwQo

To claim this, I am signing this object:

@mohitt
mohitt / gist:0a45c92d2bf42ab21aacf7a441182d55
Created November 23, 2017 15:57 — forked from emptyhammond/gist:1603144
Make a PUT request with jQuery.ajax()
$.ajax({
type: 'POST', // Use POST with X-HTTP-Method-Override or a straight PUT if appropriate.
dataType: 'json', // Set datatype - affects Accept header
url: "http://example.com/people/1", // A valid URL
headers: {"X-HTTP-Method-Override": "PUT"}, // X-HTTP-Method-Override set to PUT.
data: '{"name": "Dave"}' // Some data e.g. Valid JSON as a string
});
/* Some clients do not support PUT or it’s difficult to send in a PUT request. For these cases, you could POST the request with a request header of X-HTTP-Method-Override set to PUT. What this tells the server is that the intended request is a PUT. Obviously this relies on the API you are accessing making use of the X-HTTP-Method-Override Header.*/
# download a movie from einthusan
# you need to have ffmpeg installed
# you can get the url, by inspecting the xhr in chrome dev tools
# on windows use portable version
.\ffmpeg.exe -user-agent "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36" -i "http://75.126.5.180/einthusancom/hot/D2981.mp4.m3u8?e=1470131671&md5=h0TLi6IIq8tNhWgDrNOSJA" -c -bsf:a aac_adtstoasc BaaghiHindi.mp4
# on ubuntu
ffmpeg -user-agent "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36" -i "http://75.126.73.16/einthusancom/hot/D9005.mp4.m3u8?e=1471147397&md5=oMxkF0ZbR7lZPNjaaaOm3A" -strict -2 RaghRaghav.mp4