Skip to content

Instantly share code, notes, and snippets.

View aruponse's full-sized avatar

Alfonso Aguilar aruponse

View GitHub Profile
input = ARGV[0]
index = 0
numbers = ""
File.open(input, 'r') do |f|
while line = f.gets
if index==0
limit=line.to_i
index+=1
next
end
@aruponse
aruponse / luhn.rb
Last active April 16, 2016 14:22
Algoritmo de Luhn (Ruby)
def is_valid?(number)
digits = number.to_s.reverse.chars.map(&:to_i)
check_sum = 0
digits.each_slice(2) do |odd, even|
check_sum += odd
next unless even
even *= 2
even = even.divmod(10).inject(:+) if even > 9
check_sum += even
@aruponse
aruponse / gist:96b923d863f1718386b70fc5cd07f480
Created January 3, 2018 20:50 — forked from ymirpl/gist:1052094
Python unicode e-mail sending
#coding: utf-8
from cStringIO import StringIO
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.header import Header
from email import Charset
from email.generator import Generator
import smtplib
# Example address data
@aruponse
aruponse / moda_media.py
Created January 9, 2018 15:33 — forked from juanpabloaj/moda_media.py
ejemplo python: moda y mediana
#!/usr/bin/python
# -*- coding: utf-8 -*-
# http://docs.python.org/tutorial/datastructures.html
l = [ 1, 10, 4, 2, 4, 3, 3, 1, 1, 3]
print l
promedio = sum(l)/len(l)
<?php
define('ROOT_PATH', $_SERVER['DOCUMENT_ROOT'].'/rest_api_d2/');
define('CONTROLLER_PATH', ROOT_PATH.'app/controllers/');
define('MODEL_PATH', ROOT_PATH.'app/db/');
define('VIEW_PATH', ROOT_PATH.'app/views/');
?>
@aruponse
aruponse / reloadGitignore.sh
Last active May 3, 2018 17:46 — forked from davepoon/gist:4371622
Added the .gitignore, and refresh the file index so the files get ignored properly.
git rm -r --cached .
git add .
git commit -m ".gitignore is now up to date"
@aruponse
aruponse / install.sh
Created May 4, 2018 19:59 — forked from stayallive/install.sh
Install PHP 5.6.7 on Plesk 11.5 & 12 (CentOS 6)
#!/bin/bash
# Make sure you are up to date
yum -y update && yum -y install wget
# Install EPEL repository
rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# Get us a clean working directory
mkdir /php
@aruponse
aruponse / git-deployment.md
Created May 8, 2018 14:23 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.

@aruponse
aruponse / get_mfc_video_url.js
Created October 31, 2018 17:13
myfreecams livestreamer URL generator
"use strict";
// ATTENTION! Requires `npm install websocket` to run
var url = require("url"),
http = require("http"),
WebSocketClient = require("websocket").client;
function usage()
{
@aruponse
aruponse / staruml.md
Created August 12, 2019 19:55
Steps to get the full version of StarUML 3.0.2 - Ubuntu

Credits to kharek for his answer here. But his answer was for an older version (2.8). There are some minor tweaks for getting it to work on the latest version (StarUML-3.0.2-x86_64.AppImage).

Here's a complete guide (for newbies) (it worked for me on Ubuntu 18.04.1 LTS):

  1. Download the latest StarUML .AppImage from the their website staruml.io
  2. Then make the downloaded .AppImage executable by running sudo chmod +x StarUML-3.0.2-x86_64.AppImage
  3. Install npm using apt-get sudo apt install npm
  4. Install asar npm package using sudo npm install -g asar
  5. If you're using npm for the first time, then you can't directly call asar from the terminal. You need to update your $PATH variable to include the .npm-global directory to directly call globally installed npm packages. This can be done by adding export PATH="/home/$USER/.npm-global/bin:$PATH" (may