Skip to content

Commit a2b3594

Browse files
committed
more linux commands
1 parent b6432aa commit a2b3594

File tree

60 files changed

+2705
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2705
-8
lines changed

bin/1000-phrases

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# vim: ai ts=4 sts=4 et sw=4
4+
# File: 100-phrases
5+
# Author: Sergio Araujo
6+
# Purpose: <+this script aims...+>
7+
# Last Change: 2018 mai 18 12:25
8+
# Created: sex 18 mai 2018 10:49:14 -03
9+
# email: <voyeg3r ✉ gmail.com>
10+
# Github: https://github.com/voyeg3r
11+
# twitter: @voyeg3r
12+
13+
from bs4 import BeautifulSoup
14+
import requests
15+
import os
16+
#import subprocess
17+
18+
for i in range(1,20):
19+
name = f'folder-{i:02d}'
20+
os.makedirs(name)
21+
os.chdir(name)
22+
headers = {'User-Agent': 'Mozilla/5.0'}
23+
url = 'http://www.englishspeak.com/pt/english-phrases?category_key=' + str(i)
24+
r = requests.get(url, headers=headers)
25+
26+
html_content = r.text
27+
soup = BeautifulSoup(html_content, 'html.parser')
28+
29+
with open("output.csv", "w") as file:
30+
for tag in soup.select('td img'):
31+
file.write(str(tag))
32+
file.write("\n")
33+
34+
os.chdir('..')
35+

bin/dictation

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# vim: ai ts=4 sts=4 et sw=4
4+
# File: <+Filename Here+>
5+
# Author: Sergio Araujo
6+
# Purpose: play a random song
7+
# Last Change: 2018 mai 19 12:25
8+
# Created: sex 11 mai 2018 09:53:01 -03
9+
# email: <voyeg3r ✉ gmail.com>
10+
# Github: https://github.com/voyeg3r
11+
# twitter: @voyeg3r
12+
# Rererence: https://stackoverflow.com/a/41911914/2571881
13+
14+
import sys
15+
import os
16+
import random
17+
import subprocess
18+
19+
20+
def cls():
21+
if os.name == 'posix':
22+
os.system('clear')
23+
else:
24+
os.system('cls')
25+
26+
cls()
27+
28+
def randplay():
29+
cls()
30+
n = 0
31+
random.seed()
32+
for root, dirs, files in os.walk('/home/sergio/music/podcasts/dictation'):
33+
for name in files:
34+
if name.endswith("mp3"):
35+
n+=1
36+
if random.uniform(0,n) < 1:
37+
rfile=os.path.join(root, name)
38+
global file
39+
file = rfile
40+
print("your file is", file)
41+
subprocess.Popen(['mpg123', '-q', file]).wait()
42+
43+
while True:
44+
cls()
45+
print("Let's practice some dictation!")
46+
print("Type Enter to continue, r to repeat and q or Ctrl-c to quit: ", end='')
47+
result = input()
48+
if result == 'r':
49+
subprocess.Popen(['mpg123', '-q', file]).wait()
50+
print("Playing again", file, end='')
51+
elif result == 'q':
52+
cls()
53+
break
54+
else:
55+
randplay()
56+

bin/getube

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# vim: ai ts=4 sts=4 et sw=4
4+
# File: getube
5+
# Author: Sergio Araujo
6+
# Purpose: Download youtube videos
7+
# Last Change: 2018 mai 22 07:47
8+
# Created: ter 22 mai 2018 07:31:29 -03
9+
# email: <voyeg3r ✉ gmail.com>
10+
# Github: https://github.com/voyeg3r
11+
# twitter: @voyeg3r
12+
13+
import pafy
14+
import sys
15+
import os
16+
17+
if len(sys.argv) > 1:
18+
url = sys.argv[1]
19+
else:
20+
url = input("Type the youtube url or ID: ")
21+
22+
def cls():
23+
if os.name == 'posix':
24+
os.system('clear')
25+
else:
26+
os.system('cls')
27+
28+
cls()
29+
30+
video = pafy.new(url)
31+
bestvideo = video.getbestvideo()
32+
print("Baixando: ", video.title)
33+
bestvideo.download()

