Skip to content

Instantly share code, notes, and snippets.

View zkat's full-sized avatar
💭
Rusting it up

Kat Marchán zkat

💭
Rusting it up
View GitHub Profile
@zkat
zkat / gist:6277858
Last active December 21, 2015 08:28
Some fun with obfuscation
[].__proto__.subsets=function f(s,c,t)[]+(t=this)?(c=Array.concat)((s=f.call(t.slice(1))).map(s=>c([t[0]],s)),s):[[]];
@zkat
zkat / .vimperatorrc
Last active December 16, 2015 03:59
"loadplugins '\.(js|penta)$'
noremap <A-x> :
noremap <C-j> <Return>
noremap <C-f> <C-n>
noremap <C-b> <C-p>
noremap <C-a> 0
noremap <C-e> $
noremap <C-p> <Up>
noremap <C-n> <Down>
noremap <C-v> <PageDown>
@zkat
zkat / gist:5296480
Last active December 15, 2015 17:30
find/find_if search utilities
Array.prototype.find_if = function(test, opts) {
opts = opts || {};
var key = opts.key || identity;
var start = opts.start || 0;
var end = opts.end || this.length;
for (var i = 0; i < this.length; i++) {
if (test(key(this[i]))) {
return this[i];
}
}
@zkat
zkat / gist:4993214
Last active December 13, 2015 23:39
wondering about this coffeescript thing
/*
* Some quick hand-translations of code found in http://coffeescript.org/
* I know they're trying to show off random features, but going through these
* makes me wonder how much convenience CS actually adds.
*/
// # Assignment:
// number = 42
// opposite = true
var number = 42;
@zkat
zkat / gist:4683154
Last active December 12, 2015 00:19
How should this be converted?
cowboy:start_http(
?MODULE, 100,
[{port, Port}],
[{dispatch,
[{'_',
[{[<<"static">>, '...'],
cowboy_static,
[{directory,
{priv_dir, mymod,
[<<"www">>, <<"static">>]}},
@zkat
zkat / gist:4075454
Last active October 12, 2015 19:27
mouse-copy keyboard-based replacement
;; Somewhat similar to mouse-copy functionality, but no rat involved
(defun save-current-point ()
(interactive)
(point-to-register 'p)
(message "Current point saved"))
(defun load-last-point ()
(interactive)
(jump-to-register 'p))
@zkat
zkat / gist:2936463
Last active October 6, 2015 04:28
I want this over here, please
(global-set-key (kbd "C-M-s") 'save-current-point)
;; (global-set-key (kbd "C-c p") 'load-last-point)
(global-set-key (kbd "C-M-y") 'yank-to-last-point-and-indent)
(defun save-current-point ()
(interactive)
(point-to-register 'p)
(message "Current point saved"))
(defun load-last-point ()
@zkat
zkat / *slime-scratch*.txt
Last active October 5, 2015 22:17
'mock' fdefinitions
(defmacro with-fdefinition ((name lambda-list &body tmp-body) &body body)
(let ((old-fdef-var (gensym "OLD-FDEF"))
(name-var (gensym "NAME")))
`(let* ((,name-var ',name)
(,old-fdef-var (fdefinition ,name-var)))
(unwind-protect
(progn
(setf (fdefinition ,name-var)
(lambda ,lambda-list ,@tmp-body))
,@body)
@zkat
zkat / gist:2591434
Created May 4, 2012 02:20
Automated Pokewar Victory
// Paste this into a console on the Facebook poke page, challenge a friend.
setInterval(function () {
var iterator = document.evaluate("//a[contains(@ajaxify, 'poke_inline.php')]", document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
try {
var thisNode = iterator.iterateNext();
while (thisNode) {
console.log('poking');
thisNode.click();
thisNode = iterator.iterateNext();
}
@zkat
zkat / gist:2242525
Last active October 2, 2015 12:18
selenium error
WebDriverException - Element is not clickable at point (81.5, 218). Other element would receive the click: (WARNING: The server did not provide any stacktrace information); duration or timeout: 65 milliseconds
Build info: version: '2.11.0', revision: '14431', time: '2011-10-28 16:27:42'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-33-server', java.version: '1.6.0_20'
Driver info: driver.version: RemoteWebDriver' ; Screenshot: available via screen ; Stacktrace: Method newInstance threw an error in None