Skip to content

Instantly share code, notes, and snippets.

View andreyuhai's full-sized avatar
🏠
Working from home

Burak andreyuhai

🏠
Working from home
View GitHub Profile
@andreyuhai
andreyuhai / avg_compare.sql
Created December 4, 2018 14:12
Compare AVG with some other cell
select
cust_id,
gender,
weight
from customer c
WHERE weight > (SELECT AVG(weight)
FROM customer
WHERE gender = c.gender)
order by c.gender
@andreyuhai
andreyuhai / case_usage.sql
Created December 4, 2018 14:13
How to use CASE in MS SQL
WITH Orders (customerID, orderNum) AS
(
SELECT CustomerID, COUNT(*) 'number of orders'
FROM Sales.SalesOrderHeader
GROUP BY CustomerID
)
SELECT customerID, 'Value' =
CASE
WHEN orderNum > (SELECT (AVG(CAST(orderNum AS FLOAT)))
FROM Orders
@andreyuhai
andreyuhai / card_columns.html
Created December 9, 2018 21:19
Card columns bootstrap
<div class="card-columns">
<div class="card">
<img class="card-img-top" src="..." alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title that wraps to a new line</h5>
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
</div>
<div class="card p-3">
<blockquote class="blockquote mb-0 card-body">
@andreyuhai
andreyuhai / App.java
Last active January 6, 2019 03:04
How to get a button do more than one action in Java
// Just set the action command and test it in the action listener
// Once clicked this button below it pauses the thread, and when clicked once again it notifies thread to resume. Kinda start/stop
pauseButton.addActionListener(e -> {
if (e.getActionCommand().equals("resume")) {
accountCheckerBot.setRunning(true);
pauseButton.setActionCommand("pause");
pauseButton.setText("Pause");
synchronized (accountCheckerBot) {
accountCheckerBot.notify();
}
@andreyuhai
andreyuhai / sync_forked_repo.md
Last active January 8, 2019 23:46
How to sync a forked repo with the original one

How to sync a forked repo with the original one

First add your upstream

git remote -v

git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

git remote -v

@andreyuhai
andreyuhai / alias_laravel_project.md
Last active January 8, 2019 23:47
How to setup an alias for laravel project

How to set up an alias for your laravel project in a folder other than /var/www/html

Put your alias configuration in /etc/apache2/mods-enable/alias.conf

Alias /alias "/home/user/your_laravel_project_folder_/public"

    <Directory "/home/user/your_laravel_project_folder_/public">
            Options Indexes FollowSymLinks Includes ExecCGI MultiViews
            AllowOverride All

Require all granted

@andreyuhai
andreyuhai / composer_laravel.md
Last active January 8, 2019 23:48
Creating projects with composer

How to create laravel projects

To create laravel dependent projects using composer:

composer create-project laravel/laravel your_project_name --prefer-dist

@andreyuhai
andreyuhai / apache2.md
Last active January 8, 2019 23:54
apache2 change the root directory to any other

How to change Apache's root directory to some other directory

You'll have to edit apache2.conf and 000-default.conf to change the document root of apache.

The Apache server is installed on var/www/html.This is the default root directory of apache.

Either change the root directory of Apache or move the project to /var/www/html.

To change Apache's root directory, run:

@andreyuhai
andreyuhai / php_artisan.md
Last active January 9, 2019 09:18
How to create a controller and model with php artisan

How to create a controller and model with php artisan

To create a controller with php artisan just type

php artisan make:controller YourController

If you want to create your controller with resources ( index, update, edit, store...) then

php artisan make:controller YourController --resource

@andreyuhai
andreyuhai / phpmyadmin.md
Last active January 13, 2019 11:15
How to fix phpmyadmin count(): Parameter must be an array or an object that implements Countable

How to fix "count(): Parameter must be an array or an object that implements Countable" error

Just run this below command line in terminal and come back to PhpMyAdmin. Now it works fine

sudo sed -i "s/|\s*\((count(\$analyzed_sql_results\['select_expr'\]\)/| (\1)/g" /usr/share/phpmyadmin/libraries/sql.lib.php

source