This file contains 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
fizzbuzz = ( | |
lambda n: 'fizzbuzz' if n % 15 == 0 else ('fizz' if n % 3 == 0 else ('buzz' if n % 5 == 0 else str(n) )) | |
) | |
# Interactivity | |
if __name__ == '__main__': | |
import sys | |
if len(sys.argv) == 1: | |
print('Give command line arguments of number to fizzbuzz.') | |
exit(1) |
This file contains 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
<?php | |
header("Content-type: text/plain"); | |
if ( $_POST['payload'] ) { | |
shell_exec("./pull"); | |
} | |
?> |
This file contains 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
require "stumpy_png" | |
include StumpyPNG | |
width = 361 | |
height = 101 | |
spectrum = Canvas.new(width, height) | |
(0..width - 1).each do |x| | |
(0..height - 1).each do |y| | |
# RGBA.from_hsla_n(hue, saturation, lightness, alpha) is an internal helper method | |
color = RGBA.from_hsl([x, 64, y]) # Here from_hsl(x, 100, y) would work exactly the same |
This file contains 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
require "time" | |
require "big_int" | |
def primesArray(n : UInt64) | |
primedex = [false, false] of Bool | |
primedex += [true] * (n - 1) | |
(2_u64..n).each do |i| | |
(2_u64..n).each do |j| | |
begin |
This file contains 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
require "./matrix.cr" # from https://github.com/Exilor/matrix.git the src.matrix.cr file -> https://github.com/Exilor/matrix/blob/master/src/matrix.cr | |
require "big_int" | |
require "benchmark" | |
def fib(n : BigInt) | |
return 0 if n == 0 | |
return 1 if n <= 2 | |
number = Matrix.rows([[BigInt.new(1), BigInt.new(1)], [BigInt.new(1), BigInt.new(0)]]) |
This file contains 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 <iostream> | |
#include <cmath> | |
#include <string> | |
using namespace std; | |
void starCross(int n) { | |
float half = (float)n * 0.5; | |
This file contains 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
require 'matrix' | |
class Sphere | |
def initialize(shine, shineFocus, mood, r) | |
@shades = ['.', ':', '|', '*' 'o', 'e', '&', '%', '#', '@'] | |
@shine = shine.normalize | |
@shineFocus = shineFocus | |
@mood = mood | |
@r = r |
This file contains 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 | |
ORIGIN=$(pwd) | |
REPOROOT="$1" | |
if [ -z "$1" ]; then | |
REPOROOT="$HOME/Git" | |
if ! [ -d "$REPOROOT" ]; then | |
REPOROOT="$HOME/git" | |
fi | |
if ! [ -d "$REPOROOT" ]; then |
This file contains 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
#!/usr/bin/env ruby | |
height = %x{ tput lines }.to_i - 3 # -3 for PS1 | |
width = %x{ tput cols }.to_i | |
scale = 0.6 * width.to_f / height.to_f | |
definition = 40 | |
def calculate a, b, c_arr | |
ca, cb = c_arr |
This file contains 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
. /etc/bashrc | |
prompt() { | |
extra=2 | |
PS1=$(printf "\n%*s\r%s\n>>> " "$(expr $(tput cols) - ${#PWD} + $(if [[ $PWD/ = "$HOME"/* ]]; then echo ${#HOME} - 1; else echo 0; fi) + $extra )" '[ \w ]' '\u@\h') | |
} | |
PROMPT_COMMAND=prompt | |
. ~/.functions | |
. ~/.aliases |
OlderNewer