Skip to content

Instantly share code, notes, and snippets.

View revnode's full-sized avatar
🏙️

Marat A. Denenberg revnode

🏙️
View GitHub Profile
@revnode
revnode / PhantomJS to PDF
Created June 13, 2013 19:52
PhatomJS to PDF conversion script.
page = require('webpage').create()
system = require 'system'
if system.args.length < 3 or system.args.length > 4
console.log 'Usage: rasterize.coffee URL filename [paperwidth*paperheight|paperformat]'
console.log ' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"'
phantom.exit 1
else
address = system.args[1]
output = system.args[2]
@revnode
revnode / remote tar to local
Created June 5, 2013 19:04
Create a local compressed tarball from remote host directory
ssh user@host "tar -zcf - /path/to/dir" > dir.tar.gz
@revnode
revnode / push a string in a command's stdin
Created June 5, 2013 19:02
Using a bash "here strings" and "here documents" look leeter than piping echo into the command. Also prevents subshell execution. Word is also expanded as usual.
command <<< word
@revnode
revnode / tar.gz with gpg-encryption on the fly
Created June 5, 2013 17:46
Create a encrypted tar.gz file from a directory on the fly. The encryption is done by GPG with a public key. The resulting filename is tagged with the date of creation. Very usefull for encrypted snapshots of folders.
tar -cvz /<path>/ | gpg --encrypt --recipient <keyID> > /<backup-path>/backup_`date +%d_%m_%Y`.tar.gz.gpg
@revnode
revnode / calc
Created May 28, 2013 18:42
CSS Calc
/* basic calc */
.simpleBlock {
width: calc(100% - 100px);
}
/* calc in calc */
.complexBlock {
width: calc(100% - 50% / 3);
padding: 5px calc(3% - 2px);
margin-left: calc(10% + 10px);
@revnode
revnode / kwicks
Created May 28, 2013 18:36
Kwicks in CSS
<ul id="kwicks">
<li><a class="john" href="http://en.wikipedia.org/wiki/John_lennon" title="John Lennon">John Lennon</a></li>
<li><a class="paul" href="http://en.wikipedia.org/wiki/Paul_mccartney" title="Paul McCartney">Paul McCartney</a></li>
<li><a class="george" href="http://en.wikipedia.org/wiki/George_harrison" title="George Harrison">George Harrison</a></li>
<li><a class="ringo" href="http://en.wikipedia.org/wiki/Ringo_starr" title="Ringo Starr">Ringo Starr</a></li>
</ul>
<style>
/* structure */
#kwicks { width: 590px; overflow-x: hidden; }
@revnode
revnode / Links
Created May 28, 2013 18:33
Links
@revnode
revnode / Regular Expressions
Created May 26, 2013 18:23
I know you'll fall in love with this feature, no more js or a server side code to check if the user's input is a valid email or url adress, with the pattern attribute you can use regular expressions directly.
<input type="email" pattern="[^ @]*@[^ @]*" value="">
@revnode
revnode / Download Attribute
Created May 26, 2013 18:22
The HTML5 download attribute allows developers to force a file to download rather than go to that specific page, you no longer need to rely on server side code to do that.
<a href="download_pdf.php?id=15" download="myfile.pdf">Download PDF</a>
@revnode
revnode / Link Prerendering
Created May 26, 2013 18:21
Also you can use the prerendering feature which will make your website even faster, the browser will fetch and render the entire next page on the background and show it only when the user click on the link.