You need Node, obviously, and JSDom. Then use it like this:
$ ./pathformer.js test.svg > test.out.svg
# This probably isn't a good thing to want to do, but it came up for me, | |
# so in the spirit of helping others with weird problems (and because this | |
# seems to be documented almost nowhere): | |
after_save do | |
if some_failing_condition | |
errors.add(:something, "some failure happened.") | |
raise ActiveRecord::RecordInvalid.new(self) | |
end |
You need Node, obviously, and JSDom. Then use it like this:
$ ./pathformer.js test.svg > test.out.svg
<?php | |
/* Caveat: I'm not a PHP programmer, so this may or may | |
* not be the most idiomatic code... | |
* | |
* FPDF is a free PHP library for creating PDFs: | |
* http://www.fpdf.org/ | |
*/ | |
require("fpdf.php"); | |
class PDF extends FPDF { |
-- adapted from <http://johnmacfarlane.net/pandoc/scripting.html> | |
import Text.Pandoc | |
import Text.Pandoc.Shared (stringify) | |
extractURL :: Inline -> [String] | |
extractURL (Link txt (u,_)) = [stringify txt ++ " : <" ++ u ++ ">"] | |
extractURL (Image _ (u,_)) = [u] | |
extractURL _ = [] | |
extractURLs :: Pandoc -> [String] |
# Assumptions: | |
# 1. $("#pdf-download") is something you can click on (not really required). | |
# 2. $(".result-page") is something in your existing page that you want to turn into a PDF. | |
# 3. You want to add a class of `pdf-rendered` to it and then specify some CSS which applies when that class is added. | |
# 4. Your CSS for `.pdf-rendered` specifies a useful width for a PDF (795px is pretty good) and anything else you like | |
# (this is for portrait ("p") PDFs; obviously you'll need to make a few modifications for landscape PDFs!). | |
# How it works: | |
# 1. Take the requested element in your existing page, clone it, add a "pdf-rendered" class to it, and append to | |
# the body. |
$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome -disable-prompt-on-repost & |
I hereby claim:
To claim this, I am signing this object:
# This might not be the best way, it might be improved in more | |
# recent versions of Rails Admin, but this seems to work okay | |
# for me. | |
class SomeModel < ActiveRecord::Base | |
enum :some_enum => { | |
:some_key => 0 | |
} |
// Sometimes you care about the order in which RequireJS-loaded modules | |
// are retrieved, and wish to execute a callback for each module in the | |
// order in which you originally specified them, rather than the order | |
// in which they are loaded. You can do this with a queue. | |
var Queue = function() { | |
var q, | |
callCount = 0; | |
class Foo < ActiveRecord::Base | |
scope :random_n, -> (n) { limit(n).order("RANDOM()") } | |
end | |
Foo.random_n(5) # -> five randomly chosen Foos | |
# For extra points, put this sort of thing into a Concern. |