Skip to content

Instantly share code, notes, and snippets.

View rsmithlal's full-sized avatar

Robert Smith rsmithlal

View GitHub Profile
@lobermann
lobermann / sh
Created June 25, 2019 20:16
Install wkhtmltopdf on headless ubuntu 18 vps
wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
apt-get install fontconfig libxrender1 xfonts-75dpi xfonts-base
dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
@Tomassito
Tomassito / download-file.js
Last active March 11, 2022 23:53 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
link.click();
@demisx
demisx / active_record_objects_autosave.md
Last active February 26, 2024 17:31
When Active Record Child Objects are Autosaved in Rails

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.
@philfreo
philfreo / file_upload.js
Last active September 18, 2017 15:45
Backbone-Forms File Upload Editor
// directly uploads to S3
// See http://philfreo.com/blog/how-to-allow-direct-file-uploads-from-javascript-to-amazon-s3-signed-by-python/
// See https://github.com/elasticsales/s3upload-coffee-javascript
editors.Filepicker = editors.Text.extend({
tagName: 'div',
events: {
'change input[type=file]': 'uploadFile',
@jimmynotjim
jimmynotjim / gist:3724006
Created September 14, 2012 19:04
Use Modernizr and jQuery to show a loading gif while an iframe loads
@benatkin
benatkin / Global.sublime-settings
Created July 20, 2011 04:26
excluding node_modules from Sublime Text 2
// Place user-specific overrides in this file, to ensure they're preserved
// when upgrading
{
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "node_modules"]
}