Skip to content

Instantly share code, notes, and snippets.

View sergey-miryanov's full-sized avatar
💭
Father of the little toddler, may be spontaneously unavailable

Sergey Miryanov sergey-miryanov

💭
Father of the little toddler, may be spontaneously unavailable
View GitHub Profile
## Бессмертные объекты и субинтерпретаторы
Интересный факт - если посмотреть код реализации субинтерпретаторов, то никаких отсылок к бессмертным объектам найти не удастся. При этом они являются неотъемлемой основой субинтерпретаторов в CPython.
Как это происходит?
Как уже упоминалось выше, к бессмертным объектам относятся:
1. *статически* выделенные константы - `None`, `False`, `True`, `...`, `NotImplementedType`, `0`, `1`, `''`, `b''`, `()`. (`object.c:_Py_GetConstant_Init`)
2. целые числа в диапазоне [-5, 256] (`pycore_runtime_structs.h:_Py_static_objects`)
3. символы в кодировке latin1
4. статические типы (`_Py_TPFLAGS_STATIC_BUILTIN`), а также их компоненты, такие как, базовый класс, список базовых классов, `MRO` (method-resolution order)
5. интернированные строки и идентификаторы (`pycore_runtime_structs.h:_Py_cached_objects`)
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"newline": true,
"segments": [
{
"type": "text",
"style": "plain",
def func():
raise ConnectionError
# 1 вариант - обрабатывает и подавляет исключение
try:
func()
except ConnectionError as exc:
print('exception: ', type(exc), exc)
# получите сообщение:
# exception: <class 'ConnectionError'>
using Serilog;
using Serilog.Core;
using Serilog.Events;
Log.Logger = new LoggerConfiguration()
.WriteTo.Console(formatProvider:new GuidFormatter())
.Destructure.With<GuidDestructuringPolicy>()
.Destructure.ByTransforming<CustomClass>(Helper.ToString)
.Destructure.ByTransforming<CustomStruct>(Helper.ToString)
.CreateLogger();
<#
.SYNOPSIS
Generates a project change log file.
.LINK
Script posted over:
http://open.bekk.no/generating-a-project-change-log-with-teamcity-and-powershell
#>
# Where the changelog file will be created
#$changelogFile = "%system.teamcity.build.tempDir%\changes_%teamcity.build.id%.txt"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using DevExpress.Xpf.Grid;
using GUI.Params.DynamicTable.Impl;
from distutils.core import setup
from distutils.dir_util import copy_tree
from py2exe.build_exe import py2exe
import glob
import os
import zlib
import shutil
import time
import shutil
import enthought.tvtk
@sergey-miryanov
sergey-miryanov / gist:7784273
Last active December 30, 2015 05:39
Sampel of flixel bitmap cache usage
private static function getSpriteImpl(filename : String, width : Float,
resize : IResizeBitmapData) : FlxSprite
{
var key = resize.key(filename, width);
if(!FlxG.bitmap.checkCache(key))
{
if(cacheWarning)
{
trace([filename, key, "Not found"]);
}
package;
import flash.display.Sprite;
class Main extends Sprite {
public function new () {
INRES="1680x1050"
OUTRES="1366x768"
FPS="30"
MAXRATE="1000k"
AUDIOBITRATE="60k"
QUAL="veryfast"
STREAM_KEY="STREAM KEY !!!"
URL="rtmp://live.justin.tv/app/$STREAM_KEY"
avconv -v verbose -f x11grab -show_region 1 -s "$INRES" -r "$FPS" \