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
import java.lang.Math; | |
import java.util.Random; | |
import java.util.Arrays; | |
public class scratch | |
{ | |
public static void main ( String [] args ) | |
{ | |
int lottoNums[] = new int [6]; | |
int myNums[] = {1,13,15,22,41,36}; |
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
# A recursive solution to https://github.com/Bryukh-Checkio-Tasks/checkio-task-stair-steps/blob/master/info/task_description.html | |
def golf(nums,skipped): | |
if nums: | |
x = nums.pop(0) # grab current number | |
if x < 0 and not skipped: # is this one negative ? | |
print 'Skipping',x | |
return golf(nums[0:],True) # then skip | |
else: | |
print 'returning',x | |
return x+golf(nums[0:],False) # otherwise, don't skip |
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
$> cat viewports.sh | |
#!/bin/bash | |
get_screen_geometry() | |
{ | |
xwininfo -root | awk '/-geometry/{gsub(/+|x/," ");print $2,$3}' | |
} | |
SCHEMA="org.compiz.core:/org/compiz/profiles/unity/plugins/core/" | |
read screen_width screen_depth <<< "$(get_screen_geometry)" |
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
get_hex_xids() | |
{ | |
xprop -root -notype _NET_CLIENT_LIST | \ | |
awk 'BEGIN{printf "ibase=16"}\ | |
{gsub(/\,/," ");for(i=1;i<=NF;i++) \ | |
if ($i~/0x/) printf ";%s",substr(toupper($i),3) }' | |
} | |
convert_hex2dec() | |
{ |
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
#!/bin/bash | |
get_window_paths() | |
{ | |
qdbus org.ayatana.bamf /org/ayatana/bamf/matcher org.ayatana.bamf.matcher.WindowPaths | |
} | |
get_running_apps() | |
{ | |
qdbus org.ayatana.bamf /org/ayatana/bamf/matcher org.ayatana.bamf.matcher.RunningApplications |
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
window_stack() | |
{ | |
qdbus --literal com.canonical.Unity.WindowStack | |
/com/canonical/Unity/WindowStack \ | |
com.canonical.Unity.WindowStack.GetWindowStack | \ | |
awk -F '{' '{gsub(/\}|\]|,/,"");gsub(/\[/,"\n");print $2}' | \ | |
awk '!/compiz/&&!/^$/ && $4!="\""$3"\"" { L[n++] = $0 }\ | |
END { while(n--) print L[n] }' | |
} |
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
DIR:/xieerqi|16:06|skolodya@ubuntu: | |
$ cat monitor_stack.sh | |
get_monitor_stack() | |
{ | |
qdbus org.ayatana.bamf \ | |
/org/ayatana/bamf/matcher \ | |
org.ayatana.bamf.matcher.WindowStackForMonitor $1 | |
} | |
for window in $( get_monitor_stack $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
#!/bin/bash | |
#set -x | |
wait_ac_connect() | |
{ | |
while ! on_ac_power ; do : ; sleep 0.25 ; done && echo PLUGGED_IN | |
} | |
wait_ac_disconnect() | |
{ | |
while on_ac_power ; do : ; sleep 0.25 ; done && echo UNPLUGGED |
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
#!/bin/bash | |
list_windows() | |
{ | |
# get list of all currently open windows | |
qdbus org.ayatana.bamf \ | |
/org/ayatana/bamf/matcher \ | |
org.ayatana.bamf.matcher.WindowPaths | |
} |
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
#!/bin/bash | |
# run script like so: bash thirds.sh NUMBER | |
# where NUMBER is 0,1 or 2 | |
# 0 is left, 1 is center, 2 is right | |
get_screen_geometry() | |
{ | |
# determine size of the desktop | |
xwininfo -root | \ | |
awk -F ':' '/Width/{printf "%d",$2/3}/Height/{print $2}' | |
} |
OlderNewer