Skip to content

Instantly share code, notes, and snippets.

View konchunas's full-sized avatar

Julian Konchunas konchunas

View GitHub Profile
@konchunas
konchunas / collision-shape-from-code.gd
Created April 5, 2020 14:10
Adds a CollisionShape to a StaticBody in GDScript
func create_collision():
var body = StaticBody.new()
var collision = CollisionShape.new()
var shape = CylinderShape.new()
shape.radius = 100
shape.height = 50
collision.set_shape(shape)
body.add_child(collision)
self.add_child(body)
fn has_even(numbers: Vec<i32>) -> bool {
for num in numbers {
if num % 2 == 0 {
return true;
}
}
return false;
}
fn main() {
let vec = vec![1, 9, 2, 5, 4];
from typing import List
def has_even(numbers: List[int]) -> bool:
for num in numbers:
if num % 2 == 0:
return True
return False
def main() -> None:
vec = [1,9,2,5,4]
even_exists = has_even(vec)
def has_even(numbers):
for num in numbers:
if num % 2 == 0:
return True
return False
def main():
vec = [1,9,2,5,4]
even_exists = has_even(vec)
print("Has even number", even_exists)
fn has_even<T0, RT>(numbers: T0) -> RT {
for num in numbers {
if num % 2 == 0 {
return true;
}
}
return false;
}
fn main() {
let vec = vec![1, 9, 2, 5];
struct Genesis {
timestamp: ST0,
prev_hashes: ST1,
}
impl Genesis {
fn __init__<T0>(&self, creation_time: T0) {
self.timestamp = creation_time;
self.prev_hashes = vec![];
}
class Genesis(Block):
def __init__(self, creation_time):
self.timestamp = creation_time
self.prev_hashes = []
def get_hash(self):
return self.precalculated_genesis_hash
fn main() {
let mut numbers = vec![1, 5, 10];
let multiplied = numbers.iter().map(|num| num * 3).collect::<Vec<_>>();
println!("{:?} {:?} ", "result is", multiplied);
}
if __name__ == "__main__":
numbers = [1,5,10]
multiplied = list(map(lambda num: num*3, numbers))
print("result is", multiplied)
#!/bin/sh
LAYOUT_COUNT=2
CURRENT_LAYOUT=$(gsettings get org.gnome.desktop.input-sources current)
CURRENT_LAYOUT_NUMBER=$(echo -n $CURRENT_LAYOUT | tail -c 1)
DESIRED_LAYOUT=$(expr $CURRENT_LAYOUT_NUMBER + 1)
if [ `expr $DESIRED_LAYOUT % $LAYOUT_COUNT` -eq 0 ]