Skip to content

Instantly share code, notes, and snippets.

View alogic0's full-sized avatar

Oleg Tsybulskyi alogic0

  • Odessa, Ukraine
View GitHub Profile
@alogic0
alogic0 / gasolina.html
Last active January 10, 2019 03:17
error message from a yii site
<html>
<pre>
Phasolina\PhasolinaException: Unknown error in /home/gasonline/www/vendor/gasolina/phasolina/src/Phasolina.php:242
Stack trace:
#0 /home/gasonline/www/frontend/components/User.php(132): Phasolina\Phasolina-&gt;request(Object(Phasolina\Endpoint\CityAccountGetRequest))
#1 /home/gasonline/www/frontend/components/User.php(150): frontend\components\User-&gt;loginByCookie()
#2 /home/gasonline/www/frontend/components/User.php(28): frontend\components\User-&gt;renewAuthStatus()
#3 /home/gasonline/www/vendor/yiisoft/yii2/web/User.php(351): frontend\components\User-&gt;getIdentity()
#4 /home/gasonline/www/vendor/yiisoft/yii2/base/Component.php(130): yii\web\User-&gt;getIsGuest()
#5 /home/gasonline/www/frontend/components/View.php(49): yii\base\Component-&gt;__get('isGuest')
@alogic0
alogic0 / Cyrillic_in_GHCi.md
Last active August 11, 2018 10:48
Вывод кириллицы в GHCi

source: http://edu.mmcs.sfedu.ru/mod/page/view.php?id=16778
author: Vitaly Bragilevsky

Вывод кириллицы в GHCi

Для того, чтобы в консоли GHCi нормально отображалась кириллица, можно сделать следующее (при условии, что установлена Haskell Platform):

Установить пакет wl-pprint:

cabal install wl-pprint

@alogic0
alogic0 / rn-video.hs
Last active August 17, 2018 21:06
Using regex-applicative for renaming files
module Main where
import Text.Regex.Applicative
import Text.Regex.Applicative.Common
import System.Environment
import Control.Monad.State
-- transformation example: "4_CAM 6_main_20180801101345_20180801101432.avi"
-- --> "20180801101345_20180801101432_4_CAM_6.avi"
-- or: "5_IPC_main_20160807164154_20160807164247.avi"
@alogic0
alogic0 / 1.sql
Created July 24, 2018 17:30
SQL lessons
-- https://www.w3schools.com/sql/trysql.asp
CREATE TABLE Countries(
ID int IDENTITY(1,1) PRIMARY KEY,
Country varchar(255),
Continent varchar(255)
);
INSERT INTO Countries (Country)
SELECT DISTINCT Country FROM Customers;
@alogic0
alogic0 / 1.php
Last active July 21, 2018 21:38
PHP examples
// http://sandbox.onlinephpfunctions.com/code/d1983f5ae45977a035bfb54a9d8782c74c69833c
<?php
$t = date("H");
if ($t < 18) {
echo "Have a good day!";
}
else {echo "Good evening!";}
echo "\n";
@alogic0
alogic0 / sinPlot.hs
Created July 10, 2018 14:17
sinus & cosinus
program = drawingOf(sinPlot & cosPlot & coordinatePlane)
rmax = 2 * 180
k = rmax / 10
ymax = 5
sinPlot = trigLine sin
cosPlot = trigLine cos
trigLine f = curve([(x, y) | p <- [-10 .. 10], d <- [0 .. 9], let x = p + d/10, let y = ymax * f (x * k)])
@alogic0
alogic0 / FillScreenWithDigits.hs
Last active June 12, 2018 12:00
Funny Haskell. try to run `matrix 2 (7^12345)` in ghci
import Data.Char (digitToInt)
import Data.List (unfoldr)
import Data.Tuple (swap)
bin2dec :: String -> Integer
bin2dec = foldl (\d i -> d*2 + i) 0 . map (toInteger . digitToInt)
-- dec2bin = reverse . map intToDigit . unfoldr (test . swap . flip divMod 2) where test x = if x == (0,0) then Nothing else Just x
matrix b = unfoldr (test . swap . flip divMod b) where test x = if x == (0,0) then Nothing else Just x
@alogic0
alogic0 / bootstrap.sh
Last active June 6, 2018 08:27
Installing GHC 8.4.X and cabal-install-2.2.0.0 on Windows7
#!/bin/sh
set -e
# A script to bootstrap cabal-install.
# It works by downloading and installing the Cabal, zlib and
# HTTP packages. It then installs cabal-install itself.
# It expects to be run inside the cabal-install directory.
# Install settings, you can override these by setting environment vars. E.g. if
@alogic0
alogic0 / HindleyMilner.hs
Last active June 7, 2018 12:32
The Hindley-Milner's algorithm of unification of two types. If they could be unified, of course.
module HindleyMilner where
import Control.Applicative ((<|>))
import Control.Monad (guard)
import Data.Maybe (fromJust)
type Symb = String
infixr 3 :->
data Type
@alogic0
alogic0 / anekdots.txt
Last active March 10, 2018 01:29
анекдоты для русских националистов
Нет такой одноразовой вещи, котрую русский человек не мог бы использовать дважды.
Русский, собираясь в гости, стоит перед выбором: или один носок дырявый, или оба целые, но разные.
Сошёл с рельс поезд в Украине. Машинист оправдывается.
- Там русский на рельсы вышел.
Судья:
- Так надо было давить его.
- Так я и задавил, только пришлось в поле выехать и гнаться.