Skip to content

Instantly share code, notes, and snippets.

@harshanas
harshanas / FlaskApache.md
Last active September 5, 2017 08:24
Deploy Flask App to apache in Ubuntu 16.04

Deploy Flask App to apache in Ubuntu 16.04

  1. Make New Directory in var/www/ mkdir bots
  2. Create FILENAME.wsgi file sudo nano bots.wsgi
  3. Add this content and Save File
    #! /usr/bin/python3
    import sys
@harshanas
harshanas / PythonBeautifulSoup.md
Last active August 28, 2019 17:14
BeautifulSoup Code Snippets

Basic Imports, Loading Page and Parsing it to BS

from bs4 import BeautifulSoup
import urllib.request

page = urllib.request.urlopen("https://google.com/").read()
soup = BeautifulSoup(page, 'html.parser')  # Uses html.parser to parse the page

Working with Elements

@harshanas
harshanas / VariousPythonCodes.md
Created August 27, 2019 05:01
Various Python code snippets that can be useful in day to day work

Get Now Date Time

import datetime
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
@harshanas
harshanas / gist:8a15d29c155a0ad1c7be22722e04798b
Last active May 24, 2020 04:51
Setting up Selenium Environment in Heroku
@harshanas
harshanas / buildspec.yml
Created August 12, 2020 17:18
Integrate SonarCloud with AWS CodeCommit and CodeBuild
version: 0.2
phases:
install:
runtime-versions:
nodejs: 10
commands:
- apt-get update
- apt-get install -y jq
- wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.3.0.1492-linux.zip
<?php
$name = sanitize_text_field( $_REQUEST['name'] );
$email = sanitize_email( $_REQUEST['email'] );
$address = sanitize_textarea_field( $_REQUEST['address'] );
<?php
if ( is_email( $_REQUEST['email'] ) ) {
// Let's Roll!!
}else{
// Invalid email
}
<?php
$html = esc_html( '<a href="http://www.example.com/">The example link</a>' );
// Returns &lt;a href=&quot;http://www.example.com/&quot;>The example link&lt;/a>
echo $html;
<?php
namespace TheBestPluginIntheWorld;
define( ‘TBPW_API_KEY’, '123456789' );
class TBPW_User{
function tbpw_send_email(){
$tbpw_sender_email "[email protected]";
// Sends Email
}
<?php
function tbpw_get_email_count(){
return 100;
}
echo __('Send Email', 'tbpw');
printf(
_n(
'%s email',