Skip to content

Instantly share code, notes, and snippets.

View morten-olsen's full-sized avatar
🤖

Morten Olsen morten-olsen

🤖
View GitHub Profile
@morten-olsen
morten-olsen / async.js
Last active August 29, 2015 14:01
A collection of front end scripts (1.3KB gzipped)
window.R.def('async', [], function (exports) {
exports.handle = function (target, origin) {
var xhr = new XMLHttpRequest();
xhr.onload = function () {
var data = JSON.parse(xhr.responseText);
for (var i = 0; i < data.changes.length; i++) {
window.R.publish('async.changeRequest', data.changes[i]);
}
};
if (target.tagName = 'form') {
@morten-olsen
morten-olsen / install.sh
Last active June 20, 2017 20:14
My "get up and running in VIM" script
sudo rm -R ~/.vim
cat > ~/.vimrc << EOF
set nu
execute pathogen#infect()
syntax on
filetype plugin indent on
set t_Co=256
set mouse=a
@morten-olsen
morten-olsen / demo.html
Last active August 29, 2015 14:02
Very minimal function primer... and a pub sub system, which fit inside a tweet, just for god messure
<html>
<head>
<script src="primer.js"></script>
</head>
<body>
<button p-click="demo|notYetReady('test')">Try</button>
<script>
setTimeout(function () {
window.notYetReady = function (msg) {
alert(msg)
function foo() {
return {
hello: 'world'
};
}
function bar()
{
return
{
delay=5; prev=`du -sk .git/ | cut -f 1`; sleep $delay; while true; do cur=`du -sk .git/ | cut -f 1`; expr \( $cur - $prev \) / $delay ; prev=$cur; sleep $delay; done
@morten-olsen
morten-olsen / iwillhuntyou.js
Last active August 29, 2015 14:13
Some fun with XSS
(function IWillHuntYou () {
var stupidUser = false, // Never say that I am not an optimist
attack = function (window) {
// Add your attack here, It will be called each time a new page is loaded
// Example:
// window.document.documentElement.addEventListener('submit', function (evt) {
// sendTargetFormToEvilServerBeforeSubmitting();
// });
};
@morten-olsen
morten-olsen / compression.js
Last active August 29, 2015 14:16
Calculations of an compression algorithm which can (should, very slightly) compress random data
console.clear();
var targetReduction = 22, // Decompressor in KB
patternBytes = 1,
sequenceLengths = [4,5],
blocksize = 4; // Block size of FS in KB
// ---- Lot of technical mumbo-jumbo
var logs = [],
totalCompression = 0,
@morten-olsen
morten-olsen / 01 - find.js
Last active August 29, 2015 14:21
A simple gist for easily extracting elements from a DOM element into a pretty hierarchical structure
Node.prototype.find = function (elms) {
if (typeof elms === 'string') {
return this.querySelector(elms);
}
var result = {};
for (var key in elms) {
result[key] = this.find(elms[key]);
}
return result;
};
$psPath = ([environment]::getfolderpath("mydocuments") + '\WindowsPowerShell')
$modulePath = $psPath + '\Modules'
$modulePathExists = Test-Path $modulePath
if ($modulePathExists -eq $false)
{
New-Item $modulePath -type directory
}
$modulesource = 'https://gist.githubusercontent.com/mortenolsendk/afdd9e2db9f1bea476d4/raw/modules.ps1'
import React, { PropTypes, Component } from 'react';
import { connect as reduxConnect } from 'react-redux';
export class Split extends Component {
static get childContextTypes() {
return {
stateMap: PropTypes.func,
};
}