Skip to content

Instantly share code, notes, and snippets.

View spot62's full-sized avatar

SLPotapenko spot62

  • Ryazan
View GitHub Profile
@spot62
spot62 / solution.java
Created February 15, 2017 16:15
Java MD5
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
public class Solution {
@spot62
spot62 / fsm_simple.c
Created January 29, 2017 09:55
Simple FSM
typedef void (*t_func)(void);
enum s_state{
STATE1,
STATE2
};
void func_state1()
{
printf("func_state1\n");
@spot62
spot62 / yd_uploader.sh
Created January 18, 2017 14:35
Yandex Disk file uploader
#!/bin/bash
#
# article: http://neblog.info/skript-bekapa-na-yandeks-disk
#
# REST API: https://tech.yandex.ru/disk/api/reference/upload-docpage/
TOKEN=""
# NB: slash ending
@spot62
spot62 / Makefile
Created December 24, 2016 14:05
ICMP ping utility
all:
/usr/local/musl/bin/musl-gcc -o pping pping.c
# $(CC) -o pping pping.c
@spot62
spot62 / memoryused.sh
Last active November 21, 2016 08:47
Sort proccess by memory used
#!/bin/bash
#sort
ps -eo size,pid,user,command | awk '{ hr=$1/1024 ; printf("%13.6f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }' | sort
# memory statistics
cat /proc/meminfo
# drop cache (but not for VPS)
sync
#!/bin/bash -eux
if [[ "$DESKTOP" =~ ^(true|yes|on|1|TRUE|YES|ON])$ ]]; then
exit
fi
echo "==> Disk usage before minimization"
df -h
echo "==> Installed packages before cleanup"
@spot62
spot62 / spiral.c
Created September 30, 2016 23:25
Fill an array of spiral
int main (int argc, char *argv[])
{
int i;
int j;
int n=2;
int size = 2*n+1;
int (*data)[size] = malloc(sizeof(int[size][size]));
memset(data, 0, sizeof(int[size][size]));
for line in $(seq 996 1086) ; do history -d 996; done
@spot62
spot62 / zimage_extract.sh
Created May 21, 2016 08:31
Extract zImage from uImage
#!/bin/sh
#
# Copyright (C) 2010 Matthias Buecher (http://www.maddes.net/)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/gpl-2.0.txt
@spot62
spot62 / www_rights_setup.sh
Created May 21, 2016 08:29
Rights setup recursive
#!/bin/sh
# recursive rights setup for files and directories (instead of chmod -R)
find ${DIR} -type d -exec chmod 755 {} \;
find ${DIR} -type f -exec chmod 644 {} \;
# in the case of blocking by seLinux:
# restorecon -rv /var/www/html