Skip to content

Instantly share code, notes, and snippets.

View pachacamac's full-sized avatar
🌶️
Mmmmhmmmm

Marc pachacamac

🌶️
Mmmmhmmmm
  • Hacker/Founder
  • Germany, Berlin
View GitHub Profile
@pachacamac
pachacamac / 0_reuse_code.js
Created October 4, 2015 23:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@pachacamac
pachacamac / visualizer.html
Last active September 11, 2015 17:28
visualize stuff with three js
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>visualize</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r71/three.min.js"></script>
<script src="https://mrdoob.github.io/three.js/examples/js/controls/TrackballControls.js"></script>
</head>
<body>
</body>
@pachacamac
pachacamac / more_keywords.rb
Created August 25, 2015 17:09
find usable keywords from documents
require 'set'
documents = {
'http://example.com/politic/china' => "China's central bank cut interest rates and lowered the amount of reserves banks must hold for the second time in two months on Tuesday, ratcheting up support for a stuttering economy and a plunging stock market that has sent shockwaves around the globe.",
'http://example.com/politic/election/trump' => "Thousands of people are expected to stream into an events center here on the banks of the Mississippi River on Tuesday to see Donald Trump. When they do, his presidential campaign will be waiting, looking to convert casual gawkers into hardcore supporters who will cast votes for the billionaire presidential candidate in the Iowa caucuses next year.",
'http://example.com/worldnews/syria' => "Islamic State militants published photos on Tuesday purporting to show the destruction of a Roman-era temple in the ancient Syrian city of Palmyra, an act the U.N. cultural agency UNESCO has called a war crime.",
'http://example.com/worldnews/china'
@pachacamac
pachacamac / tiny_neural_net.rb
Last active August 4, 2016 01:58
simple feed forward network with back propagation learning, used to detect dice
require 'matrix'
class Matrix
def []=(i, j, x); @rows[i][j] = x; end
def size; [self.row_size, self.column_size]; end
end
class Vector
def []=(i, x); @elements[i] = x; end
def length; @elements.length; end
@pachacamac
pachacamac / scrollster.js
Created August 12, 2015 16:35
fuck parallax, use scrollster
var Scrollster = (function(options){
window.requestAnimationFrame = window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(f){setTimeout(f,1000/60)};
var options = options || {}, effects = {}, i = 0, intrinsics = {};
var calculateIntrinsics = function(){
intrinsics = {
scrollHeight: document.body.scrollHeight, // height of entire document
windowHeight: window.innerHeight, // height of browser window
scrollTop: window.pageYOffset // distance scrolled
};
@pachacamac
pachacamac / fbp.rb
Last active August 29, 2015 14:26
Flow Based Programming test
class FBPNode
attr_accessor :inputs, :outputs, :opts, :processor, :input_buffers
def initialize(opts={}, &block)
@inputs = opts[:inputs] || []
@outputs = opts[:outputs] || []
@options = opts[:options] || {}
@name = opts[:name]
@debug = true
@processor = block
@pachacamac
pachacamac / gist:f3b1310b1bbb0bcf8746
Last active August 29, 2015 14:25 — forked from atcuno/gist:3425484ac5cce5298932
HowTo: Privacy & Security Conscious Browsing

The purpose of this "howto" is to document how browsing can be done in a privacy and security conscious manner. This information is compiled from a number of sources, which are referenced throughout the document, as well as my own experiences with the described technologies.

I welcome contributions and comments on the information contained. Please see the "How to Contribute" section for information on contributing your own knowledge.

Table of Contents

function foo(args) {
var i, j, k;
// ...
// j acquires some interesting value
// Who called foo when j took this interesting value?
//
var e = new Error('dummy');
var stack = e.stack.replace(/^[^\(]+?[\n$]/gm, '')
.replace(/^\s+at\s+/gm, '')
@pachacamac
pachacamac / audiobookplayer.html
Created July 12, 2015 12:30
simple html and js based audiobook player project
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AudiobookPlayer</title>
<style>
/*style here*/
</style>
<script src="https://rawgit.com/kolber/audiojs/master/audiojs/audio.min.js"></script>
<script>
@pachacamac
pachacamac / time_in_words.rb
Last active August 29, 2015 14:24
A pretty decent time_in_words method without any dependencies
def time_in_words(to, from=Time.now, opts={})
dist = (to.to_i - from.to_i).abs
prefix, appendix = from > to ? ['',opts[:appendix]||' ago'] : [opts[:prefix]||'in ', '']
raw = [['years',31557600],['months',2592000],['weeks',604800],['days',86400],['hours',3600],['minutes',60],['seconds',1]].map{|u,s|
c = (dist / s).floor
dist -= c * s
c == 0 ? nil : "#{c} #{c == 1 ? u[0...-1] : u}"
}.compact.join(' ')
"#{prefix}#{raw}#{appendix}"
end