Autohotkey's your answer :
for Chrome
#IfWinActive ahk_class Chrome_WidgetWin_1
^!WheelUp::Send ^{PgUp}
^!WheelDown::Send ^{PgDn}
#IfWinActive
for M$ Edge (doesn't work well when you have Office docs open - Excel, Word... why? :(
#IfWinActive ahk_class ApplicationFrameWindow
^!WheelUp::Send ^{PgUp}
^!WheelDown::Send ^{PgDn}
#IfWinActive
What do you do? Get AHK from autohotkey
Do a simple script. I would recommend the Johnny EasyWindowDrag_KDE script.
Add these lines.. at the end. How do I know to use Chrome_WidgetWin_1? Easy - use Window Spy (once you have a basic script running, right click on the script icon in the Taskbar and .. )
Hard-to-find tips on otherwise easy-to-do tasks involving everyday technology, with some advanced insight on history and culture thrown in. Brought to you by a master dabbler. T-S T-S's mission is to boost your competitiveness with every visit. This blog is committed to the elimination of the rat from the tree of evolution and the crust of the earth.
Thursday, June 28, 2018
Friday, June 15, 2018
Java : Find the Best N In Your List Based on a Figure of Merit (FOM)
Here's the deal : you have two ArrayLists, one keeps the name of something and the other, the FOM associated with that entity. For example, a list of usernames and the FOM is number of followers on Instagram.
Someone asks you : tell me the 10 most popular people. If you get the indexes of these ten (in an array0, then you do a simple for loop to 10 and dump out the name_ArrayList.get(i) to spit out the answer.
How do you get the indexes of the top N? Here's how :
public int[] bestN(int N){
int [] maxes = new int[N];
int [] inds = new int[N];
// N passes.
for( int ptr = 0; ptr < N; ptr++){
maxes[ptr] = 0;
inds[ptr] = 0;
for( int i = 0; i < FOM_list.size(); i++ ){
if( FOM_list.get(i) > maxes[ptr] ){
if( (0 ==ptr) || (ptr > 0 && FOM_list.get(i) < maxes[ptr-1]) ){
// if it's the first item, nothing else to consider. Go ahead and enter. Else, ensure that this
// entry is not higher (in FOM) than the one that's supposed to be better than it 😊
maxes[ptr] = FOM_list.get(i);
inds[ptr] = i;
}
}
}
}
return inds;
}
And then :
createTheArrayLists();
int [] best10 = new int[10];
best10 = bestN(10);
System.out.println("Most popular bloggers:");
for( int i = 0; i< 10; i++){
System.out.println(bloggerAList.get(best10[i]) + ": " + followers.get(best10[i]));
}
Thursday, June 14, 2018
A Tasty Morsel
How do you get a function (in Python obviously:) to behave differently when the debugger is active?
import inspect
def isDBG():
for frame in inspect.stack():
if frame[1].endswith("pdb.py"):
return True
return False
Then, just use
if isDBG() :
Confession - the title came out of a joke in "What the Rugby Jokes Did Next" (whose first page said, "You should be ashamed of yourself for picking up a book like this" :
What do a passionate kiss and a spider have in common?
They both lead to the undoing of the fly.
import inspect
def isDBG():
for frame in inspect.stack():
if frame[1].endswith("pdb.py"):
return True
return False
Then, just use
if isDBG() :
Confession - the title came out of a joke in "What the Rugby Jokes Did Next" (whose first page said, "You should be ashamed of yourself for picking up a book like this" :
What do a passionate kiss and a spider have in common?
They both lead to the undoing of the fly.
Monday, June 11, 2018
Python Flatten List of Lists (Magic)
How does this work?
l_of_lists = [list(range(10)), list(range(20,30)), list(range(50,60))]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29], [50, 51, 52, 53, 54, 55, 56, 57, 58, 59]]
>>> l = [y for x in l_of_lists for y in x]
>>> l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
https://coderwall.com/p/rcmaea/flatten-a-list-of-lists-in-one-line-in-python
l_of_lists = [list(range(10)), list(range(20,30)), list(range(50,60))]
[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29], [50, 51, 52, 53, 54, 55, 56, 57, 58, 59]]
>>> l = [y for x in l_of_lists for y in x]
>>> l
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]
https://coderwall.com/p/rcmaea/flatten-a-list-of-lists-in-one-line-in-python
Sunday, June 10, 2018
Debugging Aids for Coursera Assignments
If you're not doing the rigorous stress testing thing and looking to just get the max out of the supplied test-cases, then, try
$ cat tests/20 | python3 by_learners/whaterver.py
after you've inserted enough cute text that can be spotted when something bad happens - maybe just an exit instead of a pdb.set_trace() ??
Ideally, keep a count of the input lines being parsed and dump out
print( "num lines .......... " , lin_count )
Then, you can just do
$ head 55 tests/20 | python3 by_learners/whatever.py
Probably seems lame to a true CS hacker, but ... as my dad used to say when we let a roach eluded the slipper every so often, "they too have a right to live"
Tried it? Didn't work? You're not the first to find out, neither am I :)
https://stackoverflow.com/questions/5843741/how-can-i-pipe-initial-input-into-process-which-will-then-be-interactive?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
$ cat tests/20 | python3 by_learners/whaterver.py
after you've inserted enough cute text that can be spotted when something bad happens - maybe just an exit instead of a pdb.set_trace() ??
Ideally, keep a count of the input lines being parsed and dump out
print( "num lines .......... " , lin_count )
Then, you can just do
$ head 55 tests/20 | python3 by_learners/whatever.py
Probably seems lame to a true CS hacker, but ... as my dad used to say when we let a roach eluded the slipper every so often, "they too have a right to live"
Tried it? Didn't work? You're not the first to find out, neither am I :)
https://stackoverflow.com/questions/5843741/how-can-i-pipe-initial-input-into-process-which-will-then-be-interactive?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
Tuesday, June 05, 2018
Action Taken - Initiated by FBI and VPNFilter
Block WAN Request
|
By enabling the Block WAN Request feature, you can prevent your network from being "pinged," or detected, by other Internet users. The Block WAN Request feature also reinforces your network security by hiding your network ports. Both functions of the Block WAN Request feature make it more difficult for outside users to work their way into your network. This feature is enabled by default. Uncheck to disable this feature.
|
Monday, June 04, 2018
World Class Resources for Budding Coders
This one's a blast just for the goofy English :
http://www.comp.nus.edu.sg/~stevenha/myteaching/competitive_programming/cp1.pdf
And, recommended by Alexander Kulikov and friends :
http://www.cs.yale.edu/homes/aspnes/classes/223/notes.pdf
Pg. 90 of the above is a good one to take in after (or while) you do nand2tetris :) :
You usually don’t need to look at assembly language, but it can sometimes be enlightening to see what the compiler is doing with your code. One thing that I find interesting about this particular code (which is for the x86 architecture) is that most of the instructions are movl, the x86 instruction for copying a 32-bit quantity from one location to another: most of what this program is doing is copying data into the places expected by the library functions it is calling. Also noteworthy is that the beautiful compound statements like if and for that so eloquently express the intent of the programmer get turned into a pile of jump (jmp) and conditional jump (jl, je) instructions, the machine code versions of the often dangerous and confusing goto statement. This is because CPUs are dumb: they don’t know how to carry out an if branch or a loop, and all they can do instead is be told to replace the value of their program counter register with some new value instead of just incrementing it as they usually do.
5.3 Abstract data types
One of the hard parts about computer programming is that, in general, programs are bigger than brains. Unless you have an unusally capacious brain, it is unlikely that you will be able to understand even a modestly large program in its entirety. So in order to be able to write and debug large programs, it is important to be able to break it up into pieces, where each piece can be treated as a tool whose use and description is simpler (and therefor fits in your brain better) than its actual code. Then you can forget about what is happening inside that piece, and just treat it as an easily-understood black box from the outside. This process of wrapping functionality up in a box and forgetting about its internals is called abstraction, and it is the single most important concept in computer science.
5.3.2.2 When to build an abstract data type
The short answer: Whenever you can. A better answer: The best heuristic I know for deciding what ADTs to include in a program is to write down a description of how your program is going to work. For each noun or noun phrase in the description, either identify a built-in data type to implement it or design an abstract data type.
http://www.comp.nus.edu.sg/~stevenha/myteaching/competitive_programming/cp1.pdf
And, recommended by Alexander Kulikov and friends :
http://www.cs.yale.edu/homes/aspnes/classes/223/notes.pdf
Pg. 90 of the above is a good one to take in after (or while) you do nand2tetris :) :
You usually don’t need to look at assembly language, but it can sometimes be enlightening to see what the compiler is doing with your code. One thing that I find interesting about this particular code (which is for the x86 architecture) is that most of the instructions are movl, the x86 instruction for copying a 32-bit quantity from one location to another: most of what this program is doing is copying data into the places expected by the library functions it is calling. Also noteworthy is that the beautiful compound statements like if and for that so eloquently express the intent of the programmer get turned into a pile of jump (jmp) and conditional jump (jl, je) instructions, the machine code versions of the often dangerous and confusing goto statement. This is because CPUs are dumb: they don’t know how to carry out an if branch or a loop, and all they can do instead is be told to replace the value of their program counter register with some new value instead of just incrementing it as they usually do.
5.3 Abstract data types
One of the hard parts about computer programming is that, in general, programs are bigger than brains. Unless you have an unusally capacious brain, it is unlikely that you will be able to understand even a modestly large program in its entirety. So in order to be able to write and debug large programs, it is important to be able to break it up into pieces, where each piece can be treated as a tool whose use and description is simpler (and therefor fits in your brain better) than its actual code. Then you can forget about what is happening inside that piece, and just treat it as an easily-understood black box from the outside. This process of wrapping functionality up in a box and forgetting about its internals is called abstraction, and it is the single most important concept in computer science.
5.3.2.2 When to build an abstract data type
The short answer: Whenever you can. A better answer: The best heuristic I know for deciding what ADTs to include in a program is to write down a description of how your program is going to work. For each noun or noun phrase in the description, either identify a built-in data type to implement it or design an abstract data type.
Subscribe to:
Posts (Atom)