Skip to content

Instantly share code, notes, and snippets.

View tomeduarte's full-sized avatar

Tomé Duarte tomeduarte

View GitHub Profile
@timurcatakli
timurcatakli / webpack.config.js
Last active May 1, 2023 18:25
An Easy to Understand Webpack 4+ Configuration File with Comments
const publicPath = 'public';
// Node os module
// The os module provides a number of operating system-related utility methods.
// It can be accessed using:
const os = require('os');
// Using a single monolithic configuration file impacts comprehension and
// removes any potential for reusability.
// As the needs of your project grow, you have to figure out the means to manage
// webpack configuration more effectively.
@atcuno
atcuno / gist:3425484ac5cce5298932
Last active March 25, 2024 13:55
HowTo: Privacy & Security Conscious Browsing

The purpose of this document is to make recommendations on how to browse in a privacy and security conscious manner. This information is compiled from a number of sources, which are referenced throughout the document, as well as my own experiences with the described technologies.

I welcome contributions and comments on the information contained. Please see the How to Contribute section for information on contributing your own knowledge.

Table of Contents

@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active February 12, 2024 17:18
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@bf4
bf4 / Gemfile
Created July 2, 2013 18:36
Rails lograge and logstash request logging
gem 'lograge' # more readable logs
gem 'logstash-event' # for logstash json format
gem 'mono_logger' # threadsafe logging
@turadg
turadg / subdomains.rb
Last active January 21, 2024 19:45 — forked from rtekie/subdomains.rb
Drop-in utility to test your app subdomains with Capybara, Rspec, and a Javascript driver (Poltergeist, Webkit, or Selenium)
# Support for Rspec / Capybara subdomain integration testing
# Make sure this file is required by spec_helper.rb
# (e.g. save as spec/support/subdomains.rb)
def switch_to_subdomain(subdomain)
# lvh.me always resolves to 127.0.0.1
hostname = subdomain ? "#{subdomain}.lvh.me" : "lvh.me"
Capybara.app_host = "http://#{hostname}"
end
@waseem
waseem / start.md
Last active December 14, 2015 09:50
How one should start learning Ruby and Rails.

If you're just starting with Rails, I will suggest you to learn Ruby first. If you know how its object model, inheritance and mixins work, you're good to start creating web application with it. This is very important. A lot of people dive into Rails without learning basic Ruby first (that's how I did) and get frustrated because they don't understand how it works. I will highly recommend The Well Grounded Rubyist by David Black to start learning Ruby. You can also get a good introduction of Ruby by working your way through interactive tutorials on Codeacademy. You don't need to understand metaprogramming in the beginning. But if you decide to do so, I will suggest book Metaprogramming Ruby by Paolo Perrotta. It's best in covering the subject matter. It's a little bit old though but still good nonetheless. Also see third point in [comment](https://gist.github.com/waseem/5068050/#

@mudge
mudge / unicorn.conf.rb
Last active February 9, 2017 21:55
Unicorn configuration for Rails 3.2 application to log to a different file per worker (to stop logs interleaving with one another).
after_fork do |server, worker|
# Override the default logger to use a separate log for each Unicorn worker.
# https://github.com/rails/rails/blob/3-2-stable/railties/lib/rails/application/bootstrap.rb#L23-L49
Rails.logger = ActiveRecord::Base.logger = ActionController::Base.logger = begin
path = Rails.configuration.paths["log"].first
f = File.open(path.sub(".log", "-#{worker.nr}.log"), "a")
f.binmode
f.sync = true
logger = ActiveSupport::TaggedLogging.new(ActiveSupport::BufferedLogger.new(f))
@mudge
mudge / logstash.conf
Last active April 17, 2019 07:58
A grok pattern for Rails 3.2 logs for use with logstash. Assumes that you have a multiline filter to combine Rails logs into one line and only one worker is logging to a file (c.f. https://gist.github.com/mudge/5063930).
multiline {
tags => ["rails"]
pattern => "^Started"
negate => true
what => "previous"
}
@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: