Skip to content

Instantly share code, notes, and snippets.

@SanderTheDragon
SanderTheDragon / postman-deb.sh
Last active April 3, 2024 05:30
A shellscript to create a Postman .deb file, for simple installation on Debian-based Linux distro's. Also creates a .desktop file.
#!/bin/sh
# SPDX-FileCopyrightText: 2017-2022 SanderTheDragon <sanderthedragon@zoho.com>
#
# SPDX-License-Identifier: MIT
curlExists=$(command -v curl)
echo "Testing Postman version"
@krasnoukhov
krasnoukhov / 2013-01-07-profiling-memory-leaky-sidekiq-applications-with-ruby-2.1.md
Last active October 4, 2023 21:53
Profiling memory leaky Sidekiq applications with Ruby 2.1

My largest Sidekiq application had a memory leak and I was able to find and fix it in just few hours spent on analyzing Ruby's heap. In this post I'll show my profiling setup.

As you might know Ruby 2.1 introduced a few great changes to ObjectSpace, so now it's much easier to find a line of code that is allocating too many objects. Here is great post explaining how it's working.

I was too lazy to set up some seeding and run it locally, so I checked that test suite passes when profiling is enabled and pushed debugging to production. Production environment also suited me better since my jobs data can't be fully random generated.

So, in order to profile your worker, add this to your Sidekiq configuration:

if ENV["PROFILE"]
@dhoelzgen
dhoelzgen / base_controller.rb
Last active October 7, 2021 16:19
CORS in Rails 4 APIs
class API::V1::BaseController < ApplicationController
skip_before_filter :verify_authenticity_token
before_filter :cors_preflight_check
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET, PUT, DELETE, OPTIONS'
@bumi
bumi / post-merge
Created June 4, 2013 14:55
post-merge hook to automatically run bundle install and rake db:migrate if needed
#!/bin/sh
# INSTALL
#
# make sure you have installed lolcat and cowsay
# brew install cowsay
# gem install lolcat
#
# filename: post-merge
#
@jhilden
jhilden / tabs.js.coffee
Created August 28, 2012 10:33
Remove jquery-ui styling for tabs
$ ->
jquery_ui_classes = [".ui-tabs", ".ui-tabs-nav", ".ui-tabs-panel", ".ui-widget", ".ui-widget-header", ".ui-widget-content", ".ui-corner-all", ".ui-corner-top", ".ui-corner-bottom", ".ui-helper-clearfix", ".ui-helper-reset", ".ui-state-default"]
$(".js-tabs").tabs().each ->
# removes all the jquery-ui specific classes (except ones like ui-state-active)
$elements = $(this).find( jquery_ui_classes.join(", ") ).andSelf()
$elements.removeClass( jquery_ui_classes.join(" ").replace(/\./g, "") )
@ChristianPeters
ChristianPeters / config-application.rb
Created April 16, 2012 12:29
Adapted for Rails Asset Pipeline: Split CSS files so that there are no more than a given number of selectors in one style sheet. This is a tool to cope with Internet Explorer's limitation of max. 4095 selectors per stylesheet.
#...
module MyProject
class Application < Rails::Application
config.assets.precompile += %w( ie6.css ie6_portion2.css ie7.css ie7_portion2.css ie8.css ie8_portion2.css ie9.css ie9_portion2.css)
#...
@medialwerk
medialwerk / css_splitter.rake
Created March 8, 2012 11:09 — forked from ChristianPeters/css_splitter.rake
Split CSS files so that there are no more than a given number of selectors in one style sheet. This is a tool to cope with Internet Explorer's limitation of max. 4095 selectors per stylesheet. Fix bug when there is no charset. Always write first partial o
require 'rake'
require Compass::AppIntegration::Rails.root.to_s + '/lib/compass/css_splitter'
namespace :css do
desc 'split css files'
task :split do
infile = ENV['infile'] || raise("missing infile")
outdir = ENV['outdir'] || File.dirname(infile)
max_selectors = ENV['max_selectors'] || 4095
@bumi
bumi / psych_yml_tester.rb
Created June 7, 2011 09:53 — forked from jhilden/yamltester.rb
YAML tester
# USAGE:
# ruby -e "$(curl -fsSL https://raw.github.com/gist/1011972/2e6ac978bc06905f60e380b5fe5abbf898b3af0a)" <directory>
# for example:
# ruby -e "$(curl -fsSL https://raw.github.com/gist/1011972/2e6ac978bc06905f60e380b5fe5abbf898b3af0a)" .
require 'rubygems'
require 'yaml'
YAML::ENGINE.yamler = 'psych'
directory = ARGV[0]
@abarringer
abarringer / rvm_install.sh
Created June 4, 2011 14:32
RVM Ubuntu Install
#!/bin/bash
#Based on http://railsapps.github.com/installing-rails-3-1.html
cd ~
sudo apt-get -y install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev curl git-core
bash < <(curl -sk https://rvm.beginrescueend.com/install/rvm)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
@mirisuzanne
mirisuzanne / input-placeholder.sass
Created April 16, 2011 22:56
styling placeholder text
// Mixins ---------------------------------------------------------------
=placeholder-style
color: #777
// add your defaults here.
// if you need more than one style-group you can either create several mixins,
// or just name the style-groups and take a single style-group-name argument.
=apply-placeholders
&::-webkit-input-placeholder