Skip to content

Instantly share code, notes, and snippets.

View analytik's full-sized avatar
😐
b u r n o u t

Milan B analytik

😐
b u r n o u t
View GitHub Profile
@analytik
analytik / rename_nested_deep.sh
Created May 23, 2011 15:18
Traverse directories 3 layers and then rename/move something inside
for file in *; do
if [ -d $file ]; then
#echo $file;
#cd $file;
for file2 in $file/*; do
if [ -d $file2 ]; then
#cd $file2;
#echo $file2;
for file3 in $file2/*; do
if [ -d $file3 ]; then
@analytik
analytik / servant.js
Created March 3, 2015 20:28
XKit Servant plugin version 0.4 REV E modified to include "hide post" functionality (mostly copied from XKit Blacklist)
//* TITLE Servant **//
//* VERSION 0.4 REV E **//
//* DESCRIPTION XKit Personal Assistant **//
//* DETAILS Automator for XKit: lets you create little Servants that does tasks for you when the conditions you've set are met. **//
//* DEVELOPER STUDIOXENIX **//
//* FRAME false **//
//* SLOW true **//
//* BETA false **//
XKit.extensions.servant = new Object({
import atexit
import pika
from rest_framework.renderers import JSONRenderer
from Bar.serializers import BarSerializer
RABBIT_HOST = 'localhost'
class FooChangePublisher(object):
@analytik
analytik / install_bower_1_5_3.bat
Created October 9, 2015 10:22
How to install Bower 1.5.3 on Windows when hitting the 255 char limit path limit
npm rm bower
npm cache clean
npm install -g abbrev@1.0.7
npm install -g amdefine@1.0.0
npm install -g ansi-escapes@1.1.0
npm install -g ansi-regex@2.0.0
npm install -g ansi-styles@2.1.0
npm install -g ansicolors@0.2.1
npm install -g archy@1.0.0
@analytik
analytik / rethinkdb_table_keys.js
Created December 21, 2015 08:31
How to get all RethinkDB table keys and sub-keys (this version does not work recursively)
r.db('test').table('test')
.concatMap(function(doc) {
return doc.keys().map(function(tlKey) {
return r.branch(doc(tlKey).typeOf().eq('OBJECT'),
doc(tlKey).keys().map(function(name){ return r.expr(tlKey).add('.').add(name);}),
tlKey);
});
}).distinct()
/**
* For object
[auth]
bitbucket.prefix = https://bitbucket.org/
bitbucket.username = xxxxxx
[ui]
username=Milan Brezovsky <xxxxxx@xxxxxx.com>
ignore=C:\Users\xxxxxx\Documents\hgignore_global.txt
merge = kdiff3
[extensions]
@analytik
analytik / happylog.js
Last active January 28, 2024 17:09
Generate a list of headings and subheadings for every day in DokuWiki format for the purpose of keeping a track of nice things that happened to you
/**
* Created by milan on 2016-04-02.
* HappyLog skeleton generator (DokuWiki format)
*/
"use strict";
let strftime = require('strftime');
let day = new Date();
day.setDate(1);
day.setMonth(day.getMonth());
let month = day.getMonth();
@analytik
analytik / Combine similar transactions
Created April 5, 2016 06:07
An example on how to use fold introduced in RethinkDB 2.3 to combine similar consequential documents
return r.db('db1').table('table1')
.getAll('asdfgh', {index: 'user_id'})
.orderBy(r.desc('created'))
.fold([], function (acc, doc) {
return r.branch(
acc.isEmpty(),
acc.add([doc]),
acc.nth(-1)('transaction_type').eq(doc('transaction_type')),
acc.slice(0, -1).append(acc.nth(-1).merge({
amount: acc.nth(-1)('amount').add(doc('amount'))
@analytik
analytik / Testing eachAsync for memory leaks
Last active June 29, 2016 12:56
Testing memory usage for a large number of events with changefeeds and eachAsync
var Promise = require('bluebird');
var util = require('util');
var heapdump = require('heapdump');
function log(message) {
console.log(new Date().toISOString() + ' - ' + message);
}
function gc() {
log('-- Forced GC');
r.db('rethinkdb').table('table_status')
.filter(r.row('status')('ready_for_writes').not())
.forEach((tbl)=>{
return r.db(tbl('db')).table(tbl('name')).reconfigure({emergency_repair: 'unsafe_rollback'});
})