Skip to content

Instantly share code, notes, and snippets.

@llagerlof
llagerlof / dbdiff-how-to.md
Created August 1, 2018 12:11
How to use DBDiff to discover differences between databases' tables structures

How to use DBDiff

https://github.com/DBDiff/DBDiff

  • Create a .dbdiff file in project root directory with the connection settings for 2 servers. Add to "tablesToIgnore" a list of tables and views that should be ignored on comparisson.

.dbdiff

server1:
 user: root
@llagerlof
llagerlof / PhabricatorAnnoyanceRemover.user.js
Last active February 8, 2025 18:18
Phabricator task edit's textarea height is auto adjusted to content. All comment entries that aren't true comments are removed from view. Task view and task edit font is set to Courier New.
// ==UserScript==
// @name Phabricator Annoyance Remover
// @description Task view description and task edit description font is set to Courier New. The edit description height is auto adjusted to content. All comment entries that aren't true comments are removed from view.
// @namespace https://github.com/llagerlof/
// @author 2018, Lawrence Lagerlof (https://github.com/llagerlof)
// @license MIT
// @include /https?:\/\/.*\/maniphest\/task\/edit\//
// @include /https?:\/\/.*\/T[0-9]+(?:#([0-9]+))?$/
// @require https://cdnjs.cloudflare.com/ajax/libs/autosize.js/4.0.2/autosize.min.js
// @version 1.3
@llagerlof
llagerlof / CSS_insertRule_example.js
Created August 28, 2018 12:11
How to change CSS rules dinamically
/*
source: https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule
*/
var styleElement = document.createElement('style');
document.head.appendChild(styleElement);
styleSheet = styleElement.sheet;
styleSheet.insertRule("p, h1, h2, h3 {font-family: Courier New; color: blue;", 0);
@llagerlof
llagerlof / duplicate_mysql_database.sh
Created September 3, 2018 13:14
How to duplicate a entire MySQL database to another one in the same MySQL server
# Use the -p flag if needed:
mysqldump -u root db_with_data | mysql -u root db_empty
# If you have the error
# "mysqldump: Got error: 1449: The user specified as a definer ('someuser'@'someaddress')
# does not exist when using LOCK TABLES",
# create the missing user:
mysql> create user 'someuser'@'someaddress';
# Run the dump:
@llagerlof
llagerlof / generateCallTrace.php
Last active February 23, 2022 09:35
PHP function to generate a human readable call trace.
<?php
/**
* generateCallTrace() function
*
* A function for getting a nice and comprehensible call trace.
* It is probably more resource-intensive than some other alternatives but it is short,
* understandable, and gives nice output (Exception->getTraceAsString()).
*
* @package generateCallTrace
* @version 1.0
@llagerlof
llagerlof / kill_oracle_connections_by_session.sql
Last active March 26, 2019 13:41
How to kill oracle connections by session
SELECT * FROM V$SESSION WHERE SCHEMANAME = 'MYSCHEMA' AND MACHINE = 'applicationserver.localdomain' AND STATUS = 'INACTIVE';
ALTER SYSTEM KILL SESSION '87,33311'; -- SID,SERIAL
ALTER SYSTEM DISCONNECT SESSION '87,33311' IMMEDIATE;
@llagerlof
llagerlof / identify_foreign_key_oracle.sql
Created April 4, 2019 14:08
Identify a Oracle constraint or foreign key rule by its name.
/*
USE REF_CONSTRAINT IF ITS A FOREIGN KEY.
USE CONSTRAINT IF ITS ANOTHER TYPE OF CONSTRAINT.
*/
SELECT DBMS_METADATA.GET_DDL('REF_CONSTRAINT', 'FK_HUMAN_PLANET') FROM dual;
@llagerlof
llagerlof / count_bytes.sh
Created June 28, 2019 17:50
Count bytes in files grouping by byte number
#!/bin/bash
# Thanks Stephen Kitt (https://unix.stackexchange.com/a/527524/273356)
od -t x1 -w1 -v -An mybinaryfile | sort | uniq -c
Delete node and/or node_modules from /usr/local/lib
Delete node and/or node_modules from /usr/local/include
Delete node, node-debug, and node-gyp from /usr/local/bin
Delete .npmrc from your home directory (these are your npm settings, don’t delete this if you plan on re-installing Node right away)
Delete .npm from your home directory
Delete .node-gyp from your home directory
Delete .node_repl_history from your home directory
Delete node* from /usr/local/share/man/man1/
Delete npm* from /usr/local/share/man/man1/
Delete node.d from /usr/local/lib/dtrace/
@llagerlof
llagerlof / set_utf8.sh
Last active August 6, 2019 13:36 — forked from panchicore/bash
GIT error on push/pull: "remote: perl: warning: Setting locale failed" [SOLVED]
#!/bin/bash
# perl: warning: Setting locale failed.
# perl: warning: Please check that your locale settings:
# LANGUAGE = (unset),
# LC_ALL = (unset),
# LC_CTYPE = "UTF-8",
# LANG = "en_US.UTF-8"
# are supported and installed on your system.
# perl: warning: Falling back to the standard locale ("C").