Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mikedfunk's full-sized avatar

Mike Funk mikedfunk

View GitHub Profile
@mikedfunk
mikedfunk / paypaltest.md
Created February 28, 2014 20:49
How to create a paypal test account
<project name="Einstein2" default="build" basedir=".">
<property name="basedir" value="${project.basedir}" />
<property name="source" value="${basedir}/app"/>
<property name="php_bin_path" value="" />
<target name="clean" description="Clean up and create artifact directories">
<delete dir="${basedir}/build/api"/>
<delete dir="${basedir}/build/code-browser"/>
<delete dir="${basedir}/build/coverage"/>
<delete dir="${basedir}/build/logs"/>
@mikedfunk
mikedfunk / sed.sh
Last active August 29, 2015 14:01
sed example
# search and replace with backup
# with -i it specifies a backup. So the file will be copied from myfile.txt to myfile.txt.bak before replacing any text.
# the * at the end is the filename. It can be myfile.* or *.txt or * or myfile.txt or whatever.
# mac version
sed -i .bak 's/hello/gbye/g' *
# linux version
sed -ibak 's/hello/gbye/g' *
# or just
sed 's/hello/gbye/g' *
@mikedfunk
mikedfunk / CsvSeeder.php
Last active August 29, 2015 14:02
Laravel 4 CSV seeder class
<?php
/**
* CSV file seeder. put the csv in the same dir named like table_name.csv. Then
* set the tableName property. The run command picks up from there.
*
* @copyright MIT
*/
namespace InternetBrands\AutoClassifiedsPlatform\Common\Seeds;
@mikedfunk
mikedfunk / viewpresenterproscons.md
Created September 26, 2014 01:12
View presenter pros/cons

View Presenter pros/cons

Pros Cons
👍 Makes large views readable as to what they contain 👎 If you want to change text and it's all in one view, just ctrl-f for it and change the text. If it's in sub-views, you first have to find which view fragment it resides in before you change it. The frustration of this IMHO outweighs the simplicity of knowing what's going on in the master view
👍 Allows you to reuse sections of code with different parameters (this is only helpful if you plan on reusing the abstracted code) 👎 When you abstract segments that are only being used in one place, it adds unnecessary complexity and processing requirements.
👎 Dealing with an extra closing div is a nightmare. Now you have to go through each @included file and find the extra .
👎 Indentation adjustment is a pain in the ass because you have to match child file indentation to be one more than the parent
#! /bin/bash
if [[ ! -f "/my/file/whatever/cron.disabled" ]]
/usr/bin/php /var/www/sites/staging/live/artisan cron:run
fi
@mikedfunk
mikedfunk / ChunkLoop.php
Last active August 29, 2015 14:07
Go through queries in chunks so you don't run out of memory
<?php
$offset = 0;
// only process 1000 at a time
$increment = 1000;
// getByOffsetAndLimit is the key factor here!
while ($galleries = $this->listingGalleryRepository->getByOffsetAndLimit($offset, $increment)) {
// we have to break out of the loop if there are no more left
@mikedfunk
mikedfunk / MyClass.php
Created November 16, 2014 04:21
optionally allow an array in php
<?php
// ...
public function processData($input)
{
if (is_array($input)) {
// if it's an array, loop through each one and recursively
// call the function we're in but this time without an
// array. So it should skip past this line for each one.
@mikedfunk
mikedfunk / 0_reuse_code.js
Last active August 29, 2015 14:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mikedfunk
mikedfunk / javascript_resources.md
Last active August 29, 2015 14:11 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage