Skip to content

Instantly share code, notes, and snippets.

View alexandrusavin's full-sized avatar
🤞
Coding

Alexandru Savin alexandrusavin

🤞
Coding
View GitHub Profile
@alexandrusavin
alexandrusavin / AbstractEventsDispatcher.js
Last active December 26, 2015 02:49
Simplified event dispatcher for in browser javascript.
/**
* Ex:
*
* Object = function () {}
* Object.prototype = new AbstractEventsDispatcher;
*
* Object.trigger("event", arguments);
*/
var AbstractEventsDispatcher = function () {
@alexandrusavin
alexandrusavin / deleteFiles.php
Created January 29, 2014 16:27
Script to delete lot's of files without a big impact on the system IO
<?php
// path where the files should be deleted
define('PATH', '/.');
// delete only files older than OLDER_THAN_DAYS days
define('OLDER_THAN_DAYS', 14);
// delete only files that match MATCH_NAME
define('MATCH_NAME', '/some regexp/i');
// do NOT actually delete the files
define('DRYRUN', false);
// sleep SLEEP_USEC microsecconds after each delete
@alexandrusavin
alexandrusavin / glassfishWrapper.sh
Created January 29, 2014 16:36
Wrapper script for starting/stopping Glassfish3 application with supervisord
#!/bin/bash
pidfile=/path/to/the/pidfile
function stopDomain {
echo "Sutting down domain."
/path/to/bin/asadmin stop-domain name
}
function startDomain {
module.exports = {
testIfArray: function (arr) {
return !!arr && Array.isArray(arr);
},
testIfObject: function (obj) {
return !this.testIfArray(obj) && typeof obj === 'object';
},
input {
stdin {
type => "stdin-type"
}
udp {
port => "9999"
}
tcp {
port => "9998"
}
@alexandrusavin
alexandrusavin / setup.js
Created September 30, 2015 17:36
root mocha setup for mongodb int tests
'use strict';
var mongoose = require('mongoose');
var _ = require('lodash');
var conn;
function clearDB() {
var cleaned = [];
@alexandrusavin
alexandrusavin / 2bunyan.sh
Created March 31, 2016 17:40
Wrap node interpreter to be to pipe to bunyan in Intellij IDEs run configurations
#!/usr/bin/env bash
~/.nvm/nvm.sh use default
node $@ | ./node_modules/.bin/bunyan
@alexandrusavin
alexandrusavin / binds_on_mount.sh
Last active February 4, 2024 14:48
Add letsencrypt certificate to dd-wrt web interface
#!/bin/sh
if [ `nvram get https_enable` -gt 0 ] ; then
# get the absolute directory of the executable
SELF_PATH=$(cd -P "$(dirname "$0")" && pwd -P)
echo SELF_PATH: ${SELF_PATH}
# extract the mount path
@alexandrusavin
alexandrusavin / .zshrc
Last active January 30, 2022 13:58
My MacOS zsh config file
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export PATH=/Users/alexandrusavin/bin:$PATH
#!/bin/sh
# Based on gist.github.com/gboudreau/install-ffmpeg-amazon-linux.sh
# and https://trac.ffmpeg.org/wiki/CompilationGuide/Centos
if [ "`/usr/bin/whoami`" != "root" ]; then
echo "You need to execute this script as root."
exit 1
fi
cat > /etc/yum.repos.d/centos.repo<<EOF