Skip to content

Instantly share code, notes, and snippets.

View andresmatasuarez's full-sized avatar

Andrés Mata Suárez andresmatasuarez

  • Buenos Aires, Argentina
View GitHub Profile
@andresmatasuarez
andresmatasuarez / readme.md
Last active April 8, 2019 19:01
Switching Fn behaviour for Logitech K780 on Ubuntu 18

Switching Fn behaviour for Logitech K780 on Ubuntu 18

  1. Install Solaar package manually following instructions from https://github.com/pwr/Solaar/blob/master/docs/installation.md

  2. Add manually-installed Solaar to /usr/bin/, for example ln -s path-to/Solaar-master/bin/solaar /usr/bin/solaar-latest

  3. Run solaar-latest config 1 fn-swap false where 1 is the device number of the K780 keyboard

  4. Whenever Unifying Receiver is disconnected/connected to computer or K780 keyboard is switched off/on, you must go through step 3 again.

@andresmatasuarez
andresmatasuarez / README.md
Last active August 29, 2015 14:26
Bash | Auto-open terminals running custom commands

Auto-open terminal tabs in Gnome

Features

  • Custom titles
  • Default commands executed on them
  • No need to modify .bashrc
  • Tested in Ubuntu 14.04 and Ubuntu 15.04

Installation & usage

  • Copy the contents of autotty.sh to a file in your system
  • Give it execution rights: chmod +x autotty.sh
@andresmatasuarez
andresmatasuarez / cloudinary_file_uploader.coffee
Last active August 29, 2015 14:25
AngularJS | Module | CloudinaryFileUploader
###
CloudinaryFileUploader
--------------------------
REQUIREMENTS
ngFileUpload: https://github.com/danialfarid/ng-file-upload
USAGE
1. Include as your AngularJS app dependencies
angular.module('yourApp', [ 'cloudinary-file-uploader' ])
@andresmatasuarez
andresmatasuarez / find_nested.coffee
Created July 13, 2015 01:34
JavaScript | findNested | Find a property by its name deeply in an object (without knowing its level).
# Based on: http://stackoverflow.com/questions/15642494/find-property-by-name-in-a-deep-object
findNested = (obj, key, memo) ->
proto = Object.prototype
ts = proto.toString
'[object Array]' != ts.call(memo) and (memo = [])
for own k, v of obj
if k == key
memo.push v
@andresmatasuarez
andresmatasuarez / mongo_db_utils.js
Last active October 8, 2015 01:18
NodeJS | Module: mongo-db-utils | Promisified (with Bluebird) connection handler for Mongoose connections.
/**
* @module mongo-db-utils
* @desc Promisified (with Bluebird) connection handler for Mongoose connections.
* @see {@link https://gist.github.com/andresmatasuarez/343d5ff39bb1a208a046| GitHub gist}
* @author Andrés Mata Suárez <amatasuarez@gmail>
* @license {@link http://www.opensource.org/licenses/mit-license.php| MIT License}
*
* @requires {@link https://github.com/visionmedia/debug|debug}
* @requires {@link https://github.com/petkaantonov/bluebird|bluebird}
* @requires {@link http://mongoosejs.com/|mongoose}
@andresmatasuarez
andresmatasuarez / humanize_duration.js
Created March 20, 2015 19:12
NodeJS | Module: HumanizeDuration | Humanizes MomentJS duration object up to 'week' unit
/**
* // USAGE
* var humanizer = new HumanizeDuration();
*
* humanizer.humanize(10080, 'minutes' ); // Returns: '1 week'
* humanizer.humanize(21344, 'minutes' ); // Returns: '2 weeks, 19 hours, 44 minutes'
* humanizer.humanize(2101080000, 'milliseconds'); // Returns: '3 weeks, 3 days, 7 hours, 38 minutes'
* humanizer.humanize(59, 'days' ); // Returns: '8 weeks, 3 days'
* humanizer.humanize(211777, 'seconds' ); // Returns: '2 days, 10 hours, 49 minutes, 37 seconds'
* humanizer.humanize(10080, 'hours' ); // Returns: '60 weeks'
@andresmatasuarez
andresmatasuarez / stringifiable_errors.js
Created March 4, 2015 18:19
Javascript | Make Error objects JSON.stringify-able
// more info: https://stackoverflow.com/questions/18391212/is-it-not-possible-to-stringify-an-error-using-json-stringify
// Example:
// var error = new Error('testing');
// error.detail = 'foo bar';
// console.log(JSON.stringify(error)); // Prints {"message":"testing","detail":"foo bar"}
Object.defineProperty(Error.prototype, 'toJSON', {
value: function(){
var alt = {};
@andresmatasuarez
andresmatasuarez / log.js
Last active August 29, 2015 14:16
NodeJS | Module: Log | Logging utils.
/**
* @module Log
* @desc Logging utils.
* @see {@link https://gist.github.com/andresmatasuarez/66edcd9710986cca4c59| GitHub gist}
* @author Andrés Mata Suárez <amatasuarez@gmail>
* @license {@link http://www.opensource.org/licenses/mit-license.php| MIT License}
*
* @requires {@link http://nodejs.org/api/util.html| util}
* @requires {@link https://github.com/lorenwest/node-config| config}
* @requires {@link https://github.com/winstonjs/winston| winston}
@andresmatasuarez
andresmatasuarez / repeat.js
Last active November 24, 2016 15:19
NodeJS | Module: Repeat | Offers an abstraction for a repeatable task execution, wrapping it up in a startable and stoppable object.
/**
* @module Repeat
* @desc Offers an abstraction for a repeatable task execution, wrapping it up in a startable and stoppable object.
* @see {@link https://gist.github.com/andresmatasuarez/34ff17f63affe05e77a3| GitHub gist}
* @author Andrés Mata Suárez <amatasuarez@gmail>
* @license {@link http://www.opensource.org/licenses/mit-license.php| MIT License}
*
* @requires {@link https://github.com/petkaantonov/bluebird| bluebird}
* @requires {@link https://gist.github.com/andresmatasuarez/66edcd9710986cca4c59| Log}
*
@andresmatasuarez
andresmatasuarez / collapsable_section.coffee
Created February 28, 2015 00:18
AngularJS | Directive | Collapsable section
'use strict'
# Usage:
# <collapsable-section section="'Support pages settings *'" description="'Placeholders: {{c}} - Calendar name, {{n}} - Landing name, {{l}} - Landing title'" start-collapsed="true">
# I am the content of this section!
# </collapsable-section>
app = angular.module 'app'
app.directive 'collapsableSection', ->