This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Code was written in Javascript (ES6) | |
* Tests will work only in Node.js environment | |
*/ | |
/** | |
* Flatten an array of arbitrarily nested arrays of integers into | |
* a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4]. | |
* | |
* @param {Array} input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files: | |
"/etc/nginx/conf.d/custom_config.conf": | |
content: | | |
server_tokens off; | |
client_max_body_size 2M; | |
"/etc/nginx/sites-available/elasticbeanstalk-nginx-docker-proxy.conf": | |
content: | | |
map $http_upgrade $connection_upgrade { | |
default "upgrade"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rsync -n -u --stats --progress /home/user/test/1/* /home/user/test/2/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function optimize | |
{ | |
echo $1 | |
filesize=`stat --format=%s "$1"` | |
if [[ $filesize -lt 10000 ]]; then | |
jpegtran -copy none -optimize "$1" > "$1.bak" | |
echo "pet" | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://css-tricks.com/snippets/javascript/strip-whitespace-from-string/ | |
// Remove leading and trailing whitespace | |
// Requires jQuery | |
var str = " a b c d e f g "; | |
var newStr = $.trim(str); | |
// "a b c d e f g" | |
// Remove leading and trailing whitespace | |
// JavaScript RegEx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nginx -t -c /etc/nginx/nginx.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Original post: http://www.thebigblob.com/how-to-restrict-user-access-to-content-in-folders-using-php-and-apache-htaccess-files/ | |
*/ | |
# The .htaccess file | |
RewriteEngine on | |
RewriteBase / | |
RewriteCond %{REQUEST_URI} ^\/(path\/to\/some\/folder|dummy)\/.*$ | |
RewriteRule !^((.*.php)|(.*\/))$ authorize.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// replace string and update | |
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
menu_rebuild(); | |
drupal_flush_all_caches(); | |
die(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysql -u username -p -h localhost DATA-BASE-NAME < data.sql |
NewerOlder