Skip to content

Instantly share code, notes, and snippets.

View RDCH106's full-sized avatar
Partially offline. No time...

Rubén de Celis Hernández RDCH106

Partially offline. No time...
View GitHub Profile
@RDCH106
RDCH106 / flash.sh
Last active March 29, 2017 15:20 — forked from iBet7o/description.md
Color del texto en scripts bash
#! /bin/bash
# Variables
# ------------------------------------------------------------------------------
txtSuccess='\033[1;32m'
txtError='\033[0;31m'
txtNoColor='\033[0m'
@RDCH106
RDCH106 / rename.sh
Last active March 29, 2017 15:21 — forked from iBet7o/description.md
Script bash para renombrar directorios y archivos
#! /bin/bash
source flash.sh
# Variables
# ------------------------------------------------------------------------------
pathLog=`echo $(pwd)/log.txt`
echo -n "Path to rename: "
@RDCH106
RDCH106 / cpp_logger.h
Created January 23, 2018 15:22
C++ logger with logging levels (standard output)
#pragma once
#if defined(___LOG_DEBUG)
# include <iostream>
# define LOGD(...) std::cout << " " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl;
# define LOGI(...) std::cout << " " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl;
# define LOGW(...) std::cout << " * Warning: " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl;
# define LOGE(...) std::cout << " *** Error: " << __VA_ARGS__ << "\t - " << LOG_TAG << std::endl;
#elif defined(___LOG_INFO)
@RDCH106
RDCH106 / .htaccess
Created June 22, 2018 15:50 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@RDCH106
RDCH106 / Python TCP Client Example.py
Created June 22, 2018 15:52 — forked from Integralist/Python TCP Client Example.py
Python TCP Client Server Example
import socket
hostname, sld, tld, port = 'www', 'integralist', 'co.uk', 80
target = '{}.{}.{}'.format(hostname, sld, tld)
# create an ipv4 (AF_INET) socket object using the tcp protocol (SOCK_STREAM)
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# connect the client
# client.connect((target, port))
@RDCH106
RDCH106 / cpp_callback_example.cpp
Created November 22, 2018 14:17
C++ calback example
#include <iostream>
#include <string>
#include <vector>
// Dll
typedef bool (*PointerToF)(int number);
struct A {
PointerToF m_f;
@RDCH106
RDCH106 / python_switch_examples.py
Last active December 2, 2018 16:12
Examples of switch flow control structure in Python
#############################
# Example with values
#############################
def switch_value(x):
return{
0: "APPLE",
1: "ORANGE",
2: "BANANA",
3: "PEACH"
@RDCH106
RDCH106 / cpp_inheritance_with_functions_with_default_parameter_example.cpp
Created March 21, 2019 14:40
C++ Inheritance with functions with default parameter example
#include <iostream>
#include <string>
#include <vector>
struct A
{
void f_sinarg() {
f(3);
}
@RDCH106
RDCH106 / md2rst.py
Created April 15, 2019 10:56
Script to convert Markdown (.md) to ReStructuredText (.rst)
# -*- coding: utf-8 -*-
try:
import pypandoc
except ImportError:
print("pypandoc not available!!")
exit("First install pypandoc. Ex: \"pip install pypandoc\"")
long_description = pypandoc.convert('README.md', 'rst', outputfile='README.md2rst')
@RDCH106
RDCH106 / explicit_method.cpp
Created April 15, 2019 11:09
Explicit directive simulation for method arguments and avoid implicit conversion
#include <iostream>
#include <string>
#include <vector>
#include <type_traits>
struct A
{
operator const char*() {
return m_str.c_str();
}