Skip to content

Instantly share code, notes, and snippets.

View jasondavis's full-sized avatar

Jason Davis jasondavis

View GitHub Profile
@jasondavis
jasondavis / .gitignore
Created December 25, 2017 18:03 — forked from iffy/.gitignore
Example using electron-updater with `generic` provider.
node_modules
dist/
yarn.lock
wwwroot
@jasondavis
jasondavis / nodejs_installer.ps1
Created May 19, 2017 05:28 — forked from nweldev/nodejs_installer.ps1
Powershell script installing nodejs (with git) and some npm packages
write-host "`n ## NODEJS INSTALLER ## `n"
### CONFIGURATION
# nodejs
$version = "4.4.7-x64"
$url = "https://nodejs.org/dist/latest-v4.x/node-v$version.msi"
# git
$git_version = "2.9.2"
@jasondavis
jasondavis / list_and_download_files_through_sftp_with_php.php
Created April 17, 2017 05:32 — forked from danielbwa/list_and_download_files_through_sftp_with_php.php
List and download all files in a directory through sftp with php / ssh2. In my example i use scandir to list the files and ssh2_scp_recv to grab a file. I've found a lot of examples using fopen to grab the remote file, that didn't work for me and i found the code below cleaner than the fopen option. For an example on how to do the same as my exa…
<?php
$username = "your_username";
$password = "your_pass";
$url = 'your_stp_server_url';
// Make our connection
$connection = ssh2_connect($url);
// Authenticate
@jasondavis
jasondavis / filltextGist
Created April 2, 2017 20:46 — forked from joemaddalone/filltextGist
gist example for filltext.com
{
"rows" : "!",
"id" : "{index}",
"active" : "{bool}",
"fname" : "{firstName}",
"lname" : "{lastName}",
"category" : "[13,16,19,21]",
"tel" : "{phone}",
"address" : "{addressObject}",
"cc" : "{ccObject}",
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Array#forEach</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
<?php
$c = new Client('https://poste.io/admin/api/v1/', '[email protected]', 'admin');
$c->delete('domains/t.com');
$c->post('domains', ['name' => 't.com']);
$c->post('boxes', ['email' => '[email protected]', 'passwordPlaintext' => 't', 'name' => 't']);
$c->patch('boxes/[email protected]', ['name' => 'a', 'disabled' => true, 'passwordPlaintext' => 'a']);
@jasondavis
jasondavis / post_message_example.js
Created March 16, 2017 19:38 — forked from vishaltelangre/post_message_example.js
window.postMessage example
// recieve message
// event object contains:
// - data: message sent
// - origin (host from which the message was sent, e.g. http://blah.example.com)
// - source (reference to a Window object from which message was sent)
function postMessageHandler( event ) {
console.log("We've got a message!");
console.log("* Message:", event.data);
console.log("* Origin:", event.origin);
console.log("* Source:", event.source);
@jasondavis
jasondavis / class-autoloading-php.md
Created March 14, 2017 23:00 — forked from umidjons/class-autoloading-php.md
Class autoloading in PHP

Class Autoloading

File Application/Autoload/Loader.php:

<?php
namespace Application\Autoload;

class Loader
{
    const UNABLE_TO_LOAD = 'Unable to load';
@jasondavis
jasondavis / pub-sub.php
Created March 14, 2017 22:47 — forked from umidjons/pub-sub.php
PubSub pattern / Events in PHP
<?php
// more: http://baylorrae.com/php-pubsub/
class PubSub
{
private static $events = array(); // all subscriptions
// Don't allow PubSub to be initialized outside this class
@jasondavis
jasondavis / remote-image-cache.php
Created February 9, 2017 01:48 — forked from ScottPhillips/remote-image-cache.php
Cache remote image using PHP
<?php
function cache_image($image_url){
//replace with your cache directory
$image_path = 'path/to/cache/dir/';
//get the name of the file
$exploded_image_url = explode("/",$image_url);
$image_filename = end($exploded_image_url);
$exploded_image_filename = explode(".",$image_filename);
$extension = end($exploded_image_filename);
//make sure its an image