Skip to content

Instantly share code, notes, and snippets.

[Adblock Plus 2.0]
! Title: cbs adblock
! Version: 1
! Expires: 1 days
! cbs https://adblockplus.org/forum/viewtopic.php?f=2&t=21002&sid=44caa2415db4ba23cdd8bd503379dd03&start=390#p150134
@@||pubads.g.doubleclick.net/gampad/ads?*rule=$domain=cbs.com
@@|http://$xmlhttprequest,image,domain=cbs.com
@@/adblock$domain=cbs.com
@@||ifmnwi.club$domain=cbs.com
@JLarky
JLarky / html_encode.ex
Created April 28, 2017 21:34
Encode html entities or escape html with Elixir and xmerl Erlang module
defp html_encode(text) do
[_ | xml] = :xmerl.export_simple([{:xmlText, [], 0, [], text, :text}], :xmerl_xml)
:erlang.iolist_to_binary(xml)
end
@JLarky
JLarky / encode_uri_rfc3986_binary.erl
Last active April 8, 2018 14:06
Erlang url encode with unicode/utf8 support working on binary instead of lists/strings
-module(encode_uri_rfc3986_binary).
-author('Renato Albano <[email protected]>').
-author('JLarky <[email protected]>').
-export([encode/1]).
%% Taken from <http://erlangexamples.com/>,
%% from <http://github.com/CapnKernul/httparadise>
%% and <http://www.erlang.org/doc/man/edoc_lib.html>
@JLarky
JLarky / grapheme-splitter.d.ts
Created August 1, 2017 07:32
grapheme-splitter typescript type declaration
// import GraphemeSplitter = require("grapheme-splitter");
// console.log((new GraphemeSplitter()).splitGraphemes("🌷🎁💩😜👍🏳️‍🌈"));
declare module 'grapheme-splitter' {
class GraphemeSplitter {
constructor();
public splitGraphemes(input: string): string[];
public countGraphemes(input: string): number;
}
@JLarky
JLarky / action.ts
Last active December 17, 2019 16:31
type safe redux actions (typescript)
// like typesafe-actions
export type AnyAction<T extends string, A> = A & {
type: T;
};
export function createAction<T extends string, P, AC extends (...args: any[]) => AnyAction<T, P>>(
type: T,
map: AC
): AC & { type: T } {
export type Left<L> = { left: L };
export type Right<R> = { right: R };
export type Either<L, R> = Left<L> | Right<R>;
export function isLeft<L, R>(value: Either<L, R>): value is Left<L> {
return "left" in value;
}
export function isRight<L, R>(value: Either<L, R>): value is Right<R> {
return "right" in value;
var fs = require("fs");
var path = require("path");
var pdf2img = require("pdf2img-lambda-friendly");
var input = __dirname + "/test.pdf";
pdf2img.setOptions({
type: "png", // png or jpg, default jpg
density: 600, // default 600
outputdir: __dirname + path.sep + "output", // output folder, default null (if null given, then it will create folder name same as file name)
@JLarky
JLarky / compare_hard_drives_amazon.js
Last active January 17, 2020 05:27
Compare prices of hard drives on amazon which would allow you to see how much you are going to pay per TB
$$(".s-search-results .s-result-item").map(x => {try{const name = x.querySelector(".a-price").parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.previousElementSibling.innerText.split("\n")[0]; const v = parseInt(name.replace(/(.*) ([0-9+]+)[TG]B(.*)/, '$2')); const p = parseFloat(x.querySelector(".a-price .a-offscreen").innerText.replace("$", "")); return {name, s: p/v, p, v}} catch(e) {return {}}}).sort((a,b) => a.s - b.s)
// OR
$$(".s-search-results .s-result-item")
.map(x => {
try {
const name = x
.querySelector(".a-price")
.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.previousElementSibling.innerText.split(
@JLarky
JLarky / console.ex
Created March 12, 2020 22:45
Utility to replace your regular IO.inspect with some nice Console.log
defmodule Console.Implementation do
defmacro __using__(_opts) do
quote do
@not_set :this_parameter_was_NoT_set
require Logger
def f(args) do
values = Enum.take_while(args, &(&1 != @not_set))
values = Enum.map(values, &Kernel.inspect/1)
Enum.join(values, ", ")
{ stdenv, fetchurl, unzip }:
# this is more stupid version of https://github.com/denoland/deno_install/blob/master/install.sh
# Run this to get last version:
# curl -sSf https://github.com/denoland/deno/releases | grep denoland/deno/releases/downloa | grep -e x86_64-apple-darwin -e x86_64-unknown-linux-gnu | head -2
# based on https://qiita.com/kimagure/items/de2a4ff45dd8fe8be4b1
stdenv.mkDerivation rec {
name = "deno-${version}";