Skip to content

Instantly share code, notes, and snippets.

View madalinignisca's full-sized avatar
🏡
Open for business

Madalin Ignisca madalinignisca

🏡
Open for business
View GitHub Profile
@madalinignisca
madalinignisca / createdb.sh
Created March 8, 2018 12:38
Shell script to create a database
if [ $# -eq 0 ]
then
echo "No arguments supplied"
else
mysql -uroot --execute="CREATE DATABASE $1 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
fi
@madalinignisca
madalinignisca / docker-volume-funcs.sh
Created February 4, 2018 11:40 — forked from DALDEI/docker-volume-funcs.sh
Backup/Restore Docker Volumes
# backup files from a docker volume into /tmp/backup.tar.gz
# from http://stackoverflow.com/questions/21597463/how-to-port-data-only-volumes-from-one-host-to-another
function docker-volume-backup-compressed() {
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -czvf /backup/backup.tar.gz "${@:2}"
}
# restore files from /tmp/backup.tar.gz into a docker volume
function docker-volume-restore-compressed() {
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -xzvf /backup/backup.tar.gz "${@:2}"
echo "Double checking files..."
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie ls -lh "${@:2}"
@madalinignisca
madalinignisca / solveMeFirst.c
Last active June 2, 2017 20:35
Comparison returning the sum of 2 numbers read on CLI in many programming languages (looks like JavaScript is not so friendly...)
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int solveMeFirst(int a, int b) {
return a+b;
}
int main() {
int num1,num2;
@madalinignisca
madalinignisca / count_db_rows.sql
Created April 23, 2017 09:41
Count ROWS total in a MySQL Database
SELECT SUM(TABLE_ROWS) FROM `information_schema`.`tables` WHERE `table_schema` = 'your_database_name';
@madalinignisca
madalinignisca / settings.php
Created April 21, 2017 20:59
Heroku Postgres DB for Drupal 7
<?php
// ...
# using a Heroku Postgresql DB
$heroku_db_url = parse_url($_ENV['DATABASE_URL']);
$databases['default']['default'] = array(
'driver' => 'pgsql',
'database' => substr($heroku_db_url['path'], 1),
'username' => $heroku_db_url['user'],
'password' => $heroku_db_url['pass'],
@madalinignisca
madalinignisca / .htaccess
Created January 23, 2017 19:11
Simple Apache HTTPD Expire module rules and efficient
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 year"
ExpiresByType text/html "access plus 300 seconds"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType audio/ogg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
@madalinignisca
madalinignisca / YOUR_MODULE_NAME.views.inc
Last active October 3, 2016 15:09
Load correct number of items when using Views Load More
<?php
/**
* Implements hook_views_query_alter()
*/
function views_pager_mod_views_pre_execute(&$view) {
// some data to be used
$query_params = drupal_get_query_parameters();
@madalinignisca
madalinignisca / post-receive
Created August 10, 2016 07:03
git post-merge hook : update / install composer packages & composer itself
#!/bin/bash
# thanks http://www.jenssegers.be/blog/46/deploying-websites-with-git-and-composer-
# replace folder
cd "`dirname $0`/../../application/config"
# Check if a composer.json file is present
if [ -f composer.json ]; then
@madalinignisca
madalinignisca / .gitignore
Created June 23, 2016 13:14
Up2date Gitignore 4 WordPress
# Created by https://www.gitignore.io/api/wordpress
### WordPress ###
*.log
wp-config.php
wp-content/advanced-cache.php
wp-content/backup-db/
wp-content/backups/
wp-content/blogs.dir/
wp-content/cache/
@madalinignisca
madalinignisca / readme.markdown
Last active August 24, 2022 06:10 — forked from larrybotha/readme.markdown
Postfix Using Mailhog to capture email for web development

Configure Postfix for Localhost SMTP in Mac OSX Mavericks with Mailhog

Using Homebrew install mailhog and enable the service as instructed in the installation.

Open in any browser http://localhost:8025

Edit file /etc/postfix/main.cf

sudo vim /etc/postfix/main.cf