Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<title>Add Song</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<form>
<script>
var balance = <?php echo $_SESSION['balance']; ?>;
</script>
@iamdtang
iamdtang / a7 dvds with eloquent
Created April 26, 2015 17:18
search dvds by genre name
$dvds = Dvd::with('genre', 'rating', 'label')
->whereHas('genre', function($query) use ($genre_name) {
$query->where('genre_name', '=', $genre_name);
})
->get();
Backbone.View.extend({
events:
'click input[type=checkbox]': 'handleCheckboxChange'
handleCheckboxChange: () ->
})
angular
.module('defaultValueSelect', [])
.controller('ExampleController', function($scope, someCalculationService) {
$scope.data = {
availableOptions: [
{id: '1', name: 'Option A'},
{id: '2', name: 'Option B'},
{id: '3', name: 'Option C'}
],
selectedOption: {id: '3', name: 'Option C'} //This sets the default value of the select in the ui
@iamdtang
iamdtang / DvdController.php
Last active February 2, 2016 07:40
handling All dropdowns
$genre = $request->input('genre');
$movies = DB::table('dvds')
->select('title', 'genre_name', 'rating_name', 'label_name', 'sound_name', 'format_name')
// more joins here
->join('genres', 'dvds.genre_id', '=', 'genres.id');
if ($genre !== 'All') {
$movies = $movies->where('genre_id', '=', $genre);
}
@iamdtang
iamdtang / controllers.application.js
Last active March 25, 2016 01:16
pushObject and todos
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this.set('todos', ['todo 1', 'todo 2']);
},
actions: {
add() {
this.get('todos').pushObject('todo 3');
{
"errors": [
{
"code": "application error code (not HTTP status code)"
}
]
}
{
"errors": [
{
"code": "application error code (not HTTP status code)",
"source": {
"pointer": "data/attributes/name"
}
}
]
}
@iamdtang
iamdtang / gist:82aad471af0f824bba5effaf7721e489
Last active October 18, 2016 01:45
itp404 - code challenge 10/18/2016
[{
id: 5,
title: "Self Esteem",
artist: 1,
genre: 1,
price: 1.29,
playCount: 1,
createdBy: "admin"
}, {
id: 8,