Skip to content

Instantly share code, notes, and snippets.

View samuel-fonseca's full-sized avatar

sam samuel-fonseca

View GitHub Profile
@samuel-fonseca
samuel-fonseca / php-soap.php
Created May 10, 2017 19:44 — forked from akalongman/php-soap.php
PHP soap client example
ini_set('soap.wsdl_cache_enabled', 0);
ini_set('soap.wsdl_cache_ttl', 900);
ini_set('default_socket_timeout', 15);
$params = array('param1'=>$param1);
$wsdl = 'http://service_url/method?WSDL';
@samuel-fonseca
samuel-fonseca / bible_books_list.json
Created September 16, 2017 23:34
A JSON list of all the Bible books, the number of chapters, and the number of verses.
{
"books": [
{
"book": "Genesis",
"verses": 1533,
"chapters": 50
},
{
"book": "Exodus",
"verses": 1213,
@samuel-fonseca
samuel-fonseca / dynamic_html_PHPMailer.php
Last active June 7, 2021 09:37
A dynamic method to create HTML Emails and send them using PHPMailer XOAUTH2 with Gmail. This project is in no shape or form part of the PHPMailer project; I am simply using PHPMailer to send the emails because of their great project.
<?php
/**
* Generate dynamic HTML emails
*
* @package Dynamic HTML PHPMailer builder
* @author Samuel Fonseca <[email protected]>
* @description Setup dynamic HTML emails using PHPMailer
*/
/**
<?php
/**
* Get content from the database
*
* @param $fields an array with what columns to pull
* @param $table which table to query
*
* @return $content with the table content
* @return $message with either an error or success message
*/
<?php
# I create a private function because it's used within my class, I only call it from the class itself
private function parseErrorString( $string )
{
// create delimiters here
$delimiters = array('-', "\r\n", "\n", "\r", "chr(13)");
// start by replacing the $delimiters
$ready = str_replace( $delimiters, $delimiters[0], $string );
// create new list() item:
{
"alphabet": [
{
"alpha": {
"low": "α",
"cap": "Α"
},
"beta": {
"low": "β",
"cap": "Β"
@samuel-fonseca
samuel-fonseca / UploadDropzoneFile.php
Last active February 5, 2018 19:12
A simple script to process file uploads from Dropzone.js extension. Just call the function `uploadFile()` and add the desired params.
<?php
/**
* @var $file is an array with file data
* @var $targetDir string with path to directory
* @var $maxFileSize int with max Byte size
* @var $_allowedFileTypes a comma separated string with all the allowed extensions
*/
function uploadFile(array $file, $targetDir, $maxFileSize = 100000, $_allowedFileTypes = '(jpg)')
{
// create var from array
// source: https://stackoverflow.com/questions/2499567/how-to-make-a-json-call-to-a-url/2499647#2499647
function getJSONP(url, success) {
var ud = '_' + new Date,
script = document.createElement('script'),
head = document.getElementsByTagName('head')[0]
|| document.documentElement;
window[ud] = function(data) {
head.removeChild(script);
success && success(data);
[
{
"name": "Alabama",
"abbreviation": "AL"
},
{
"name": "Alaska",
"abbreviation": "AK"
},
{
param([string] $Path, [switch] $Recurse, [int] $Depth, [switch] $Force, [string] $Exclude, [switch] $Help)
if ($Help) {
Write-Output "This script is meant to delete all macOS dot files which serve no purpose on Windows."
Write-Output "When copying a large number of files, simply copy them onto the Windows machine, then run this script"
Write-Output "./removeMacOSDotFiles.ps1
[[-Path] <string>]
[[-Depth] <int>]
[-Recurse]
[-Force]