Skip to content

Instantly share code, notes, and snippets.

Avatar

Ivan Rodriguez ivansabik

View GitHub Profile
View rds_export.py
import boto3
def lambda_handler(event, context):
client.start_export_task(
ExportTaskIdentifier="",
SourceArn="arn:aws:rds:us-east-1:",
S3BucketName="",
IamRoleArn=",
KmsKeyId="",
S3Prefix="rds-exports",
@ivansabik
ivansabik / compare_files_in_dir.py
Last active May 5, 2017
Compares md5 hashes for files in two directories recursively. It will compare using one dir as base (the left one) against the other one (the right one).
View compare_files_in_dir.py
import argparse
import hashlib
import os
def get_checksum(f):
md5 = hashlib.md5()
md5.update(open(f).read())
return md5.hexdigest()
View print_sqlalchemy_query_mysql.py
# http://nicolascadou.com/blog/2014/01/printing-actual-sqlalchemy-queries/
from sqlalchemy.dialects import mysql; print str(query.statement.compile(dialect=mysql.dialect()))
@ivansabik
ivansabik / add_alias.sh
Last active Nov 10, 2015
Add permanent alias for CLI
View add_alias.sh
#!/bin/bash
echo "alias cls='clear'" >> ~/.bash_aliases && source ~/.bash_aliases
@ivansabik
ivansabik / soundcloudPlaylistScrape.js
Created Oct 10, 2015
Scrape soundcloud playlist with casperjs and slimerjs then save to text file
View soundcloudPlaylistScrape.js
var casper = require('casper').create();
var fs = require('fs');
casper.start('https://soundcloud.com/vlad-gonta/sets/new-1', function() {
this.viewport(768, 10000);
}).then(function () {
this.scrollToBottom();
this.wait(1000);
}).then(function () {
this.scrollToBottom();
@ivansabik
ivansabik / iconv_convert_all_mp4_to_mp3.sh
Last active Aug 29, 2015
Iconv convert all mp4 in a folder to mp3
View iconv_convert_all_mp4_to_mp3.sh
#!/bin/sh
for i in *.m4a; do avconv -i "$i" "${i/.m4a/.mp3}"; done
@ivansabik
ivansabik / alerta-cnsf
Last active Aug 29, 2015
Ejemplo node-app para ejecutar al iniciar Ubuntu
View alerta-cnsf
#!/bin/sh
# Source: https://github.com/chovy/node-startup/blob/master/init.d/node-app
# author: Anthony Ettinger (chovy)
NODE_ENV="development"
PORT="3000"
APP_DIR="~/scripts-startup"
NODE_APP="cnsf.js"
CONFIG_DIR="$APP_DIR"
@ivansabik
ivansabik / cnsf.js
Last active Aug 29, 2015
Script Node.js para checar si ya se publicó la convocatoria del premio CNSF 2015 y enviar mail de alerta
View cnsf.js
// HTTP a http://www.cnsf.gob.mx/Eventos/Paginas/Premios_2015.aspx
// Si el header de respuesta es distinto de 200, ignorar
// Si es 200 enviar mail
var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');
var request = require('request');
var URL = 'http://www.cnsf.gob.mx/Eventos/Paginas/Premios_2015.aspx';
var USER = '';
@ivansabik
ivansabik / xrayPhantomExample.njs
Last active Mar 21, 2017
Phantom with x-ray example
View xrayPhantomExample.njs
var xray = require('x-ray');
var phantom = require('x-ray-phantom');
var URL = 'http://www.yad2.co.il/Nadlan/rent.php?City=%D7%99%D7%A8%D7%95%D7%A9%D7%9C%D7%99%D7%9D&Neighborhood=&HomeTypeID=11&fromRooms=1&untilRooms=&fromPrice=200&untilPrice=&PriceType=1&FromFloor=&ToFloor=&EnterDate=&Info=';
xray(URL)
.use(phantom())
.select([{
$root: 'body',
tds: ['td']
@ivansabik
ivansabik / cronScriptExample.php
Last active Aug 29, 2015
Command line periodic script with PHP
View cronScriptExample.php
#!/usr/bin/php
<?php
while(true) {
sleep(5);
echo 'aufgewacht' . PHP_EOL;
}
?>