Skip to content

Instantly share code, notes, and snippets.

@michaellouieloria
michaellouieloria / gist:c8536cb3171c0396152f
Created February 26, 2015 06:22
Sort merged activerecord objects in Rails
@posts = @posts1 + @posts2
#Descending
@posts.sort! {|x,y| y.created_at <=> x.created_at}
#Ascending
@posts.sort! {|x,y| x.created_at <=> y.created_at}
@michaellouieloria
michaellouieloria / gist:dcbda251208d98779338
Last active August 29, 2015 14:15
Git - overwrite local changes from remote
git fetch origin
git checkout develop
git reset --hard origin/develop
@michaellouieloria
michaellouieloria / gist:c6cef2faa298a2c77a3b
Created February 11, 2015 11:03
disable column sorting in datatables 1.10.x
.no-sort::after { display: none!important; }
.no-sort { pointer-events: none!important; cursor: default!important; }
<th class="no-sort">Heading</th>
1. Package the pre-configured box => vagrant package --base preconfigured_vm --output /path/to/mybox.box. Note that as per the docs, the --base option should be the UUID of the machine, or the name VirtualBox gives the machine (found when opening the VirtualBox application).
2. transfer the box to the computer by using scp, rsync or whatever... (you also start a web server quickly by using python -m http.server PORT or ruby -run -e httpd /path/to -p PORT)
3. Init and start vagrant init preconfigured_vm /path/to/mybox.box
@michaellouieloria
michaellouieloria / gist:3eac581b1651a97eddf0
Last active August 29, 2015 14:13
Migrate column from character varying to integer in Rails
change_column :table, :column, 'integer USING CAST(column AS integer)'
@michaellouieloria
michaellouieloria / gist:632488528abd38e2abe5
Created January 16, 2015 09:20
Rails migration when mongoid is installed
rails g active_record:migration
@michaellouieloria
michaellouieloria / gist:9d7f497be642fbae1db3
Created January 13, 2015 06:24
Prevent windows in changing file permissions/mode of remote samba files
[global]
map archive = no
http://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#MAPARCHIVE
/** @jsx React.DOM */
var LopMonHoc = React.createClass({
getInitialState: function(){
return {data: []}
},
loadData: function(){
$.ajax({
url: '/daotao/lops',
success: function(data){
sudo apt-get install libmysqlclient-dev
sudo apt-get install libsphinxclient-dev
Get the tar
Configure the source code: ./configure –prefix=/usr/local
Run: make
Run: sudo make install
sudo pear install pecl/sphinx
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')