bin/randplay

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
# vim: ai ts=4 sts=4 et sw=4
4-
# File: <+Filename Here+>
4+
# File: randplay
55
# Author: Sergio Araujo
6-
# Purpose: play a random song
7-
# Last Change: 2018 mai 21 20:34
6+
# Purpose: Play a random song
7+
# Last Change: 2018 mai 22 13:39
88
# Created: sex 11 mai 2018 09:53:01 -03
99
# email: <voyeg3r ✉ gmail.com>
1010
# Github: https://github.com/voyeg3r
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
" Author: Eddie Lebow https://github.com/elebow
2+
" Description: Cucumber, a BDD test tool
3+
4+
function! ale_linters#cucumber#cucumber#GetCommand(buffer) abort
5+
let l:features_dir = ale#path#FindNearestDirectory(a:buffer, 'features')
6+
7+
if !empty(l:features_dir)
8+
let l:features_arg = '-r ' . ale#Escape(l:features_dir)
9+
else
10+
let l:features_arg = ''
11+
endif
12+
13+
return 'cucumber --dry-run --quiet --strict --format=json '
14+
\ . l:features_arg . ' %t'
15+
endfunction
16+
17+
function! ale_linters#cucumber#cucumber#Handle(buffer, lines) abort
18+
try
19+
let l:json = ale#util#FuzzyJSONDecode(a:lines, {})[0]
20+
catch
21+
return []
22+
endtry
23+
24+
let l:output = []
25+
for l:element in get(l:json, 'elements', [])
26+
for l:step in l:element['steps']
27+
if l:step['result']['status'] is# 'undefined'
28+
call add(l:output, {
29+
\ 'lnum': l:step['line'],
30+
\ 'code': 'E',
31+
\ 'text': 'Undefined step'
32+
\})
33+
endif
34+
endfor
35+
endfor
36+
37+
return l:output
38+
endfunction
39+
40+
call ale#linter#Define('cucumber', {
41+
\ 'name': 'cucumber',
42+
\ 'executable': 'cucumber',
43+
\ 'command_callback': 'ale_linters#cucumber#cucumber#GetCommand',
44+
\ 'callback': 'ale_linters#cucumber#cucumber#Handle'
45+
\})
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
" Author: Johannes Wienke <languitar@semipol.de>
2+
" Description: PMD for Java files
3+
4+
function! ale_linters#java#pmd#Handle(buffer, lines) abort
5+
let l:pattern = '"\(\d\+\)",".\+","\(.\+\)","\(\d\+\)","\(\d\+\)","\(.\+\)","\(.\+\)","\(.\+\)"$'
6+
let l:output = []
7+
8+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
9+
call add(l:output, {
10+
\ 'type': 'W',
11+
\ 'lnum': l:match[4] + 0,
12+
\ 'text': l:match[5],
13+
\ 'code': l:match[6] . ' - ' . l:match[7],
14+
\})
15+
endfor
16+
17+
return l:output
18+
endfunction
19+
20+
function! ale_linters#java#pmd#GetCommand(buffer) abort
21+
return 'pmd '
22+
\ . ale#Var(a:buffer, 'java_pmd_options')
23+
\ . ' -f csv'
24+
\ . ' -d %t'
25+
endfunction
26+
27+
if !exists('g:ale_java_pmd_options')
28+
let g:ale_java_pmd_options = '-R category/java/bestpractices.xml'
29+
endif
30+
31+
call ale#linter#Define('java', {
32+
\ 'name': 'pmd',
33+
\ 'executable': 'pmd',
34+
\ 'command_callback': 'ale_linters#java#pmd#GetCommand',
35+
\ 'callback': 'ale_linters#java#pmd#Handle',
36+
\})
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
" Author: stewy33 <slocumstewy@gmail.com>
2+
" Description: Lints mercury files using mmc
3+
4+
call ale#Set('mercury_mmc_executable', 'mmc')
5+
call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100')
6+
7+
function! ale_linters#mercury#mmc#GetExecutable(buffer) abort
8+
return ale#Var(a:buffer, 'mercury_mmc_executable')
9+
endfunction
10+
11+
function! ale_linters#mercury#mmc#GetCommand(buffer) abort
12+
let l:module_name = expand('#' . a:buffer . ':t:r')
13+
14+
return ale#path#BufferCdString(a:buffer)
15+
\ . ale_linters#mercury#mmc#GetExecutable(a:buffer)
16+
\ . ' --errorcheck-only '
17+
\ . ale#Var(a:buffer, 'mercury_mmc_options')
18+
\ . ' ' . l:module_name
19+
endfunction
20+
21+
function! ale_linters#mercury#mmc#Handle(buffer, lines) abort
22+
" output format
23+
" <filename>:<line>: <issue type>: <message>
24+
let l:pattern = '\v^\w+\.m:(\d+):\s+([W|w]arning|.*[E|e]rror.*): (.*)'
25+
let l:output = []
26+
27+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
28+
call add(l:output, {
29+
\ 'lnum': substitute(l:match[1], '\v^0*', '', '') + 0,
30+
\ 'type': l:match[2][0] =~? 'W' ? 'W' : 'E',
31+
\ 'text': l:match[2] . ': ' . l:match[3]
32+
\})
33+
endfor
34+
35+
return l:output
36+
endfunction
37+
38+
call ale#linter#Define('mercury', {
39+
\ 'name': 'mmc',
40+
\ 'output_stream': 'stderr',
41+
\ 'executable_callback': 'ale_linters#mercury#mmc#GetExecutable',
42+
\ 'command_callback': 'ale_linters#mercury#mmc#GetCommand',
43+
\ 'callback': 'ale_linters#mercury#mmc#Handle',
44+
\ 'lint_file': 1,
45+
\})
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
" Author: Oyvind Ingvaldsen <oyvind.ingvaldsen@gmail.com>
2+
" Description: NASM linter for asmsyntax nasm.
3+
4+
call ale#Set('nasm_nasm_executable', 'nasm')
5+
call ale#Set('nasm_nasm_options', '')
6+
7+
function! ale_linters#nasm#nasm#GetExecutable(buffer) abort
8+
return ale#Var(a:buffer, 'nasm_nasm_executable')
9+
endfunction
10+
11+
function! ale_linters#nasm#nasm#GetOptions(buffer) abort
12+
return ale#Var(a:buffer, 'nasm_nasm_options')
13+
endfunction
14+
15+
function! ale_linters#nasm#nasm#GetCommand(buffer) abort
16+
" Note that NASM require a trailing slash to the -I option.
17+
let l:executable = ale#Escape(ale_linters#nasm#nasm#GetExecutable(a:buffer))
18+
let l:separator = has('win32') ? '\' : '/'
19+
let l:path = ale#Escape(fnamemodify(bufname(a:buffer), ':p:h') . l:separator)
20+
let l:options = ale_linters#nasm#nasm#GetOptions(a:buffer)
21+
22+
return l:executable
23+
\ . ' -X gnu'
24+
\ . ' -I ' . l:path
25+
\ . ' ' . l:options
26+
\ . ' %s'
27+
endfunction
28+
29+
function! ale_linters#nasm#nasm#Handle(buffer, lines) abort
30+
" Note that we treat 'fatal' as errors.
31+
let l:pattern = '^.\+:\(\d\+\): \([^:]\+\): \(.\+\)$'
32+
let l:output = []
33+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
34+
call add(l:output, {
35+
\ 'lnum': l:match[1] + 0,
36+
\ 'type': l:match[2] =~? 'error\|fatal' ? 'E' : 'W',
37+
\ 'text': l:match[3],
38+
\})
39+
endfor
40+
return l:output
41+
endfunction
42+
43+
call ale#linter#Define('nasm', {
44+
\ 'name': 'nasm',
45+
\ 'executable': 'nasm',
46+
\ 'output_stream': 'stderr',
47+
\ 'lint_file': 1,
48+
\ 'command_callback': 'ale_linters#nasm#nasm#GetCommand',
49+
\ 'callback': 'ale_linters#nasm#nasm#Handle',
50+
\})
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
" Author: pylipp (www.github.com/pylipp)
2+
" Description: qmlfmt for QML files
3+
4+
let g:ale_qml_qmlfmt_executable = get(g:, 'ale_qml_qmlfmt_executable', 'qmlfmt')
5+
6+
function! ale_linters#qml#qmlfmt#GetExecutable(buffer) abort
7+
return ale#Var(a:buffer, 'qml_qmlfmt_executable')
8+
endfunction
9+
10+
function! ale_linters#qml#qmlfmt#GetCommand(buffer) abort
11+
return ale#Escape(ale_linters#qml#qmlfmt#GetExecutable(a:buffer))
12+
\ . ' -e'
13+
endfunction
14+
15+
" Find lines like
16+
" Error:11:1: Expected token `}'
17+
function! ale_linters#qml#qmlfmt#Handle(buffer, lines) abort
18+
let l:pattern = '\v^(Error|Warning):(\d+):(\d+): (.+)$'
19+
let l:output = []
20+
21+
for l:match in ale#util#GetMatches(a:lines, l:pattern)
22+
let l:item = {
23+
\ 'lnum': l:match[2] + 0,
24+
\ 'col': l:match[3] + 0,
25+
\ 'text': l:match[4],
26+
\ 'type': l:match[1] is# 'Warning' ? 'W' : 'E',
27+
\}
28+
call add(l:output, l:item)
29+
endfor
30+
31+
return l:output
32+
endfunction
33+
34+
call ale#linter#Define('qml', {
35+
\ 'name': 'qmlfmt',
36+
\ 'output_stream': 'stderr',
37+
\ 'executable_callback': 'ale_linters#qml#qmlfmt#GetExecutable',
38+
\ 'command_callback': 'ale_linters#qml#qmlfmt#GetCommand',
39+
\ 'callback': 'ale_linters#qml#qmlfmt#Handle',
40+
\})
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
" Author: Nils Leuzinger - https://github.com/PawkyPenguin
2+
" Description: Basic scala support using fsc
3+
"
4+
function! ale_linters#scala#fsc#GetExecutable(buffer) abort
5+
if index(split(getbufvar(a:buffer, '&filetype'), '\.'), 'sbt') >= 0
6+
" Don't check sbt files
7+
return ''
8+
endif
9+
10+
return 'fsc'
11+
endfunction
12+
13+
function! ale_linters#scala#fsc#GetCommand(buffer) abort
14+
let l:executable = ale_linters#scala#fsc#GetExecutable(a:buffer)
15+
16+
if empty(l:executable)
17+
return ''
18+
endif
19+
20+
return ale#Escape(l:executable) . ' -Ystop-after:parser %t'
21+
endfunction
22+
23+
call ale#linter#Define('scala', {
24+
\ 'name': 'fsc',
25+
\ 'executable_callback': 'ale_linters#scala#fsc#GetExecutable',
26+
\ 'command_callback': 'ale_linters#scala#fsc#GetCommand',
27+
\ 'callback': 'ale#handlers#scala#HandleScalacLintFormat',
28+
\ 'output_stream': 'stderr',
29+
\})

0 commit comments

Comments
 (0)