Skip to content

Instantly share code, notes, and snippets.

View macmladen's full-sized avatar

Mladen Đurić macmladen

View GitHub Profile
@macmladen
macmladen / MySQL cheat sheet.sql
Last active December 12, 2015 21:28
MySQL commands
# Some _user_ manipulating commands on _database_ (exchange for real data)
CREATE USER '_user_'@'localhost' IDENTIFIED BY '_password_';
GRANT ALL PRIVILEGES ON _database_.* TO '_user_'@'localhost';
SELECT CONCAT(QUOTE(user),'@',QUOTE(host)) UserAccount FROM mysql.user;
SHOW GRANTS FOR '_user_'@'localhost';
# Finding duplicate values http://stackoverflow.com/questions/688549/finding-duplicate-values-in-mysql
SELECT myfield, COUNT(*) AS c FROM mytable GROUP BY myfield HAVING c > 1;
SELECT * FROM mytable WHERE myfield IN (SELECT myfield FROM mytable GROUP BY myfield HAVING COUNT(myfield)>1)
@macmladen
macmladen / Drupal-sub_theming-and-inheritance.md
Created December 5, 2012 09:21
Drupal sub-theming and inheritance

From: http://technobabble.drupalgardens.com/blog/creating-sub-theme-bartik

Choose a name for the theme (mine is Coolness) and create the sub-directory sites/all/ themes/coolness on your Drupal site.

Copy the bartik.info file to that directory and rename it to coolness.info

It's best to use the same directory structure as the base theme does for /css, /js, /templates, /color, and similar sub-directories.

Change or add the following to coolness.info:

@macmladen
macmladen / bash-one-liners.sh
Last active October 7, 2016 18:19
BASH one-liners
## CHECKING HEADERS AND CERTIFICATE
# curl headers
curl -Iv https://example.com
# check certificate
openssl s_client -connect www.example.com:443
## FIXING FILES PERMISSIONS
# Remove Mac OS X Desktop Services Store files
find . -name ".DS_Store" -exec rm {} \;
# If you accidentally chmod -R 755 on everything revert files to 644
@macmladen
macmladen / RaspberryPi_install.sh
Created December 13, 2012 12:16
RaspberryPi SD card creation
diskutil list
sudo diskutil unmount /dev/disk1s1
sudo dd bs=1m if=2012-10-28-wheezy-raspbian.img of=/dev/rdisk1
sudo diskutil eject /dev/rdisk1
@macmladen
macmladen / mac-sys.sh
Last active February 13, 2016 09:41
Mac system maintenance
# Swap
sysctl vm.swapusage
# Many useful system information
sysctl -a
system_profiler
systemstats
# Wake and Sleep times on 10.9+
pmset -g log | grep " Wake "
@macmladen
macmladen / sys-admin.sh
Last active August 5, 2016 05:44
*nix sys-admin
# PS1 command prompt
# Color | Code
# ------+-----
# Black 0;30 Red 0;31 Green 0;32 Brown 0;33
# Blue 0;34 Purple 0;35 Cyan 0;36
#
# http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
export PS1='\[\e[0;32m\]\u@\h:\[\e[0m\]\w \t \$ '
export PS1='\[\e[0;35m\]\w\n\[\e[0;34m\]\u@\h:\[\e[0m\]\w \t \$ '
@macmladen
macmladen / CSS.css
Last active December 17, 2015 06:09
CSS tricks
/* Clearfix to clear floats: http://css-tricks.com/snippets/css/clear-fix/ */
.group:after {
content: "";
display: table;
clear: both;
}
@macmladen
macmladen / .inputrc
Last active December 18, 2015 20:59
InputRC for searching the shell history with up-arrow
# Use CTRL-R to get history
# Use ! to search and execute !ta -> tail error_log
# use !-4 for previous fourth command
# clean history: history -c
# export HISTCONTROL=erasedups
# export HISTCONTROL=ignoredups
# http://www.twam.info/software/tune-terminal-in-os-x-lion
"\e[B": history-search-forward
[Aerial view of Muenchen Olympic stadium.]
Football Commentator (Michael) Good afternoon, and welcome to a packed
Olympic stadium, Muenchen [caption "INTERNATIONALE PHILOSOPHIE -
Rueckspiel" {International Philospohy - Return match}] for the
second leg of this exciting final. [German philosophers jog out
of the dressing room.] And here come the Germans now, led by
their skipper, "Nobby" Hegel. They must surely start favourites
this afternoon; they've certainly attracted the most attention
from the press with their team problems. And let's now see
their line-up.
<?php
/**
* You can easily parse command line arguments into the
* $_GET variable by using the parse_str() function.
*/
parse_str(implode('&', array_slice($argv, 1)), $_GET);
/**
* PHP error reporting activation
*/