Skip to content

Instantly share code, notes, and snippets.

View guinslym's full-sized avatar

Guinslym guinslym

View GitHub Profile
@guinslym
guinslym / 2014_01_09_082357_create_users_table.php
Created January 9, 2014 08:40
I,m gettingthis following error while running "php artisan migrate"
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration {
/**
* Run the migrations.
*
@guinslym
guinslym / ImagesController.php
Created January 11, 2014 08:14
How can I add 2 Order conditions to retrieve datas
<?php
public function listImage(){
$listImages = $this->Image->find('all',
array(
'order' => array(
'Image.id' => 'desc'),
'limit' => 18));
return $listImages;
@guinslym
guinslym / gist:8369190
Last active January 2, 2016 22:19
Hi I'm trying to install [pyradio][1] to be able to play internet radio inside my terminal. I'm having these errors. I d'like to know how can I fix this. I followed this tutorial :: https://github.com/coderholic/pyradio/tree/master
guinslym@ubuntu:~/Music/radio_online/pyradio$ pip install pyradio
Downloading/unpacking pyradio
Downloading pyradio-0.5.2.tar.gz
Running setup.py egg_info for package pyradio
warning: no previously-included files found matching '*.pyc'
warning: no previously-included files found matching '*.orig'
Installing collected packages: pyradio
Running setup.py install for pyradio
deleting pyradio.egg-info/requires.txt
@guinslym
guinslym / ImagesController.php
Last active January 3, 2016 00:09
When I'm editing a picture (ImageController) I'm get the picture added in my database. So I'm having two pictures so the one that was already on the db and the new one. I'm using the https://github.com/josegonzalez/cakephp-upload plugin.
<?php
/**
* edit method
*
* @throws NotFoundException
* @param string $id
* @return void
*/
public function edit($id = null) {
@guinslym
guinslym / profile.rb
Last active January 3, 2016 00:28
Rails 3.2.16 I'm having this following error. Can't mass-assign protected attributes
class Profile < ActiveRecord::Base
attr_accessible :birthday, :name, :user_id
#association
belongs_to :user
end
@guinslym
guinslym / gist:8412161
Created January 14, 2014 02:44
I'm having a type mistmatch errors. It's a HABM relationship. Artcle<->Category. I don't understand this:
1.9.3-p484 :034 > article = Article.last
1.9.3-p484 :029 > category = Category.find_by_name('Pogramming')
Category Load (0.4ms) SELECT "categories".* FROM "categories" WHERE "categories"."name" = 'Pogramming' LIMIT 1
=> nil
1.9.3-p484 :030 > article.categories << category
(0.1ms) begin transaction
(0.1ms) rollback transaction
ActiveRecord::AssociationTypeMismatch: Category(#28243960) expected, got NilClass(#4618340)
from /home/guinslym/.rvm/gems/ruby-1.9.3-p484@rails3tutorial2ndEd/gems/activerecord-3.2.16/lib/active_record/associations/association.rb:210:in `raise_on_type_mismatch'
from /home/guinslym/.rvm/gems/ruby-1.9.3-p484@rails3tutorial2ndEd/gems/activerecord-3.2.16/lib/active_record/associations/collection_association.rb:494:in `block in concat_records'
@guinslym
guinslym / gist:8412162
Last active January 3, 2016 04:58
I'm having a type mistmatch errors. It's a HABM relationship. Artcle<->Category. I don't understand this:
1.9.3-p484 :034 > article = Article.last
Article Load (0.2ms) SELECT "articles".* FROM "articles" ORDER BY "articles"."id" DESC LIMIT 1
=> #<Article id: 3, title: "Introduction to Active Record", body: "Active Record is Rails", published_at: "2014-01-12 05:00:00", created_at: "2014-01-12 08:39:41", updated_at: "2014-01-12 08:39:41", excerpt: nil, location: nil, user_id: nil>
1.9.3-p484 :035 >
1.9.3-p484 :029 > category = Category.find_by_name('Pogramming')
Category Load (0.4ms) SELECT "categories".* FROM "categories" WHERE "categories"."name" = 'Pogramming' LIMIT 1
=> nil
1.9.3-p484 :030 > article.categories << category
(0.1ms) begin transaction
@guinslym
guinslym / gist:8443066
Created January 15, 2014 19:44
hack safe:: from Olivier!
__ __ ____ __ __ _ _____ ____ _____ ___ __
| | | / | / ]| |/ ] / ___/ / || |/ _]| |
| | || o | / / | ' / ( \_ | o || __/ [_ | |
| _ || |/ / | \ \__ || || |_| _]|__|
| | || _ / \_ | \ / \ || _ || _] [_ __
| | || | \ || . | \ || | || | | || |
|__|__||__|__|\____||__|\_| \___||__|__||__| |_____||__|
@guinslym
guinslym / gist:8449162
Created January 16, 2014 03:03
Hi! (1..9).to_a gives me an array. and [*1..9] gives me also an array but I don't understand the * character cause it's not a function where can I find the doc for * (does it have a special name cause I don't find the info in the doc)
Hi! (1..9).to_a gives me an array. and [*1..9] gives me also an array but I don't understand the * character cause it's not a function where can I find the doc for * (does it have a special name cause I don't find the info in the doc)
@guinslym
guinslym / 20130923163537_create_categories.rb
Created January 17, 2014 05:17
In a migration I have this following: " t.integer :post_count" where can I found in the doc all the attribute that I can give to 'post_*' so that Rails will make the proper sql statement. I mean can I have a t.integer :post_avg ?
class CreateCategories < ActiveRecord::Migration
def change
create_table :categories do |t|
t.string :name, null: false
t.string :slug, null: false
t.integer :post_count, default: 0
t.timestamps
end
end