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
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 | |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from gi.repository import Gio,Notify | |
import dbus | |
import sys | |
import os | |
import time | |
import subprocess | |
def get_dbus(bus_type,obj,path,interface,method,arg): |
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 | |
# We want to find the directory where all the backlight data | |
# is stored , based on the fact that there's always "actual_brightness" | |
# file in that directory | |
DIR=$(find /sys/devices/ -type f -name "actual_brightness" -printf "%h" ) | |
# Graphic cards all have different integer value for | |
# maximum level of brightness, so we need to get it | |
MAX=$(cat "$DIR"/max_brightness ) |
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
from gi.repository import GdkX11,Gdk | |
import subprocess | |
import time | |
def run_sh(cmd): | |
# run shell commands | |
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) | |
out = p.stdout.read().strip() | |
return out |
OlderNewer