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 / 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 / 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: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 / 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 / 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 / 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'