Skip to content

Instantly share code, notes, and snippets.

💭
(╯°□°)╯︵ ┻━┻

Ingvar Stepanyan RReverser

💭
(╯°□°)╯︵ ┻━┻
Block or report user

Report or block RReverser

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@RReverser
RReverser / determinant.cs
Last active Dec 10, 2015
Functional recursive solution for calculating matrix determinant
View determinant.cs
private double det(IEnumerable<IEnumerable<double>> matrix)
{
return
matrix.Any()
?
matrix
.Select((row, i) =>
(i % 2 == 0 ? +1 : -1)
* row.First()
* det(matrix.Where((curRow, curI) => curI != i).Select(curRow => curRow.Skip(1)))
@RReverser
RReverser / render.js
Last active Dec 20, 2015
Rendering page with PhantomJS with custom dimensions (not possible w/o hack)
View render.js
console.log('Usage: phantomjs render.js URL [width=1024] [height=768] [out=render.png]');
var args = require('system').args;
if (args.length < 2) {
phantom.exit();
}
var page = require('webpage').create();
var rect = page.clipRect = {
@RReverser
RReverser / part.js
Last active Dec 22, 2015
Node.js part description with automatic resolving dependencies by names in argument list (like AngularJS does).
View part.js
function part(name, exec, deps) {
console.log(name + '...');
var code = exec.toString();
if (deps) {
exec = new Function(deps, 'return(' + code + ')()');
} else {
deps =
code
@RReverser
RReverser / notwitterspam.js
Created Jan 27, 2014
Report Twitter spam automatically on search page
View notwitterspam.js
var reportedHash = 'reported' in localStorage ? JSON.parse(localStorage.reported) : {};
(function reportTweets() {
var newTweetsBar = document.querySelector('.new-tweets-bar');
newTweetsBar && newTweetsBar.click();
Array.prototype.map.call(
document.querySelectorAll('.original-tweet'),
function (tweet) {
return tweet.dataset
@RReverser
RReverser / promise-tree.js
Created Apr 17, 2014
Promise Tree traversal
View promise-tree.js
function when(value, func) {
var promise = Promise.cast(value);
if (func) {
promise = promise.then(function (value) {
return Promise.cast(func(value)).then(function (newValue) {
return newValue === undefined ? value : newValue;
});
});
}
View data-emitters.md
feature Promises streams generators
asynchronous
(can push from inner callbacks)
true true false
multiple push false true true
error catch true false false
error forwarding true false true
external dependency is a must false true false
View ObservableStream.js
var stream = require('stream');
var Rx = require('rx');
var util = require('util');
function ObservableStream(transform) {
stream.Duplex.call(this, {objectMode: true});
this.subject = new Rx.Subject();
this.observable = transform(this.subject);
this.subscription = null;
@RReverser
RReverser / index.js
Created Jul 29, 2014
requirebin sketch
View index.js
// just for RequireBin
console.log = function () {
var pre = document.createElement('pre');
pre.textContent = Array.prototype.map.call(arguments, function (arg) {
return typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg;
}).join(' ');
document.body.appendChild(pre);
};
var esprima = require('esprima-fb'), ast;
View gist:3463103840d0706aa80d
function Template(str, data) {
return str.replace(/\${([^}]+)}/g, (_, name) => data[name]);
}
var answer = 42;
(function () {
var answer = 60;
console.log(Template('Answer is ${answer}', {answer}));
})();
View gist:24da7556d656e34a2ab4
### Keybase proof
I hereby claim:
* I am RReverser on github.
* I am rreverser (https://keybase.io/rreverser) on keybase.
* I have a public key whose fingerprint is 3456 B5A0 0E7F 67D8 A049 5B85 7634 8879 1722 011A
To claim this, I am signing this object:
You can’t perform that action at this time.