Skip to content

Instantly share code, notes, and snippets.

View denysvitali's full-sized avatar

Denys Vitali denysvitali

View GitHub Profile
fn deg2meter_lng(lng: f64) -> f64 {
111412.84 * lng.cos() - 93.5 * (3.0 * lng).cos() + 0.118 * (5.0 * lng).cos()
}
fn deg2meter_lat(lat: f64) -> f64 {
111132.92 - 559.82 * (2.0 *lat).cos() + 1.175 * (4.0 *lat).cos() - 0.0023 * (6.0 *lat).cos()
}
fn get_stops_by_coordinates(c1: Coordinate, c2: Coordinate, r1: f64, r2: f64) -> String {
let result : Vec<Stop> = Vec::new();
#!/bin/bash
SER_NUM=$1
echo ${SER_NUM}
mkdir serie${SER_NUM}
tar -cvf serie${SER_NUM}/serie${SER_NUM}-source.tar.gz ../serie/src/it/denv/supsi/progconc/serie/serie${SER_NUM}
cp ~/Downloads/serie-${SER_NUM}.pdf serie${SER_NUM}/serie-${SER_NUM}.pdf
tar -cvf serie${SER_NUM}.tar.gz serie${SER_NUM}
rm -rf serie${SER_NUM}/
@denysvitali
denysvitali / customer.xml
Created January 27, 2018 22:35
SWC/customer.xml (Swisscom customer.xml from a Galaxy S8+ firmware file)
<?xml version="1.0" encoding="UTF-8"?>
<CustomerData>
<GeneralInfo>
<CSCEdition>ED0008</CSCEdition>
<Country>Switzerland</Country>
<CountryISO>CH</CountryISO>
<Region>EUR</Region>
<SalesCode>SWC</SalesCode>
<NbNetworkInfo>2</NbNetworkInfo>
<NetworkInfo>
dvitali@denvit-ws1:algoritmi/algoritmi-fgk-compression ‹master*›$ ./scripts/test.sh test/files/compression/text/bibbia-lf.txt
Starting compression of test/files/compression/text/bibbia-lf.txt
The file was compressed successfully
The file was compressed
Original file:
00469c20 74 65 73 74 61 20 71 75 65 73 74 65 20 63 6f 73 |testa queste cos|
00469c30 65 20 64 69 63 65 3a 20 22 53 ec 2c 20 76 65 72 |e dice: "S., ver|
==18535==
==18535== HEAP SUMMARY:
==18535== in use at exit: 28,996 bytes in 546 blocks
==18535== total heap usage: 227,016 allocs, 226,470 frees, 55,966,346 bytes allocated
==18535==
==18535== Searching for pointers to 546 not-freed blocks
==18535== Checked 100,104 bytes
==18535==
==18535== LEAK SUMMARY:
==18535== definitely lost: 0 bytes in 0 blocks
==16276==
==16276== HEAP SUMMARY:
==16276== in use at exit: 0 bytes in 0 blocks
==16276== total heap usage: 34,398 allocs, 34,398 frees, 5,258,437 bytes allocated
==16276==
==16276== All heap blocks were freed -- no leaks are possible
==16276==
==16276== Use --track-origins=yes to see where uninitialised values come from
==16276== ERROR SUMMARY: 22735 errors from 13 contexts (suppressed: 0 from 0)
==16276==
void create_subtree_from_node(HuffmanTree *ht, Node *node, Node** result, int* pos){
if(pos[0] * HA_DIM_X + pos[1] >= HA_DIM_X * HA_DIM_Y){
return;
}
if(node != NULL) {
if(DEBUG) {
//printf("[create_subtree_from_node] pos: [%d][%d]\n", pos[0], pos[1]);
}
result[pos[0] * HA_DIM_X + pos[1]] = node;
//ht->tree[node->node_number] = NULL;
void swap_on_diff_lvls(HuffmanTree* ht, Node* node, Node* node2){
debug("Swapping on different levels");
/*Node** arr = malloc(sizeof(Node*) * HA_DIM_X * HA_DIM_Y);
Node** arr2 = malloc(sizeof(Node*) * HA_DIM_X * HA_DIM_Y);*/
Node** arr = calloc(HA_DIM_X * HA_DIM_Y, sizeof(Node*));
Node** arr2 = calloc(HA_DIM_X * HA_DIM_Y, sizeof(Node*));
int i, k;
for(i=0; i<HA_DIM_X; i++){

Nodes positioning logic (for HTA swap)

Assuming HT_X = 257

Graph

graph G {
    "0" -- "257" -- "514";
 "0" -- "258" -- "516";
#!/bin/bash -e
. /etc/makepkg.conf
PKGCACHE=$((grep -m 1 '^CacheDir' /etc/pacman.conf || echo 'CacheDir = /var/cache/pacman/pkg') | sed 's/CacheDir = //')
pkgdirs=("$@" "$PKGDEST" "$PKGCACHE")
while read -r -a parampart; do
pkgname="${parampart[0]}-${parampart[1]}-*.pkg.tar.xz"