Skip to content

Instantly share code, notes, and snippets.

View glebm's full-sized avatar

Gleb Mazovetskiy glebm

View GitHub Profile
#!/usr/bin/env ruby
require 'base64'
require 'open-uri'
# file or url
def get_css(src)
if src.start_with? 'http'
src = src.gsub('|', '%7C')
STDERR.puts "# GET #{src}"
# simulate modern browser to get woff
grep -n5 bootstrap-sass Gemfile.lock
13- specs:
14- jquery-datatables-rails (1.11.2)
15- jquery-rails
16-
17-GIT
18: remote: git://github.com/thomas-mcdonald/bootstrap-sass.git
19- revision: 571ba865e1cd01f583c5949446803b9f2cd21926
20- branch: 3
21- specs:
@glebm
glebm / ransacks_with_scopes_initializer.rb
Last active December 20, 2015 06:19
Ransack with scopes monkey patch. (this is a fork of: https://gist.github.com/ledermann/4135215)
# Patch for ransack (https://github.com/ernie/ransack) to use scopes
# Helps migrating from Searchlogic or MetaSearch
# Place this file into config/initializer/ransack.rb of your Rails 3.2 project
#
# Usage:
# class Debt < ActiveRecord::Base
# scope :overdue, lambda { where(["status = 'open' AND due_date < ?", Date.today]) }
# end
#
# Ransack out of the box ignores scopes. Example:
@glebm
glebm / trace
Created July 8, 2013 15:15
unbalanced pop from blame stack newrelic error crashes request puma (2.2.0) rails 4
[GEM_ROOT]/bundler/gems/rpm-a063acda8e06/lib/new_relic/agent/stats_engine/transactions.rb:61
[GEM_ROOT]/bundler/gems/rpm-a063acda8e06/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb:104
[GEM_ROOT]/bundler/gems/rpm-a063acda8e06/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb:51
[GEM_ROOT]/gems/activesupport-4.0.0/lib/active_support/notifications/fanout.rb:96
[GEM_ROOT]/gems/activesupport-4.0.0/lib/active_support/notifications/fanout.rb:40
[GEM_ROOT]/gems/activesupport-4.0.0/lib/active_support/notifications/fanout.rb:40
[GEM_ROOT]/gems/activesupport-4.0.0/lib/active_support/notifications/fanout.rb:40
[GEM_ROOT]/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:36
[GEM_ROOT]/gems/activesupport-4.0.0/lib/active_support/notifications/instrumenter.rb:25
[GEM_ROOT]/gems/activesupport-4.0.0/lib/active_support/notifications.rb:159
@glebm
glebm / async_emails_i18n.rb
Last active August 8, 2017 09:42
Inject locale into Resque::Mailer and Devise::Async
require 'resque_mailer'
require 'devise/async'
# pop and set locale from the args before running
module PerformWithLocale
def perform(*args)
I18n.with_locale(args.pop) do
super(*args)
end
end
@glebm
glebm / photbox.js.diff
Created June 5, 2013 22:36
opera fix photobox
diff --git a/vendor/assets/javascripts/photobox.js b/vendor/assets/javascripts/photobox.js
index 8d4f9a9..b7ed7f5 100644
--- a/vendor/assets/javascripts/photobox.js
+++ b/vendor/assets/javascripts/photobox.js
@@ -14,6 +14,7 @@
transitionend = "transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",
isOldIE = !('placeholder' in doc.createElement('input')),
isIE = !!win.ActiveXObject,
+ isOpera = (win.navigator.appName == 'Opera'),
isMobile = 'ontouchend' in doc,
@glebm
glebm / form_helper.js.coffee
Last active December 17, 2015 19:09
AngularJS Form Helper
angular.module('myApp').factory 'FormHelper', [->
class FormHelper
constructor: (scope, object, formName) ->
@scope = scope
@formName = formName
@object = -> @scope[object]
scope.$watch "#{formName}.$pristine", (pristine) =>
@unsaved = !pristine
@saved = false unless pristine
scope.$watch "#{formName}.$valid", (valid) =>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>homebrew.mxcl.redis</string>
<key>ProgramArguments</key>
<array>
@glebm
glebm / karma.log
Created April 15, 2013 03:44
angularjs karma
Chrome 26.0 (Mac) railsResourceFactory singular should be able to delete to arbitrary url FAILED
Error: Expected DELETE /xyz with different headers
EXPECTED: {"test":{"id":123,"abc":"xyz","xyz":"abc"}}
GOT: {"Accept":"application/json"}
at Error (<anonymous>)
at $httpBackend (/Users/glebm/angularjs-rails-resource/test/lib/angular/angular-mocks.js:931:15)
at sendReq (/Users/glebm/angularjs-rails-resource/test/lib/angular/angular.js:9980:9)
at $http.serverRequest (/Users/glebm/angularjs-rails-resource/test/lib/angular/angular.js:9757:16)
at wrappedCallback (/Users/glebm/angularjs-rails-resource/test/lib/angular/angular.js:7303:59)
at wrappedCallback (/Users/glebm/angularjs-rails-resource/test/lib/angular/angular.js:7303:59)
#!/usr/bin/env ruby
# coding: utf-8
require 'net/http'
require 'json'
# a simple wrapper to do an HTTPS GET
def fetch_uri(url)
STDERR.puts "GET #{url}" if ENV['VERBOSE']
uri = URI(url)