Skip to content

Instantly share code, notes, and snippets.

View cristianrubioa's full-sized avatar
:octocat:

Cristian Rubio cristianrubioa

:octocat:
View GitHub Profile
@cristianrubioa
cristianrubioa / square.py
Last active December 14, 2020 08:30
Print the outline of a square
cant = 5
c = 'x'
x = 1
while x < cant:
if x == 1:
print(c * cant)
else:
print(c, ' ' * (cant - 4), c)
x += 1
print(c * cant)
@cristianrubioa
cristianrubioa / motion_detector.md
Created November 16, 2020 04:54
Config - Motion Detector

Install

sudo apt-get install motion

Run

sudo motion
@cristianrubioa
cristianrubioa / waiting_bar.py
Created November 16, 2020 04:41
Waiting bar animation in Python
import sys
import time
animation = "|/-\\"
for i in range(100):
time.sleep(0.5)
sys.stdout.write("\r" + animation[i % len(animation)])
sys.stdout.flush()
print("End!")
@cristianrubioa
cristianrubioa / pyramid.m
Created July 15, 2020 08:48
Pyramid (isosceles triangle) in MATLAB
n = 10; x = [];
for i = 1:n
x = strcat(x,'*');
s = [blanks(n-i) x];
disp([s fliplr(s)])
end
% Demo with n = 5
% >>
@cristianrubioa
cristianrubioa / block_hosts.txt
Created July 15, 2020 08:17
Block annoying pages
Windows: C:\Windows\System32\drivers\etc\hosts
Unix: /etc/hosts
@cristianrubioa
cristianrubioa / http_server.py
Created July 10, 2020 08:03
Simple http server with Python
import http.server
import socketserver
PORT = 8081
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()
@cristianrubioa
cristianrubioa / backup.sh
Last active July 10, 2020 07:58
Backup utility for directory
#!/bin/bash
BACKUP_PATH="/Users/user/file_backup"
HOME_PATH="/Users/user/file_home/"
DATE=`date +%d%m%Y`
BACKUP="backup_"
EXT=".tar"
@cristianrubioa
cristianrubioa / multiply.txt
Created July 8, 2020 07:50
Multiplying two numbers in assembly MS-DOS
# Connecting physical folders
MOUNT C: /Users/user/file
C:
# To view memory, enter programs into it,
# and track its execution
debug
a100
# Clean records and multiply