Skip to content

Instantly share code, notes, and snippets.

@renatoaraujoc
renatoaraujoc / modify_table_primary_key.sql
Last active September 27, 2019 19:09
Modify MySQL Table ID DataType with FKs
SET global group_concat_max_len = 4294967295;
SET @tableSchema = "SCHEMA_HERE";
SET @tableName = "TABLE_HERE";
SET @tablePrimaryDefinition = "int(10) unsigned not null auto_increment";
SET @referencedTablesColumnDefinition = "int(10) unsigned";
SELECT DISTINCT kcu.TABLE_NAME,
kcu.TABLE_SCHEMA,
kcu.COLUMN_NAME,
kcu.CONSTRAINT_NAME,
kcu.REFERENCED_TABLE_NAME,
@fredericogg
fredericogg / playlist_time.js
Last active August 14, 2024 19:01
Calcula o tempo total de uma playlist no Youtube. É só colar no console na página da playlist. Fiz esse script porque não achei o tempo total da playlist 😅.
(function() {
var timeSeconds = 0;
var timestampDivList = document.querySelectorAll(".timestamp");
for(var i = 0; i < timestampDivList.length; i++) {
var timestampDiv = timestampDivList[i];
@joshnuss
joshnuss / app.js
Last active October 10, 2024 17:37
Express.js role-based permissions middleware
// the main app file
import express from "express";
import loadDb from "./loadDb"; // dummy middleware to load db (sets request.db)
import authenticate from "./authentication"; // middleware for doing authentication
import permit from "./authorization"; // middleware for checking if user's role is permitted to make request
const app = express(),
api = express.Router();
// first middleware will setup db connection
@xem
xem / gist:670dec8e70815842eb95
Last active January 19, 2023 22:43
beep boop
<!-- solution 1, 117b, inspired by http://www.p01.org/releases/140bytes_music_softSynth/ -->
<button onclick="new Audio('data:audio/wav;base64,UklGRl9vT19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YU'+Array(1e3).join(123)).play()">Beep</button>
<!-- Solution 2, 107b, inspired by http://xem.github.io/chip8/c8.html -->
<button onclick="o=(A=new AudioContext()).createOscillator();o.connect(A.destination);o.start(0);setTimeout('o.stop(0)',500)">Boop</button>
@benjamincharity
benjamincharity / zepto.smoothScroll.js
Last active October 4, 2019 15:21 — forked from austinpray/zepto.smoothScroll.js
Smooth scrolling with Zepto.js
function smoothScroll(el, to, duration) {
if (duration < 0) {
return;
}
var difference = to - $(window).scrollTop();
var perTick = difference / duration * 10;
this.scrollToTimerCache = setTimeout(function() {
if (!isNaN(parseInt(perTick, 10))) {
window.scrollTo(0, $(window).scrollTop() + perTick);
smoothScroll(el, to, duration - 10);
@TexRx
TexRx / vanilla-not-jquery.js
Created June 5, 2013 04:44
Pure JS alternatives to common CSS class jQuery functions
function hasClass(elem, className) {
return new RegExp(' ' + className + ' ').test(' ' + elem.className + ' ');
}
function addClass(elem, className) {
if (!hasClass(elem, className)) {
elem.className += ' ' + className;
}
}
@kapkaev
kapkaev / gist:4619127
Created January 24, 2013 09:30
MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. Resque
$ redis-cli
> config set stop-writes-on-bgsave-error no
@Whoaa512
Whoaa512 / app.html
Last active August 7, 2017 17:44
Meteor code to user FB.ui & the FB SDK
<body>
{{#constant}}
<div id="fb-root"></div>
{{/constant}}
<div> {{> fb_pic}} {{loginButtons}}</div>
<br />
<div><h2>Click to post to your feed:</h2> {{> feed}} </div>
</body>