Skip to content

Instantly share code, notes, and snippets.

View dimanyc's full-sized avatar

Dimitry Nazarov dimanyc

View GitHub Profile
@dimanyc
dimanyc / gist:22924e3e08829ebcfb63c9997b487832
Created May 24, 2023 23:24
rucksack problem for materials
class Item:
def __init__(self, width, height, quantity):
self.width = width
self.height = height
self.quantity = quantity
class MaterialSheet:
def __init__(self, width, height):
self.width = width
self.height = height
@dimanyc
dimanyc / google-analytics-regular-experssion-cheatsheet.md
Last active October 7, 2022 01:41
Google Analytics RegEx cheatsheet

Common Google Analytics RegEx operators

^   beginning of string
$   end of string
.   any character (wildcard)
*   match 0 or more times
+   match 1 or more times 
?   match 0 or 1 time
| alternative
@dimanyc
dimanyc / doskey.bat
Last active November 21, 2021 18:28 — forked from PierreMage/PowerShell-profile.ps1
Make your Windows command line better with doskey
:: http://technet.microsoft.com/en-us/library/bb490894.aspx
:: F7 = history
:: Alt+F7 = history -c
:: F8 = Ctrl+R
:: Use & to run multiple commands e.g.: command1 & command2
::
:: 1. Go to your Windows folder and find regedit.exe
:: 2. Head over to:
:: HKEY_LOCAL_MACHINE\Software\Microsoft\Command
:: or
@dimanyc
dimanyc / .vimrc
Created September 8, 2021 14:20
.vimrc 09/08/21
set nocompatible " be iMproved, required
filetype off " required
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'danilo-augusto/vim-afterglow'
Plug 'thoughtbot/vim-rspec'
Plug 'tomasr/molokai'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-dispatch'
@dimanyc
dimanyc / .vimrc
Last active June 19, 2020 13:36
.vimrc as of 5/17/20
set nocompatible " be iMproved, required
filetype off " required
call plug#begin('~/.vim/plugged')
Plug 'MaxMEllon/vim-jsx-pretty'
Plug 'danilo-augusto/vim-afterglow'
Plug 'dense-analysis/ale'
Plug 'jparise/vim-graphql'
Plug 'junegunn/fzf', { 'do': './install --bin' }
Plug 'junegunn/fzf.vim'
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git\|tmp\|coverage'
@dimanyc
dimanyc / .vimrc
Created December 28, 2018 15:50
new vimrc
set nocompatible " be iMproved, required
filetype off " required
"--- Vundle
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
map <Leader>t :call RunCurrentSpecFile()<CR>
@dimanyc
dimanyc / array_refinement.rb
Created June 7, 2017 05:04
MemberUniqualizer Array Refinement
module MemberUniquelizer
refine Array do
# makes each member within an array
# unique by appending a unique number
def uniquelize(ary = self)
ary.map { |member| format_member(member) }
.flatten
.uniq
@dimanyc
dimanyc / node.rb
Created June 7, 2017 05:01
Node class
### Node Class
using MemberUniquelizer
class Node < HashWithIndifferentAccess
attr_reader :id
# constructs a new hash based on injected
# headers and attributes
def self.from_rows(headers, attributes)
headers = uniqualize_headers(headers)
@dimanyc
dimanyc / gist:fd9568f4b58991c5b255a0d18adfd3d8
Created September 2, 2016 22:17 — forked from metaskills/gist:4065702
Example Of Other/Legacy DB Connection Management & Query Cache
# Assuming you champioin your other DB connection with a class.
module OtherDb
class Connection < ActiveRecord::Base
establish_connection :other_db
self.abstract_class = true
end
end
# Alway use the connection for other/legacy connections.