This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config --global user.name "User Name" // set user name | |
git config --global user.email "user@email.com" // set user email | |
git config --list // show active settings | |
git help commit // open git manual in browser | |
cd c:/targetdir // change directory | |
git init // create git repository in this directory or reinit existing | |
git status // show info about files status (untracted / unmodified etc) | |
git add . // add all files to unmodified status | |
git commit -m "Comment" // commit files | |
git remote add origin https://github.com/user/repositoryName // set remote repository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
net use X: \\SERVER\Share | |
// привязать к расшареной папке на сетевом ресурсе имя диска (X) | |
xcopy C:\users D:\copy1 /H /Y /C /R /S | |
// скопировать все файлы и подкаталоги ( /S ) с перезаписью существующих без запроса ( /Y ) , включая скрытые и системные. ( /H ) с перезаписью файлов с атрибутом "Только чтение" (/R) и игнорированием ошибок ( /C ) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
npm install rimraf -g | |
rimraf node_modules | |
// Delete folder with all includes | |
rd /s/q path_to_folder | |
rmdir /s/q path_to_folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 1 | |
select column_name, data_type | |
from information_schema.columns | |
where table_name = 'users'; | |
-- 2 | |
SELECT | |
column_name, data_type, character_maximum_length | |
FROM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT count(*) FROM my_table; | |
-- больше способов | |
-- https://habrahabr.ru/post/30046/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE table2 AS SELECT * FROM table1 WHERE 1=2; | |
(This creates the structure only -- no data will be transferred because | |
1 will never equal 2). :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--example 1 | |
INSERT INTO cheap_books (id, note) | |
SELECT id, 'Was in use' | |
FROM Books WHERE id > (SELECT MAX(id) FROM Books) - 3 | |
--example2 | |
INSERT INTO public.table1 (id_user, id_operator, status) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- http://stackoverflow.com/questions/1746213/how-to-delete-duplicate-entries | |
-- Given table table, want to unique it on (field1, field2) keeping the row with the max field3: | |
DELETE FROM table USING table alias | |
WHERE table.field1 = alias.field1 AND table.field2 = alias.field2 AND | |
table.max_field < alias.max_field | |
-- For example, I have a table, user_accounts, and I want to add a unique constraint on email, but I have some duplicates. Say also that I want to keep the most recently created one (max id among duplicates). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* @var Получаем текущее время в миллисекундах и случайное число | |
* и хэшируем полученную строку | |
* | |
*/ | |
$hashe = md5( microtime() . mt_rand() ); | |
# Выводим хэш |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$str = 'the result inside big string'; | |
preg_match("/(?<=the )(.*)(?= inside)/", $str, $result_arr); | |
echo $result_arr[0]; // result | |
/* | |
(?<=) - с чего начинается искомая строка | |
(?=) - чем заканчивается искомая строка | |
(.*) - искомая строка содержит любое количество любых символов | |
PS: хороший конструктор регулярных выражений - http://www.phpliveregex.com/ |
NewerOlder