Skip to content

Instantly share code, notes, and snippets.

View ikushlianski's full-sized avatar
🔨

Ilya Kushlianski ikushlianski

🔨
View GitHub Profile
@ikushlianski
ikushlianski / gist:72e41f07f43964b758c0e6e2d8ef9fe7
Created July 11, 2023 10:15
Manual pre-commit hook in a monorepo
#!/bin/bash
# avoid pre-commit hooks when fixing conflicts/merging
git rev-parse -q --verify MERGE_HEAD && exit 0
# list all staged JS and TS files
js_ts_files=$(git diff --diff-filter=d --name-only --cached | grep -E '\.(js|jsx|ts|tsx)$')
#############
@ikushlianski
ikushlianski / index.js
Last active April 30, 2023 11:26
Export translations from the currently open Yandex Translate collection into Anki (TSV, CSV)
// open a collection in Yandex Translate and run the following script in your browser's developer console
function parseCollection() {
const arr = [];
document.querySelectorAll('.record-item_text > div:nth-child(2)').forEach(el => {
arr.push([el.textContent])
})
document.querySelectorAll('.record-item_translation > div:nth-child(2)').forEach((el, index) => {
@ikushlianski
ikushlianski / MainStack.js
Created April 11, 2023 11:29
Dead Letter Queue (Serverless Stack, SST)
/*
"@serverless-stack/resources": "0.59.1"
*/
const deadLetterQueue = new sst.Queue(this, "DeadLetterQueue", {
sqsQueue: {
visibilityTimeout: Duration.hours(12),
},
});
@ikushlianski
ikushlianski / git-aliases
Last active July 10, 2023 08:18
Handy git aliases (add this to .gitconfig) in home directory
[alias]
co = checkout
cob = checkout -b
b = branch
bb = branch -vvv
ll = log --oneline
l = log
brd = branch -d
brD = branch -D
reom = !git fetch && git rebase origin/master
@ikushlianski
ikushlianski / gulp server for mobile testing
Created April 25, 2019 21:23
We can run our webpack-dev-server and listen to localhost:8080 with gulp's browserSync
const gulp = require('gulp');
const browserSync = require('browser-sync');
gulp.task('mobile', function() {
browserSync({
proxy: 'localhost:8080',
open: false,
});
});
@ikushlianski
ikushlianski / webpack-react-sass-config
Created September 7, 2018 22:53
React and SASS - Webpack config
// don't forget to install node-sass, sass-loader and (save-dev) css-hot-loader
'use strict';
const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
@ikushlianski
ikushlianski / webpack.config.js
Created May 10, 2018 08:12
Webpack 1 sample config
'use strict'
var path = require('path');
const webpack = require('webpack');
const NODE_ENV = process.env.NODE_ENV || 'development';
//const NODE_ENV = 'production';
module.exports = {
context: __dirname + "/frontend",
entry: {
@ikushlianski
ikushlianski / functions.php
Last active September 23, 2017 20:16
Wordpress: pagination with custom posts. The key is to use the DEFAULT loop, with the necessary data for the loop coming from the name of the file itself, in this case: taxonomy-skill_tag.php. The WP_Query stuff will work only if default post number display options is set to 1
// fix bug when custom posts archive pagination does not work on page 2 and subsequent.
// This is the hack which works when WP_Query (not default loop) is used
$option_posts_per_page = get_option( 'posts_per_page' );
add_action( 'init', 'my_modify_posts_per_page', 0);
function my_modify_posts_per_page() {
add_filter( 'option_posts_per_page', 'my_option_posts_per_page' );
}
function my_option_posts_per_page( $value ) {
global $option_posts_per_page;
if ( is_tax( 'skill_tag') ) {
@ikushlianski
ikushlianski / webpack.config.js
Created September 8, 2017 11:15 — forked from learncodeacademy/webpack.config.js
Sample Basic Webpack Config
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: "scripts.min.js"
@ikushlianski
ikushlianski / contactform.php
Created June 24, 2017 16:22
Contact form that creates a wordpress post (translatable with Polylang)
<?php
/*
Plugin Name: Example Contact Form
Plugin URI: http://example.com
Description: Simple non-bloated WordPress Contact Form
Version: 1.0
Author: Agbonghama Collins
Author URI: http://w3guy.com
Text Domain: cform
*/