Skip to content

Instantly share code, notes, and snippets.

@joseporiol
joseporiol / SignalITF.mqh
Created February 2, 2015 11:03
Signal Filter depends on Time. Good Hours of Day, bad hours of day, Good Day of Week, Bad Days of week
//+------------------------------------------------------------------+
//| SignalITF.mqh |
//| Copyright © 2010, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//| Revision 2011.03.30 |
//+------------------------------------------------------------------+
#include <Expert\ExpertSignal.mqh>
// wizard description start
//+------------------------------------------------------------------+
//| Description of the class |
@joseporiol
joseporiol / process_all_rows.sql
Created August 20, 2014 13:14
BULCK COLLECT Example all rows and columns from a table
PROCEDURE process_all_rows
IS
TYPE employees_aat
IS TABLE OF employees%ROWTYPE
INDEX BY PLS_INTEGER;
l_employees employees_aat;
BEGIN
SELECT *
BULK COLLECT INTO l_employees
FROM employees;
@joseporiol
joseporiol / TitleExtractor.java
Created March 7, 2014 11:27
Extract title from WebPage
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@joseporiol
joseporiol / ArrayListtoString.java
Created March 1, 2014 16:01
Convert ArrayList to String[]
ArrayList<String> stock_list = new ArrayList<String>();
stock_list.add("stock1");
stock_list.add("stock2");
String[] stockArr = new String[stock_list.size()];
stockArr = stock_list.toArray(stockArr);
for(String s : stockArr)
System.out.println(s);
}
@joseporiol
joseporiol / debug_http_req_resp.java
Created February 26, 2014 17:16
View HTTP Request and response
System.setProperty("com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump", "true");
System.setProperty("com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump", "true");
System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true");
System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true");
@joseporiol
joseporiol / StringTokenizer.java
Created February 26, 2014 14:13
String tokenizer
import java.util.StringTokenizer;
public class StringTokenizer {
public static void main(String[] args) {
String str = "This is String , split by StringTokenizer, created by mkyong";
StringTokenizer st = new StringTokenizer(str);
System.out.println("---- Split by space ------");
while (st.hasMoreElements()) {
@joseporiol
joseporiol / simple_curl.php
Created February 25, 2014 13:42
Simple CURL example
function curl_download($Url){
// is cURL installed yet?
if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}
// OK cool - then let's create a new cURL resource handle
$ch = curl_init();
@joseporiol
joseporiol / overloading.php
Created February 25, 2014 13:41
Function overloading
function Test(){
$NumberOfArguments = func_num_args();
for ($x=0; $x < $NumberOfArguments; $x++){
$Argument = func_get_arg($x);
print $Argument . "\n";
}
// Another way:
@joseporiol
joseporiol / remove_empty_entries_array.php
Created February 25, 2014 13:40
Removes empty entries from a array recursivly
function array_remove_empty($arr){
$narr = array();
while(list($key, $val) = each($arr)){
if (is_array($val)){
$val = array_remove_empty($val);
// does the result array contain anything?
if (count($val)!=0){
// yes :-)
$narr[$key] = $val;
}
@joseporiol
joseporiol / random_password.php
Created February 25, 2014 13:38
Random password of given characters
function random_password($length, $characters='abcdefgh1234567890'){
if ($characters == ''){ return ''; }
$chars_length = strlen($characters)-1;
mt_srand((double)microtime()*1000000);
$pwd = '';
while(strlen($pwd) < $length){
$rand_char = mt_rand(0, $chars_length);