Skip to content

Instantly share code, notes, and snippets.

View aalonzolu's full-sized avatar

Andrés Alonzo y Alonzo aalonzolu

View GitHub Profile
@aalonzolu
aalonzolu / gitpush.sh
Last active September 26, 2017 17:48
gitpush function, send to git in one line.
#INSTALL
#Put this function on your .bashrc or /etc/profile or .profile (in macOS)
#USAGE
# gitpush <branch> "commit comment"
gitpush(){
if [[ $# -eq 0 ]] ; then
echo "arguments needed";
fi
if [[ $# -eq 2 ]] ; then
git pull origin $1 --no-edit ;
@aalonzolu
aalonzolu / recursivejava.java
Created March 24, 2017 04:09
Java recursive method example
public int restar(number){
if(number>0){
number = number-1;
restar(number);
}
else{
return number;
}
}
}
@aalonzolu
aalonzolu / reverse.java
Created April 8, 2017 15:30
Java reverse string
package reverse.string.app;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
while (true) { /// ejecutar siempre el script
System.out.println("Ingrese un Nombre");// imprimir instrucciones
Scanner hola = new Scanner(System.in); // crear objeto scanner en hola
@aalonzolu
aalonzolu / validation.java
Created April 8, 2017 16:03
Java check valid email
/**
* Created by lexo on 4/8/17.
*/
public class validacion {
public boolean isCorreo(String correo, boolean validarDominio){
boolean contiene = correo.toLowerCase().contains("@");
if(contiene){
// si tiene arroba
String[] parts = correo.split("@");
@aalonzolu
aalonzolu / antergos.mirrorlist
Created April 19, 2017 02:22
Archlinux /etc/pacman.d/mirrorlist
# Arch Linux mirrorlist generated by Cnchi #
Server = http://mirror.umd.edu/archlinux/$repo/os/$arch
Server = http://mirror.kaminski.io/archlinux/$repo/os/$arch
Server = http://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch
Server = http://mirror.js-webcoding.de/pub/archlinux/$repo/os/$arch
Server = http://mirrors.dotsrc.org/archlinux/$repo/os/$arch
Server = http://mirror.math.princeton.edu/pub/archlinux/$repo/os/$arch
Server = http://mirrors.rit.edu/archlinux/$repo/os/$arch
Server = http://mirror.datacenter.by/pub/archlinux/$repo/os/$arch
Server = http://mirrors.n-ix.net/archlinux/$repo/os/$arch
@aalonzolu
aalonzolu / pacman.conf
Created April 19, 2017 02:28
Archlinux /etc/pacman.conf
#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives
#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
@aalonzolu
aalonzolu / ram_monitor.sh
Created April 28, 2017 04:44
RAM % monitor, if > 95% kill some task
used=$(free | grep Mem | awk '{print $3/$2 * 100}'); #get % of ram used
used=${used%.*}; #conver to int
used=$(($used+8)); # add 8% because is returning a wrong number
echo $used;
if [ $used -gt 95 ]; then
killall chrome
fi
@aalonzolu
aalonzolu / addhours.js
Created May 3, 2017 00:39
GT time javascript
var nowDateGT = function (){
Date.prototype.addHours = function(h) {
this.setTime(this.getTime() + (h*60*60*1000));
return this;}
now = new Date();
return now.addHours(-6);
}
console.log(nowDateGT())
@aalonzolu
aalonzolu / query.py
Created May 12, 2017 15:37
Execute SQL in all databases
import MySQLdb
connection = MySQLdb.connect(
host = 'localhost',
user = 'root',
passwd = 'secret') # create the connection
cursor = connection.cursor() # get the cursor
cursor.execute("SHOW DATABASES") # execute 'SHOW TABLES' (but data is not returned)
tables = cursor.fetchall()
@aalonzolu
aalonzolu / javasortstring.java
Created June 2, 2017 04:43
java sort string alphabetically / Java ordenar string alfabeticamente.
// sort
String input = "fksjakqbjprckekdolwhnsiajskmle";
char[] charArray = input.toCharArray();
Arrays.sort(charArray);
String sortedString = new String(charArray);
System.out.println(sortedString);
// output
//aabcdeefhijjjkkkkkllmnopqrsssw