Skip to content

Instantly share code, notes, and snippets.

View javimosch's full-sized avatar
🏠
Working from home

Javier Leandro Arancibia javimosch

🏠
Working from home
View GitHub Profile
@javimosch
javimosch / docker_log_rotator.sh
Last active June 25, 2024 07:18
A bash script that rotates Docker container logs when they exceed a specified size threshold (5MB by default), helping to prevent log files from growing indefinitely and causing disk space issues. #Docker #LogRotation #DevOps #Containerization #Linux #Scripting #/bash #Automation #LogManagement #SystemAdministration
#!/bin/bash
# Function to convert bytes to megabytes
bytes_to_mb() {
echo $(( $1 / 1024 / 1024 ))
}
# Set log rotation size threshold (in bytes)
MAX_SIZE=$((5 * 1024 * 1024)) # 5MB
@javimosch
javimosch / sessionStorageChannel
Created July 17, 2018 13:56
Cross Window Communication With sessionStorage (Case of use: Cordova's InAppBrowser)
window.sessionStorageChannel = (function() {
const LISTEN_HANDLERS_INTERVAL = 1000
const LISTEN_PENDINGS_INTERVAL = 200
const LISTEN_RESOLVED_INTERVAL = 200
const set = (n, v, d) => window.sessionStorage.setItem(n, v || d || '')
const get = (n, d) => window.sessionStorage.getItem(n) || d || ''
const getJson = (n, d) => JSON.parse(get(n, (d && JSON.stringify(d)) || '{}'))
const setJson = (n, json) => set(n, JSON.stringify(json || {}), "{}")
const getHandlersFrom = (nsp) => getJson(nsp + '_handlers')
const setHandlersFrom = (nsp, json) => setJson(nsp + '_handlers', json)
@javimosch
javimosch / promiseSequence
Last active December 2, 2019 13:05
Promise sequence in pure javascript (browser and server)
//similar to: https://www.npmjs.com/package/promise-sequential
//input: array of functions that returns a promise
//rules:
//- if one promise fails, the sequence is cancelled and the error is returned (catch)
//returns:
//array of results
function promiseSequence(arr) {
return new Promise(function(resolve, reject) {
var result = [];
function sequence(list, results, resolve, reject) {
if (!results) {
return new Promise((resolve, reject) => sequence(list, [], resolve, reject));//first time
} else {
if (!results){
results = [];//one time
}
if (list.length == 0) {
return resolve(results);//last time
} else {
@javimosch
javimosch / MinimalFlux
Last active May 31, 2018 10:34
Minimal React Flux Library (React che)
/*
HOW IT WORKS?
- Library object is che
- Add actions using che.defineActions(["JUMP","CLICK","SUBSCRIBE","ETC"])
- Add stores using che.defineStore ... (see example below)
- Bind stores using che.store.bind
FEATURES
@javimosch
javimosch / evt.js
Created June 10, 2017 10:57
Tiny Event system that just works
/*
var detach = $evt.on('foo',console.log) //Register as normal
$evt.emit('foo',1,2,3) //Emit using N arguments
$evt.off('foo') //Detach using name (every listener is detached)
detach(); //Detach using funcion
*/
(function() {
var arr = [];
var self = window.$evt = {
emit: function() {

Hi!

This is an example of how to use [Rollup] with external dependencies, without hard-coding them.

It reads your installed NPM dependencies and treats them as external to Rollup. They still get bundled, but not as ES2015.

Make sure you have a .babelrc or a "babel":{} section in your package.json.

@javimosch
javimosch / install_ionic_compiler.sh
Created September 13, 2016 23:24
Cloud9 Free VM (2048mb Storage) + Android Cordova Ionic Compiler
#vm machine needs nodejs
#download sdk
wget http://dl.google.com/android/android-sdk_r24.2-linux.tgz
tar -xvf android-sdk_r24.2-linux.tgz
rm android-sdk_r24.2-linux.tgz
mv android-sdk-linux/ android
#install essential sdk components
~/workspace/android/tools/android update sdk -u --all --filter 2,4,168
#install enviroment dependencies
sudo apt-get install lib32stdc++6