Skip to content

Instantly share code, notes, and snippets.

@raulanatol
raulanatol / New terminal (iterm)
Last active September 30, 2015 08:35
Create new terminal instance on the same path
#New terminal in the same position
function nt {
PWD_VALUE=$PWD
osascript -e "
tell application \"System Events\" to tell process \"Terminal\" to keystroke \"n\" using command down
tell application \"iTerm\" to tell session -1 of current terminal to write text \"cd $PWD_VALUE\"
" > /dev/null 2>&1
}
@raulanatol
raulanatol / check.php
Created July 3, 2015 13:34
Database check
<?php
$hostname = "";
$username = "";
$password = "";
$database = "";
$link = mysql_connect($hostname, $username, $password);
if ( ! $link) {
echo "<p>Could not connect to the server '" . $hostname . "'</p>\n";
echo mysql_error();
@raulanatol
raulanatol / put_s3.sh
Last active February 8, 2016 13:07
Uploading to S3 (bash script)
#!/usr/bin/env bash
bucket=your-bucket
resource="/${bucket}/${file}"
file=/file_to_upload
contentType="application/x-compressed-tar"
dateValue=`date -R`
stringToSign="PUT\n\n${contentType}\n${dateValue}\n${resource}"
@raulanatol
raulanatol / 01_websockets_nginx.config
Created April 12, 2016 08:27
Configure nginx to accept websockets on AWS Elastic Beanstalk
files:
"/etc/nginx/conf.d/01_websockets.conf":
mode: "000644"
owner: root
group: root
content: |
upstream nodejs {
server 127.0.0.1:8081;
keepalive 256;
}
@raulanatol
raulanatol / broken-image.js
Created April 15, 2016 06:33
Automatically put a default image in broken images
$('img').error(function(){
$(this).attr('src', 'assets/images/broken.png');
});
@raulanatol
raulanatol / target-blank.js
Created April 15, 2016 06:35
Automatic target="blank" to external links
var mainURL = location.protocol + '//' + location.host;
$('a').not(':contains(mainURL)').click(function(){
this.target = "_blank";
});
@raulanatol
raulanatol / Smart folder - Old Downloads...
Created September 28, 2016 15:32
Raw Query to show old download files (<4 weeks)
# OLD = Before 4 weeks
kMDItemLastUsedDate < $time.this_week(-4)
@raulanatol
raulanatol / iptables.sh
Created November 27, 2016 10:13
IpTablesConfig
#!/bin/bash
iptables -F
# Defautlt policy
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
# drop invalid packets
iptables -A INPUT -m state --state INVALID -j DROP
@raulanatol
raulanatol / tslint.json
Last active March 6, 2019 14:45
TSLint configuration for React + prettier
{
"extends": [
"tslint:recommended",
"tslint-react",
"tslint-config-prettier"
],
"linterOptions": {
"exclude": [
"config/**/*.js",
"node_modules/**/*.ts",
@raulanatol
raulanatol / input.txt
Created April 11, 2018 19:41
EOI-Examples.txt
este#es#un#fichero#"csv"#aunque
no#lo#parezca#para,nada
123
1+2=tres#
#