Skip to content

Instantly share code, notes, and snippets.

@AleeRojas
AleeRojas / gist:1c0f4f7fae23f29b95e0
Created January 20, 2016 15:40
Git subtree para producción
UPDATE: Not enough happy with step 3 and 4 (essentially because of some git errors), I figured out a cleaner solution:
New 3. Now, we will use a git-subtree technique to push the build or output content to the gh-pages branch. You will need to run the following lines every time you want to update your site/blog!
git checkout master # you can avoid this line if you are in master...
git subtree split --prefix output -b gh-pages # create a local gh-pages branch containing the splitted output folder
git push -f origin gh-pages:gh-pages # force the push of the gh-pages branch to the remote gh-pages branch at origin
git branch -D gh-pages # delete the local gh-pages because you will need it: ref
@AleeRojas
AleeRojas / CORS.php
Created December 24, 2015 03:19 — forked from fhferreira/CORS.php
Try to create - Cors Filter Laravel 5 Middleware
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Http\Response;
class CORS implements Middleware {
/**
* Handle an incoming request.
<script id="courseList" type="text/x-handlebars-template"> <span id="course-option" class="course-opt" value="{{id}}">{{name}}</span> </script>
method: in main.js
window.templates = function(id) { return Handlebars.compile($('#' + id).html(), context); };
then some of my code in my view
`App.Views.CourseView = Backbone.View.extend({
tagName: 'option',
@AleeRojas
AleeRojas / token.js
Created December 11, 2015 21:56
Pasar los token en cabezeras
var oldSync;
oldSync = Backbone.sync;
Backbone.sync = function(method, model, options) {
var csrfSafeMethod;
csrfSafeMethod = function(method) {
return /^(GET|HEAD|OPTIONS|TRACE)$/.test(method);
};
options.beforeSend = function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
@AleeRojas
AleeRojas / intro.markdown
Created October 28, 2015 16:29 — forked from tillsanders/intro.markdown
Laravel: drag-and-drop repositioning with auto-save of DB entries

Laravel: drag-and-drop repositioning with auto-save of DB entries

Use case: Database entries are represented in a table. By grabbing and moving a row up or down the table, you can change the entries' order/position. The changes are submitted automatically via ajax.

  • Uses jQueryUI (custom download: sortable is needed)
  • newly created elements are added to the top (see route /jobs/create)
@AleeRojas
AleeRojas / auto_suggest.md
Created October 27, 2015 19:10
Typeahead.js & Laravel
  • view/index.blade.php
{{ Form::open(['url' => '/profile', 'method' => 'get']) }}
	{{ Form::text('user', null, ['id'=>'users']) }}
	{{ Form::submit('GO') }}
{{ Form::close() }}
  • routes.php
Route::get('/', 'SearchController@index');
@AleeRojas
AleeRojas / display_authors.php
Created July 28, 2015 18:17
Display Authors Widget
<?php
/**
* Plugin Name: Display Authors Widget
* Plugin URI: https://foxland.fi/downloads/display-authors-widget/
* Description: Register widget to display authors by role in a sidebar.
* Version: 1.1.1
* Author: Sami Keijonen
* Author URI: https://foxland.fi/
* Text Domain: display-authors-widget
* Domain Path: /languages
@AleeRojas
AleeRojas / widget-skeleton.php
Last active August 29, 2015 14:25 — forked from matiskay/widget-skeleton.php
Wordpress Widget Skeleton
<?php
class Widget_Name extends WP_Widget {
function Widget_Name() {
$widget_opts = array(
'classname' => 'your-awesome-class',
'description' => 'Your awesome Description',
);
@AleeRojas
AleeRojas / gist:8304d34f13aba404c7b4
Created February 27, 2015 20:37
Todas las imagenes de custom header
<?php
if (!is_random_header_image()) {
$imagenes = get_uploaded_header_images();
foreach ($imagenes as $imagen) {
$url = $imagen['url'];
echo '<img src="'.$url.'" height="'.get_custom_header()->height.'" width="'.get_custom_header()->width.'"/>';
}
} else {
echo '<img src="'.get_header_image().'" height="'.get_custom_header()->height.'" width="'.get_custom_header()->width.'" alt="" />';
}
@AleeRojas
AleeRojas / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console