Skip to content

Instantly share code, notes, and snippets.

View sysint64's full-sized avatar
:shipit:

Andrei Kabylin sysint64

:shipit:
View GitHub Profile
public static int calculateInSampleSize (BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int halfHeight = height / 2;
final int halfWidth = width / 2;
function NormalizeGradient (Gradient : TGradient; Norm : Integer) : TGradient;
var
i, j : Integer;
Step : Integer;
begin
Result := TGradient.Create (Norm);
Step := Gradient.Size/Norm;
i := 0;
function AverageGradientPoint (Gradient : TGradient; Point, Radius : Integer) : RGB;
var
i : Integer;
RGBSum : array[0..2] of Integer;
const
R = 0; G = 1; B = 2;
begin
@sysint64
sysint64 / .html
Last active February 21, 2016 07:55
Ucoz code highlight
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?autoload=true&amp;lang=css" defer="defer"></script>
<script>
function resize() {
$(".prettyprint").css("width", 700);
$(".prettyprint").each(function() {
var parent = $(this).closest(".posttdMessage");
$(this).css("width", $(parent).width()-24); // 24 - 2*12 padding
});
$(".posttdMessage img").css("max-width", 700);
@sysint64
sysint64 / .css
Last active February 21, 2016 07:58
Ucoz code highlight
<style>
.prettyprint {
width: 700px;
max-height: 500px;
overflow-x: auto;
overflow-y: auto;
font-size: 12px;
padding-left: 12px !important;
padding-right: 12px !important;
white-space: nowrap !important;
@staticmethod
def generate_interested (i_user, task):
title = i_user.first_name+" "+i_user.last_name
body = "Заинтересовался заданием №"+str(task.id)+": \""+task.title+"\""
notification = Notification.objects.create (to_users = True, task = task,
user = i_user, title = title, body = body, status = 3, system = False)
notification.to.add (task.user)
#notification.to.add (i_user)
tinymce.init({
selector: '.tinymce-widget',
//plugins : 'advlist autolink link image lists charmap print preview'
plugins: [
'advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker',
'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media imagetools nonbreaking',
'save table contextmenu directionality emoticons template paste textcolor',
],
height: 400,
file_picker_types: 'file image media',
@sysint64
sysint64 / bmp_palette.cpp
Created May 25, 2016 17:43
bmp_palette.cpp
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <array>
#include <math.h>
// Палитры цветов
#include "palettes.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <array>
#include <math.h>
// Палитры цветов
#include "palettes.h"
@sysint64
sysint64 / palette.h
Created May 25, 2016 17:47
Палитра 4 битная и 8 битная
#pragma once
uint8_t RGB4_Palette[][3] = {
{ 0 , 0 , 0 }, // Black
{ 255, 255, 255 }, // White
{ 255, 0 , 0 }, // Red
{ 0 , 255, 0 }, // Lime
{ 0 , 0 , 255 }, // Blue
{ 255, 255, 0 }, // Yellow
{ 0 , 255, 255 }, // Cyan / Aqua