Skip to content

Instantly share code, notes, and snippets.

View vderyagin's full-sized avatar

Victor Deryagin vderyagin

  • Ternopil, Ukraine
View GitHub Profile
@vderyagin
vderyagin / 0_reuse_code.js
Created July 4, 2014 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@vderyagin
vderyagin / PrintXResolution.hs
Created January 16, 2014 09:22
get screen resolution in X (shells out to xrandr(1))
import Data.List
import Data.Maybe
import System.Process
import Text.Regex.Posix
main :: IO ()
main = do
(w, h) <- getScreenResolution
putStrLn $ show w ++ "×" ++ show h
@vderyagin
vderyagin / words.rb
Created July 6, 2013 05:49
Find English words with three consecutive double digits
File.foreach '/usr/share/dict/web2' do |line|
puts line if line[/((.)\k<-1>){3}/]
end
# >> bookkeeper
# >> bookkeeping
# >> subbookkeeper
class EmailSender
def self.send_emails(number_of_emails, job_que_id)
emails = EmailQue.where(send_status: 'NOT SENT', job_que_id: job_que_id)
emails = emails.limit(number_of_emails) unless number_of_emails.zero?
errors = []
emails.each do |email|
email_params = {
from: '[email protected]', # <== change this to appropriate value
# == Schema Information
#
# Table name: email_ques
#
# id :integer not null, primary key
# job_que_id :integer
# to_field :string(255)
# subject_field :string(255)
# body_field :text
# send_status :text
# == Schema Information
#
# Table name: sysdba.INF_ACC_IA_INVESTMENT
#
# INF_ACC_IA_INVESTMENTID :string(12) not null
# INF_ACC_INVEST_ACCOUNTID :string(12) not null
# CREATEUSER :string(12)
# CREATEDATE :datetime
# MODIFYUSER :string(12)
# MODIFYDATE :datetime
#! /usr/bin/env ruby
require 'json'
require 'net/http'
require 'uri'
def rate_converter(from, to)
uri = URI('http://rate-exchange.appspot.com/currency')
uri.query = URI.encode_www_form(from: from, to: to)
#! /usr/bin/env ruby
=begin
Determines total duration of all media files, passed as arguments.
Shells out to ffmpeg(1).
=end
@vderyagin
vderyagin / pairs.rb
Last active December 15, 2015 15:58
#! /usr/bin/env ruby
# -*- coding: utf-8 -*-
class Integer
def factors
fail if self <= 0
(1...self).select { |num| (self % num).zero? }
end
;;;###autoload
(define-derived-mode conf-dwarf-fortress-mode fundamental-mode
"Mode for editing dwarf fortress configuration files."
:syntax-table text-mode-syntax-table
(setq font-lock-defaults
'((
("^\s*\\(\\[[^:]+:\\)\\(.*\\)\\(\\]\\)$"
(1 font-lock-type-face)
(2 font-lock-constant-face)
(3 font-lock-type-face))