Skip to content

Instantly share code, notes, and snippets.

View ochui's full-sized avatar
🌏
Working from home and farm

Ochui, Princewill Patrick ochui

🌏
Working from home and farm
View GitHub Profile
@ochui
ochui / unzip.php
Created June 23, 2021 20:49 — forked from ehnydeel/unzip.php
PHP-Unzip
<?php
// The unzip script
// This script lists all of the .zip files in a directory
// and allows you to select one to unzip. Unlike CPanel's file
// manager, it _will_ overwrite existing files.
//
// To use this script, FTP or paste this script into a file in the directory
// with the .zip you want to unzip. Then point your web browser at this
// script and choose which file to unzip.
<Response> <Dial> +13105555555 </Dial> </Response>
<?php
try {
$sSpreadsheetID = '16nfqj7V3Z4r2q4fHmiLXxmph5Ji-4Jw1BPGzYjTz3Kk';
$gclient = new \Google_Client();
$gclient->setApplicationName('Bluebot Google Sheets API PHP');
$gclient->setScopes(\Google_Service_Sheets::SPREADSHEETS);
$gclient->setAuthConfig(__DIR__.'/bluetext-adcce8c14228.json');
$gclient->setAccessType('offline');
$service = new \Google_Service_sheets($gclient);
@ochui
ochui / AutoResponder.js
Created October 30, 2020 12:13 — forked from erronjason/AutoResponder.js
Gmail auto-responder for use in https://script.google.com
function AutoResponder(e) {
// Our email account that will be recieving:
var email_account = "testemail@gmail.com";
// Search for subject:
var subject = "testsubject";
// Send our response email
var threads = GmailApp.search("subject:(" + subject + ") label:unread to:(" + email_account + ")");
for (var i = 0; i < threads.length; i++) {
@ochui
ochui / functions.php
Created September 29, 2020 06:08
Override Yoast SEO existing title or meta template variable
function filter_wpseo_replacements( $replacements ) {
if( isset( $replacements['%%currentmonth%%'] ) ){
$replacements['%%currentmonth%%'] = 'Sept';
}
return $replacements;
};
// Add filter
add_filter( 'wpseo_replacements', 'filter_wpseo_replacements', 10, 1 );
@ochui
ochui / spintax.php
Created June 17, 2020 08:04 — forked from irazasyed/spintax.php
PHP: Text Spinner Class - Nested spinning supported.
<?PHP
/**
* Spintax - A helper class to process Spintax strings.
*
* @author Jason Davis - https://www.codedevelopr.com/
*
* Tutorial: https://www.codedevelopr.com/articles/php-spintax-class/
*
* Updated with suggested performance improvement by @PhiSYS.
@ochui
ochui / Gender.js
Last active February 13, 2020 06:27
NativeBase and Redux Form - Radio button
import React from 'react'
import { View } from 'native-base'
import { Field } from 'redux-form'
// Custom components
import { RadioButton } from '../Form'
export default class Gender extends React.Component {
state = {
selected: 'male'
const MONTH_NAMES = [
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
];
const getFormattedDate = (date, prefomattedDate = false, hideYear = false) => {
const day = date.getDate();
const month = MONTH_NAMES[date.getMonth()];
const year = date.getFullYear();
@ochui
ochui / actions.py
Last active January 11, 2020 17:56 — forked from jeremyjbowers/actions.py
Export to CSV for Django admin
import csv
from django.http import HttpResponse
def export_as_csv_action(description="Export selected objects as CSV file", fields=None, exclude=None, header=True):
"""
This function returns an export csv action
'fields' and 'exclude' work like in django ModelForm
'header' is whether or not to output the column names as the first row
"""
@ochui
ochui / redux-socket-middleware-example.js
Created November 15, 2019 22:26 — forked from markerikson/redux-socket-middleware-example.js
Redux socket middleware example usage
const createMySocketMiddleware = (url) => {
return storeAPI => {
let socket = createMyWebsocket(url);
socket.on("message", (message) => {
storeAPI.dispatch({
type : "SOCKET_MESSAGE_RECEIVED",
payload : message
});
});