Skip to content

Instantly share code, notes, and snippets.

@gordinmitya
gordinmitya / isprime.pas
Created November 23, 2015 14:29
Составить программу для проверки, можно ли заданное натуральное число N представить в виде квадрата простого числа.
var n, h: Integer;
function isPrime(n: INteger): Boolean;
var i: integer;
begin
isPrime:=true;
//for i:=2 to n-1 do - как тебе больше нравится
for i:=2 to trunc(sqrt(n)) do
if n mod i = 0 then
isPrime := false;
<?php
$key = "GDSHG4385743";
$attempt = 0;
if (isset($_REQUEST["input"]))
{
$attempt=isset($_REQUEST["attempt"])?(int)$_REQUEST["attempt"]:0;
$x = $_REQUEST["x"];
$randNumber = encode($_REQUEST["randNumber"], $key);
if ($attempt<7)
@gordinmitya
gordinmitya / Guess.cs
Last active April 18, 2016 07:30 — forked from anonymous/Guess
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Index1
{
public class Program
{
<?php
namespace Models;
abstract class EventSubject {
public static abstract function subjectName();
public static function reverseName(){}
/*public static function subjectId() {
<?php
namespace Models;
class Group extends EventSubject
{
public static function subjectName() {
return 'group';
}
public static function reverseName() {
<?php
namespace Models\v2;
abstract class EventSubject extends \Models\EventSubject {
public static function schedule($id) {
$res = parent::schedule($id);
for ($w=0; $w<count($res); ++$w) {
for ($d=0; $d<count($res[$w]['days']); ++$d) {
for ($e=0; $e<count($res[$w]['days'][$d]['events']); ++$e) {
import random
import math
from datetime import datetime
def eco_pov(a, d, p):
res = a % p
d -= 1
while d > 0:
res *= a
res %= p
@gordinmitya
gordinmitya / wtf.js
Last active December 11, 2016 17:19
<!DOCTYPE html>
<html>
<head></head>
<body>
<div id="task1">
<input id="t0" type="number" value="18.5"/>
</div>
<div id="task2">
<input id="t0" type="number" value="18.5"/>
</div>
@gordinmitya
gordinmitya / EndlessList.kt
Created January 30, 2017 14:54
Бесконечный скролл RxKotlin Android
class EndlessList {
companion object {
fun <T> get(recyclerView: RecyclerView, next: (Int) -> Observable<Response<T>>): Observable<Response<T>> {
var loading = false
var hasNextPage = true
return Observable.create<Int> {
val lm = recyclerView.layoutManager
val getLastVisible = if (lm is LinearLayoutManager) {
fun() = lm.findLastVisibleItemPosition()
} else if (lm is GridLayoutManager) {
@gordinmitya
gordinmitya / MainActivity.java
Last active February 3, 2017 09:02
Пример безопасной работы с потоками
// GameManager.java
public class GameManager {
private GameManager() {}
public static create(){
GameManager gm = new GameManager();
gm. // инициализируем созданием нового
return gm;
}
public static createFromStream(InputStream stream){
GameManager gm = new GameManager();