$ rails g model User
belongs_to
has_one
| # Usage | |
| # | |
| # OptimizedPDFKit.new(html_tempfile).to_pdf(pdf_tempfile_path) | |
| # | |
| class OptimizedPDFKit < PDFKit | |
| def initialize(url_file_or_html, options = {}) | |
| @source = Source.new(url_file_or_html) | |
| @stylesheets = [] |
| // Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core? | |
| L.TileLayer.Common = L.TileLayer.extend({ | |
| initialize: function (options) { | |
| L.TileLayer.prototype.initialize.call(this, this.url, options); | |
| } | |
| }); | |
| (function () { | |
| # based on http://www.paulund.co.uk/smooth-scroll-to-internal-links-with-jquery | |
| $ -> | |
| $('a[href^="#"]').on 'click.smoothscroll', (e) -> | |
| e.preventDefault() | |
| target = @hash | |
| $target = $(target) |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| module AuthHelper | |
| def http_login | |
| user = 'username' | |
| pw = 'password' | |
| request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user,pw) | |
| end | |
| end | |
| module AuthRequestHelper | |
| # |
Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.
For the sake of this example, let’s pretend the subfolder containing your site is named dist.
Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).
| // <summary> | |
| // Logging methods. | |
| // </summary> | |
| Log = { | |
| Dump: function (object) | |
| { | |
| if (object) | |
| { | |
| console.debug(object); | |
| } |
This may not be relevant to many, but it's a process that I just had to go through and it was a bit tricky to figure a smooth way to make it work.
The gist of it is that you must do the following:
| # You have your csv data and it looks like so... It's in a file named "my_data.csv" and we want to import it into a table named "my_things". | |
| "1", "Something", "0.50", "2013-05-05 10:00:00" | |
| "2", "Another thing", "1.50", "2013-06-05 10:30:00" | |
| # Now you want to import it, go to the command line and type: | |
| $ PGPASSWORD=PWHERE psql -h HOSTHERE -U USERHERE DBNAMEHERE -c "\copy my_things FROM 'my_data.csv' WITH CSV;" | |
| # Voila! It's impoted. Now if you want to wipe it out and import a fresh one, you would do this: |