Skip to content

Instantly share code, notes, and snippets.

View coffeesam's full-sized avatar
:octocat:
GitHubbing..

Sam Hon coffeesam

:octocat:
GitHubbing..
View GitHub Profile
@azagniotov
azagniotov / beautiful.rest.api.docs.in.markdown.md
Last active November 1, 2024 13:12
Example to create beautiful REST API docs in Markdown, inspired by Swagger API docs.
@senderle
senderle / hand-modify-pdf.md
Created September 23, 2020 15:03
So you want to modify the text of a PDF by hand

So you want to modify the text of a PDF by hand...

If you, like me, resent every dollar spent on commercial PDF tools, you might want to know how to change the text content of a PDF without having to pay for Adobe Acrobat or another PDF tool. I didn't see an obvious open-source tool that lets you dig into PDF internals, but I did discover a few useful facts about how PDFs are structured that I think may prove useful to others (or myself) in the future. They are recorded here. They are surely not universally applicable --
the PDF standard is truly Byzantine -- but they worked for my case.

@choonkeat
choonkeat / html2sprockets.rake
Last active May 7, 2016 03:35
`html2sprockets:assets` is a quick way to add 3rd-party js/css to your rails app that is asset pipeline compatible; creates local gem in `vendor/gems` and apply them in your `Gemfile`
require 'fileutils'
namespace :html2sprockets do
desc "Setup env for gem creation"
task :env do
@gemname = ENV.fetch('NAME')
@gemdir = File.join(ENV.fetch('GEMDIR', 'vendor/gems'), @gemname)
@asset_dst_path = File.join(@gemdir, ENV.fetch('DST', 'vendor/assets'))
@asset_src_paths = ENV.fetch('SRC').each_line.collect(&:strip)
@coffeesam
coffeesam / bootstrap-progress-animation.scss
Last active October 2, 2019 21:09
Bootstrap progress animating stripes for all HTML elements
@-webkit-keyframes u-progress-stripes {
from { background-position: 0 0 }
to { background-position: 40px 0 }
}
@-moz-keyframes u-progress-stripes {
from { background-position: 0 0 }
to { background-position: 40px 0 }
}
@keyframes u-progress-stripes {
from { background-position: 0 0 }
@johnhany97
johnhany97 / gist:2e667d3a54b45b178aad
Created April 23, 2015 00:31
Batch Replace specific text in PDF automatically using pdftk
Create a file with this:
#!/bin/bash
oldtext=$1
newtext=$2
pdffile=$3
cp $pdffile $pdffile.bak
pdftk $pdffile output $pdffile.tmp uncompress
@michaellouieloria
michaellouieloria / gist:0ff4376475b68e1e78c2
Created September 18, 2014 08:04
PDFtk commands to create fdf and fill form
create fdf
pdftk form.pdf generate_fdf output data.fdf
fill form
pdftk form.pdf fill_form data.fdf output form_with_data.pdf
@aarongustafson
aarongustafson / backup-to-s3.sh
Created January 22, 2014 19:36
backup to S3 as a shell command (uses s3cmd)
#!/bin/bash
##
# Backup Server to S3 script
#
# Creates a local cached backup of the source folder using rsync and then
# synchronises that with Amazon S3.
#
#
# It is assumed you have rsync installed on the server.
@eddiemoore
eddiemoore / nric-validation.js
Last active October 17, 2022 05:39
Validation for Singapore NRIC and FIN number
//Based on http://www.samliew.com/icval/
function validateNRIC(str) {
if (str.length != 9)
return false;
str = str.toUpperCase();
var i,
icArray = [];
for(i = 0; i < 9; i++) {
@wsargent
wsargent / docker_cheat.md
Last active June 29, 2024 19:32
Docker cheat sheet
@plentz
plentz / nginx.conf
Last active November 1, 2024 06:31
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048