Skip to content

Instantly share code, notes, and snippets.

@clouddueling
clouddueling / feed.php
Last active December 14, 2015 03:29
Long pulling with Laravel
<?php
class Feed_Controller extends Base_Controller
{
public $layout = 'layouts.feed';
public function get_index()
{
$records = Record::where_deleted(0)
->order_by('updated_at', 'desc')
@clouddueling
clouddueling / upload_image.php
Created February 25, 2013 05:17
upload an image to s3 using laravel
function upload_image($options = array())
{
$defaults = array(
'bucket' => 'socialdueling',
'sizes' => array('small' => 150, 'medium' => 300),
'input_name' => 'image',
'file_path' => 'storage/work/',
'return_value' => '',
'storage_path' => 'uploads/',
@clouddueling
clouddueling / routes.php
Created February 27, 2013 22:48
username in url laravel
Event::listen('404', function()
{
$username = URI::segment(1);
$user = User::where_username($username)
->where_type('account')
->first();
if ($user != null) {
if ($user->username != '') {
@clouddueling
clouddueling / remember_nav.js
Last active December 14, 2015 08:28
Remember which bootstrap tab you were on.
// Remember the tab you were on.
$('a[data-toggle="tab"]').on('shown', function(e){
//save the latest tab using a cookie:
$.cookie('last_tab', $(e.target).attr('href'));
});
//activate latest tab, if it exists:
var lastTab = $.cookie('last_tab');
if (lastTab) {
$('a[href=' + lastTab + ']').tab('show');
@clouddueling
clouddueling / asynch_laravel.php
Created March 3, 2013 03:06
asynchronous php laravel
public function post_create()
{
ignore_user_abort(true);
set_time_limit(0);
Log::go('user can start browsing or whatever cause they aren't here anymore');
Log::go('uploading file to S3 because flash sucks');
}
@clouddueling
clouddueling / upload.js
Created March 3, 2013 07:34
resumable.js example
var uploader = (function(){
var r = Resumable({
target: '/upload/stream',
chunkSize: 1*1024*1024,
query: {
serie_id: {{ $serie->id }}
}
}),
@clouddueling
clouddueling / page.php
Created March 11, 2013 22:43
Pay with a tweet or share laravel
<div class='btn-group row-fluid'>
<a class='btn btn-success btn-large' href='#pay-with-share' data-toggle='modal'>
Pay with a Tweet or Share
</a>
</div>
<div class='modal hide fade' id='pay-with-share'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>&times;</button>
@clouddueling
clouddueling / focus.php
Created March 17, 2013 22:54
Using REST in Laravel
<?php
class Focus_Controller extends Base_Controller
{
public function post_test()
{
dd('post');
}
public function get_test()
@clouddueling
clouddueling / delay.js
Created March 22, 2013 01:06
delay instead of setTimeout
<script type="text/javascript">
(function() {
var delay;
delay = function(ms, func) {
return setTimeout(func, ms);
};
toastr.options = {
positionClass: 'toast-bottom-left'
@clouddueling
clouddueling / focus.js
Created March 24, 2013 03:27
Single Page Web app written in jQuery
var c = $('.focus-container'),
Focus = (function(window, document, undefined) {
var s = {
alphaContacts: {},
clearTagsBtn: '.focus-clear-tags-btn',
contact: null,
contacts: {},
contactsAlphaBtn: $('.focus-alpha-contacts-btn'),
contactList: $('.focus-contact-list'),
contactProfile: $('.focus-contact-profile'),