Skip to content

Instantly share code, notes, and snippets.

View adam8810's full-sized avatar

Adam Booth adam8810

  • Oklahoma City
View GitHub Profile
@adam8810
adam8810 / Array-Digging-Question
Created September 7, 2012 18:15
Array Digging
This is the array that I'd be digging into.
array(
"results" => array(
"list" => array(
"content" => "content stuff"
)
)
)
This is my code and I think it's really ugly in it's current state. I'm trying to get the info in "content":
url = '/api/movie.json/' + $id;
$.ajax({
url: url,
success: function(data)
{
$(data.cast).each(function($index)
{
// pseudocode in php
echo "this is the title" . data.name;
$(data.cast).each(function($index)
{
// Set defaults
$profile_path = "/assets/img/missing_" + (($index % 5) + 1) + ".png";
$position_offsets = "";
// Check to see if image exists
if(this.profile_path != null)
{
$profile_path = "http://cf2.imgobject.com/t/p/w185" + this.profile_path;
@adam8810
adam8810 / gist:5417000
Created April 18, 2013 23:28
Select2 Events
$('#add_to_list').on('change', function($e) {
if ($e.added !== undefined) {
$.ajax({
url: '/api/add_to_list.json',
data: {list_id: $e.added.id, movie_id: $id, user_id: $user_id},
success: function() {
add_notify($movie_title, $e.added.text, $poster);
}
});
}
@adam8810
adam8810 / gist:5423049
Created April 19, 2013 20:36
Email Friendly
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body style="font-family: arial">
<h1 style="font-family: 'Arial Black'"><?php echo $task_name; ?> Completed</h1>
<table style="border:1px solid #999; padding:2px">
<tr style="background: #333; color: #FFF;">
<td style="padding:5px;border-right:1px solid #999;border-bottom:1px solid #999;"><strong>Location:</strong></td>
@adam8810
adam8810 / gist:6259898
Last active December 21, 2015 05:49
DB vs ORM
$query = DB::select(DB::expr('person.homeid, home.addressid, person.personid, person.firstName, person.middleName, person.lastName, person.gender, person.maritalStatus, person.birth'))
->from(DB::expr('home, person'))
->where(DB::expr('home.homeid'), DB::expr('person.homeid'))
->and_where(DB::expr('person.homeid'), $homeid);
$people = Person::query()
->related('homes')
->get();
// list people's addresses
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-scroll-header-panel/core-scroll-header-panel.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
@adam8810
adam8810 / logging.js
Last active February 1, 2025 00:36
A simple node module that makes console.log/error/warn/debug statements log through winston (simply include at the beginning of your app)
'use strict';
var util = require('util'),
winston = require('winston'),
logger = new winston.Logger(),
production = (process.env.NODE_ENV || '').toLowerCase() === 'production';
module.exports = {
middleware: function(req, res, next){
console.info(req.method, req.url, res.statusCode);