This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import BaseHTTPServer | |
from SimpleHTTPServer import SimpleHTTPRequestHandler | |
import sys | |
import base64 | |
key = "" | |
class AuthHandler(SimpleHTTPRequestHandler): | |
''' Main class to present webpages and authentication. ''' | |
def do_HEAD(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def upload_file(self, file_path, upload_url): | |
""" | |
Upload file using curl | |
based on https://github.com/Lispython/pycurl/blob/master/examples/file_upload.py | |
:param file_path: | |
:param upload_url: | |
:return: abs file url path of uploaded file. | |
""" | |
if file_path is None or not os.path.exists(file_path): | |
print("File '{}' cant be uploaded".format(file_path)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'schedule_event', 'limit_cron_events' ); | |
if ( ! funciton_exists( 'limit_cron_events' ) ) { | |
/** | |
* Limitize WordPress default scheduled tasks | |
* https://codex.wordpress.org/Plugin_API/Filter_Reference/schedule_event | |
* | |
* @param object $event event being scheduled | |
* @return void |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# To enable this hook, rename this file to "pre-commit" and move it to .git/hooks/ in your project dir. | |
# For windows user, if you are using Git for windows (https://git-scm.com/download/win) then use following shebang | |
# #!C:/Program\ Files/Git/usr/bin/sh.exe | |
# For windows I prefer you use cygwin so that it supports bash script interpretation | |
# For windows if you are using https://git-scm.com/download/win then by default it uses cygwin. | |
# This script assumes the working directory already does have composer dependencies installed. | |
# @dependency: composer, phpcs, wpcs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -u | |
set -o pipefail | |
# installs composer if required | |
function maybe_install_composer() { | |
# If composer exists then return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! function_exists( 'twr_array_unique_by_key' ) ) { | |
/** | |
* Return unique multidimensional array filtered by given key. | |
* | |
* @param $array should be multidimensional array | |
* @param string $key | |
* @return array | |
*/ | |
function twr_array_unique_by_key( $array, $key ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Post duplicator component. | |
* | |
* @author Bhaskar K C | |
* @since 24/05/2017 | |
*/ | |
class Component_post_duplicator extends Component { | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! function_exists( 'twr_get_progressive_line') ) { | |
/** | |
* Returns proper line string from given $string content by progressively matching each line of the given html blob | |
* @param string $content | |
* @param integer $nth_line nth line to scan of given string | |
* @param integer $scanned_chars characters scanned | |
* @return mixed|null|string | |
*/ |