Skip to content

Instantly share code, notes, and snippets.

@illarionov
illarionov / MainActivity.kt
Last active January 17, 2022 12:17
Demonstration that the Android can destroy background activities on memory pressure without restarting the application
/**
* Demonstration that the Android can destroy background activities on memory pressure without restarting
* the application
https://cs.android.com/android/platform/superproject/+/android-12.0.0_r4:frameworks/base/core/java/android/app/ActivityThread.java;l=7534
*/
const val ARG_ACTIVITY_NO = "ARG_ACTIVITY_NO"
const val TAG = "MainActivity"
val gcThresholds = GcActivityMemoryThresholds()
@illarionov
illarionov / dlink_ports.pl
Created February 7, 2017 09:20
ports set converter for D-link switches
@illarionov
illarionov / uicolor2argb
Created August 15, 2016 13:06
UIColor(red:0.643, green:0.549, blue:0.839, alpha: 1) -> ffa48cd6
#!/bin/sh
#Usage: echo 'UIColor(red:0.643, green:0.549, blue:0.839, alpha: 1)' | uicolor2argb
perl -nle 'if (/UIColor\(red\:\s*(\S+)\,\s*green:\s*(\S+)\,\s*blue:\s*(\S+),\s*alpha:\s*(\S)/) { printf "%02x%02x%02x%02x\n", 0.5+255*$4, 0.5 + 255 * $1, 0.5+255*$2, 0.5+255*$3}'
package com.example.swiperefreshtest;
import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AbsListView;
public class MySwipeRefreshLayout extends SwipeRefreshLayout
@illarionov
illarionov / build.sh
Created August 13, 2013 14:14
Compile sqlcipher 2.21 with libspatialite-4.1.1
#!/bin/sh
#sqlcipher
git clone https://github.com/sqlcipher/sqlcipher.git
cd sqlcipher
./configure --enable-tempstore=yes --enable-load-extension CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto"
sudo make install
cd ..
#spatialite
@illarionov
illarionov / sync_shapers.pl
Created January 19, 2013 22:54
Cкрипт, синхронизирующий состояние IPFW с текстовым конфигом с шейперами sync_shapers.pl. Описание: http://forum.nag.ru/forum/index.php?showtopic=54379&view=findpost&p=518655
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Class::Struct;
use Data::Dumper;
use Fcntl qw(:flock);
use Getopt::Long;
use Pod::Usage;
@illarionov
illarionov / sirfmsg.pl
Created March 12, 2012 19:02
Sirf payload to transport message converter
#!/usr/bin/perl
use strict;
#Encapsualtes hex payload into SiRF binary transport message
#Example: sirfmsg.pl a600020500000000
my $payload = pack("H*", $ARGV[0]);
my $csum = 0;
my $payload_length = map { $csum = ($csum + $_) & 0x7ff } unpack("C*", $payload);