Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name anti key-grabber
// @description Prevent web apps from capturing and muting vital keyboard shortcuts
// @grant none
// @version 1.1
// ==/UserScript==
(function(){
var isMac = unsafeWindow.navigator.oscpu.toLowerCase().contains("mac os x");
unsafeWindow.document.addEventListener('keydown', function(e) {
if (e.keyCode === 116) {
#!/usr/bin/python
import sys
NR_LAYER = 10
def get_n_plus_1(weights):
length = len(weights)
lower_weights = [[1 for col in range(length+1)] for row in range(length+1)]
print "---- %d -----" % len(weights)
list=($(echo file?))
max=${#l[@]}
i=0
while (( i < max ))
do
j=0
while (( j < max-i-1))
do
echo ${list[$j]} ${list[$i]}
let j++
@ryo1kato
ryo1kato / xscreensaver-command wrapper
Created January 9, 2014 05:53
a wrapper for xscreensaver-command to behave like gnome-screensaver-command
#!/bin/bash
# screen-saver wrapper to fix/modify xflock4 behavior
# It also logs when it's activated.
#logfile="$HOME/.screensaver.log"
logfile="$HOME/usr/var/log/screensaver.log"
control_command () {
#gnome-screensaver-command "$@"
/usr/bin/xscreensaver-command "$@"
@ryo1kato
ryo1kato / dot.bashrc.minimal
Created January 3, 2014 14:27
My minimal .bashrc file for new environment.
. /etc/skel/.bashrc
set -o noclobber
PS1='$ '
######## aliases #######
if type lv >/dev/null 2>&1
then
alias lv=less
fi
@ryo1kato
ryo1kato / shrink-vbox-image.sh
Last active June 26, 2018 18:39
clean cache and zerofill unused filesystem space for VirtualBox *.vdi image files
#!/bin/sh
#
# clean cache and zerofill unused filesystem space for VirtualBox *.vdi image files
#
set -ue
set -x
sudo apt-get clean
if ! type pv > /dev/null 2>&1
then
#!/bin/sh
#
# print list of Debian/Ubuntu packages sorted in installed-size.
#
dpkg --get-selections |
awk '{print $1}' |
xargs apt-cache show |
egrep '^(Package|Installed-Size): ' |
tr '\n' ',' |
@ryo1kato
ryo1kato / Cursor key shortcut
Created May 6, 2013 13:17
Disable annoying Chrome webapp shortcut for Emacs users! (e.g. MacOSX + Chrome + Google Spreadsheet.)
//Use https://chrome.google.com/webstore/detail/shortcut-manager/mgjjeipcdnnjhgodgjpfkffcejoljijf
//to assign key-shortcut to this JS snippet
function moveCaret(win, charCount) {
var sel;
sel = win.getSelection();
if (sel.rangeCount > 0) {
var textNode = sel.focusNode;
console.log(textNode)
var newOffset = sel.focusOffset + charCount;
sel.collapse(textNode, Math.min(textNode.length, newOffset));
function disableCtrlKeyCombination(e)
{
var key;
var isCtrl;
key = e.which;
if( e.ctrlKey ){
console.log('Ctrl+ASCII shortcut hooked.')
if (String.fromCharCode(key).toLowerCase() == 'b') { //debug
console.log('Ctrl+b')
// ==UserScript==
// @name DontStealMyShurtcut
// @namespace http://ryo1kato.github.com/
// @version 0.1
// @description enter something useful
// @match https://docs.google.com/spreadsheet/*
// @require http://code.jquery.com/jquery-latest.min.js
// ==/UserScript==
function disableCtrlKeyCombination(e)