Skip to content

Instantly share code, notes, and snippets.

View niczky12's full-sized avatar
🖊️

Bence Komarniczky niczky12

🖊️
View GitHub Profile
data_simple = [0.1, 0.2, 0.3, 0.7, 0.8, 0.9]'
@niczky12
niczky12 / fizzbuzz.jl
Created May 26, 2020 09:07
FizzBuzz in Julia
function fizzer()
for i in 1:100
if i % 15 == 0
x = "FizzBuzz"
elseif i % 5 == 0
x = "Buzz"
elseif i % 3 == 0
x = "Fizz"
else
x = i
@niczky12
niczky12 / generate_column.sql
Created May 26, 2020 09:16
Create a row using array generators in BQ
SELECT *
FROM UNNEST(GENERATE_ARRAY(1, 15)) AS num
@niczky12
niczky12 / fizzbuzz.sql
Last active May 26, 2020 09:29
doing fizzbuzz with BigQuery case when statements
WITH
numbers AS (
-- this is the same as before, but wrapped in a with statement
SELECT
*
FROM
UNNEST(GENERATE_ARRAY(1, 100)) AS num )
SELECT
num,
@niczky12
niczky12 / fibonacci.js
Last active May 27, 2020 19:39
Fibonacci in JS
function fib(n) {
var numbers = [0, 1] // initialise the array
while (n > 1) {
var new_num = numbers[0] + numbers[1];
numbers.shift(); // drop the first element
numbers.push(new_num); // add the new element to the end
n -= 1;
}
return numbers[n];
}
@niczky12
niczky12 / fibonacci_fun.sql
Created May 27, 2020 19:46
fibonacci function in BQ
CREATE TEMP FUNCTION fibonacci(n INT64)
RETURNS INT64
LANGUAGE js AS
"""
var numbers = [0, 1]
while (n > 1) {
var new_num = numbers[0] + numbers[1];
numbers.shift();
numbers.push(new_num);
n -= 1;
@niczky12
niczky12 / fibonacci_50.sql
Created May 27, 2020 19:51
First 50 fibonacci numbers in BQ
CREATE TEMP FUNCTION fibonacci(n INT64)
RETURNS INT64
LANGUAGE js AS
"""
var numbers = [0, 1]
while (n > 1) {
var new_num = numbers[0] + numbers[1];
numbers.shift();
numbers.push(new_num);
n -= 1;
@niczky12
niczky12 / sum_fibonacci.sql
Created May 27, 2020 20:03
sum of fibonacci in BQ
CREATE TEMP FUNCTION fibonacci(n INT64)
RETURNS INT64
LANGUAGE js AS
"""
var numbers = [0, 1]
while (n > 1) {
var new_num = (numbers[0] + numbers[1]) % 1000000;
numbers.shift();
numbers.push(new_num);
n -= 1;
@niczky12
niczky12 / bq_dataset.sh
Created June 3, 2020 06:18
Create BQ dataset
export LOCATION=europe-west2
bq --location=$LOCATION mk --dataset \
--default_table_expiration 7200 \
--description "Tables for different file types" \
files
@niczky12
niczky12 / boston.py
Created June 3, 2020 06:36
Create a toy CSV file
import pandas as pd
from sklearn import datasets
# load a toy dataset
data = datasets.load_boston()
boston_df = pd.DataFrame(data["data"], columns=data["feature_names"])
# save as CSV
boston_df.to_csv("boston.csv", index=False)