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
| v=i=>(!(eval(i.split('').map((e,i)=>(e*[1,3][i%2])).join('+'))%10)) |
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
| #include <cassert> | |
| #include <cmath> | |
| #include <iostream> | |
| long calc(long a, long n, long b) | |
| { | |
| if (n == 1) | |
| return static_cast<long>(pow(a, b)); | |
| else if (n >= 1 && b <= 0) | |
| return 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
| function $(value) { | |
| return document.querySelector(value); | |
| } | |
| const canvas = $('canvas'); | |
| const sets = [ | |
| [-0.4, 0.0, 0.0, -0.4, -1.0, 0.1], | |
| [0.76, -0.4, 0.4, 0.76, 0.0, 0.0] | |
| ]; |
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
| package main | |
| import ( | |
| "fmt" | |
| "github.com/fogleman/gg" | |
| "math/rand" | |
| ) | |
| func randomFromDistribution(distribution []float64) int { | |
| randFloat := rand.Float64() |
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
| #!/bin/bash | |
| wget https://source.unsplash.com/random/1920x1080 -O ~/.wallpaper.jpg | |
| feh --bg-fill ~/.wallpaper.jpg |
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
| p 'Would you like to play a game?' | |
| abort 'I hope to play sometime' unless gets.chomp.upcase.ord==89 | |
| p 'Rock, paper or scissors?' | |
| p (s=(a={82=>83,80=>82,83=>80}).keys.sample)==(i=gets.upcase.ord) ? 'Tie' : (a[i]==s ? 'Win' : 'Loss') |
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 |
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
| #!/bin/bash | |
| xev | grep -Po '\(keysym\s[^)]+,\s\K([^\)]+)' |
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
| # Euclidean distance in ruby (2-dimensional) | |
| # The points have to be in the format [x, y] | |
| def euclidean_distance(point1, point2) | |
| # First; group the x's and y's, then sum the squared difference in x's and y's | |
| Math.sqrt(point1.zip(point2).reduce(0) { |sum, p| sum + (p[0] - p[1]) ** 2 }) | |
| end |
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
| Array.prototype.flatten = function () { | |
| var flat_arr = []; | |
| var dirty = false; | |
| for (var i = 0; i < this.length; i++) { | |
| if (typeOf(this[i]) == "array") { | |
| flat_arr = flat_arr.concat(this[i]); | |
| dirty = true; | |
| } else { | |
| flat_arr.push(this[i]); |