Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
If you want a reply on something please tag me @framp

Federico Rampazzo framp

:octocat:
If you want a reply on something please tag me @framp
View GitHub Profile
View paypal-invoice-rates.js
//npm i --save request request-promise
const fs = require("fs");
const request = require("request-promise");
const getHMRCMonth = (date) =>
(date.getMonth() < 9 ? "0" : "") +
[date.getMonth() + 1, date.getYear() % 100].join("");
const hmrcBasePage = (year) =>
`https://www.gov.uk/government/publications/hmrc-exchange-rates-for-${year}-monthly`;
@framp
framp / Cargo.toml
Created Nov 11, 2020
rust opencv test
View Cargo.toml
[package]
name = "rust-ela"
version = "0.1.0"
edition = "2018"
[dependencies]
opencv = {version = "0.46", features = ["contrib"]}
View thank-you-ny-times.js
// ==UserScript==
// @name Thank you NY Times
// @namespace nytimes.com
// @version 0.1
// @description Thank you NY Times
// @author You
// @match *://*.nytimes.com/*
// @grant none
// ==/UserScript==
View face-api-test.js
/*
nvm use 14
cp -R ../face-api-js-master/weights .
echo {} > package.json
npm i --save @tensorflow/tfjs@2.6.0 @tensorflow/tfjs-node@2.6.0 canvas face-api.js
Doesn't work with tfjs-node@2.7.0
package.json:
{
View run.py
from __future__ import division
import math
import numpy as np
import tensorflow as tf
from PIL import Image
net_model = tf.keras.models.load_model('NIvsCG_sgd_lr-1e-5_WITH_REDUCE-LR.28-0.29.h5')
## images here
images = []
@framp
framp / so_meta.ts
Last active Sep 3, 2020
Get a list of keys from a TS interface (and kill some kittens on the way)
View so_meta.ts
// npm install --save recast babylon@next @types/node
import * as recast from "recast";
import * as typescriptParser from "recast/parsers/typescript";
import * as fs from "fs";
export interface IMyTable {
id: number;
title: string;
createdAt: Date;
View NumericInput.jsx
export default (props) => (
<input
onKeyDown={(event) => {
const { keyCode } = event;
if (
(keyCode >= 8 && keyCode <= 9) || //BACKSPACE and TAB
(keyCode >= 37 && keyCode <= 40) || // Arrows
keyCode === 46 || //DEL
keyCode === 190 || //DEL
(keyCode >= 48 && keyCode <= 57) || // Numbers
View pinchAndZoom-panning-rotation.html
<html>
<head>
<title>Pinch and Zoom + Panning + Rotation</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style>
html,body {
overscroll-behavior-x: none;
overscroll-behavior-y: none;
touch-action: none;
height: 100%;
View canarias-real-estate.fish
set url "http://www.cardenas-grancanaria.com/search-results.asp?FirstRecord=1&txtRC=R&txtOperacion=1&txtLocation=&txtPropType=1%2C2%2C3%2C4%2C+5%2C6%2C7%2C8%2C9%2C+19%2C20&txtBeds=&txtMinPrice=0&txtMaxPrice=&txtPool=&txtParking=&txtNewDev=&txtSeaView=&txtLux=False&txtI=False&txtSF=False&txtRF=False&pagesize=300&price_order=DESC"
curl $url | rg -o 'href\s*="([^"]+for-sale[^"]+)"' | sd '(^href="|"$)' '' | uniq > properties
xargs -n 1 curl -O < properties
rg -oe '(Type|Location|Bedrooms|Bathrooms|Build Size|Living Area|Price) : </b></td><td>(.*?)</td>' | sd "<[^<]*>" "" | sd " : " ":" | node -e 'console.log("ID;Type;Location;Bedrooms;Bathrooms;Build Siz;Living Area;Price") || console.log(Object.values(fs.readFileSync("/dev/stdin").toString().split("\\n").filter(Boolean).map(a => a.split(":")).reduce((acc, [id, type, val]) => ({ ...acc, [id]: { ...(acc[id] || {}), Id: id.replace(".htm", ""), [type]: val.trim().replace(/\\s+/g, " ") } }) , {})).filter(({ Price }) => Number(Price.split(" ")[0].replace(/\\./,""))).s
View randommac.sh
#!/bin/sh
sudo ip link set down dev wlp3s0 && sudo ip link set dev wlp3s0 address $(tr -dc A-F0-9 < /dev/urandom | head -c 10 | sed -r 's/(..)/\1:/g;s/:$//;s/^/02:/') && sudo ip link set up dev wlp3s0