Skip to content

Instantly share code, notes, and snippets.

View spot62's full-sized avatar

SLPotapenko spot62

  • Ryazan
View GitHub Profile
@spot62
spot62 / expcalc.c
Created December 29, 2015 07:36
Extended Schildt's calculator
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "expcalc.h"
enum
{
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
struct point {
int t;
double R;
};
const struct point NCP18XH103F03RB_10K[]={
@spot62
spot62 / check_iface.sh
Created May 21, 2016 08:07
Checking interface working
#!/bin/bash
IFACE_NAME="p2p1"
IFACE_IP="192.168.1.1"
RES=`ping -I ${IFACE_NAME} ${IFACE_IP} -c 3 | grep "100%" |wc -l`
if ! [ ${RES} -ne "1" ];
then
echo "${IFACE_NAME} is not working"
else
@spot62
spot62 / daemon.sh
Created May 21, 2016 08:22
Unix shell daemon
#!/bin/sh
#1. сhange CWD to /
cd /
#2. disconnect from current terminal
exec >/dev/null
exec 2>/dev/null
#3. forked and leave in background
@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
@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
for line in $(seq 996 1086) ; do history -d 996; done
@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]));
#!/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 / 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