Skip to content

Instantly share code, notes, and snippets.

View simonewebdesign's full-sized avatar
🇺🇦
💙 💛

Simone Vittori simonewebdesign

🇺🇦
💙 💛
View GitHub Profile
@simonewebdesign
simonewebdesign / regex.rb
Created April 21, 2014 22:49
Sublime Text find/replace anything (code) between HTML tags
find: <pre>(((?!<\/pre>).|\n)+)<\/pre>
replace: ``` javascript\n$1\n```
@simonewebdesign
simonewebdesign / editor-demo.html
Created April 17, 2013 20:06
How to make a real-time in-browser editor with the HTML5′s contenteditable attribute -
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title contenteditable>Hey, buddy!</title>
<style class="default">
* {
transition: all .5s ease;
}
@simonewebdesign
simonewebdesign / fullscreen3.js
Last active October 15, 2021 19:34
JavaScript Full Screen API (completely cross-browser!)
// quando clicco su enterfullscreen:
// vai in fullscreen
// all'entrata in fullscreen:
// mostra pulsante exitfullscreen
// nascondi header e footer
// quando clicco su exitfullscreen:
// esci da fullscreen
@simonewebdesign
simonewebdesign / postgres.sh
Last active May 7, 2021 18:05
Postgres Cheatsheet for Linux and macOS: Login on psql and create a new user role. Also dump and restore.
# Install postgres first (e.g. OS X):
brew install postgres
# After installation... if user not created:
# This is a wrapper around CREATE ROLE, you might not have it.
# BTW, a role is the same as a user.
# A role is an entity that can own database objects and have database privileges;
# a role can be considered a "user", a "group", or both depending on how it is used.
createuser --superuser postgres # -s works as well
@simonewebdesign
simonewebdesign / gpg.md
Last active November 17, 2020 18:58
My GPG Cheatsheet

GPG Getting Started

Initial setup - Make sure you installed:

brew install gnupg pinentry-mac

You also have to do:

export GPG_TTY=$(tty)
@simonewebdesign
simonewebdesign / applyDebug.js
Last active September 16, 2020 20:30
Debugging a JS app with Aspect Oriented Programming
function applyDebug(obj) {
for (var f in obj) {
if (obj.hasOwnProperty(f) && typeof obj[f] === 'function') {
console.log(obj[f].toString());
origFunc = obj[f];
obj[f] = function () {
console.debug("called at " + new Date());
return origFunc.apply(this, arguments);
/*
Common vector operations
Author: Tudor Nita | cgrats.com
Version: 0.51
*/
function Vec2(x_,y_)
{
this.x = x_;
this.y = y_;
@simonewebdesign
simonewebdesign / self.rb
Last active April 3, 2020 17:21
A self-reproducing Ruby program
#!/usr/bin/env ruby
puts File.read $0 # This is cheating, I know
@simonewebdesign
simonewebdesign / example.erl
Created March 26, 2017 16:08
tail-recursive sum in Erlang and LFE
sum(L) -> sum(L,0).
sum([], Total) -> Total;
sum([H|T], Total) -> sum(T, H+Total).
@simonewebdesign
simonewebdesign / snake.p8
Created July 25, 2019 22:34
Snake in PICO-8 — work in progress
pico-8 cartridge // http://www.pico-8.com
version 16
__lua__
x=64
y=64
dir=nil
l=0
r=1
u=2
d=3