Skip to content

Instantly share code, notes, and snippets.

View JJ's full-sized avatar
🏠
Working from home

Juan Julián Merelo Guervós JJ

🏠
Working from home
View GitHub Profile
@MattOates
MattOates / BioREPL
Last active January 12, 2017 13:22
New Rakudo REPL with slanged multiline quote constructor for arrays of bio-sequence objects. Example takes copy pasted FASTA formatted sequence data between ` ` and creates an array of sequence objects. Translated into amino acids we get the PERL peptide ;3 For the code that generates the slang please see https://github.com/MattOates/BioInfo/blo…
$ perl6 -MBioInfo
To exit type 'exit' or '^D'
> my @dna = `
* >id comment
* CCCGAACGGCTT
* `;
[>id comment
CCCGAACGGCTT
]
> @dna[0].translate
@yowcow
yowcow / bin-dec-hex.p6
Last active May 3, 2018 09:38
Binary/Decimal/Hex in Perl 6
use v6;
# Hex => Dec
:16("ff").base(10); # 255
# Dec => Bin
:10("10").base(2); # 1010
# Bin => Hex
:2("1111").base(16); # F
@gwillem
gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created June 16, 2016 21:59
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# [email protected]
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
#!/usr/bin/env perl6
my Int $len = 16;
my $maxlen = 32768;
my $how-many =100000;
while $len < $maxlen {
my $start = now;
my int @ones[$len];
for 1..$how-many {
loop (my int $i = 0; $i < $len; $i++) {
@ElenaMerelo
ElenaMerelo / cards.md
Last active January 8, 2017 11:57
Deck of cards which can be shuffled

#Deck of cards First we pick a random card, then in the second line we shuffle the whole deck of cards, including the one chosen

((1,2,3,4,5,6,7,8,9,10,'j','q','k') X~ <♥,♦,♣,♠>).roll

((1,2,3,4,5,6,7,8,9,10,'j','q','k') X~ &lt;♥,♦,♣,♠&gt;).pick(52)

PLAYING CARDS


Here we have the code of the program. <((1,2,3,4,5,6,7,8,9,10,'J','Q','K') X ("♠","♥","♦","♣")).roll>

<((1,2,3,4,5,6,7,8,9,10,'J','Q','K') X ("♠","♥","♦","♣")).pick(52)>

<roll> is used for picking any card randomly.

@skids
skids / rolevolution.txt
Last active May 23, 2018 18:45
rakudo rolevolution branch
TLDR:
https://github.com/skids/rakudo/tree/rolevolution3
... is a spectest-passing branch of rakudo with:
A) Working diamond role composition
B) A solution to Ovid's complaint about role method overrides
...but the code needs a bit of work.
@myshov
myshov / function_invocation.js
Last active August 19, 2024 12:23
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);
@israelem
israelem / intervalo.py
Created August 3, 2017 22:33
Lee tres números, dos son los extremos de un intervalo y el tercero es el número que hay que comprobar si se encuentra en el intervalo.
"""
Lee tres números, dos son los extremos de un intervalo y el tercero es el número que hay que comprobar si se encuentra en el intervalo.
"""
minimo = int(input())
maximo = int(input())
numero = int(input())
print(minimo <= numero <= maximo)
@israelem
israelem / potencias_de_2.py
Last active January 29, 2018 17:36
Listar todos los números que sean potencia de dos entre los 1000 primeros números.
"""
Listar todos los números que sean potencia de dos entre los 1000 primeros números.
"""
from math import log2
list(filter(lambda x: log2(x) == int(log2(x)), range(1, 1000)))