This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "System Preferences" | |
reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard" | |
tell application "System Events" | |
click checkbox 1 of tab group 1 of window 1 of application process "System Preferences" | |
end tell | |
end tell | |
if application "System Preferences" is running then | |
tell application "System Preferences" to quit | |
end if |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func! ViewResource() | |
let f = input("Filename: ", expand("<cfile>:p")) | |
let f2=substitute(f, "/", "\\", "g") | |
" windows system. | |
" using irfanview | |
call system('"C:/Program Files/IrfanView/i_view32.exe" '.f2) | |
endfunc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" To use, save this file and type ":so %" | |
" Optional: First enter ":let g:rgb_fg=1" to highlight foreground only. | |
" Restore normal highlighting by typing ":e" | |
setlocal nohlsearch | |
d search('^" BEGIN_COLOR_LIST', 'e') | |
while search('\w\+') > 0 | |
let w = expand('<cword>') | |
if w == 'END_COLOR_LIST' | |
break | |
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Color test: Save this file, then enter ':so %' | |
" Then enter one of following commands: | |
" :VimColorTest "(for console/terminal Vim) | |
" :GvimColorTest "(for GUI gvim) | |
function! VimColorTest(outfile, fgend, bgend) | |
let result = [] | |
for fg in range(a:fgend) | |
for bg in range(a:bgend) | |
let kw = printf('%-7s', printf('c_%d_%d', fg, bg)) | |
let h = printf('hi %s ctermfg=%d ctermbg=%d', kw, fg, bg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infix operator + { | |
associativity left | |
precedence 140 | |
} | |
infix operator ... { | |
associativity none | |
precedence 135 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def qsort(alist): | |
if len(alist) == 0: | |
return [] | |
pivot = alist[0] | |
less = filter(lambda x: x < pivot, alist[1:]) | |
greater = filter(lambda x: x >= pivot, alist[1:]) | |
return qsort(less) + [pivot] + qsort(greater) | |
a = [45, 53, 26, 93, 62, 20, 33, 17] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bubble Sort | |
func bubbleSort<T:Comparable>(inout l:[T]) { | |
if l.count == 0 { return } | |
var changed = true | |
while changed { | |
changed = false | |
for i in 1..<l.count { | |
if l[i] < l[i-1] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def combinations(iterable, r): | |
# combinations('ABCD', 2) -> AB AC AD BC BD CD | |
pool = tuple(iterable) | |
n = len(pool) | |
if r > n: | |
return | |
indices = range(r) | |
yield tuple(pool[i] for i in indices) | |
while True: | |
for i in reversed(range(r)): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "sort.h" | |
/** | |
* sort array by using bubble sort | |
* @param void* base: array's pointer | |
* @param int n: number of elements in array | |
* @param int size: size of value type | |
* @param int(*cmp)(const void*, const void*): compare function | |
* cmp(a, b) : returns 1 if a > b, 0 if a == b, 0 otherwise. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is NOT licensed under the GPLv3, which is the license for the rest | |
# of YouCompleteMe. | |
# | |
# Here's the license text for this file: | |
# | |
# This is free and unencumbered software released into the public domain. | |
# | |
# Anyone is free to copy, modify, publish, use, compile, sell, or | |
# distribute this software, either in source code form or as a compiled | |
# binary, for any purpose, commercial or non-commercial, and by any |