Skip to content

Instantly share code, notes, and snippets.

View johonunu's full-sized avatar

Nikola Trifunović johonunu

View GitHub Profile
@shivanshs9
shivanshs9 / rename-database.sql
Last active December 17, 2024 07:43
Rename MySQL Database
DROP PROCEDURE IF EXISTS moveTables;
DROP PROCEDURE IF EXISTS renameDatabase;
DELIMITER $$
CREATE PROCEDURE moveTables(_schemaName varchar(100), _newSchemaName varchar(100))
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE table_name VARCHAR(64);
DECLARE table_cursor CURSOR FOR SELECT information_schema.tables.table_name FROM information_schema.tables
WHERE information_schema.tables.table_schema = _schemaName;
@gsusmonzon
gsusmonzon / custom-entity-not-found-exception-filter.md
Last active June 17, 2025 21:20
Make NestJs returns 404 when EntityNotFoundError exception is thrown

Make NestJs returns 404 when EntityNotFoundError exception is thrown

When using findOrFail() or findOneOrFail() from typeORM, a 500 error is returned if there is no entity (EntityNotFoundError).

To make it returns a 404, use an exception filter as described in https://docs.nestjs.com/exception-filters .

file /src/filters/entity-not-found-exception.filter.ts

@BjornDCode
BjornDCode / gist:5cb836a6b23638d6d02f5cb6ed59a04a
Created February 3, 2020 11:58
Tailwind - Fixed sidebar, scrollable content
// Source: https://twitter.com/calebporzio/status/1151876736931549185
<div class="flex">
<aside class="h-screen sticky top-0">
// Fixed Sidebar
</aside>
<main>
// Content
</main>
@vades
vades / angular-expression-changed.md
Last active January 7, 2026 09:55
Fixing "Expression has changed after it was checked" in Angular

Fixing "Expression has changed after it was checked" in Angular

The exception appears (in the development mode) at the moment the value is checked and value is different of the updated value.

Error message example

AppComponent.html:1 ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngIf: true'. Current value: 'ngIf: false'.
    at viewDebugError (core.js:20440)
    at expressionChangedAfterItHasBeenCheckedError (core.js:20428)
    at checkBindingNoChanges (core.js:20530)
@zhuravljov
zhuravljov / yii2-queue-wait-time-benchmark.md
Created November 4, 2017 13:48
Yii2 Queue Wait Time Benchmark
$ php tests/yii benchmark/waiting fast 1000 10

- gearmanQueue:     MEDIAN = 0.0005 s; AVG = 0.0006 s; MIN = 0.0002 s; MAX = 0.0049 s
- beanstalkQueue:   MEDIAN = 0.0007 s; AVG = 0.0008 s; MIN = 0.0004 s; MAX = 0.0135 s
- redisQueue:       MEDIAN = 0.0013 s; AVG = 0.0014 s; MIN = 0.0006 s; MAX = 0.0056 s
- amqpQueue:        MEDIAN = 0.0016 s; AVG = 0.0020 s; MIN = 0.0007 s; MAX = 0.0595 s
- mysqlQueue:       MEDIAN = 0.8187 s; AVG = 0.7847 s; MIN = 0.0021 s; MAX = 0.9679 s
- fileQueue:        MEDIAN = 0.8408 s; AVG = 0.8332 s; MIN = 0.0407 s; MAX = 0.9703 s
@johonunu
johonunu / gist:d840c1a0e8e2c37e3ba0
Created December 24, 2014 08:00
REDIRECT VIRTUALHOST TO ANOTHER 301
<VirtualHost long-domain-name.example.com:80>
ServerAlias long-domain-name.example.com
DocumentRoot "/var/www/html/example.com"
<Directory "/var/www/html/example.com">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
<VirtualHost short.example.com:80>
@ricardo-rossi
ricardo-rossi / ElasticSearch.sh
Last active February 25, 2025 22:09
Installing ElasticSearch on Ubuntu 14.04
#!/bin/bash
### USAGE
###
### ./ElasticSearch.sh 1.7 will install Elasticsearch 1.7
### ./ElasticSearch.sh will fail because no version was specified (exit code 1)
###
### CLI options Contributed by @janpieper
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch
@anchetaWern
anchetaWern / php-webscraping.md
Created August 4, 2013 13:18
web scraping in php

Have you ever wanted to get a specific data from another website but there's no API available for it? That's where Web Scraping comes in, if the data is not made available by the website we can just scrape it from the website itself.

But before we dive in let us first define what web scraping is. According to Wikipedia:

{% blockquote %} Web scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites. Usually, such software programs simulate human exploration of the World Wide Web by either implementing low-level Hypertext Transfer Protocol (HTTP), or embedding a fully-fledged web browser, such as Internet Explorer or Mozilla Firefox. {% endblockquote %}

@gnarf
gnarf / ..git-pr.md
Last active February 26, 2026 06:25
git pr - Global .gitconfig aliases for Pull Request Managment

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from remotes:

  • git pr 4 - creates local branch pr/4 from the github upstream(if it exists) or origin remote and checks it out
  • git pr 4 someremote - creates local branch pr/4 from someremote remote and checks it out
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: