Skip to content

Instantly share code, notes, and snippets.

View denyago's full-sized avatar
🤠

Denys Yahofarov denyago

🤠
View GitHub Profile
@denyago
denyago / natural_scroll.rb
Created September 8, 2013 10:13
Enables Natural Scrolling at Ubuntu like OS X has. Simple script to run on X start.
#!env ruby
# This script enables 'Natural scrolling' as in OS X.
#
# Usage:
# 1. Find your touchpad name by running xinput list
# 2. Run ./natural_scroll.rb 'touchpad name'
#
# Limitations:
# - Tested only on Ubuntu 13.04
require 'erb'
require 'net/http'
require 'json'
template = %q{
This is one: <%= data_obj.one %>
The foo is <%= data_obj.foo %>
}
class MyDataObj
@denyago
denyago / rails_issue_5057.rb
Last active January 1, 2016 12:19 — forked from tilo/rails_issue_5057.rb
Minimal ActiveRecord setup with SQlite3
gem 'rails', '3.2.1'
require 'active_record'
puts "Active Record #{ActiveRecord::VERSION::STRING}"
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => ':memory:'
)

My pi runs a raspbian distro (2013-09-25-wheezy-raspbian.zip)

Java

What the raspberry page officially recommends is the jdk. (Source: http://www.raspberrypi.org/archives/4920).

sudo apt-get update && sudo apt-get install oracle-java7-jdk

However, this doesn't include a server on the pi. The jre needs to be installed instead.

require 'diff_matcher'
RSpec::Matchers.define :be_matching do |expected|
match do |actual|
@difference = DiffMatcher::Difference.new(normalize(expected), normalize(actual), opts)
no_errors_happened? && @difference.matching?
end
failure_message do |actual|
no_errors_happened? ? @difference.to_s : "Critical errors during matching:\n#{errors.join("\n")}"
@denyago
denyago / perf.rb
Last active August 29, 2015 14:20
Ruby profiling
# gem 'ruby-prof'
module WithProfiling
def self.run
RubyProf.start
puts 'Start'
result = yield
Capybara.register_driver :en_browser do |app|
require 'selenium-webdriver'
Selenium::WebDriver::Firefox::Binary.path = '/Users/di/Applications/Firefox.app/Contents/MacOS/firefox-bin'
profile = Selenium::WebDriver::Firefox::Profile.new
profile['intl.accept_languages'] = 'en'
Capybara::Selenium::Driver.new(app, {:browser => :firefox, :profile => profile})
end
mysql.server start --log-error=/tmp/mysql.errors.log &&\
watch -c -n 20 'mysql.server status; echo "\n"; tail -n 20 /tmp/mysql.errors.log' ;\
mysql.server stop
\set QUIET 1
-- formatting
\x auto
\set VERBOSITY verbose
\set ON_ERROR_ROLLBACK interactive
-- show execution times
\timing
-- limit paging
\pset pager off

Keybase proof

I hereby claim:

  • I am denyago on github.
  • I am denyago (https://keybase.io/denyago) on keybase.
  • I have a public key whose fingerprint is 99BC 63B5 8267 CEF2 F293 E409 6CDA 082D FE39 D507

To claim this, I am signing this object: