Skip to content

Instantly share code, notes, and snippets.

@naazeri
naazeri / snake.py
Created September 19, 2023 10:36
snake_game_in_30_line_python_pygame
import pygame as pg
pg.init()
y, step, head = segments = [15, 16, 17]
n, apple = step, 99
screen = pg.display.set_mode([225] * 2, pg.SCALED)
score = 0
while segments.count(head) % 2 * head % n * (head & 240):
for e in pg.event.get(768):
void multiply(int number)
{
number *= 2;
}
void add(ref int number)
{
number += 1;
}
setTimeout(() => {
console.log("timeout 1")
Promise.resolve().then(() => {
console.log("p1")
})
}, 0)
setTimeout(() => {
console.log("timeout 2")
from tkinter import *
from tkinter.ttk import *
from time import strftime
# creating window
window = Tk()
window.title('Clock')
# create label
class Node:
def __init__(self, value):
self.value = value
self.next = None
class LinkedList:
def __init__(self, head=None):
self.head = head
import random
numbers = []
def getUniqueRandom(start, end):
while True:
n = random.randrange(start, end)
if n not in numbers:
return n
import random
# choices in game. r=rock, p=paper, s=scissors
choices = ['r', 'p', 's']
# get user input
userChoice = input('Choose your weapon [r]ock, [p]aper, or [s]cissors: ')
if userChoice not in choices:
print('Invalid input')
@naazeri
naazeri / n28s.lua
Created December 2, 2022 16:43 — forked from Lerg/n28s.lua
Script wrapper for Defold
local hashed = require('libs.hashed')
local _M = {}
local scripts = {}
-- NoMoreGlobalFunctionsInScripts
function _M.new()
local script = {
@naazeri
naazeri / gistGitAlias.md
Last active March 23, 2023 18:05
Add Alias to Git

this command set alias for git add -A to git a:

git config --global alias.a 'add -A'

@naazeri
naazeri / gist:167ce9941098930e1160864e3753be29
Created March 9, 2021 15:01
Show All Git Commits in Beautiful Mode
git log --oneline --graph --reflog --date-order