Skip to content

Instantly share code, notes, and snippets.

View MaxXx1313's full-sized avatar

Maksim Chartkou MaxXx1313

View GitHub Profile
#!/bin/bash
# place in .bash_profile or .bashrc
# colors is here: https://misc.flogisoft.com/bash/tip_colors_and_formatting
PS1="\[\e]0;\u@\h: \w\a\]"
PS1="$PS1\[\033[38;5;22m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
@MaxXx1313
MaxXx1313 / Remove VK ads.js
Last active April 4, 2021 14:41
Remove promoted posts and ads on vk.com (tampermonkey script)
// ==UserScript==
// @name Remove VK ads
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Remove VK advertisement
// @author maxxx1313
// @match https://vk.com/*
// @grant none
// @runat document-end
// ==/UserScript==
@MaxXx1313
MaxXx1313 / git remove huge files.sh
Last active June 24, 2018 09:16
git remove file/folder from the history
git filter-branch \
--prune-empty -d /dev/shm/scratch \
--index-filter "git rm -rf --cached --ignore-unmatch oops.iso" \
--tag-name-filter cat \
-- --all
@MaxXx1313
MaxXx1313 / iso-8601.js
Last active May 18, 2018 08:53
ISO8601 string to Date
const assert = require('assert');
/**
* Parse string date representation into Date object
* input string - date in ISO format:
* * "2018-05-17T16:40:56"
* * "2018-05-17T16:40:56.303Z"
* * "2018-05-17T16:40:56.303+00:00"
@MaxXx1313
MaxXx1313 / $.fn.serializeObject
Last active January 29, 2018 17:06
jQuery serializeObject for a form
$.fn.serializeObject = function() {
return this.serializeArray().reduce(function(result, item){
result[item.name]=item.value;
return result;
}, {});
};
@MaxXx1313
MaxXx1313 / xpath.js
Last active March 17, 2019 18:35
Xpath operations with objects
"use strict";
/* global describe */
/* global it */
/* global require */
/* jshint esversion: 6 */
const assert = require('assert');
/**
*
@MaxXx1313
MaxXx1313 / git forward
Last active January 15, 2020 08:40
git forward <branch name> - fast-forward pointed branch to the current state
# add next line in ~/.gitconfig
[alias]
forward = !git tag _temp && git checkout $1 --quiet && git merge _temp --ff-only && git tag _temp -d && git status
mergeto = !bash -x -c 'ish=$(git status |grep -P \"(HEAD detached at|On branch)\" | grep -oP \"[^ ]+$\" ) && echo "$ish" && git checkout '"$1"' --quiet && git merge "$ish" --no-ff --no-edit && git status'
// custom middleware: use res.promise() to send promise response
app.use((req,res,next)=>{
/*
Report error
You can use it in severqal ways:
- promise.catch() from promise
- res.error(new Error()) - pass any error object
- res.error({status:401, message:'alala'}) - pass any object
- res.error(401, 'alala') - pass code and message separately
{
"header": {
"number": {
"low": 0,
"high": 0,
"unsigned": true
},
"previous_hash": "",
"data_hash": "223e57f14464047011a96d77eea75aa0296b25a10d50cdecf217948513644124"
},
if (!Object.assign) {
Object.assign =
function (target) {
var from, to = Object(target), symbols;
for (var s = 1; s < arguments.length; s++) {
from = Object(arguments[s]);
for (var key in from) {
if (Object.prototype.hasOwnProperty.call(from, key)) {
to[key] = from[key];
}