Skip to content

Instantly share code, notes, and snippets.

View ariera's full-sized avatar
🐢
Fixing the world. I'll let you know when I'm done.

Alejandro Riera ariera

🐢
Fixing the world. I'll let you know when I'm done.
View GitHub Profile
@ariera
ariera / gist:965d78d88a030867821fcb7d1cb1a2fc
Created December 7, 2017 10:51 — forked from dhbradshaw/gist:e2bdeb502b0d0d2acced
Rename field using migrations in django 1.7
To change a field name in django 1.7+
1. Edit the field name in the model (but remember the old field name: you need it for step 3!)
2. Create an empty migration
$ python manage.py makemigrations --empty myApp
3. Edit the empty migration (it's in the migrations folder in your app folder, and will be the most recent migration) by adding
migrations.RenameField('MyModel', 'old_field_name', 'new_field_name'),
to the operations list.
@ariera
ariera / index.html
Created March 6, 2017 07:04
vue-devtools issue #273
<!doctype html>
<html>
<head>
<title>Vue Devtools Bug</title>
</head>
<body>
<div id="app">
<my-component :model="myModel"></my-component>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.10/vue.js"></script>
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Config;
class SchemaDumpCommand extends Command
{
@ariera
ariera / file_queue.rb
Created October 21, 2015 08:04 — forked from daddz/file_queue.rb
a ruby queue based on a file
class FileQueue
def initialize(file_name)
@file_name = file_name
end
def push(obj)
safe_open('a') do |file|
file.write(obj + "\n")
end
<script type='text/javascript'>// <![CDATA[
(function(){
var e = document.createElement('script'); e.type = 'text/javascript'; e.async = true;
e.src = "//www.pagebox.es/assets/embeds/parent.js";
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(e);
})();
// ]]></script>
<iframe src="//www.pagebox.es/embeds/e8a63cb2f8ef466d7dbae65fa5ac4f1190151189" data-pagebox-id='e8a63cb2f8ef466d7dbae65fa5ac4f1190151189' frameborder='0' scrolling="no" style="width:100%; overflow:hidden;"></iframe>
require 'spec_helper'
describe "User" do
it "should be able to log in", js:true do
user = create(:user, :with_subscription, :with_customer_info, :with_user_data)
visit new_user_session_path
within ".login_form" do
@ariera
ariera / jquery.locksubmit.js
Created March 3, 2014 08:45
jQuery.lockSubmit
//BASED ON:
// Lock a submit button when clicked from being clicking again and change the value of the submit to a message, while preserving the submits name and value in a hidden input.
// License: http://www.gnu.org/licenses/lgpl.txt
// Homepage: http://blog.leenix.co.uk/2009/09/jquery-plugin-locksubmit-stop-submit.html
// Version 1.03
jQuery.fn.lockSubmit = function(options) {
adjustHeights: (target) ->
#http://css-tricks.com/equal-height-blocks-in-rows/
currentTallest = 0
currentRowStart = 0
rowDivs = new Array()
topPosition = 0
target.each ->
$el = $(this)
topPostion = $el.position().top
require 'net/http'
require 'xmlsimple'
url = "http://www.user-agents.org/allagents.xml"
xml_data = Net::HTTP.get_response(URI.parse(url)).body
data = XmlSimple.xml_in(xml_data)
agents = data['user-agent'].select{|agent| type = agent["Type"].first; type.include?("R") || type.include?("S")}
agent_names = agents.collect {|agent| agent["String"].first}
@ariera
ariera / unicorn
Created February 22, 2013 10:05 — forked from shapeshed/unicorn
#!/bin/sh
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/path/to/your/app/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENVIRONMENT=production