Skip to content

Instantly share code, notes, and snippets.

View skounis's full-sized avatar

Stavros Kounis skounis

View GitHub Profile
@skounis
skounis / sed.sh
Created June 5, 2019 07:43
Remove YML references
sed -i '/\uuid:/d' ./*
sed -i '/\default_config_hash:/d' ./*
@skounis
skounis / drop-all-tables.sh
Created June 4, 2019 06:46
Drop all the tables from a MySQL database
mysqldump --add-drop-table --no-data -u root -p -h localhost db_name | grep 'DROP TABLE' > drop_all_tables.sql
mysql -u root -p -h localhost db_name < drop_all_tables.sql
@skounis
skounis / development.services.yml
Last active March 22, 2019 18:58
Drupal 8 - Enabling Twig debug
parameters:
twig.config:
debug : true
auto_reload: true
cache: false
@skounis
skounis / closure.js
Created February 6, 2019 11:51
A dead simple Closure example in Javascript
const partialApply = (fn, ...fixedArgs) => {
return function (...remainingArgs) {
return fn.apply(this, fixedArgs.concat(remainingArgs));
};
}
const add = (a, b) => a + b;
const add10 = partialApply(add, 10);
@skounis
skounis / calculate
Created February 6, 2019 11:47
Carrying in Javascript. A simple example
volume(10)(20)(3) // 600
@skounis
skounis / cancellable.js
Created February 5, 2019 05:59
Cancel a Promise
// Adapted from:
// https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html
function cancellable(promise) {
let cancelled = false;
// Creates a wrapper promise to return. This wrapper is
// resolved or rejected based on the wrapped promise, and
// on the "cancelled" value.
const promiseWrapper = new Promise((resolve, reject) => {
promise.then(
@skounis
skounis / phpinfo.php
Created January 12, 2018 07:08
PHP Info
<?php
phpinfo();
?>
@skounis
skounis / iframe.htaccess
Created February 15, 2017 05:15
Apache, Disable the "Refused to display in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'."
# Add headers to all responses.
<IfModule mod_headers.c>
# Disable content sniffing, since it's an attack vector.
# Header always set X-Content-Type-Options nosniff
Header unset X-Frame-Options
</IfModule>
@skounis
skounis / secure-git.sh
Created January 17, 2017 07:49
Secure .git folder
BASE_PATH=/var/www/html
find $BASE_PATH/. -name ".git" -exec chown root:root -R {} \;
find $BASE_PATH/. -name ".git" -exec chmod a-rxw -R {} \;
@skounis
skounis / drop-mysql-tables.sh
Created January 17, 2017 07:39
MySQL Drop Tables from CLI
mysqldump --no-data --add-drop-table DB_NAME | grep ^DROP | mysql -v DB_NAME