Skip to content

Instantly share code, notes, and snippets.

View olaferlandsen's full-sized avatar
🏠
Aló?

Olaf Erlandsen olaferlandsen

🏠
Aló?
  • Chile
  • 19:22 (UTC -04:00)
View GitHub Profile
@olaferlandsen
olaferlandsen / install_ffmpeg_ubuntu.sh
Created May 26, 2016 03:39 — forked from xdamman/install_ffmpeg_ubuntu.sh
Install latest ffmpeg on ubuntu 12.04 or 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
@olaferlandsen
olaferlandsen / AngularStorage.js
Last active September 30, 2016 19:42
A angular storage object to persistent data
/**
*
*/
$rootScope.storage = function () {
/**
* Set default API
**/
this.API = window.sessionStorage;
/**
* Set localStorage API
@olaferlandsen
olaferlandsen / isEmpty.js
Last active January 24, 2020 16:48
isEmpty is a compilation of functions to check if is a empty value on javascript compatible with ECMA5+
/**
*
* boolean isEmpty ( value )
*
* Example:
*
* var a = null;
* if (isEmpty(a)) {
* alert ('empty variable');
* }
@olaferlandsen
olaferlandsen / objectPathExists.js
Last active November 17, 2016 17:40
Check if a variable is a object and if path key exists.
/**
* Implementation with pure javascript
*
* Example:
*
* var someObject = {a: {b: {c: 1}}};
*
* objectPathExists(someObject, 'a'); // return true
* objectPathExists(someObject, 'a.b'); // return true
* objectPathExists(someObject, 'a.b.c'); // return true
@olaferlandsen
olaferlandsen / directives.js
Created December 5, 2016 17:54
Set dynamic attributes with angular
angular.module('olaferlandsen', [])
/**
* Example of usage:
* <input type="element" ng-attrs='{"my-own-attr" : "value", "max": 10, "min":0}'>
*/
.directive('ngAttributes', function($injector, $compile) {
return function (scope, element, attrs) {
var ngAttributes = attrs.ngAttributes;
if (typeof ngAttributes== 'string') ngAttributes = ngAttributes.replace(/(^\s+|\s+$)/ig, '')
if (ngAttributes.length == 0) return;
@olaferlandsen
olaferlandsen / directive.js
Created December 5, 2016 18:00
A simple RUT(chile) mask for Angular.
angular.module('olaferlandsen', [])
.directive('ngRut', function() {
return function (scope, element, attrs) {
element.bind('keypress', function (event) {
var value = element.val().replace(/[^0-9k]/ig, '');
if (value.length == 9) event.preventDefault()
if ( (event.which >= 48 && event.which <= 57) || event.which == 75) {
// reemplazamos todo lo que no sea parte del rut
// establecemos el guion medio(-)
if (value.length == 7 || value.length == 8) element.val(value + '-')
@olaferlandsen
olaferlandsen / check.js
Created December 7, 2016 17:56
Check if a variable exists in Javascript
/**
* simple
*/
function isDefined (varname) {
return window.hasOwnProperty(varname);
}
@olaferlandsen
olaferlandsen / check.js
Last active December 12, 2016 18:59
Check
//
function isNull (value) {
return value === null;
}
//
function isUndefined (value, strict) {
if (strict === true) return value === undefined;
return value == 'undefined';
}
//
@olaferlandsen
olaferlandsen / ngNumber.js
Last active December 16, 2016 13:56
ngNumber - Simple and powerful directive for allow only numbers on text input.
/**
* How to use it?
* You only need set 'ng-number' attribute on you input like
Example:
* <input ng-model="myModel" ng-number>
*
* How to integrate?
* You need copy this code and paste after you module definition on you Angular app.
* Example:
* module('controllers', [])
@olaferlandsen
olaferlandsen / android_instructions.md
Created March 15, 2017 19:06 — forked from patrickhammond/android_instructions.md
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"