Skip to content

Instantly share code, notes, and snippets.

@JacobBennett
JacobBennett / jquerySerialize.js
Created March 11, 2014 18:49
Jquery function to serialize an into an object
/*
* === A JQUERY FUNCTION USED FOR SERIALIZING INTO AN OBJECT ===
*/
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {

###Jeffrey Way (1) - Bootcamp

Jeffrey went through about 12 subjects one right after the other and gave tips along the way.

  1. Mail Drivers for mail notifications.
1. With Laravel 4.2 it’s easier to use APIs like Mailgun and Mandrill for e-mail notifications. This avoids using SMTP which is really cool.
  1. File Generators for generating schema migrations.

How to make faster scroll effects?

  • Avoid too many reflows (the browser to recalculate everything)
  • Use advanced CSS3 for graphic card rendering
  • Precalculate sizes and positions

Beware of reflows

The reflow appens as many times as there are frames per seconds. It recalculate all positions that change in order to diplay them. Basically, when you scroll you execute a function where you move things between two reflows. But there are functions that triggers reflows such as jQuery offset, scroll... So there are two things to take care about when you dynamically change objects in javascript to avoid too many reflows:

<?php
class BaseModel extends Eloquent {
public function columns(){
$table = $this->getTable();
return DB::select(" SHOW COLUMNS FROM ".$table);
}
@JacobBennett
JacobBennett / Validation.php
Last active January 12, 2021 04:41
Laravel Custom Validation to check if the given value Exists as a Column in Table
<?php
// BELIEVE THIS ONLY WORKS WHEN USING MYSQL
// DROP THIS INTO GLOBAL.PHP
Validator::extend('columnexists', function($attribute, $value, $parameters)
{
$query = DB::select("SHOW COLUMNS FROM " . $parameters[0]);
@JacobBennett
JacobBennett / gist:7127791f18b679116650
Created October 23, 2014 13:28
Update a program Icon
If you only want to update one Application icon, ie, in App.app/Contents/Resources/App.icns just touch the App.app folder. (I've read you need to do the Info.plist as well sometimes, although I've never needed to.)
Close the finder windows and:
touch /Applications/App.app
touch /Applications/App.app/Contents/Info.plist
You can refresh the dock icon cache using the commands above, also do a killall Dock to restart it. Personally I would just drag the application in question, off the dock and re-start / keep in dock, because this is generally a one off thing. As always, script it if possible / and you're doing it a lot.
@JacobBennett
JacobBennett / ExampleUsage.php
Last active October 2, 2015 12:33
Validator that accounts for context of validation
<?php
// After injecting the class into your controller, you would call it on a method like so
// store here is the context
// this will validate it against that set of rules
$this->validator->validate(Input::all(), 'store');
@JacobBennett
JacobBennett / blade_stuff.md
Last active August 29, 2015 14:13
Set of blade yield, section, and extend use cases that are handy to remember without having to look up http://daylerees.com/codebright/blade every time :)

Default yield statement

@yield('section_name')

Default Section

@section('section_name')
	content that will always be present
@stop
@JacobBennett
JacobBennett / gist:edcda5625098fe3b6bab
Last active October 6, 2015 05:24
Setup Node and Gulp on a Digital Ocean Droplet for Elixir
sudo apt-get update
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
npm install -g gulp
ALSO...
https://www.digitalocean.com/community/tutorials/how-to-get-started-with-gulp-js-on-your-vps
https://www.digitalocean.com/community/tutorials/how-to-install-an-upstream-version-of-node-js-on-ubuntu-12-04
$( function()
{
var targets = $( '[rel~=tooltip]' ),
target = false,
tooltip = false,
title = false;
targets.bind( 'mouseenter', function()
{
target = $( this );