Skip to content

Instantly share code, notes, and snippets.

@ahadyekta
ahadyekta / convert
Created January 27, 2018 09:51
Batch convert JPG to WebP in Ubuntu
#First install the webp converter by this
sudo apt-get install webp
#go inside the directory where all images are there
#make sure all images are in RGB color mode, otherwise you will get error for CMYK images.
#Convert all images to RGB by this command (you should install ImageMagik to do that)
for f in *.jpg; do convert -colorspace RGB "$f" "${f}"; done
#finally convert all images to Webp format
@demidovakatya
demidovakatya / article.md
Last active December 30, 2017 12:37
«БЫДЛО» КАК КЛЮЧЕВОЕ СЛОВО РУНЕТА

«БЫДЛО» КАК КЛЮЧЕВОЕ СЛОВО РУНЕТА

С. Г. Воркачев | Политическая лингвистика. – Вып. 3(41). – Екатеринбург, 2012. – С. 17-26.

Полузабытое и диалектное слово «быдло», заимствованное в восточнославянские языки из польского в значении «крупный рогатый скот» и зафиксированное в лексикографии прошлого века с пометами «устар.», «обл.» и обязательно «прост. презр.» и «бран.», «прогибернировав» в общем фонде русского языка в виде своего рода «дремлющей инфекции» до начала XXI в., внезапно проснулось и взмыло чуть ли не на вершины речевого употребления, воспользовавшись, видимо, ослаблением культурно-языкового иммунитета. Так, если по данным частотного словаря, составленного на основе корпуса современного русского языка, включающего тексты, большинство из которых написаны между 1980 и 1995 гг., частотность слова «быдло» относительно невелика – 2.53 ipm (вхождений на миллион слов) при 374.86 ipm для слова «народ» (т. е. соотношение 1:150), то в настоящий момент поисковая система «Яndex» уже дает для него 5.000.000

@wesleybliss
wesleybliss / docker-compose-node-mongo.yml
Created September 9, 2016 21:37
Docker Compose with example App & Mongo
version: '2'
services:
myapp:
build: .
container_name: "myapp"
image: debian/latest
environment:
- NODE_ENV=development
- FOO=bar
volumes:
@erikbern
erikbern / use_pfx_with_requests.py
Last active May 1, 2024 11:45
How to use a .pfx file with Python requests – also works with .p12 files
import contextlib
import OpenSSL.crypto
import os
import requests
import ssl
import tempfile
@contextlib.contextmanager
def pfx_to_pem(pfx_path, pfx_password):
''' Decrypts the .pfx file to be used with requests. '''
@eusonlito
eusonlito / backup-mysql.sh
Last active June 26, 2023 04:25
Automate your MySQL backups
#!/bin/bash
# -------------------------------------
# Databases backup with X days storage history
#
# User executing this script must have FULL permissions
# to mysql and mysqldump
#
# Use $HOME/.my.cnf to store MySQL auth
#
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
@lingceng
lingceng / form_submit.js
Last active October 31, 2020 00:19
JavaScript request like a form submit
// http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit
// form_submit('/contact/', {name: 'Johnny Bravo'});
function form_submit(path, params, method) {
method = method || "post"; // Set method to post by default if not specified.
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
@ericremoreynolds
ericremoreynolds / client.html
Last active February 25, 2024 21:55
Flask-socket.io emit to specific clients
<html>
<body>
<h1>I feel lonely</h1>
<script type="text/javascript" src="//code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/0.9.16/socket.io.min.js"></script>
<script type="text/javascript" charset="utf-8">
var socket = io.connect('http://' + document.domain + ':' + location.port);
socket.on('connect', function() {
socket.emit('connected');
@drorata
drorata / gist:146ce50807d16fd4a6aa
Last active February 27, 2024 10:15
Minimal Working example of Elasticsearch scrolling using Python client
# Initialize the scroll
page = es.search(
index = 'yourIndex',
doc_type = 'yourType',
scroll = '2m',
search_type = 'scan',
size = 1000,
body = {
# Your query's body
})
@dschneider
dschneider / convert_utf8_to_utf8mb4
Created May 7, 2014 14:44
How to easily convert utf8 tables to utf8mb4 in MySQL 5.5
# For each database:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
# For each table:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# For each column:
ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# (Don’t blindly copy-paste this! The exact statement depends on the column type, maximum length, and other properties. The above line is just an example for a `VARCHAR` column.)