Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE HTML>
<html>
<head>
<style>
body {
font: 10px sans-serif;
}
svg {
def vim(*args)
if self.class == Rush::Dir
system "cd #{full_path}; vim +NERDTree"
else
super
end
end
alias_method :v, :vim
require 'matrix'
class TwoSquare
attr_accessor :first_square, :second_square
ALPHABET = 'йцукенгшщзхъэждлорпавыфячсмитьбю.,- '.split('')
def initialize
@first_square = build_square
@second_square = build_square
@s-mage
s-mage / graph_search.rb
Created April 22, 2014 09:58
Solucion of well-known puzzle about river crossing.
# Search of graph.
#
# Algorightm of graph construction:
# Define start state.
# Define finish state.
# Define valid state.
# For each not opened node
# open node
# end
#
@s-mage
s-mage / test_by_tag.rb
Created February 8, 2014 07:30
Find test in cucumber by tag.
TAG_STRING = /(@\w+\W?)+/
EMPTY_STRING = /^\W*$/
def scan_project(dirname, tag)
Dir.new(dirname).
select { |file| File.extname(file) == '.feature' }.
inject('') { |r, f| r << format_file(f, scan_file(f, tag)) }
end
def format_file(filename, scan_result)
@s-mage
s-mage / 2flickr.rb
Last active January 3, 2016 02:49
Upload photos to flickr.
#!/usr/bin/env ruby
require 'flickraw'
require 'json'
CREATE_API_KEY = 'https://secure.flickr.com/services/apps/create/apply'
CONFIG_FILE = File.expand_path '~/.config/2flickr.json'
def init
#!/usr/bin/env ruby
require 'sparql/client'
sparql = SPARQL::Client.new("http://dbpedia.org/sparql")
query = "prefix dbpprop: <http://dbpedia.org/property/>
prefix dbpedia-owl: <http://dbpedia.org/ontology/>
select ?name, ?hdi
where {
?country a dbpedia-owl:Country .
%h2.expandall Expand/Collapse All
- @tag.pages.each do |page|
%div{ class: 'title', id: "title_#{page.title}" }
= page.pretty_title
= link_to(" [edit]", controller: 'wiki', action: 'show', |
project_id: page.project, id: page.title)
%div{ class: 'section', id: page.title }
= raw Redmine::WikiFormatting::Textile::Formatter.new(page.text).to_html
:javascript
vim.o.background = "light"
vim.o.termguicolors = true
if vim.g.colors_name then vim.cmd("hi clear") end
vim.cmd("syntax reset")
vim.g.colors_name = "Boring Tomorrow"
-- Default GUI Colours
@s-mage
s-mage / run_tags.rb
Last active December 21, 2015 17:09
Set git hook that runs ctags automatically after each pool, commit and checkout. Got from https://gist.github.com/tobias/42308/raw/2e7b7072278a2ba65e9d95597e148498d9ba7654/run_tags.rb and refactore. Need to set it more flexible.
#!/usr/bin/env ruby
# A script to run ctags on all .rb files in a project. Can be run on
# the current dir, called from a git callback, or install itself as a
# git post-merge and post-commit callback.
CTAGS = '/usr/bin/env ctags'
HOOKS = %w{ post-merge post-commit post-checkout }
HOOKS_DIR = '.git/hooks'
def install