Skip to content

Instantly share code, notes, and snippets.

@gustavorv86
gustavorv86 / Agenda.c
Last active February 23, 2017 09:36
Adaptación del lenguaje C a la programación orientada a objetos
/*
File: Agenda.c
*/
#include "Agenda.h"
#include <stdio.h>
#include <stdlib.h>
void addLast(Agenda _this, Persona persona) {
AgendaNode node;
@gustavorv86
gustavorv86 / sort.c
Last active April 12, 2017 06:33
Sort algorythms in C/C++
#include "sort.h"
#include <stdlib.h>
#define SWAP(a, b, tmp) ((tmp)=(a), (a)=(b), (b)=(tmp))
void bubble_sort(float*array, int size) {
int i, j;
float tmp;
@gustavorv86
gustavorv86 / array.c
Last active April 12, 2017 06:35
Dynamic array implementation in C/C++
#include "array.h"
#include <stdio.h>
#include <stdlib.h>
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
ARRAY array_new(unsigned int size) {
ARRAY s_array;
@gustavorv86
gustavorv86 / search.c
Last active April 12, 2017 06:35
Search algorythms in C/C++
#include "search.h"
unsigned int linear_search(int* array_items, unsigned int size, int search_item) {
unsigned int i;
for(i=0; i<size; i++) {
if(array_items[i] == search_item) {
/* elemento encontrado, devolvemos el indice 'i' */
return i;
@gustavorv86
gustavorv86 / get_files.py
Created March 27, 2019 15:22
Python get all path files (not directories) of a directory recursively
#!/usr/bin/env python
import os
import sys
def _r_get_files(parent_dir, list_files):
for child_name in os.listdir(parent_dir):
## Ignore directories
# if child_name == ".git":
# continue
@gustavorv86
gustavorv86 / exec_function_timeout_process.py
Created March 28, 2019 11:49
Python: execute a function with timeout using multiprocess
#!/usr/bin/env python
import sys
import multiprocessing
import time
def fn_loop_count(message, start_count, end_count):
for i in range(start_count, end_count):
print(message + ":" + str(i))
start_count +=1
@gustavorv86
gustavorv86 / exec_function_timeout_signal.py
Created March 28, 2019 11:50
Python: execute a function with timeout using signals
#!/usr/bin/env python
import signal
import time
class SigalrmException(Exception):
pass
def sigalrm_handler(signum, frame):
raise SigalrmException()
@gustavorv86
gustavorv86 / check_ascii_file.py
Created May 16, 2019 12:45
Check if file contains ASCII printable characters.
#!/usr/bin/env python3
import os
import sys
PRINTABLE_ASCII = [
9, 10, 13, (32, 126)
]
@gustavorv86
gustavorv86 / find_symlinks.py
Created May 17, 2019 06:52
Search symbolic links into a directory.
@gustavorv86
gustavorv86 / find_broken_symlinks.py
Created May 17, 2019 06:53
Search broken symbolic links into a directory.