Skip to content

Instantly share code, notes, and snippets.

View weotch's full-sized avatar
👋
Heya

Robert Reinhard weotch

👋
Heya
View GitHub Profile
@weotch
weotch / umd.js
Created February 10, 2014 19:29
Example of implementing UMD spec
// Based on https://github.com/umdjs/umd/blob/master/returnExports.js
(function (root, factory) {
// AMD
if (typeof define === 'function' && define.amd) {
define([
'jquery'
, 'lodash'
], factory);
@weotch
weotch / view.js
Last active August 29, 2015 13:57
Example change handler function. Does a basic fade.
// Change the page
View.change = function(e, new_page) {
// Make sure old page has lower z-index and stop any trams.
// Note: calling set() invokes stop()
var old = this.$slides.eq(e.previous('page')).tram()
.set({'z-index': 1})
;
// Hide the old one after the transition is done. Don't use
@weotch
weotch / browser-refresh.json
Last active August 29, 2015 13:57
My sublime settings
[
{
"keys": ["super+shift+r"], "command": "browser_refresh", "args": {
"auto_save": true,
"delay": 0.0,
"activate_browser": true,
"browser_name" : "Google Chrome"
}
}
]
<?php
// Homepage feed
public function index($filter = null) {
// Tell Laravel where to find the mustache views for post
app('view')->addNamespace('js', public_path().'/js');
// Render the view
$this->layout->nest('content', 'gadget.index', array(
@weotch
weotch / view.js
Created May 13, 2014 17:30
Basic backbone template
define(function (require) {
// Dependencies
var $ = require('jquery')
, _ = require('lodash')
, Backbone = require('backbone')
;
// Setup view
var View = {};
@weotch
weotch / commands.md
Last active August 29, 2015 14:02
Moving files between PagodaBox instances

Since you can't ssh from PagodaBox (the binary isn't installed), you can't rsync or scp between servers. Thus you need to copy them locally and then upload back up

  1. Enable ssh in PB for both servers.
  2. SSH to the first server and tar the uploads dir: tar -cvf uploads.tar shared/public/uploads. Not bothering with zipping causing it would take along time and it's all binary so I don't expect much compression help.
  3. Download the uploads.tar file to your comp.
  4. Delete uploads.tar file from server.
  5. Upload uploads.tar file to the root of second server.
  6. Connect to second server via SSH
  7. Uncompress it: tar -xvf uploads.tar
  8. Delete uploads.tar file from the second server
@weotch
weotch / new_gist_file.php
Created September 15, 2014 16:45
Make a visible column nullable in a separate migration, like when you forget.
DB::connection()->getPdo()->exec('ALTER TABLE `webinars` CHANGE `visible` `visible` TINYINT(1) NULL');
@weotch
weotch / migrate.php
Created October 1, 2014 21:23
Laravel foreign key example
$table->foreign('article_id')->references('id')->on('articles')->onUpdate('cascade')->onDelete('cascade');
// Set null style
$table->foreign('article_id')->references('id')->on('articles')->onUpdate('cascade')->onDelete('set null');
@weotch
weotch / notes.md
Last active August 29, 2015 14:16
Hardened JS queries
  • Another module, a mediator, would call query({types:"one,two"}) to intiate a search.
  • The query() method is debounced to prevent a bunch of successive calls if the person is actively using the UI. But, it has the leading and trailing attributes so that the first clicks is immediately handled and so that a final GET is made once the user is done being spastic, responding to the final search terms.
  • We save the xhr response so that we can use it to abort a still running request. Thus, if the request still hasn't finished by the time the trailing execution happens, the done() callback won't be fired for the previous query.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class ProductImagesTable extends Migration {
/**
* Run the migrations.
*