Skip to content

Instantly share code, notes, and snippets.

View conf's full-sized avatar

Aleksey Shein conf

View GitHub Profile
@shiroyasha
shiroyasha / dog.rb
Created February 16, 2016 22:20
Method tracer for Ruby classes
class Dog
attr_writer :name
def initialize(name)
@name = name
end
def bark
puts "patrick"
end
@jaytaylor
jaytaylor / .psqlrc
Created January 6, 2015 17:37
My .psqlrc file.
-- Found at:
-- http://www.if-not-true-then-false.com/2009/postgresql-psql-psqlrc-tips-and-tricks/
-- http://opensourcedbms.com/dbms/psqlrc-psql-startup-file-for-postgres/
\set QUIET ON
\pset pager always
\pset null 'NULL'
@larrycai
larrycai / README.markdown
Last active September 16, 2022 03:59
check the plugin usage in jenkins
@christopheranderton
christopheranderton / homebrew-github-api-token.md
Last active January 2, 2024 13:07
Set your Github API Token If you hit a ”GitHub API rate limit exceeded” when searching with Homebrew (http://brew.sh/).

Description

PLEASE SCROLL DOWN AND READ THE COMMENTS FOR A MORE UP TO DATE WAY (AND EASIER) TO DO THIS
When using Homebrew (http://brew.sh) and searching formulas or pull requests you may get the dreaded error message: Github API Rate limit exceeded

Let's fix that! (yeah!)


Short version

PLEASE SCROLL DOWN AND READ THE COMMENTS FOR A MORE UP TO DATE WAY (AND EASIER) TO DO THIS

@dergachev
dergachev / squid-deb-proxy_on_docker.md
Last active May 25, 2023 03:55
Caching debian package installation with docker

TLDR: I now add the following snippet to all my Dockerfiles:

# If host is running squid-deb-proxy on port 8000, populate /etc/apt/apt.conf.d/30proxy
# By default, squid-deb-proxy 403s unknown sources, so apt shouldn't proxy ppa.launchpad.net
RUN route -n | awk '/^0.0.0.0/ {print $2}' > /tmp/host_ip.txt
RUN echo "HEAD /" | nc `cat /tmp/host_ip.txt` 8000 | grep squid-deb-proxy \
  && (echo "Acquire::http::Proxy \"http://$(cat /tmp/host_ip.txt):8000\";" > /etc/apt/apt.conf.d/30proxy) \
  && (echo "Acquire::http::Proxy::ppa.launchpad.net DIRECT;" >> /etc/apt/apt.conf.d/30proxy) \
  || echo "No squid-deb-proxy detected on docker host"

Constant lookup in Ruby can happen lexically or through the ancestry tree of the receiver(a class or module). You can identify which lookup rules are being applied by the context you're in or by the syntax being used to define a class or module.

A class body that is defined as class A::B::C; …; end will lookup constants through the ancestry tree when a constant is evaluated in its class body. Anytime you see A::B::C being used as syntax to define a class or lookup the value of a constant the ancestry tree is being used for the lookup.

@esycat
esycat / PrettyPrinter.groovy
Last active December 19, 2023 16:20
A simple way to pretty print nested lists and maps in Groovy.
import static groovy.json.JsonOutput.*
def config = ['test': 'lalala']
println prettyPrint(toJson(config))
@SabretWoW
SabretWoW / rspec_model_testing_template.rb
Last active March 7, 2024 03:56
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@leemour
leemour / FontFix RubyMine
Last active October 6, 2018 06:42
Fixing font anti-aliasing for Ubuntu.
# Change Java Runtime:
sudo update-alternatives --config java
# Delete Open-JDK
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
# Change fonts - remove hinting:
http://askubuntu.com/questions/32624/ugly-fonts-in-netbeans-how-can-i-make-it-use-the-system-font
# Change RubyMine AntiAliasing first:
@nicolas-raoul
nicolas-raoul / dump2pdf.sh
Last active December 2, 2019 10:10 — forked from rogerleite/tdg.rb
#!/bin/sh
# Usage example: ./dump2pdf log_file output_file.pdf
ruby tdg.rb $1 > /tmp/graph.dot
dot -Tpdf /tmp/output_file.dot -o $2