Skip to content

Instantly share code, notes, and snippets.

@bbatsche
bbatsche / student.php
Last active August 29, 2015 14:06
Student Class Example
<?php
class Student
{
public $firstName;
public $lastName;
public $cohort;
public $classStart;
<?php
class Ad {
public $dbc;
public $id;
public $title = '';
public $body = '';
@bbatsche
bbatsche / jquery.data.html
Created September 29, 2014 22:50
Demonstrate getting & setting data attributes of an element
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>JQuery, YAY!</title>
</head>
<body>
<h1 id="heading" data-alt-heading="MAGIC">Example Page</h1>
@bbatsche
bbatsche / laravel-ajax.php
Created October 15, 2014 20:06
Ajax Request
{{ link_to_action('PostsController@edit', 'Edit', $post->id, array('class' => 'btn btn-default')) }}
<button type="button" class="btn btn-danger delete-btn" data-post-id="{{{ $post->id }}}">Delete</button>
<script>
var csrfToken = "{{{ Session::get('_token') }}}";
$(".delete-btn").click(function() {
var postId = $(this).data('post-id');
if (confirm('Are you sure you want to delete this post?')) {
$(document).ready(function() {
$(".collapse-column").each(function() {
$(this).data('default-height', $(this).height());
$(this).height('80');
});
$(".collapse-column").click(function() {
var targetHeight = $(this).data('default-height');
@bbatsche
bbatsche / 01.cmake
Last active August 29, 2015 14:28
brew install hhvm --verbose Error Logs
2015-08-24 11:19:16 -0500
cmake
.
-DBOOST_INCLUDEDIR=/usr/local/opt/boost/include
-DBOOST_LIBRARYDIR=/usr/local/opt/boost/lib
-DCCLIENT_INCLUDE_PATH=/usr/local/opt/imap-uw/include/imap
-DCMAKE_C_FLAGS=-I/usr/local/opt/readline/include -L/usr/local/opt/readline/lib
-DCMAKE_CXX_FLAGS=-I/usr/local/opt/readline/include -L/usr/local/opt/readline/lib
-DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/hhvm/3.9.0
@bbatsche
bbatsche / PostsController.php
Last active January 27, 2016 20:32
Angular 1.4 + Laravel 4.2
<?php
// app/controllers/PostsController.php
class PostsController extends \BaseController
{
// ...
public function destroy($id)
{
// ...
@bbatsche
bbatsche / README.md
Created September 10, 2015 14:53
How to use a custom Angular filter with Moment.js to parse and display dates from PHP

When a PHP DateTime (or Carbon date) object is converted to JSON it is sent in a format that native JavaScript cannot parse, like this:

{
  "date": "2015-09-10 14:09:46",
  "timezone_type": 3,
  "timezone": "UTC"
}
@bbatsche
bbatsche / Model.php
Created September 29, 2015 20:06
Haversine Query Scope
<?php
class BaseModel {
const UNIT_KM = 111.045;
const UNIT_MI = 69.0;
// Throw this function in any model with latitude/longitude columns
// Or if multiple models have those values you can put it in your BaseModel
public function scopeNearLatLong($query, $lat, $lng, $radius = 10, $unit = 69.0)
{
"use strict";
var Hangman = {
words: [], // Set of words for hangman to choose from
currentWord: '', // Current word for the game
correctGuesses: [], // Correct letters the user has guesses
incorrectGuesses: [], // Wrong letters the user has guessed
maxGuesses: 0, // Maximum number of wrong guesses the user is allowed
/**