- 1
str_replace("\t", " ", $file_new);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+24.7
str_replace("\t", " ", $file_new);
4страйко)
+29
global $page_parent; //Целочисленный массив с айдями родителя страницы
global $page_title; //Строковый массив с названиями страниц
global $page_dir; //Целочисленный массив массивов списка страниц в странице (o_O)
global $page_dirs; //Количество страниц в странице, если 0 то страница не содержит
... some code ...
function TreeBuild($ina)
{
foreach($page_dir[$ina] as $ina)
{
echo $ina.'=>'.$page_dirs[$ina].'<br>';
if($page_dirs[$ina] != 0)
{
TreeBuild($ina);
}
}
return 0;
}
TreeBuild($i);
Нихрена не пойме с этой рекурсией
+1
if ($text[2] == 'www.' or $text[2] == 'Www.' or $text[2] == 'wWw.' or $text[2] == 'wwW.' or $text[2] == 'WwW.' or $text[2] == 'WWw.' or $text[2] == 'wWW.' or $text[2] == 'WWW.')
Можно было так: if(strtolower($text[2]) == 'www.')
0
# Теперь нам нужны несколько изображений для выполнения
# логического вывода. Давайте загрузим их с помощью wget.
urls = [
"https://mir-s3-cdn-cf.behance.net/project_modules/max_3840/2712bd29493563.55f6ec5e98924.jpg",
"https://i.pinimg.com/736x/5a/8a/5c/5a8a5c4cd658580ae4719e5c96043541.jpg",
"https://mir-s3-cdn-cf.behance.net/project_modules/max_1200/4d222729493563.55f6420cd3768.jpg"
]
downloaded_files = []
for index, url in enumerate(urls, start=1):
os.system(f"wget {url} -O pose-{index}.jpg")
downloaded_files.append(f"pose-{index}.jpg")
Датасаентист — не программист, и сегодня ему предстояла трудная ночь...
https://habr.com/ru/articles/772558/
0
Events.on(EventType.ClientLoadEvent, () => {
const oneDialog = new BaseDialog(" ");
oneDialog.cont.add(" ").row();
oneDialog.cont.button("OK", () => {
oneDialog.hide();
const twoDialog = new BaseDialog(" ");
twoDialog.cont.add(" ").row();
twoDialog.cont.button("OK", () => {
twoDialog.hide();
const threeDialog = new BaseDialog(" ");
threeDialog.cont.add(" ").row();
threeDialog.cont.button("OK", () => {
threeDialog.hide();
const fourDialog = new BaseDialog(" ");
fourDialog.cont.add(" ").row();
fourDialog.cont.button("OK", () => {
fourDialog.hide();
const fiveDialog = new BaseDialog(" ");
fiveDialog.cont.add(" ").row();
fiveDialog.cont.button("OK", () => {
fiveDialog.hide();
const sixDialog = new BaseDialog(" ");
sixDialog.cont.add(" ").row();
sixDialog.cont.button("OK", () => {
sixDialog.hide();
const sevenDialog = new BaseDialog(" ");
sevenDialog.cont.add(" ").row();
sevenDialog.cont.button("OK", () => {
sevenDialog.hide();
const eightDialog = new BaseDialog(" ");
eightDialog.cont.add(" ").row();
eightDialog.cont.button("OK", () => {
eightDialog.hide();
const nineDialog = new BaseDialog(" ");
nineDialog.cont.add(" ").row();
nineDialog.cont.button("OK", () => {
nineDialog.hide();
const tenDialog = new BaseDialog(" ");
tenDialog.cont.add(" ").row();
tenDialog.cont.button("OK", () => {
tenDialog.hide();
const elevenDialog = new BaseDialog(" ");
elevenDialog.cont.add(" ").row();
elevenDialog.cont.button("OK", () => {
elevenDialog.hide();
const twelveDialog = new BaseDialog(" ");
twelveDialog.cont.add(" ").row();
twelveDialog.cont.button("OK", () => {
twelveDialog.hide();
const thirteenDialog = new BaseDialog(" ");
thirteenDialog.cont.add(" ").row();
thirteenDialog.cont.button("OK", () => {
thirteenDialog.hide();
const fourteenDialog = new BaseDialog(" ");
fourteenDialog.cont.add(" ").row();
fourteenDialog.cont.button("OK", () => {
fourteenDialog.hide();
const fifteenDialog = new BaseDialog(" ");
fifteenDialog.cont.add(" ").row();
fifteenDialog.cont.button("OK", () => {fifteenDialog.hide();if(Core.settings.get("wentdowntherabbithole",false)){
const again = new BaseDialog(" ");
// ...
https://github.com/camelStyleUser/popup-unforked/blob/main/scripts/main.js
−4
import java.lang.Math;
import java.util.Random;
public class MyVector {
public static MyVector[] generateVectors(int N) {
MyVector[] generated_vectors = new MyVector[N];
for (int i = 0; i < N; i++) {
MyVector vec = new MyVector();
generated_vectors[i] = vec;
}
return generated_vectors;
}
public MyVector(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public MyVector() {
final Random random = new Random();
this.x = random.nextInt();
this.y = random.nextInt();
this.z = random.nextInt();
}
public double getX() { return this.x; }
public void setX(double newX) { this.x = newX; }
public double getY() { return this.y; }
public void setY(double newY) { this.y = newY; }
public double getZ() { return this.z; }
public void setZ(double newZ) { this.z = newZ; }
public double getLength() {
return Math.sqrt(Math.pow(this.x, 2) +
Math.pow(this.y, 2) +
Math.pow(this.z, 2));
}
public String toString() {
StringBuilder representation = new StringBuilder();
representation.
append(" { ").
append(this.x).
append(" ; ").
append(this.y).
append(" ; ").
append(this.z).
append(" } ");
return representation.toString();
}
public double scalarProduct(MyVector vec) {
return (this.getX() * vec.getX() +
this.getY() * vec.getY() +
this.getZ() * vec.getZ());
}
public MyVector vectorProduct(MyVector vec) {
MyVector result = new MyVector();
result.setX(this.getY() * vec.getZ() -
this.getZ() * vec.getY());
result.setY(this.getZ() * vec.getX() -
this.getX() * vec.getZ());
result.setZ(this.getX() * vec.getY() -
this.getY() * vec.getX());
return result;
}
public MyVector substract(MyVector vec) {
MyVector result = new MyVector();
result.setX(this.getX() - vec.getX());
result.setY(this.getY() - vec.getY());
result.setZ(this.getZ() - vec.getZ());
return result;
}
public MyVector add(MyVector vec) {
MyVector result = new MyVector();
result.setX(this.getX() + vec.getX());
result.setY(this.getY() + vec.getY());
result.setZ(this.getZ() + vec.getZ());
return result;
}
private double x;
private double y;
private double z;
}
Что здесь не так?
+1
СТРЗАМЕНИТЬ(СОКРЛ(СТРЗАМЕНИТЬ(уатПутевойЛист.Номер, "0", " ")), " ", "0") КАК НомерПЛ,
Удаляет нули в номере документа для вывода на печатную форму
0
.org 80h
src: db "++++++++++[>+++++++>++++++++++>+++<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+."
table:
db 0h db 3Eh dw @i1
db 0h db 3Ch dw @i2
db 0h db 2Bh dw @i3
db 0h db 2Dh dw @i4
db 0h db 5Dh dw @i5
db 0h db 2Eh dw @i6
db 0h db 5Bh dw @i7
start: ; %a iptr %b dptr ;
.loop:
mov %cl [%a + @src]
cmp %cl 0h
je @.loop.break
mov %si 0h
.tloop:
mov %ch [4h * %si + {@table + 1h}]
cmp %cl %ch
jne @.tloop.continue
push @.tloop.break
mov %ip [4h * %si + {@table + 2h}]
.tloop.continue:
inc %si
cmp %si 8h
jl @.tloop
.tloop.break:
inc %a
jmp @.loop
.loop.break:
int 0h
i1: ; > ;
inc %b ret
i2: ; < ;
dec %b ret
i3: ; + ;
push %el
mov %el [%b + @data]
inc %el
mov [%b + @data] %el
pop %el
ret
i4: ; - ;
push %el
mov %el [%b + @data]
dec %el
mov [%b + @data] %el
pop %el
ret
i5: ; ] ;
push %c
mov %cl [%b + @data]
cmp %cl 0h
je @.loop.break
mov %c 0h
dec %a
.loop:
cmpb [%a + @src] 5Dh ; ']' ;
jne @.loop.1
inc %c
.loop.1:
cmpb [%a + @src] 5Bh ; '[' ;
jne @.loop.2
cmp %c 0h
jz @.loop.break
dec %c
.loop.2:
loop %a @.loop
.loop.break:
pop %c
ret
i6: ; . ;
push %cl
outb E9h [%b + @data]
.wait:
inb %cl E9h
cmp %cl 0h
jne @.wait
pop %cl
ret
i7: ; [ ;
push %c
mov %c [%b + @data]
cmp %c 0h
jne @.loop.break
mov %c 0h
.loop:
cmpb [%a + @src] 5Bh ; '[' ;
jne @.loop.1
inc %c
.loop.1:
cmpb [%a + @src] 5Dh ; ']' ;
jne @.loop.2
cmp %c 0h
jz @.loop.break
dec %c
.loop.2:
inc %a
jmp @.loop
.loop.break: pop %c ret
Hello World!
0
Let's count a number of rules that can be built in GoL-like automatas. Rule is the matrix that maps some condition of cells to new state.
Cell itself could be alive or dead. And cell could have 0-8 neighbors. So, there are 2^(2*9) = 262144 different rules. Well known, that
the majority of them are primitive and produces some pure pattern or just dies in finite number of generations / infinitely fills the world
with alive cells. We also know that some rules are symmetric to each other as if we just rename (swap colors of) alive and dead cells.
Conway found the most interesting rule from entropy point of view.
2^18 is not so much. Let's take a look at 2D automata known as Rule 110. State 100 keeps cell dead:
100 -> 0
While state 001 makes cell alive:
001 -> 1
In terms of neighborhood, this two rules are indifferent: both means one live neighbor next to dead cell. But in Rule 110 not only a /number/
of neighbors is meaningful, but the /position/ of separate neighbor.
Let's imagine the GoL-like rule with the same property: we will look not only at number of neighbors, but at their position. What if to have one
neighbor at north-west gives not the same result as if neighbor were at south-east.
This change gives us much more different rules. If each neighbor is meaningful, then we have 2 ^ 8 different states of neighborhood, and cell
could be still alive or dead. If I'm not wrong there must be 2 ^ (2 * (2 ^ 8)) = 2 ^ 512 different rules.
Obviously, this space includes Conway's Game of Life and all different rules from that 262144, and gives billions of new ones. Obviously,
the majority of them are trivial too. But there may be some interesting entropy-like rules different from the Conway's one.
This space is too huge to be discovered manually, and even with bruteforce algorithms too. But evolution algorithms could be used to find rules
with some special properties.
So, I have two questions:
1) Does this space has a given name, anybody researched that?
2) I will be glad to hear any ideas on how to make this space simpler by excluding symmetric states etc. to save the time for discovering.
Any cellular nerds here?
0
#include <functional>
#include <string>
void rooster(uint32_t number)
{
}
void rooster(std::string& str)
{
}
int main()
{
//не осилил ни один компилятор
std::function<void(std::string&)> f = std::bind(&rooster, std::placeholders::_1);
//осилил gcc6.1+, но не может осилить clang 13.0
std::function<void(std::string&)> f2 = std::bind<void(std::string&)>(&rooster, std::placeholders::_1);
return 0;
}
Почему компиляторы крестов не могут сами разрулить ситуацию?