$ ActiveRecord::Base.connection.reset_pk_sequence!('table_name')
If you need the table names:
$ ActiveRecord::Base.connection.tables
=> ["accounts", "assets", ...]
$ ActiveRecord::Base.connection.reset_pk_sequence!('table_name')
If you need the table names:
$ ActiveRecord::Base.connection.tables
=> ["accounts", "assets", ...]
| Here is a list of scopes to use in Sublime Text 2 snippets - | |
| ActionScript: source.actionscript.2 | |
| AppleScript: source.applescript | |
| ASP: source.asp | |
| Batch FIle: source.dosbatch | |
| C#: source.cs | |
| C++: source.c++ | |
| Clojure: source.clojure | |
| CoffeeScript: source.coffee |
Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.
Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.
First you will need to get an OAuth Token from GitHub using your own username and "note"
| # A class-based template for jQuery plugins in Coffeescript | |
| # | |
| # $('.target').myPlugin({ paramA: 'not-foo' }); | |
| # $('.target').myPlugin('myMethod', 'Hello, world'); | |
| # | |
| # Check out Alan Hogan's original jQuery plugin template: | |
| # https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template | |
| # | |
| (($, window) -> |
I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.
If you want to roll up all of these into a single jQuery plugin check out Sharrre
Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.
| #encoding: UTF-8 | |
| require 'rubygems' | |
| require 'sinatra' | |
| require 'erb' | |
| require 'pp' | |
| class Sinatra::Request | |
| def pjax? | |
| env['HTTP_X_PJAX'] || self['_pjax'] |
| sphinx: bundle exec rake thinking_sphinx:run_in_foreground RAILS_ENV=development --trace |
sudo aptitude install apache2 apache2-prefork-dev autoconf bison build-essential \ clang curl dnsutils git-core imagemagick libc6-dev libcurl4-openssl-dev libffi-dev \ libmagickwand-dev libmysqlclient16 libmysqlclient16-dev libreadline6-dev libsqlite3-0 \ libsqlite3-dev libssl-dev libxml2 libxml2-dev libxslt-dev libxslt1.1 libxslt1-dev \ libyaml-dev mysql-client mysql-server openssl sqlite3 wget zlib1g zlib1g-dev
Problem: I learned how to run RSpec to test classes and modules in my gem. But, if I wanted to test my gem as if it were already included in a Rails app, I couldn't find much info about it online.
I usually do unit tests with RSpec, and I test the whole stack with Cucumber. So here we will just setup Cucumber to run the Rails app that you embed in your gem.
Before we begin:
MyGem and my_gem below refer to the name of the gem we are creating. Replace this with your own name.