Skip to content

Instantly share code, notes, and snippets.

View revuel's full-sized avatar

M. Revuelta Espinosa revuel

View GitHub Profile
@revuel
revuel / reactNativeAlert.js
Created July 4, 2021 22:16
Example of an Alert/Prompt like component for React Native
import * as React from 'react';
import {View} from "react-native";
import {Text, IconButton} from "react-native-paper";
const Alert = ({severity, message}) => {
let msg = message === undefined || message === null ? 'undefined' : message;
let svt;
let icon;
let border;
@revuel
revuel / sortingExample.R
Created May 5, 2021 19:37
A way to sort a data.frame where the first dimension is a vector of integers
# Data Generation
start.time <- Sys.time()
random.data <- c("Hola", sample(1:100, 1000, replace=TRUE), "adios")
myInput <- data.frame('number' = random.data)
myInput$isNumber <- myInput$number == as.integer(myInput$number)
myInput$isNumber <- ifelse(!is.na(myInput$isNumber), TRUE, FALSE)
splitted <- split(myInput, myInput$isNumber == TRUE)
myNumbers <- splitted[['TRUE']]
import { useState } from "react";
import { Menu, MenuItem, ListItemIcon } from "@material-ui/core";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import ListItemText from "@material-ui/core/ListItemText";
import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction";
import IconButton from "@material-ui/core/IconButton";
import MoreVertIcon from "@material-ui/icons/MoreVert";
import EditIcon from "@material-ui/icons/Edit";
import DeleteForeverIcon from "@material-ui/icons/DeleteForever";
import React, { useState, useEffect } from "react";
export default function StackExample() {
const [myArray, setMyArray] = useState([]);
const addElement = () => {
var myArrayCopy = [...myArray];
var newKey = myArray.length;
myArrayCopy.push({
item: <input disabled type="button" key={newKey} value={newKey} />
# REPLACE ELEMENTS SURROUNDED BY ANGLE BRACKETS ACCORDING TO YOUR NEEDS
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "<NAME OF USER TO BE REPLACED>" ];
then
GIT_COMMITTER_NAME="<NEW USER NAME OF THE COMMIT";
GIT_AUTHOR_NAME="<NEW USER NAME OF THE COMMIT>";
GIT_COMMITTER_EMAIL="<NEW USER EMAIL OF THE COMMIT>";
GIT_AUTHOR_EMAIL="<NEW USER EMAIL OF THE COMMIT>";
git commit-tree "$@";
else
@revuel
revuel / switch.py
Last active October 18, 2020 12:08
Dummy way to use switch like method in python 3
""" Switch example for python 3 """
def _say_hello() -> str:
return 'Hello'
def _say_goodbye() -> str:
return 'Good bye'
@revuel
revuel / inmutable_class.py
Created September 20, 2020 16:35
Dummy example of immutable class in python
""" Dumb way to produce immutable instances in Python """
class ImmutablePerson(object):
""" ... """
__slots__ = ('name', 'dob')
def __init__(self, name: str, dob: str):
""" Only available at initialization """
@revuel
revuel / playing_slots.py
Created September 20, 2020 11:57
Example of using slotting a POPO class overriding __setattr__ to do validations
""" Just playing around with slots (BASIC EXAMPLE Plain Old Python Object) """
import re
date_pattern = re.compile(r'(\d{4})[/.-](\d{2})[/.-](\d{2})$')
class Person(object):
""" Person sample class with slots """
__slots__ = ('name', 'dob')
/* To get rid of the useless subscription block of the digital diary "20Minutes"
* Works as of July 2020
* Just copy and paste the follwoing code to the browser's console at 20minutes site
*/
function enableRead() {
// Allow scroll down
var body = document.getElementsByTagName("body")
body[0].setAttribute("style", "")
@revuel
revuel / random_time_report.py
Last active January 2, 2020 08:33
Generates random time intervals, for time reporting purposes...
""" Generates random time intervals """
import random
for x in range(30):
entry_h = random.randint(8, 10)
entry_m = random.randint(0, 59)
if entry_h == 10:
entry_m = 0