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 / 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 / 1.md
Last active January 15, 2019 12:43
REGEX

Validate string for PHP DateInterval. (P or PT, then any number with no leading zeros. At the end H for hour interval and W,D or M for weeks, days and months)

(P((0|[1-9][0-9]*))(W|D|M)|PT((0|[1-9][0-9]*))H)
@grambas
grambas / alias.md
Last active January 21, 2019 18:57
[Docker] Docker related snippets and scripts

CLEAN DOCKER COMPLETLY

echo "alias docker-clean-unused='docker system prune --all --force --volumes'
alias docker-clean-containers='docker container stop $(docker container ls -a -q) && docker container rm $(docker container ls -a -q)'
alias docker-clean-all='docker container stop $(docker container ls -a -q) && docker system prune -a -f --volumes'" \
>> ~/.zshrc && source ~/.zshrc     ##  for zsh:

>> ~/.bashrc && source ~/.bashrc   ##  for bash:
@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 / maintaince.html
Last active January 21, 2019 19:00
[HTML]
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@grambas
grambas / git.md
Last active January 21, 2019 19:05
[GIT]

lazy one command commit

alias lazygit="git add .; git commit -a -m 'lazy commit'; git push;";

git lg command to style log output

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@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
@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'
@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;