Skip to content

Instantly share code, notes, and snippets.

@jorinvo
jorinvo / canvas-filter.html
Last active August 29, 2015 14:02
Demo for Basic Image Filtering Using a Canvas Element
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Demo for Basic Image Filtering Using a Canvas Element</title>
</head>
<body>
<div>
<input type="file" id="loader">
var last = function(fn, l) {
return function() {
var args = Array.prototype.slice.call(arguments);
args.push(l);
return l = fn.apply(null, args);
};
};
const pipeline = (...fns) => (val) => fns.reduce((prom, fn) => prom.then(fn), Promise.resolve(val));
const myPipe = pipeline(
(val) => val + 1,
(val) => val + 1
);
Promise.resolve(1)
.then(myPipe)
.then((result) => {
@Bemmu
Bemmu / tally.js
Last active September 19, 2017 18:24
Highlighting tally
// I had to write this code in just a few minutes to get it ready while my article was still trending.
// I decided to exclude anyone not on desktop Chrome to avoid spending time on browser issues.
// Here I am trying to test if the user is on desktop Chrome.
function onDesktopChrome() {
var pattern = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i;
var isMobile = pattern.test(navigator.userAgent);
if (isMobile) {
return false;
} else {
anonymous
anonymous / pipe.clj
Created December 18, 2012 12:49
(defn pipe
"Returns a vector containing a sequence that will read from the
queue, and a function that inserts items into the queue.
Source: http://clj-me.cgrand.net/2010/04/02/pipe-dreams-are-not-necessarily-made-of-promises/"
[]
(let [q (LinkedBlockingQueue.)
EOQ (Object.)
NIL (Object.)
s (fn queue-seq []

Follow the dirty money

A shady Internet business has been discovered.

The website has been made public by a whistle blower. We have enough evidence about the dirty deals they did. But to charge them we need to get hands on precise numbers about the transactions that happened on their platform.

Unfortunately no record of the transactions could be seized so far. The only hint we have is this one transaction:

clj -m cljs.main -re nashorn
(def thread (.type js/Java "java.lang.Thread"))

(let [global-atom-lock
      (let [ctor (.type js/Java "java.util.concurrent.locks.ReentrantLock")]
        (new ctor))]
@justinmc
justinmc / svgclass.js
Last active August 5, 2018 15:05 — forked from shshaw/svgclass.js
(function($){
/* addClass shim
****************************************************/
var addClass = $.fn.addClass;
$.fn.addClass = function(value) {
var orig = addClass.apply(this, arguments);
var elem,
i = 0,
package main
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"plugin"
@taylorwood
taylorwood / google-redirect.md
Created June 21, 2019 19:35
Google Redirect (Beta)

Google Redirect (Beta)

Google has a https://www.google.com/url?q= endpoint that redirects to q, and it turns out you can nest these recursively and it'll 302 redirect you to each one in succession.

So here's the the most inefficient link to Google that will fit in a Tweet:

https://www.google.com/url?q=https%3A%2F%2Fwww.google.com%2Furl%3Fq%3Dhttps%253A%252F%252Fwww.google.com%252Furl%253Fq%253Dhttps%25253A%25252F%25252Fwww.google.com%25252Furl%25253Fq%25253Dhttps%2525253A%2525252F%2525252Fwww.google.com

Here's some Clojure I used to make the link: