Skip to content

Instantly share code, notes, and snippets.

View grambas's full-sized avatar

Mindaugas Milius grambas

View GitHub Profile
@grambas
grambas / The Technical Interview Cheat Sheet.md
Created September 21, 2016 08:42 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@grambas
grambas / record.py
Last active February 15, 2019 11:06
[ffmpeg] Recodring, streaming, ripping
#! python
# Record stream with python from m3u8 file in 1h parts
import time
import subprocess as sp, sys
import urllib
def record():
sourcePath ='https://url.m3u8'
name = '_video.ts'
@grambas
grambas / Unlimited_parameters_in_route.php
Last active January 21, 2019 18:58
[LARAVEL 5 snippets]
<?php
#PageController.php
public function show($slugs_string){
$slugs = explode('/', $slugs_string);
$page = null;
foreach($slugs as $key => $slug){
$page = Page::where('slug', $slug)
->where('parent_id', '=', is_null($page)?null:$page->id)
@grambas
grambas / domain.conf
Last active January 21, 2019 21:47
[Webserver Security]
# Common bandwidth hoggers and hacking tools.
map $http_user_agent $limit_bots {
default 0;
~*(AltaVista|Slurp|BlackWidow|Bot|ChinaClaw|Custo|DISCo|Download|Demon|eCatch|EirGrabber|EmailSiphon|EmailWolf|SuperHTTP|Surfbot|WebWhacker) 1;
~*(Express|WebPictures|ExtractorPro|EyeNetIE|FlashGet|GetRight|GetWeb!|Go!Zilla|Go-Ahead-Got-It|GrabNet|Grafula|HMView|Go!Zilla|Go-Ahead-Got-It) 1;
~*(rafula|HMView|HTTrack|Stripper|Sucker|Indy|InterGET|Ninja|JetCar|Spider|larbin|LeechFTP|Downloader|tool|Navroad|NearSite|NetAnts|tAkeOut|WWWOFFLE) 1;
~*(GrabNet|NetSpider|Vampire|NetZIP|Octopus|Offline|PageGrabber|Foto|pavuk|pcBrowser|RealDownload|ReGet|SiteSnagger|SmartDownload|SuperBot|WebSpider) 1;
~*(Teleport|VoidEYE|Collector|WebAuto|WebCopier|WebFetch|WebGo|WebLeacher|WebReaper|WebSauger|eXtractor|Quester|WebStripper|WebZIP|Wget|Widow|Zeus) 1;
~*(Twengabot|htmlparser|libwww|Python|perl|urllib|scan|Curl|email|PycURL|Pyth|PyQ|WebCollector|WebCopy|webcraw) 1;
}
@grambas
grambas / DEBUG MSG.cpp
Created May 23, 2017 13:22
C++ Snippets
#ifdef DEBUG
#define DEBUG_MSG(str) do { std::cout << str << std::endl; } while( false )
#else
#define DEBUG_MSG(str) do { } while ( false )
#endif
int main()
{
DEBUG_MSG("Hello" << ' ' << "World!" << 1 );
return 0;
@grambas
grambas / backup.sh
Last active January 21, 2019 19:11
[Webserver]
#!/bin/bash
# Execute it as root, due to archiving permision conflicts
#CRONTAB entry for every day at 04:00 AM
#0 4 * * * /usr/local/bin/webserver-backup.sh >/dev/null 2>&1
# DATABSE DATA
DB_USER="XXX"
DB_PASSWORD="XXX"
# PATH'S
#!/bin/bash
# This bash script exports all mysql databases and archives it with all webserver files.
# Created archive will be encrypted with gpg key.
# After sending to cloud storage all created files will be deleted
# This script uses: tar, gpg, mysql and aws3 s3
# ** IMPORTANT** :
# ** You need to have generated gpg key !!! Otherwise comment encryption part.
# ** Execute this script with proper rights. It means that if in webserver dir
# you have files with permisions only for root user, then use sudo.
@grambas
grambas / commands.md
Last active January 21, 2019 19:12
[Terminal]
Check what process is using a port
netstat -tulpn | grep 80
Search in 'path' for 'pattern' in files
grep -rnw 'path' -e 'pattern'
Search in 'to/path' for file 'pattern'
<?php
/**
Send message to slack channel.
$hook can be created at https://mindau.slack.com/apps/A0F7XDUAZ-incoming-webhook
*/
function sendLog($title, $msg)
{
$hook = "https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$data = array(
'channel' => '#logging',
@grambas
grambas / trav-get-names.js
Last active January 21, 2019 19:18 — forked from Yiin/userscript.js
[Userscripts]
// ==UserScript==
// @name Unnamed Script 760860
// @version 1
// @grant GM.xmlHttpRequest
// get all players who sent reinforcement
// ==/UserScript==
(async () => {
const rows = [...document.querySelectorAll('#overview > tbody > tr')];
const thisPlayer = document.getElementsByClassName('playerName')[0].childNodes[3].innerHTML;