Skip to content

Instantly share code, notes, and snippets.

View strykstaguy's full-sized avatar

Cody Benner strykstaguy

  • Little Rock, AR
View GitHub Profile
/*
this is a pubsub pattern example.
the pubsub mechanism is in PubSub.
any class can use it by creating an instance ie:
// the class that accepts subscribers must implement PubSub:
//"MyClass" definitions:
//...
this.pubsub = new PubSub();
@strykstaguy
strykstaguy / Drag and Drop
Created January 3, 2022 15:04 — forked from KislyakovS/Drag and Drop
Drag and Drop
let element = document.querySelector('.block');
element.addEventListener('mousedown', (evt) => {
let startCoords = {
x: evt.clientX,
y: evt.clientY
};
let onMouseMove = function(moveEvt) {
let shift = {
@strykstaguy
strykstaguy / gist:e0605fe3985bc85b5db203731dbc0662
Created July 27, 2020 00:45 — forked from JesseObrien/gist:7418983
Bind parameters into the SQL query for Laravel ORM
<?php
class MyModel extends Eloquent {
public function getSql()
{
$builder = $this->getBuilder();
$sql = $builder->toSql();
foreach($builder->getBindings() as $binding)
{
@strykstaguy
strykstaguy / gitcom.md
Created June 23, 2020 20:08 — forked from jednano/gitcom.md
Common git commands in a day-to-day workflow

Git Cheat Sheet

Initial Setup

Create an empty git repo or reinitialize an existing one

$ git init
@strykstaguy
strykstaguy / interval.js
Created January 11, 2020 17:53 — forked from ncou/interval.js
setTimeout and setInterval with pause and resume
// http://stackoverflow.com/questions/7279567/how-do-i-pause-a-window-setinterval-in-javascript
function RecurringTimer(callback, delay) {
var timerId, start, remaining = delay;
this.pause = function() {
window.clearTimeout(timerId);
remaining -= new Date() - start;
};
@strykstaguy
strykstaguy / umd-script-boilerplate.js
Created January 7, 2020 21:21 — forked from cferdinandi/umd-script-boilerplate.js
A simple boilerplate for UMD JS modules.
(function (root, factory) {
if ( typeof define === 'function' && define.amd ) {
define([], factory(root));
} else if ( typeof exports === 'object' ) {
module.exports = factory(root);
} else {
root.myPlugin = factory(root);
}
})(typeof global !== "undefined" ? global : this.window || this.global, function (root) {

#Set DB_CONNECTION to use sqlite in-memory database when testing

  • Open `phpunit.xml' file in the current project
  • Add the following environment variables to the appropriate section
  <env name="DB_CONNECTION" value="sqlite">
  <env name="DB_DATABASE" value=":memory:">
  • in config\database.php file, change the default sqlite connection to
  'connections' => [
@strykstaguy
strykstaguy / substring.php
Created October 23, 2017 13:47 — forked from hamidsamak/substring.php
find string between two needles
<?php
/**
* find string between two needles
* @param string $string
* @param string $needle_1
* @param string $needle_2
* @param boolean $case_insensitive
* @return string/boolean
*/

PHPExcel Cheat Sheet

Documentation

Snippets

Install.

composer require phpoffice/phpexcel