Skip to content

Instantly share code, notes, and snippets.

View u-mulder's full-sized avatar
🤔
Hmmmmmm

Kirill Baranov u-mulder

🤔
Hmmmmmm
View GitHub Profile
@owainlewis
owainlewis / Example.hs
Last active June 1, 2020 20:30
Haskell HTTP GET request example
module Example () where
import Network.HTTP
-- Non HTTPS
-- 1. Perform a basic HTTP get request and return the body
get :: String -> IO String
get url = simpleHTTP (getRequest url) >>= getResponseBody
@nikic
nikic / php-5.5-features.md
Last active August 31, 2020 10:39
List of new features in PHP 5.5
@nelsonsar
nelsonsar / PosixErrorCodes.php
Created February 11, 2015 01:59
Posix error codes as class of constants. From here: http://fxr.watson.org/fxr/source/sys/errno.h
<?php
class PosixErrorCode
{
const EPERM = 1; /* Operation not permitted */
const ENOENT = 2; /* No such file or directory */
const ESRCH = 3; /* No such process */
const EINTR = 4; /* Interrupted system call */
const EIO = 5; /* Input/output error */
const ENXIO = 6; /* Device not configured */
@stefansundin
stefansundin / install-pre-commit.sh
Last active September 17, 2023 11:46
Git pre-commit check to stop accidental commits to master/main/develop branches.
#!/bin/bash
# This gist contains pre-commit hooks to prevent you from commiting bad code or to the wrong branch.
# There are six variants that I have built:
# - pre-commit: stops commits to master/main/develop branches.
# - pre-commit-2: also includes a core.whitespace check.
# - pre-commit-3: the core.whitespace check and an EOF-newline-check.
# - pre-commit-4: only the core.whitespace check.
# - pre-commit-5: elixir formatting check.
# - pre-commit-6: prettier formatting check.
# Set the desired version like this before proceeding:

Обращение к российским IT-специалистам

Коллеги! Армия Путина вторглась в Украину под предлогом «денацификации» и ведёт там грязную войну. У многих из нас есть коллеги из Украины, с которыми можно пообщаться и убедиться в том, что никакого «освобождения» от Путина им не нужно.

Многим из нас сейчас страшно. Но открытое письмо нашей индустрии против этой войны собрало уже более 30 000 подписей. Нас много, и мы уверены, что это не предел.

Правительству тоже страшно: страшно потерять нас. А значит, действия каждого из нас могут помочь прекратить это безумие.

Что делать

@nikic
nikic / objects_arrays.md
Last active April 12, 2024 17:05
Post explaining why objects often use less memory than arrays (in PHP)

Why objects (usually) use less memory than arrays in PHP

This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)

The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array part of it away. So how does that work?

The key here is that objects usually have a predefined set of keys, whereas arrays don't:

@henriquemenezes
henriquemenezes / postgresql-set-id-seq.sql
Created March 31, 2016 12:23
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));