Skip to content

Instantly share code, notes, and snippets.

View moalex's full-sized avatar
🫛
Farting

moalex moalex

🫛
Farting
View GitHub Profile

ImageMagic Color Invert

ImageMagick 6

Can invert color intensities with -negate option only)

[-negate][neg]

@moalex
moalex / string-is-empty.sh
Created October 12, 2021 11:58
bash :: Пустая ли строка
#!/bin/bash
val1="testing"
val2=''
### Не пустая ли строка
if [ -n $val1 ]; then
echo "Строка '$val1' не пустая"
else
echo "Строка '$val1' пустая"
@moalex
moalex / aria2c.md
Last active January 22, 2024 18:09
@moalex
moalex / renamed.sh
Created February 22, 2021 15:51
This utility will find <Search> string and replace it with <Replacement> string in all files in current folder including their both filename and contents.
#!/bin/bash
cat <<EOF
This utility will find <Search> string and replace it with <Replacement> string
in all files in current folder including their both filename and contents
EOF
# check if GNU rename utility exists
if [ ! -f /usr/local/bin/rename ]

Batch convert

The simplest solution is like most already posted. A simple bash for loop.

for i in *.png
do
  convert "$i" "${i%.*}.jpg"
done
@moalex
moalex / document.ready.ts
Created April 1, 2019 22:58 — forked from supermoos/main.ts
TypeScript jQuery document ready
///<reference path="./typings/jquery/jquery.d.ts"/>
'use strict';
class Main {
constructor() {
jQuery(document).ready(() => {
console.log('Hello from app/scripts/ts/Main.ts');
});
}
}

Generating a new SSH key

  1. Open Terminal.

  2. Paste the text below, substituting in your GitHub email address.

    ssh-keygen -t rsa -b 4096 -C "trofimoff@live.ru"

PHP - POST JSON Data with cURL

<?php
$data = array("name" => "Hagrid", "age" => "36");                                                                    
$data_string = json_encode($data);                                                                                   
                                                                                                                     
$ch = curl_init('http://api.local/rest/users');                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     

cURL

15 Practical Command Examples

cURL is a software package which consists of command line tool and a library for transferring data using URL syntax.

cURL supports various protocols like, DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP.

jQuery - Создание плагина

Как вы уже знаете, одним из главных качеств библиотеки jQuery является очень удобный поиск элементов и возможность дальнейших манипуляций с ними. Так вот, список этих манипуляций можно расширять, организуя новые методы для объекта jQuery. Вынесенные в отдельный файл, такие расширения образуют плагины для библиотеки jQuery.

Далее, описывая правила создания собственных плагинов мы будем реализовывать отдельный полноценный плагин в качестве примера. Его функциональность будет состоять в добавлении нового поведения для выбранных элементов — изменение цвета при наведении курсора. Назовем плагин responsiveBlock (отзывчивый блочный элемент).

Подключение