Skip to content

Instantly share code, notes, and snippets.

@ka8725
ka8725 / model.py
Last active January 2, 2016 10:49
Oop model comparison Ruby and Python
from abc import ABCMeta
from random import randint
class SortableGoods(object):
__metaclass__ = ABCMeta
_GOODS_CLASSES_PRIORITY = {
'Person': 0,
'Container': 1,
def method1
end
def method2(default: 1)
end
method(:method1).arity # => 0
method(:method2).arity # => 0
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin
@vibegui
vibegui / compress-pdf-with-gs.md
Created August 30, 2013 14:39
Compress PDF files with ghostscript

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.
@aras-p
aras-p / preprocessor_fun.h
Last active March 20, 2026 15:26
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@bismark64
bismark64 / gist:5911034
Last active December 19, 2015 06:19
Two Ruby powerful iterators I really love

Two (or three) powerful iterators

If you have some experience working with Ruby you probably had to deal with collections. Collections can be tedious. But TTR (Thanks To Ruby) we have a large arsenal to deal with them!

In this post I'll show you two Ruby iterator methods I really love, thanks to its simplicity and beauty.

My whimsical example

@olivierlacan
olivierlacan / gary_bernhardt_screencasting_parley.md
Created June 1, 2013 03:04
Gary Bernhardt on Screencasting

I'm planning on either writing this up in detail or maybe doing a screencast about screencasting, but I'll give a short version here.

On sound quality:

This matters a lot. In decreasing order of importance:

  1. Remove echo. You have to hear this to understand. Set up a mic in front of your mouth and record a sentence. Then, put a thick comforter over you and the mic and say it again at the same distance. Listen to
@sethetter
sethetter / max_subarray.rb
Last active April 1, 2016 12:44
Maximum Subarray
#!/usr/bin/env ruby
# Maximum Subarray
# Using any language or technique, write a program that meets the following criteria:
# Given an array containing positive and negative integers, return the maximum sum that
# can be generated from any contiguous set.
# For example in the following array:
@briarsweetbriar
briarsweetbriar / README.md
Last active December 16, 2015 22:28 — forked from linjunpop/README.md
@andreypronin
andreypronin / setup_hstore.rb
Last active August 22, 2016 02:09
Migration to enable hstore for PostgreSQL with Rails 4. See also http://platformonrails.wordpress.com/2013/03/17/using-postgres…e-with-rails-4/
class SetupHstore < ActiveRecord::Migration
def self.up
enable_extension "hstore"
end
def self.down
disable_extension "hstore"
end
end