Skip to content

Instantly share code, notes, and snippets.

class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.timestamps
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_token
@yurifrl
yurifrl / zsh.md
Created July 17, 2014 13:52 — forked from tsabat/zsh.md

installing postgresql 9.3.2 on ubuntu 12.04

$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install postgresql-9.3 postgresql-contrib-9.3

you should succesfully installing postgresql 9.3.2 on your machine.

@yurifrl
yurifrl / gist:ae7e77446b0c1e8e08da
Last active August 29, 2015 14:14
spree upload image via api
conn = Faraday.new(url: 'http://veran.lvh.me:3000/', params: { token: 'ac350077d3066be3d2ca79fd0586e1b1d386b88a5870a1c0' }) do |f|
f.request :multipart
f.request :url_encoded
f.adapter :net_http
end
response = conn.post('api/products/abacate-embalagem-de-1kg/images',{image: {attachment: Faraday::UploadIO.new('./image.jpg', 'image/jpeg')}})
##
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// Because if you don't, the become global variables.
(function() {
@yurifrl
yurifrl / ajax.js
Last active August 29, 2015 14:18
Example of spree CORS ajax
$.ajax({
url: "http://charles.lvh.me/api/products",
method: "GET",
contentType: "application/json; charset=utf-8",
crossDomain: true,
beforeSend: function(xhr){
xhr.setRequestHeader('X-Spree-Token', 'a19d529a7ee5bc807a0b30b83adf998399f3c1804323f349');
xhr.setRequestHeader('Access-Control-Allow-origin', '*');
xhr.setRequestHeader('Access-Control-Allow-Methods', 'PUT, DELETE, GET');
}
// config/environment.js
// This is not for production. But it will get your
// console to stop screaming errors if your messing
// around with ember cli
module.exports = function(environment) {
//lots of stuff
// <Add this chunk>
@yurifrl
yurifrl / bad.js
Last active August 29, 2015 14:23
Javascript Examples
function getQueryParams(qs) {
qs = qs.split("+").join(" ");
var params = {},
tokens,
re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
}

Products

index of products 25 first

curl -i -H "X-Spree-Token: YOUR_TOKEN_ID" http://0.0.0.0:3000/api/products.json

Show a product

curl -i -H "X-Spree-Token: YOUR_TOKEN_ID" http://0.0.0.0:3000/api/products/706676762.json

Modify a product

curl -i -X PUT -H "X-Spree-Token: YOUR_TOKEN_ID" -d "product[name]=Headphones" http://0.0.0.0:3000/api/products/706676762.json

@yurifrl
yurifrl / about.md
Last active August 29, 2015 14:26 — forked from tiagoamaro/about.md
searchkick-apartment-example-codes