Skip to content

Instantly share code, notes, and snippets.

View bsa7's full-sized avatar

Belevskij Sergeij bsa7

View GitHub Profile
@bsa7
bsa7 / map.coffee
Last active August 29, 2015 14:22
map jquery elements
result = $("label.some-class-name").map((i, item) ->
$(item).text()
).toArray()
@bsa7
bsa7 / style.scss.erb
Last active August 29, 2015 14:22
Iterate styles on create
<%
def rules(sizes, style_selector, rules)
rule_stub = "<rules>"
size_stub = "<size>"
rules_result = ""
sizes.each do |size|
rule_template = "#{style_selector.sub(size_stub, "#{size}")}{#{rule_stub}}"
[rules].flatten.each do |rule|
rule_template.sub!(rule_stub, rule.gsub(size_stub, "#{size}") + rule_stub)
end
@bsa7
bsa7 / regexp.rb
Created May 12, 2015 20:33
sublime: add some output after all funcs definitions:
Ctrl + H
^([^\s].+)->\n
\1->\n\twindow.if_console "\1 ->"\n
@bsa7
bsa7 / mc_keys.md
Last active August 29, 2015 14:19
Midnight Commander keyboards shortcuts

Navigational and basic hot keys

CTRL-X + D

(compare directories) sequence must be issued by pressing together CTRL and X, and then D button - like in Emacs editor. Enter has different functions depending on the context:

  • if you have text in command line (oNavigational and basic hot keys
CTRL-X + D

(compare directories) sequence must be issued by pressing together CTRL and X, and then D button - like in Emacs editor. Enter has different functions depending on the context:

  • if you have text in command line (one with command prompt, above function keys in the last) it will be executed as command
@bsa7
bsa7 / recursive_delete_empty_folders.bat
Created April 19, 2015 06:58
windows - recursive delete empty folders
for /f "delims=" %%d in ('dir /s /b /ad ^| sort /r') do rd "%%d"
pause
@bsa7
bsa7 / sublime 3 keyboard shortcuts.md
Last active August 29, 2015 14:19
sublime multiline editing

Mouse

Windows/Linux

Building blocks:

  • Positive/negative:
    • Add to selection: Ctrl
@bsa7
bsa7 / copy archives to storages.bat
Last active August 29, 2015 14:18
Native Windows Server Rotary Archivation
robocopy c:\ЂаеЁўл\ \\Buh\Ўге аеЁўл\ /E /XC /XN /XO
NET USE V: \\Buh\Ўге аеЁўл
forfiles /P V:\ /S /M *.7z /D -15 /C "cmd /c del @PATH"
NET USE V: /DELETE /YES
robocopy c:\ЂаеЁўл\ \\User1\ аеЁўл\ /E /XC /XN /XO
NET USE V: \\User1\ аеЁўл
forfiles /P V:\ /S /M *.7z /D -15 /C "cmd /c del @PATH"
NET USE V: /DELETE /YES
@bsa7
bsa7 / midnight commander cheatsheet.md
Last active April 18, 2025 09:25
midnight commander cheatseet

Navigational and basic hot keys

Notes:

CTRL-X + D - compare directories or files;

TAB or Ctrl-U is switching focus between left and right panel;

@bsa7
bsa7 / first n words and last n words.rb
Last active August 29, 2015 14:07
leave first or last n words from
def first_n_words n
text = self.clone
words = text.scan(/[a-zA-Zа-яёА-ЯЁ]+/)[0..n-1]
if words.size < n
res = text
else
res = words.each_with_object([]){|k,v|t= text.index k; v << text[0..t+k.size-1]; text = text[t+k.size..-1]}.join
end
res
end
@bsa7
bsa7 / recursive find and delete files and dirs.bash
Last active August 29, 2015 14:07
recursive find & delete
find . -name "*.bak" -type f -delete
find -type d -name '.svn' -exec rm -rfv {} \;