Skip to content

Instantly share code, notes, and snippets.

@becomingGuru
becomingGuru / compress-pdf-with-gs.md
Created Jul 31, 2017 — forked from firstdoit/compress-pdf-with-gs.md
Compress PDF files with ghostscript
View compress-pdf-with-gs.md

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
View gist:9423841e11d2b676c7ff

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

View frontendDevlopmentBookmarks.md
@becomingGuru
becomingGuru / sl2-setup.md
Created Nov 17, 2012 — forked from javan/sl2-setup.md
My Sublime Text 2 setup
View sl2-setup.md
@becomingGuru
becomingGuru / redis_session_backend.py
Created Dec 5, 2011 — forked from mikeyk/redis_session_backend.py
A redis backend for Django Sessions, tested on Django 1.3+
View redis_session_backend.py
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
@becomingGuru
becomingGuru / bootstrap.sh
Created Jun 2, 2011 — forked from anonymous/bootstrap.sh
Django on Heroku with Celery and Sentry
View bootstrap.sh
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
View gist:960830
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <conio.h>
#define IN "A-large-practice.in"
#define OUT "A-large-practice.out"
using namespace std;
View wikipedia_abstract_from_dbpedia.py
from xml.etree import ElementTree as ET
import urllib
dbpedia_endpoint = "http://dbpedia.org/sparql?"
ns = {'ns': '{http://www.w3.org/2005/sparql-results#}'}
result_xpath ='%(ns)sresults/%(ns)sresult/%(ns)sbinding/%(ns)sliteral' % ns
def wikipedia_abstract_from_dbpedia(dbpedia_key):
sparql = """
SELECT ?abstract
View gist:281029
======================================================
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10
======================================================
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu
8.10. The article is targeted at a production environment, but keep in mind
this is a more generalized environment. You may have different requirements,
but this article should at least provide the stepping stones.
The article will use distribution packages where nesscary. As of 8.10 the