Skip to content

Instantly share code, notes, and snippets.

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

Juan Sebastian Ocampo Ospina Capriatto

🏠
Working from home
View GitHub Profile
@Capriatto
Capriatto / Mysql-Jtable-java
Created June 13, 2013 03:57
Connect database with Jtable java
import java.awt.BorderLayout;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
// some useful functions in mql4
// Alert() prints an alert with sound and window. So, it's useful to important notifications
// make sure you always cast numbers to string in order to avoid warnings in the console
Alert("");
// Print() prints a message in the experts page in the mt4's terminal window
// This is intended to inform the user all the changes that the expert or the script does.
// This is more quiet than the alarm type.
Print("");
@Capriatto
Capriatto / website-monitoring-1
Created March 4, 2020 19:19 — forked from adeekshith/website-monitoring-1
Scripts for website monitoring using Python
#!/usr/bin/env python
# sample usage: checksites.py eriwen.com nixtutor.com yoursite.org
import pickle, os, sys, logging
from httplib import HTTPConnection, socket
from smtplib import SMTP
def email_alert(message, status):
fromaddr = 'you@gmail.com'
#proxying requests to other server.
upstream webserver {
server 127.0.0.1:8069 weight=1 fail_timeout=600s;
}
#server listening 80 port
server {
listen 80;
server_name example.com;
@Capriatto
Capriatto / ScriptActualizarModulosOpenerp7.sh
Created June 26, 2018 06:00
Este Script permite actualizar todas las bases de datos del servidor OpenERP 7 de forma automatizada.
#!/bin/bash
#permite obtener los nombres de las bases de datos
OUTPUT="$(psql -U openerp -d template1 -X -t -A -c "SELECT datname FROM pg_database where datname not in ('template0', 'template1', 'postgres')")"
read -a arr_ids_temp <<< $OUTPUT #crea un arreglo con los nombres
tamanio=${#arr_ids_temp[@]} #tamaño del arreglo
mult_cuatro=(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100) #Estos multiplos de 4 se usan para actualizar las bases de datos en grupos de 4.
PID_list=() #arreglo que almacena el id de los 4 procesos que estan actualizando bases de datos
@Capriatto
Capriatto / bash
Created June 24, 2018 00:11 — forked from forkb0mb84/bash
bash
#!/bin/bash
# First line of the script is shebang which tells the system how to execute
# the script: http://en.wikipedia.org/wiki/Shebang_(Unix)
# As you already figured, comments start with #. Shebang is also a comment.
# Simple hello world example:
echo Hello world!
# Each command starts on a new line, or after semicolon:
echo 'This is the first line'; echo 'This is the second line'
@Capriatto
Capriatto / java-snippets.md
Created March 1, 2018 22:03 — forked from thomd/java-snippets.md
Java code snippets

Java Snippets

Converting Strings to int and int to String

String a = String.valueOf(2); 
int i = Integer.parseInt(a);  

Convert String to Date

@Capriatto
Capriatto / normalise.py
Created April 1, 2016 23:37 — forked from j4mie/normalise.py
Normalise (normalize) unicode data in Python to remove umlauts, accents etc.
# -*- coding: utf-8 -*-
import unicodedata
""" Normalise (normalize) unicode data in Python to remove umlauts, accents etc. """
data = u'naïve café'
normal = unicodedata.normalize('NFKD', data).encode('ASCII', 'ignore')
print normal
<p><a href="MY WEBSITE LINK" target="_blank"><img src="IMAGE LINK" style='width:100%;' border="0" alt="Null"></a></p>
@Capriatto
Capriatto / string java to clipboard
Last active December 19, 2015 17:39
Using a string for put text in pc's clipboard.
package test;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
public class CopyStringToClipboard {
public static void main(String[] args) {