Skip to content

Instantly share code, notes, and snippets.

View nlevchuk's full-sized avatar
🪐

Nikita Levchuk nlevchuk

🪐
View GitHub Profile
@sharipov-ru
sharipov-ru / exceptions_handling.rb
Last active August 29, 2015 14:01
Exceptions handling with ruby 2.1
class ServiceException < StandardError; end
class RepositoryException < StandardError; end
class RethinkDBError < StandardError; end
class RecordsController
def self.update
RecordsService.update(@record)
rescue ServiceException => error
puts "Failure: #{error.inspect}"
puts "Original failure: #{error.cause.inspect}"
@jnunemaker
jnunemaker / oauth2_example.rb
Created April 22, 2010 22:18 — forked from technoweenie/oauth2_example.rb
oauth2, sinatra, faraday
# see http://github.com/intridea/oauth2
require 'rubygems'
require 'sinatra'
require 'oauth2'
require 'json'
class ConnectionLogger < Faraday::Middleware
def call(env)
env[:response].on_complete do |env|
puts "RESULT: #{env[:status]}\n#{env[:body]}"
@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, "") )
@the-teacher
the-teacher / spec_helper.rb
Created December 10, 2013 19:23
Rspec + Views + Isolated Engine
ActionView::TestCase::TestController.instance_eval do
helper MyEngine.routes.url_helpers
helper ApplicationHelper
include Devise::TestHelpers
end
@niquola
niquola / list.md
Last active May 20, 2018 04:52
Must Read from Ravil Bayramgalin (https://github.com/brainopia) + my small adds :)

Books

Concepts-Techniques-Models-Computer-Programming CMT это известная книжка CMT, за которой слава закрепилась не хуже чем у SICP

это из этой книжки классификация различных парадигм Если присмотришься, то увидишь, что Oz поддерживает большинство вариаций (с этой целью его и конструировали, чтобы можно было наглядно продемонстрировать различные подходы в одном языке)

@mustafaturan
mustafaturan / ruby.2.0.0-setup.sh
Last active May 21, 2019 23:00
ruby 2.0.0 centos 6
#!/usr/bin/env bash
# repository
cd /tmp
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm
# system update
yum -y update
yum -y groupinstall "Development Tools"
yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel libyaml-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel valgrind-devel mysql-devel ImageMagick-devel ImageMagick
@nicolashery
nicolashery / environment-variables-jekyll-templates.md
Last active January 22, 2023 15:56
Make environment variables available in Jekyll Liquid templates

Environment variables in Jekyll templates

This is one way to pass some data (API tokens, etc.) to your Jekyll templates without putting it in your _config.yml file (which is likely to be committed in your GitHub repository).

Copy the environment_variables.rb plugin to your _plugins folder, and add any environment variable you wish to have available on the site.config object.

In a Liquid template, that information will be available through the site object. For example, _layouts/default.html could contain:

@mrrooijen
mrrooijen / Capistrano-Deployment-Recipe.rb
Created July 29, 2009 09:34
a "base" Capistrano Rails Deployment Recipe. Use it to deploy your Rails application. It is also easily expandable. So feel free to grab this Recipe and add your own tasks/customization!
# Guide
# Configure the essential configurations below and do the following:
#
# Repository Creation:
# cap deploy:repository:create
# git add .
# git commit -am "initial commit"
# git push origin master
#
# Initial Deployment:
@larsar
larsar / shared_folder_centos_virtualbox.txt
Created January 27, 2012 08:04
Mount shared folder on CentOS in VirtualBox
# The VirtualBox documentation[1] for how to install guest additions
# for Linux on a virtual host is somewhat messy. So here is what
# I did to make it work.
# Install the packages required
yum update
yum install gcc kernel-devel make
reboot
@sinisterchipmunk
sinisterchipmunk / LICENSE
Last active September 8, 2023 17:57
tar, gzip, and untar files using ruby in memory without tempfiles
Copyright (C) 2011 by Colin MacKenzie IV
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in