Skip to content

Instantly share code, notes, and snippets.

View jsianes's full-sized avatar

Javier Sianes jsianes

  • AWS
  • O Grove, Galicia
  • 00:56 (UTC +02:00)
  • LinkedIn in/jsianes
View GitHub Profile
@jsianes
jsianes / mirage-ami.sh
Last active October 15, 2015 19:02
Shell script to register a new AMI from Mirage Unikernel into AWS (N.Virginia region)
#!/bin/bash
#
# Shell script to register a new AMI from Mirage Unikernel into AWS (N.Virginia region)
# Developed by: Javier Sianes - jsianes@gmail.com
#
usage() {
echo "Incorrect parameters."
echo "Usage:"
echo ""
@jsianes
jsianes / ftp.c.patch
Created August 16, 2015 11:11
Patch for 'ftp.c' file of ncftp v.2.3.5 to use within AWS instances
--- libncftp/ftp.c.orig 2009-10-23 23:31:22.000000000 +0000
+++ libncftp/ftp.c 2015-08-15 19:49:04.014889944 +0000
@@ -5,6 +5,73 @@
*
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <curl/curl.h>
+#include <string.h>
@jsianes
jsianes / configure.patch
Last active August 29, 2015 14:27
Patch for 'configure' file of ncftp v3.2.5 to use within AWS instances
--- configure.orig 2011-02-02 23:17:19.000000000 +0000
+++ configure 2015-08-15 19:35:58.317989930 +0000
@@ -8,6 +8,10 @@
# gives unlimited permission to copy, distribute and modify it.
# Defaults:
+
+# adding libcurl libary
+CFLAGS="$CFLAGS -lcurl"
+
@jsianes
jsianes / ginfo.sh
Last active October 7, 2015 14:28
Shell script to obtain useful information about a Linux instance for troubleshooting
#!/bin/bash
timestamp() {
TIMESTAMP=`date -u +"%Y-%m-%dT%H:%M:%S.000Z"`
}
line() {
echo "==================================================================================" >>${LOGFILE} 2>${ERROR}
echo "==================================================================================" >>${LOGFILE} 2>${ERROR}
}
sline() {
@jsianes
jsianes / keypair.sh
Last active August 29, 2015 14:06
Shell script to manage keypairs. You can add an user and establish a new keypair, reset an existing keypair or repair ownerships and permissions.
#!/bin/bash
#
# Developed by: Javier Sianes - jsianes@gmail.com
#
BITS="4096"
username(){
USERNAME=`echo ${USERNAME} | tr '[:upper:]' '[:lower:]' | sed 's/ /_/g'`
@jsianes
jsianes / ipassign
Last active September 5, 2021 08:04
Script to assign Public IP from Elastic IP pool for instances hosted in AWS. 'ec2-utils' and AWS CLI packages required. Instance role or access keys need to allow at least next EC2 actions: describe-addresses, associate-address and disassociate-address. Shell script is designed to be integrated with instance start-up
#!/bin/bash
# chkconfig: 2345 99 10
# description: Set Public IP from ElasticIP pool during instance startup
# processname: ipassign
# Provides: ipassign
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Set Public IP from ElasticIP pool during instance startup
@jsianes
jsianes / testELB.sh
Last active August 29, 2015 14:00
Shell script file to test ELB activity
#!/bin/bash
#
#
# Developed by: Javier Sianes - jsianes@gmail.com
#
# Shell script to test ELB request activity health
#
#
function on_exit()
@jsianes
jsianes / ReversedBinaryNumbers.java
Last active December 22, 2015 03:29
Spotify 'Reversed Binary' test program solved (https://www.spotify.com/us/jobs/tech/reversed-binary/)
import java.util.Scanner;
public class ReversedBinaryNumbers {
public static void main(String[] args) {
if (args.length == 1) {
Scanner scanner=new Scanner(args[0]);
if (scanner.hasNextLong()) {
long l=scanner.nextLong();
if ((l>0)&&(l<1000000001)) {System.out.println(Long.parseLong(new StringBuilder(Long.toBinaryString(l)).reverse().toString(),2));}
}
@jsianes
jsianes / LCAP.java
Last active December 19, 2015 17:49
This Java code helps you to analyze economic proposals of a contest according to art.85 hiring law of Public Administrations in Spain (Real Decreto 1098/2001,Reglamento LCAP - artículo 85: http://is.gd/uANADN )
import java.io.*;
import java.util.*;
import java.text.*;
public class LCAP {
public static void Ley() {
System.out.printf("Evaluacion segun la LCAP:\n\n"+
"Articulo 85. Criterios para apreciar las ofertas desproporcionadas o temerarias en las\n"+
"subastas.- Se consideraran, en principio, desproporcionadas o temerarias las ofertas que\n"+
@jsianes
jsianes / backup-BBDD.sh
Last active January 24, 2022 09:56
This shell-script creates a local MySQL backup file, maintaining a 10 days rotation period (by default. Can be configured on parameters). Controls if there is enough space before doing it and overlap executions.
#!/bin/bash
#
# This script make a local MySQL DB backup
# Developed for RHEL5 by Javier Sianes - jsianes@gmail.com
#
# Start of Parameters
##############################################
USUARIO="username"
PASSWORD="password"