Skip to content

Instantly share code, notes, and snippets.

View rewida17's full-sized avatar
💭
Hard working 😄

rewida17

💭
Hard working 😄
  • Poland
View GitHub Profile
@rewida17
rewida17 / Get-YcombinatorFeed.ps1
Last active September 16, 2023 09:51
Get latest news headers from news.ycombinator.com (top 5)
# For PowerShell 7+, because Foreach-Object -Parallel is used
# Based on https://github.com/HackerNews/API
#
function Get-YcombinatorFeed {
(Invoke-RestMethod -Method Get "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty") -as [array] |
Select-Object -First 5 | Foreach-Object -ThrottleLimit 5 -Parallel {
Invoke-RestMethod -Method Get ( "https://hacker-news.firebaseio.com/v0/item/{0}.json" -f $_ )
@rewida17
rewida17 / server.py
Created November 25, 2020 09:39 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
@rewida17
rewida17 / get_latest_release.ps1
Last active August 31, 2020 20:24 — forked from lukechilds/get_latest_release.sh
PowerShell - Get latest release zip from GitHub
$name="creator/project"
$uri="$(Invoke-WebRequest -Method Get "https://api.github.com/repos/$name/releases/latest" | ConvertFrom-Json | Select-Object -ExpandProperty zipball_url)"
Invoke-RestMethod -Method Get -Uri $uri -OutFile last.zip
Expand-Archive -Path last.zip -DestinationPath $targetDir
@rewida17
rewida17 / goupload
Last active November 11, 2024 18:40
Upload files to gofile.io via api. Required curl and jq
#!/bin/bash
#Simple test/help
if [[ "$#" == '0' ]]
then
echo -e '\nPlease Select File\n'
#Great, file selected.. Lets upload that..
elif [[ "$#" == '1' ]]
then
@rewida17
rewida17 / ethstat.sh
Created February 28, 2020 09:26
interface stats based on /sys/class/net/eth0/statistics/
#!/bin/bash
a="$(cat /sys/class/net/eth0/statistics/rx_bytes)"
b="$(cat /sys/class/net/eth0/statistics/tx_bytes)"
rx="$(echo "scale=3;$a/1024^3"|bc)"
tx="$(echo "scale=3;$b/1024^3"|bc)"
sum=$(echo "scale=3;$rx+$tx"|bc)
printf "\n\e[41mETH0_STATS:\e[0m \e[42m RX: $rx GB TX: $tx GB Su: $sum GB\e[0m\n\n"
@rewida17
rewida17 / MPU9250_ENC28J60
Last active December 8, 2019 21:32
Get data from MPU and print in JSON on site #arduino
/*
Web Server + MPU9250
*/
#include <SPI.h>
#include <UIPEthernet.h>
#include <MPU9250_asukiaaa.h>
#include <TinyGPS.h>
#include <SoftwareSerial.h>
String AX = String("\"aX\":");
@rewida17
rewida17 / wirewrap
Created September 2, 2019 18:07
simple "wrapper" around wg and wg-quick that can simplify tasks
#!/bin/bash
if [ "$#" == '0' ]
then
printf 'Enter Parametrs [up|down|show|status|ssh]\n'
elif [ "$1" == 'up' ] || [ "$1" == 'on' ] || [ "$1" == 'start' ]
then
sudo wg-quick up /etc/wireguard/wg0.conf
#!/bin/bash
while IFS= read -r ip
do
snmpwalk -v1 -c public "${ip}" 1.3.6.1.4.1.14988.1.1.3.8.0 | awk -v ip="$ip" '{print ip"=>"$4/10"V"}'
done < <(cat ~/ip)
@rewida17
rewida17 / mpv_conf
Created May 4, 2019 21:47
chromebook Thinkpad 11e mpv.conf
#!/bin/env bash
if ![[ -e ~/.config/mpv/mpf.conf]]
then
mkdir -pv ~/.config/mpv
echo 'LS1od2RlYz12YWFwaQotLXZvPXZhYXBpCi0teXRkbC1mb3JtYXQ9YmVzdHZpZGVvW2hlaWdodDw9PzcyMF1bZnBzPD0/NjBdW3Zjb2RlYyE9P3ZwOV0rYmVzdGF1ZGlvL2Jlc3QKLS12b2x1bWUtbWF4PTIwMAotLXNhdmUtcG9zaXRpb24tb24tcXVpdAo=' |base64 -d > ~/.config/mpv/mpv.conf
elif [[ -e ~/.config/mpv/mpv.conf]]
then
echo -e 'mpv.conf already exist, nothing to do.\\nBye :)'
ffmpeg -i input.mp4 \
-map 0:1 \
-c:a copy \
-y output.m4a