Skip to content

Instantly share code, notes, and snippets.

sudo apt-get install ser2net
sudo nano /etc/ser2net.conf
% change last lines to 2000:telnet:600:/dev/ttyAMA0:57600 8DATABITS NONE 1STOPBIT banner
sudo /etc/init.d/ser2net restart
sudo nano /etc/inittab % add hash to this line #T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
sudo nano /boot/cmdline.txt % delete references to ttyAMA0 % "console=ttyAMA0,115200 kgdboc=ttyAMA0,115200"
sudo shutdown -r now
DECLARE @name VARCHAR(50) -- database name
DECLARE @path VARCHAR(256) -- path for backup files
DECLARE @fileName VARCHAR(256) -- filename for backup
DECLARE @fileDate VARCHAR(20) -- used for file name
-- specify database backup directory
SET @path = 'F:\Backup\'
@tacettin
tacettin / routes.rb
Created January 3, 2014 14:40
Url Routing, custom action rails 4.0.2
RailsApp::Application.routes.draw do
devise_for :members
mount RailsAdmin::Engine => '/manage', :as => 'rails_admin'
match ':controller(/:action(/:id(.:format)))',via: :get
end
@tacettin
tacettin / Rails add user in rails console
Created December 30, 2013 13:57
Rails add user in rails console
This is quite a 'classic' problem and the immediate thought ("just do it mySQL") doesn't work here because of the need to have the rails piece that encodes a password that is entered.
So you need to actually use rails, something like this (this should all be happening in your local development environment which is the default when working locally):
You need to create a user.
Try this:
cd the_root_of_the_project
script/rails console
@tacettin
tacettin / gist:8133823
Created December 26, 2013 13:27
protected_attributes
It is because in rails-4, ActiveModel::MassAssignmentSecurity has been taken out of ActiveModel. But devise uses attr_accessible, hence to use that, just add the following gem in ur Gemfile and try to load once again.
gem 'protected_attributes'
EDIT:
Now devise is supporting for rails-4. Include this in your Gemfile.
gem 'devise', '3.0.0.rc'
@tacettin
tacettin / gist:8133819
Created December 26, 2013 13:26
First of all in has_many class name should be in plural: has_many :choices And you should add attr_accessible poll_id or choice_ids for Model from which you want to edit this association. Or just delete all attr_accessible for first try.
class Poll < ActiveRecord::Base
attr_accessible :published, :title, choice_ids
validates :published, :presence => true
validates :title, :presence => true, :length => { :minimum => 10 }
has_many :choices, :dependent => :destroy
end
@tacettin
tacettin / Rails
Created December 26, 2013 12:10
Rails namespace routes and custom action on resource
You need to add a collection
namespace :api do
namespace :v1 do
resources :users do
collection do
get 'all'
end
end
resources :sessions

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@tacettin
tacettin / gist:8121437
Last active January 1, 2016 08:58
Vendor of rails_admin
#Comment
=begin
FWIW, I'm on Rails 3.1/ruby 1.9.2 and want a clean production precompile (such that I could have config.assets.compile = false in production.rb so realtime compilation never happens).
I had to do the following things to make this work:
use the rake task in https://gist.github.com/1185448 instead of the builtin assets:precompile