Skip to content

Instantly share code, notes, and snippets.

View maruf89's full-sized avatar

Marius Miliunas maruf89

  • Vilnius, Lithuania
View GitHub Profile
@maruf89
maruf89 / pre-commit
Last active February 8, 2021 07:21
Node update version in file git precommit hook – checks if certain staged files changed, and updates the version number of a correllating file, then git adds that file to be committed as well
#!/usr/bin/env node
// This precommit checks if certain staged files changed, and updates the version number of a correllating file, then `git add`s that file to be committed as well
// Useful for breaking caches like in WordPress which will serve the same CSS or JS if you forget to increment the version
//
// Example test usage after you added your program and regex match at the end of the `defaultArgs` (line 26)
// `git add assets/dist/community-directory.js` // A file correlating to `programs` (line 46)
// `node .git/hooks/precommit -s=true` // Will simulate a change
// `node .git/hooks/precommit -t=major` // Updates the version, increments the major value '1.5.5' => '1.6.0'
@maruf89
maruf89 / YouTubeTriggerRemove.js
Last active July 16, 2017 08:57
Clear your youtube watch later playlist. Paste this into your inspector, change the start & end variables to only remove a portion, or all videos in your playlist.
var start = 0; // starts from the first video
var end = 9; // deletes the first ten videos, set to -1 to remove all
var removeButtons = Array.prototype.slice.call(document.querySelectorAll('.pl-video .pl-video-edit-remove'), start, end);
// gathers all of the remove buttons and triggers a click event on all of the selected with a 250 ms interval
removeButtons.forEach(function (elem, index) { setTimeout(function () { console.log('removing index ' + index); elem.click() }, index * 250) })
@maruf89
maruf89 / coffee2js_beautify.js
Last active January 17, 2017 15:48
Compiles all coffeescript files into JS while preserving single line comments then it beautifies the compiled javascript before saving it alongside the coffeescript files.
"use strict";
var fs = require('fs'),
cs = require('coffee-script'),
os = require('os'),
glob = require('glob'),
beautify = require('js-beautify').js_beautify,
mkdirp = require('node-mkdirp');
var path = require('path');
@maruf89
maruf89 / gist:5c9e3ff21e39d848cd66
Last active August 29, 2015 14:22
Promise chaining styles
//// If short
fnThatReturnsPromise('some val').catch(function () {
// handleError
}).then(functionThatLogsSomething) // Here we're assuming that there's no way this function can error out. If it can then do the next format
//// Or
// One pair
fnThatReturnsPromise('some val').catch(function () {
// handleError
@maruf89
maruf89 / Script.coffee
Last active January 12, 2017 23:48
Angular ng-flow + jcrop + Cloudinary upload
'use strict'
angular.module('uploadApp', [
'flow'
'ngJcrop'
]).config [
'flowFactoryProvider'
'ngJcropConfigProvider'
(flowFactoryProvider, ngJcropConfigProvider) ->
@maruf89
maruf89 / gist:7c1cb805511b48ac7720
Last active August 29, 2015 14:17
Bounding box query not working
echo 'Loading test_index mapping'
curl -XPUT localhost:9200/test_index -d '{
"mappings":{
"user":{
"_id":{
"path":"userID"
},
"_routing":{
"path":"userID"
},
@maruf89
maruf89 / .zshrc
Last active August 29, 2015 14:14
My zsh env
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Example aliases
@maruf89
maruf89 / rc.local
Last active August 29, 2015 14:14
startup file for new server
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
##################### Elasticsearch Configuration Example #####################
# This file contains an overview of various configuration settings,
# targeted at operations staff. Application developers should
# consult the guide at <http://elasticsearch.org/guide>.
#
# The installation procedure is covered at
# <http://elasticsearch.org/guide/en/elasticsearch/reference/current/setup.html>.
#
# Elasticsearch comes with reasonable defaults for most settings,
@maruf89
maruf89 / startfile
Last active August 29, 2015 14:14
Elasticsearch startfile
#!/bin/bash
NAME=elasticsearch
DIR=/opt/${NAME}
PID=/var/run/${NAME}.pid
if [ ! -f $PID ]; then
echo $$ > $PID
fi