Skip to content

Instantly share code, notes, and snippets.

View boris's full-sized avatar
🏠
Working from home

Boris Quiroz boris

🏠
Working from home
View GitHub Profile
@boris
boris / awk_sum
Created June 25, 2012 14:58
Add numbers from a file with awk
cat file_with_numbers.txt | awk '{a=+$1}END{print a}'
hadoop fs -count /path/to/shit | awk '{print $6 / $1 *100 }'
@boris
boris / hello
Created July 26, 2012 16:05
capitalize in Ruby
puts "hello world".capitalize
@boris
boris / rightscale
Created July 31, 2012 13:50
verification for rightscale scripts
#!/bin/bash
if test "$RS_REBOOT" = "true" ; then
echo "Skip Example script on reboot."
logger -t BaseServerConfigScript "Skipping on reboot."
exit 0
fi
rm -rf /some/path
s3cmd get s3://path/to/your/data
@boris
boris / gist:3261697
Created August 5, 2012 04:33
Ubuntu firewall default policy
DEFAULT_INPUT_POLICY="DROP"
DEFAULT_OUTPUT_POLICY="DROP"
@boris
boris / gist:3261699
Created August 5, 2012 04:34
ubuntu firewall example rules
sudo ufw enable
sudo ufw allow httpd
sudo ufw allow ftp
sudo ufw allow proto tcp from 1172.16.0.0 to port 25
sudo ufw allow proto tcp from 200.83.5.145 to port 22
@boris
boris / custom_fields error
Created August 7, 2012 00:27
mysql repair table post on blog.insert-coinorg
mysql> show fields from custom_fields;
ERROR 1034 (HY000): Incorrect key file for table 'custom_fields';
try to repair it
@boris
boris / gist:3279958
Created August 7, 2012 00:32
check table
mysql> check table custom_fields;
+----------------------------+-------+----------+----------------------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+----------------------------+-------+----------+----------------------------------------------------------------+
| code_redmine.custom_fields | check | Error | Incorrect key file for table 'custom_fields'; try to repair it |
| code_redmine.custom_fields | check | error | Corrupt |
+----------------------------+-------+----------+----------------------------------------------------------------+
2 rows in set (0.00 sec)
@boris
boris / gist:3280005
Created August 7, 2012 00:35
check myisam
me@my-server:~# myisamchk -r /var/lib/mysql/redmine/custom_fields.MYI
- recovering (with sort) MyISAM-table '/var/lib/mysql/redmine/custom_fields.MYI'
Data records: 5
- Fixing index 1
- Fixing index 2
@boris
boris / success!
Created August 7, 2012 00:37
custom_fields
mysql> show fields from custom_fields;
+-----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| type | varchar(30) | NO | | | |
| name | varchar(30) | NO | | | |
| field_format | varchar(30) | NO | | | |
| possible_values | text | YES | | NULL | |
| regexp | varchar(255) | YES | | | |