Skip to content

Instantly share code, notes, and snippets.

Tomas tomasdev

Block or report user

Report or block tomasdev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tomasdev
tomasdev / examples.sh
Created Dec 19, 2019
Guide to patch - diff
View examples.sh
# Create a patch file
diff -u file.old file.new > file.patch
# Apply a patch
patch < file.patch
# Create a backup before applying patch
patch -b < file.patch
# Create a versioned backup before applying patch
@tomasdev
tomasdev / gif.sh
Created Dec 12, 2019
Video to GIF converter (uses ffmpeg)
View gif.sh
#!/bin/bash
printable_colours=256
# DEFAULTS
SIZE=480
FPS=15
LENGTH=2
# Report usage
usage() {
@tomasdev
tomasdev / numbers.js
Created Nov 7, 2019
poorly performance pandigital fractions
View numbers.js
var unique = n => Array.from(new Set((n+'').split(''))).length === (n+'').length
var possibilities1 = []
var possibilities2 = []
var combos = []
for (var i = 1234; i < 9876; i++) {
if (!(i+'').includes('0') && unique(i)) possibilities1.push(i)
}
for (var i = 12345; i < 98765; i++) {
@tomasdev
tomasdev / utils.js
Created Nov 15, 2018
Utilities for easing and animation ala jquery but vanilla javascript
View utils.js
// easing equations from https://github.com/danro/easing-js/blob/master/easing.js
export const EASING = {
linear: x => x,
easeOut: x => Math.sin(x * (Math.PI / 2)),
easeInOut: x => (-0.5 * (Math.cos(Math.PI * x) - 1)),
easeInOutQuint: x => (x /= 0.5) < 1 ? 0.5 * Math.pow(x, 5) : 0.5 * (Math.pow((x - 2), 5) + 2)
};
export const animate = (method, ms = 1000, ease = EASING.easeInOut) => {
const now = () => (window.performance || Date).now();
@tomasdev
tomasdev / mp4-to-gif.sh
Created Feb 9, 2018
MP4 to GIF using FFMPEG
View mp4-to-gif.sh
# Step 1: define video
export VIDEO=name.mp4
# Step 2: create palette to have a better image quality result
ffmpeg -i $VIDEO -vf fps=15,scale=320:-1:flags=lanczos,palettegen palette.png
# Step 3: use the palette to convert the mp4 to gif
ffmpeg -i $VIDEO -i palette.png -filter_complex "fps=15,scale=400:-1:flags=lanczos[x];[x][1:v]paletteuse" $VIDEO.gif
@tomasdev
tomasdev / uuid-v4.js
Last active Feb 26, 2018
JavaScript UUID Generation using RFC4122 v4 (Random)
View uuid-v4.js
// UPDATE: shorter, non RFC compatible, but safe enough version
function guid() {
const s4 = () => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}
// Based off https://github.com/kelektiv/node-uuid
View snapchat-bug-post.js
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
View .hyper.js
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
const foregroundColor = '#f0f8f2';
const backgroundColor = '#272822';
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
@tomasdev
tomasdev / script.md
Last active Dec 13, 2017
JavaScript dominant color for image
View script.md

Inspired by manu.ninja approach there's a front-end (or nodejs if using node-canvas) equivalent without using GraphicsMagick:

const canvas = document.createElement('canvas');
const context = canvas.getContext('2d');
const image = new Image();
image.onload = () => {
    canvas.width = image.width;
    canvas.height = image.height;
    context.drawImage(image, 0, 0, 1, 1);
View gist:b526c5ddfa06a417297012d6a46b36b0

BEWARE https://files.fm/u/u7x6q9t7 THIS IS A VIRUS FOR WORDPRESS. DO NOT INSTALL IT ON YOUR WEBSITE.

A chinese person (in our contact case was AMELIA SMITH (amelia.smith12@outlook.com) is sending emails from outlook dot com saying they'd pay $50 to $100 per month if you install that. It has a backdoor that lets people upload and delete files from your server.

It is not the plugin https://github.com/sketchmouse/wp-gif-player that @dbedenknecht created, since that one (original) doesn't have the sneaky file in question, wp-inc.php

This "Amelia" is claiming to "verify" the plugin is installed in other sites by mentioning a different file, part of the original plugin.

Again, always check with a programmer before manually installing plugins into WordPress that aren't from wp.com

You can’t perform that action at this time.