This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| ts = [list(reversed(sorted([random.randint(1,6) for x in range(n)]))) for n in [3,2]] | |
| js = ["attaquant", "défenseur"] | |
| for t, j in zip(ts, js): | |
| print("tirage " + j + ": " + str(t)) | |
| r = [a>d for a,d in zip(ts[0][0:2], ts[1])] | |
| djs = [-sum(_ == v for _ in r) for v in [False, True]] | |
| for dj, j in zip(djs, js): | |
| print("domage " + j + ": " + str(dj)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use List::Util qw(zip) | |
| @a = reverse sort map {int(rand 6) + 1} (1..3) | |
| print "tirage attaquant: @a\n" | |
| @d = reverse sort map {int(rand 6) + 1} (1,2) | |
| print "tirage defenseur: @d\n" | |
| @r = map {$_->[0] > $_->[1]} ((zip \@a, \@d)[0..1]) | |
| $dd = - grep $_ == 1, @r | |
| $da = - grep($_ == "", @r) | |
| print "dommage attaquant:$da\n" | |
| print "dommage défenseur:$dd\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use List::Util qw(zip) | |
| @t = ( [ 3, "attaquant", "" ], [ 2, "defenseur", 1]) | |
| map { push @$_, ([reverse sort map {(int rand 6) + 1} (1..$_->[0])]) } @t | |
| map { print "tirage $_->[1]: @{$_->[3]}\n" } @t | |
| @r = map {$_->[0] > $_->[1]} ((zip $t[0]->[3], $t[1]->[3])[0..1]) | |
| map { $v = $_->[2]; push @$_, ( - grep $_ == $v, @r) } @t | |
| map { print "domage $_->[1]: $_->[4]\n" } @t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cat /dev/urandom | tr -dc '1-6' | head -c 3 | sed -r 's/(.)/\1\n/g' | sort -r > DA ; echo 'tirage attaquant'; cat DA; cat /dev/urandom | tr -dc '1-6' | head -c 2 | sed -r 's/(.)/\1\n/g' | sort -r > DD ; echo 'tirage défenseur'; cat DD; paste DA DD | head -n 2 | sed -e '1 iA=0; D=0' -e 's/\([1-6]\).*\([1-6]\)/if [[ \1 -le \2 ]]; then A=\$(( A - 1 )); else D=\$(( D - 1 )); fi/' -e '$ aecho attaquant \$A ; echo defenseur \$D ' | bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #added to .profile | |
| (sleep $((20 * 60 )); cvlc --play-and-exit /usr/local/share/sounds/Alarm_or_siren.ogg ; gnome-session-quit --logout ; sleep $(( 2 * 60 )); cvlc --play-and-exit /usr/local/share/sounds/Alarm_or_siren.ogg ; gnome-session-quit --force ; ) & |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Main { | |
| public static void main(String[] args) { | |
| System.out.println(Long.toBinaryString(Double.doubleToLongBits(1650e-9))); | |
| System.out.println(Long.toBinaryString(Double.doubleToLongBits(1650e-9)).length()); | |
| System.out.println(Long.toBinaryString(Double.doubleToLongBits(-1650e-9))); | |
| System.out.println(Long.toBinaryString(Double.doubleToLongBits(-1650e-9)).length()); | |
| } | |
| } | |
| // 1111101011 1011101011101011001000101111100100101001010011000011 | |
| // 62 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (define (square x) (* x x)) | |
| (define (sum-of-squares x y)(+ (square x) (square y))) | |
| (define (sum-of-squares-a-max-b-c a b c) | |
| (if (< b c) | |
| (sum-of-squares a c) | |
| (sum-of-squares a b))) | |
| (define (sum-of-squares-2-greatests x y z) | |
| (if (< x y) | |
| (sum-of-squares-a-max-b-c y x z) | |
| (sum-of-squares-a-max-b-c x y z))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Input: list of rows with format: "<filesize> filename", e.g. | |
| # filesizes.txt | |
| ####################### | |
| # 1000K file1.txt | |
| # 200M file2.txt | |
| # 2G file3.txt | |
| # | |
| # Output: | |
| cat filesizes.txt | numfmt --from=iec | awk 'BEGIN {sum=0} {sum=sum+$1} END {printf "%.0f\n", sum}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @match https://*/auth/realms/myrealm/protocol/openid-connect/auth* | |
| (function() { | |
| 'use strict'; | |
| var divDuration = document.createElement("div"); | |
| divDuration.setAttribute('id', 'userscript_duration'); | |
| document.getElementById('kc-header-wrapper').after(divDuration); | |
| const start = Date.now(); | |
| function update_userscript_duration() { | |
| document.getElementById('userscript_duration').innerHTML = ((Date.now() - start) / 1000 / 60).toFixed(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @match https://mygitlab.com/groups/mygroup/-/merge_requests?* | |
| (function() { | |
| 'use strict'; | |
| const names = ["alice", "bernard", "etc."]; | |
| const projects = ["save-world", "cure-all-diseases"]; | |
| const selectors = names.map(name => `div.issuable-info-container div.issuable-info span.issuable-authored a[data-username="${name}"]`) | |
| .concat(projects.map(project => `div.issuable-info-container div.issuable-main-info div.merge-request-title span.merge-request-title-text a[href*="/${project}/"]`));; | |
| [].filter.call(document.querySelectorAll('main#content-body > ul > li'), li => !selectors.find(selector => li.querySelector(selector))).forEach(li => li.remove()); | |
| })(); |