Skip to content

Instantly share code, notes, and snippets.

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

Yoel yoelfme

🏠
Working from home
  • Guatemala
View GitHub Profile
@yoelfme
yoelfme / goTo
Last active August 29, 2015 14:08
It's a function used to emulate to scrollTo of library jQuery but not using jQuery, only use pure Javascript :).
function goTo(container, idElementTo, duration,last_difference){
if (duration < 0) return;
last_difference = typeof last_difference !== 'undefined' ? last_difference : -1;
to = document.getElementById(idElementTo);
var difference = to.offsetTop - container.scrollTop;
var perTick = difference / duration * 10;
if (last_difference === difference ) return;
@yoelfme
yoelfme / formatMoney
Created January 30, 2015 17:59
Format money at Javascript.
Number.prototype.formatMoney = function(c, d, t){
var n = this,
c = isNaN(c = Math.abs(c)) ? 2 : c,
d = d || ".",
t = t || ",",
s = n < 0 ? "-" : "",
i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};
@yoelfme
yoelfme / UploadX
Created March 24, 2015 00:58
Upload and Download Files with Laravel
<?php
/**
* Created by PhpStorm.
* User: yoel
* Date: 8/12/14
* Time: 18:13
*/
namespace App\Helpers;
@yoelfme
yoelfme / NoticesWithFiles
Created March 24, 2015 17:59
Create record with files
if ($validator->passes())
{
$record = $this->repo->create($data);
$image = UploadX::uploadFile($request->file('image'),'notices',$record->id);
$record->image = $image['url'];
$record->save();
return compact('success','message','record');
}
@yoelfme
yoelfme / crontab.txt
Last active September 19, 2015 01:10
Setup Crontab
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
HOME=/
MAILTO="your@mail.com"
# Your crons
@yoelfme
yoelfme / docker-compose.yml
Created November 3, 2015 21:21
Elactic with Docker Compose
elasticsearch:
image: elasticsearch
command: elasticsearch -Des.network.host=_non_loopback_
ports:
- "9200:9200"
@yoelfme
yoelfme / helpers.js
Last active January 3, 2016 22:22
Module for prevent the touchstart when scrolling
// Declare internals
var internals = {
startX: null,
startY: null,
tap: false
};
internals.setTap = function () {
internals.tap = true;
setTimeout(function () {
@yoelfme
yoelfme / avit-custom.zsh-theme
Last active January 19, 2016 17:41
This is a theme oh my zsh, forked from @avit
# AVIT ZSH Theme
PROMPT='
$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
🐑 💨 '
PROMPT2='%{$fg[grey]%}🐑 💨 %{$reset_color%} '
RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
@yoelfme
yoelfme / delete_images_without_tag.sh
Created January 27, 2016 20:10
Command used for delete all images without tag (none)
docker rmi -f $(docker images | grep none | awk '{print $3}')
@yoelfme
yoelfme / cleanup_volumes_docker.sh
Created February 5, 2016 17:52
Clean up unused volumes of docker
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock:ro -v /var/lib/docker:/var/lib/docker martin/docker-cleanup-volumes