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
# Rename .haml files to .erb | |
ls *.haml | sed 's/haml//g' | xargs -i mv {}haml {}erb |
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
sudo -u postgres psql | |
ALTER USER Postgres WITH PASSWORD 'NEW PWD'; | |
psql -h hostname -d databasename -U username -f file.sql |
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
$(function () { | |
"use strict"; | |
// for better performance - to avoid searching in DOM | |
var content = $('#content'); | |
var input = $('#input'); | |
var status = $('#status'); | |
// my color assigned by the server | |
var myColor = false; |
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
# Install packgage control (http://wbond.net/sublime_packages/package_control/installation) - execute in Sublime Text 2 Console: | |
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation' | |
# Use Regex (Regular Expressions) to find text patterns on files | |
# Search in Google for Regexp then use in Sublime Text - you will need to understood then to use and gain productivity, that can be helpful in many situations :) | |
# => Examples: https://github.com/andreydjason/SublimeText-Regexp-Utils |
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
### do a benchmark in a website with the Apache Benchmark Tool | |
## -n must be HIGHER than -c to have measurable results | |
$ ab -c10 -n100 http://google.com/ | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking google.com (be patient).....done | |
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 ruby | |
# encoding: utf-8 | |
# Ruby | |
# | |
# to run in a Rails environment (add the line below) | |
# require './config/environment' | |
# | |
# An example of how select the last item of an array that's not nil | |
def select_last_not_nil(options) | |
item = nil |
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
# Return the columns with status of table, including the Auto_Increment value: | |
=> SHOW TABLE STATUS LIKE '<table_name>' | |
# Return a random number: | |
1) => (<MinRange> + FLOOR(RAND() * (<MaxRange> - <MinRange> + 1))) as random_number | |
2) => FLOOR(<MinRange> + RAND() * <MaxRange>) as random_number | |
* Replace the values in <these_tag_type> whitin your values. |
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
require 'date' | |
require 'time' | |
require 'net/smtp' | |
Dir.chdir('/home/andrey/Cronjobs/') | |
def verify_rsync_output(rsync_output) | |
if rsync_output == '' | |
raise RuntimeError, '* Rsync returned empty result for backup - SSH access to the server has ben set?' | |
end |
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/php <- location of the php parser | |
<?php | |
# This script receives command line args and transforms it into an array of *params | |
# example from command line: ($ <- is the bash) | |
# $ /usr/bin/env php script.php --onevar=ThisIsMyValue --another_var=1 --some-var="some value" --integerVar=102323 | |
# in theory, the variables accepts any kind of value, just set the value as ypu set it in PHP | |
error_reporting(0); | |
$this_script = $_SERVER["SCRIPT_NAME"]; |
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
#!/bin/sh | |
# CRON | |
## delete encrypted backups older than 5 days | |
#55 3 * * * find /path/to/backups-enc -mtime +5 -exec rm {} \; | |
## delete un-encrypted backups older than 1 days | |
#55 3 * * * find /path/to/backups -mtime +0 -exec rm {} \; | |
## database dump at 4am UTC = 8pm PST (9pm PDT) | |
#0 4 * * * /path/to/this/script |
NewerOlder