Skip to content

Instantly share code, notes, and snippets.

View stokito's full-sized avatar
Self-hosting become easier

Sergey Ponomarev stokito

Self-hosting become easier
View GitHub Profile
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
A: array of Integer; // массив целых чисел
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <crypt.h>
/*
To compile:
$ gcc check.c -lcrypt -o check
$ ./check
*/

Keybase proof

I hereby claim:

  • I am stokito on github.
  • I am stokito (https://keybase.io/stokito) on keybase.
  • I have a public key ASCpL3KIIhac4IjEIhLojZyzFSqceSuBLJaf08RZXn4sXQo

To claim this, I am signing this object:

@stokito
stokito / StacktracePatternLayout.java
Created November 11, 2017 15:05
StacktracePatternLayout: LOG4J pattern enhanced for stacktraces
package com.example;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.helpers.PatternConverter;
import org.apache.log4j.helpers.PatternParser;
import org.apache.log4j.spi.LoggingEvent;
@stokito
stokito / pom.xml
Last active December 5, 2017 07:58
Example of creation symlink to target folder on Windows. symlink may be to another partion with more space or even in memory (that increases build speed up to 20%)
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.stokito</groupId>
<artifactId>clean-symlink-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
package util;
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
public class XMLEscaper {
public static final String[] ESCAPED_CHAR = {"&", "'", "\"", "<", ">"};
public String escape(String aText) {
if (aText == null) return null;
/* BEGIN OF RESPONSIVE PLACEHOLDER CLASS */
/**
placeholder-xs class to show placeholder with field name for mobile phones but to hide and show label instead on larger screens.
Media for bigger devices than phones (tablet, laptops larger than 767px)
*/
@media (min-width: 768px) {
.placeholder-xs::-webkit-input-placeholder { /* Chrome */
color: transparent;
}
@stokito
stokito / MemoryEater.java
Created June 19, 2018 22:34
Recover from OutOfmemoryException
package name.stokito.memeater;
import org.apache.derby.iapi.services.memory.LowMemory;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.ArrayList;
import java.util.List;
public class MemoryEater {
private static final int MB = 1048576;
/**This example illustrates how to extract the sign (the leftmost bit), exponent (the 8 following bits) and mantissa (the 23 rightmost bits) from a float in Java.*/
void floatDestuct() {
int bits = Float.floatToIntBits(-0.005f);
int sign = bits >>> 31;
int exp = (bits >>> 23 & ((1 << 8) - 1)) - ((1 << 7) - 1);
int mantissa = bits & ((1 << 23) - 1);
System.out.println(sign + " " + exp + " " + mantissa + " " +
Float.intBitsToFloat((sign << 31) | (exp + ((1 << 7) - 1)) << 23 | mantissa));
}
@stokito
stokito / binary_search.asm
Created March 17, 2019 14:40
Binary Search on x8085 ASM
; Just for test purposes it would be nice to automatically generate test array (haystack) in which to find a needle.
; Fill memory with 8 elements: 0, 1.. 7 and value of element corresponds to it's addresses.
mvi b, 7 ; last index to fill untill
mvi h, 0 ; set up HL as memory pointer
mvi l, 0 ; set up HL as memory pointer
loop: inr l ; increase l by one
mov m, l
mov a, l
cmp b
jm loop