Skip to content

Instantly share code, notes, and snippets.

: 2+ \ n -- m
1+ 1+ ;
: 2- \ n -- m
1- 1- ;
: .NUM \ n --
s>d 0 d.r ;
VARIABLE TABLICA
@damjes
damjes / App.js
Created March 11, 2024 21:28
Test funkcji Reacta
import { useRef, useState } from 'react'
import 'bootstrap/dist/css/bootstrap.css'
function App() {
const [klik, setKlik] = useState(2)
const wpiszRef = useRef(null)
const lista = [
'Przycisk +1 jest niebieski',
'Przycisk wpisz jest czerwony',
@damjes
damjes / App.tsx
Created January 5, 2024 18:45
Porównanie wartości i lambdy jako argumentu do setX dla useState w Reaccie
import { useState } from 'react'
function App() {
const [count, setCount] = useState(0)
const [linijka, setLinijka] = useState('')
// ten sposób jest krótszy niż lambda
// wada: działa tylko raz, bo count przechowuje starą wartość
function zwiekszWartoscia() {
setCount(count + 1)
@damjes
damjes / binary-gcd-verbose.c
Created November 18, 2022 13:57
Binarne GCD
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
srand(time(NULL));
unsigned int a=rand(), b=rand();
int przesuniecie = 0;
LDX #$00
JSR a
LDX #$08
JSR a
LDX #$10
JSR a
LDX #$18
JSR a
BRK
a:
@damjes
damjes / trojkat.cpp
Created September 21, 2022 12:20
Trójkąt Pascala w Z/2 czyli Sierpińskiego
#include <iostream>
using namespace std;
int main()
{
int ile_pieter;
cout << "Trójkąt Pascala!" << endl;
cout << "Ile pięter? ";
@damjes
damjes / trojkat.cpp
Created September 21, 2022 11:38
Trójkąt Pascala
#include <iostream>
using namespace std;
int main()
{
int ile_pieter;
cout << "Trójkąt Pascala!" << endl;
cout << "Ile pięter? ";
@damjes
damjes / magicznePiatki.pl
Last active August 13, 2022 03:53
Magiczne Piątki
wstaw(E, [], [E]).
wstaw(E, [X | Xs], [E, X | Xs]) :-
E =< X.
wstaw(E, [X | Xs], [X | Ys]) :-
E > X,
wstaw(E, Xs, Ys).
sortuj([], Y, Y).
sortuj([X | Xs], Y, W) :-
wstaw(X, Y, Y1),
<?php
class Komunikat {
private static $komunikaty = [];
public $tresc;
public $typ;
function __construct($tresc, $typ = 'info') {
$this->tresc = $tresc;
$this->typ = $typ;
@damjes
damjes / sundaram.rb
Last active June 24, 2021 19:20
Sundaram sieve
# IT REALLY WORKS! CHECK IT AT https://bit.ly/3d9iWIU !
def primes(limit)
limit /= 2
t = [true] * limit
t[0] = false
i = 0
k = 1
while i < limit