Skip to content

Instantly share code, notes, and snippets.

@tomasdev
tomasdev / uuid-v4.js
Last active February 26, 2018 04:50
JavaScript UUID Generation using RFC4122 v4 (Random)
// 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
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
// 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 November 18, 2023 15:00
JavaScript dominant color for image

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);
@tomasdev
tomasdev / gist:b526c5ddfa06a417297012d6a46b36b0
Last active October 27, 2017 18:11
https://files.fm/u/u7x6q9t7 IS A VIRUS wp-gif-player download link

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

// This file is overwritten whenever you change your user settings in the game.
// Add custom configurations to the file "userconfig.cfg".
unbindall
bind "TAB" "+showscores"
bind "ENTER" "+attack"
bind "ESCAPE" "cancelselect"
bind "SPACE" "+jump"
bind "'" "+moveup"
bind "+" "sizeup"
@tomasdev
tomasdev / contentful-ui-extension.html
Created June 6, 2017 15:32
Minimum HTML required for a Contentful extension
<!DOCTYPE html>
<html>
<head>
<!-- the following is optional -->
<link rel="stylesheet" type="text/css" href="https://unpkg.com/contentful-ui-extensions-sdk@2/dist/cf-extension.css">
</head>
<body>
<h1>Hello World</h1>
<script src="https://unpkg.com/contentful-ui-extensions-sdk@2"></script>
<script>
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
@tomasdev
tomasdev / google_twunter_lol
Created November 28, 2016 22:30 — forked from jamiew/google_twunter_lol
All the dirty words from Google's "what do you love" project: http://www.wdyl.com/
easterEgg.BadWorder.list={
"4r5e":1,
"5h1t":1,
"5hit":1,
a55:1,
anal:1,
anus:1,
ar5e:1,
arrse:1,
arse:1,
class StickerBrowserViewController: MSStickerBrowserViewController {
let stickerNames = ["piggie_cute", "piggie_bowing", "piggie_waving", "piggie_crying", "piggie_laughing", "piggie_winking", "professor_pig", "piggie_cheering", "piggie_scorning", "piggie_swooning", "wtf", "870194"]
var stickers = [MSSticker]()
weak var delegate: StickerBrowserViewControllerDelegate?
override func viewDidLoad() {
super.viewDidLoad()
loadStickers()