Skip to content

Instantly share code, notes, and snippets.

View pradumangoyal's full-sized avatar
🙃
LETs not declare WARS

Praduman Goyal pradumangoyal

🙃
LETs not declare WARS
View GitHub Profile
@pradumangoyal
pradumangoyal / badge-props-proposal.js
Created April 1, 2019 07:38
Props proposal for Badge component
const propTypes = {
/**
* Change badge color and that of text accordingly
*/
color: PropTypes.oneOf(['inverse', 'lightest']),
/**
* CSS classes that are applied to the span.
*/
className: PropTypes.oneOfType([
PropTypes.array,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Single Page Apps for GitHub Pages</title>
<script type="text/javascript">
// Single Page Apps for GitHub Pages
// https://github.com/rafrex/spa-github-pages
// Copyright (c) 2016 Rafael Pedicini, licensed under the MIT License
# method to get the client IP address
def get_client_ip(request):
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for:
ip = x_forwarded_for.split(',')[0]
else:
ip = request.META.get('REMOTE_ADDR')
return ip
... # Other imports
import requests
import get_client_ip from './utils.py' # See next snippet
secret_key = 'YOUR_SECRET_SITE_KEY' # Preferably from settings.py
class Submission(APIView):
...
def post(self, request, *args, **kwargs):
handleSubmit = () => {
if(this.state.captcha){
let headers = {
'X-CSRFToken': getCookie('csrftoken')
}
let data = {
information: this.state.information,
'g-recaptcha-response': this.state["g-recaptcha-response"]
}
axios.post(urlContactMe(), data, {headers: headers})
handleCaptcha = (key) => {
this.setState({
captcha: true,
'g-recaptcha-response': key
})
}
import ReCAPTCHA from 'react-google-recaptcha'
const recaptchaRef = React.createRef()
<ReCAPTCHA
onChange={this.handleCaptcha}
ref={recaptchaRef}
//This ref can be used to call captcha related functions in case you need.
sitekey="PROVIDE-YOUR_SITE_KEY_HERE"
theme="dark"
/>
@pradumangoyal
pradumangoyal / workshop18.sh
Created October 13, 2018 17:54
Script for setting up php, apache, mysql in ubuntu
apt-get install git
apt-get install sublime-text -y
apt install google-chrome-stable -y
apt-get install apache2 -y
apache2ctl configtest
systemctl restart apache2
ufw app list
ufw app info "Apache Full"
ufw allow in "Apache Full"
apt-get install curl -y