Skip to content

Instantly share code, notes, and snippets.

View alonisser's full-sized avatar

Alonisser alonisser

View GitHub Profile
@alonisser
alonisser / precommit.sh
Created July 15, 2013 09:34
A naive implentation of a pre commit jslinting hook
#!/bin/sh
# A naive implentation of a pre commit jslinting hook
# First: checking if jshint is installed
retval=`jshint ; echo $?`
if [[ retval -ne 0 ]]
then
echo "You have to install JSHINT for this to work"
echo "npm install -g jshint"
exit 1
fi
@alonisser
alonisser / setup.md
Last active December 17, 2015 20:38
memo to self: how to setup a python developer windows 7 computer

#Setting up a windows 7 python dev computer

  • Set up a dev folder in root with subfolders: projects, programs, custom, envs.

  • Set a HOME (Check specific) variable to point to c:\dev\custom so .dot files should go there.

  • Python: install python 2.7.X 32bit in dev\programs also easy_install pip,and pip install virtualenv.

  • Install virtualenv-wrapper for windows and sets WORKON_HOME to c:\dev\envs

@alonisser
alonisser / double.js
Created May 21, 2013 09:42
a whatwg suggestion to solve to double sumbitting forms problem
//a crude polyfill to handle this functionality
@alonisser
alonisser / unicode csv reader
Last active December 13, 2015 20:28
python 2.7 csv reader the supports unicode (hebrew)
#based on a stackoverflow answer, I currently can't find.
import csv
def unicode_csv_reader(utf8_data, dialect=csv.excel, **kwargs):
"""
helper function: a generic csv reader function adapted to unicode
"""
unicode_reader = csv.reader(utf8_data, dialect=dialect, encoding = 'windows-1255', **kwargs)# opening the file with python csv reader
@alonisser
alonisser / postgres_connections
Last active November 27, 2015 18:09
Finding the postgres connections hog
#Broken somehow. need to fix
SELECT COUNT(*) as datname, datname, datid FROM pg_stat_activity GROUP BY datname;
#Works without id
SELECT COUNT(*) as datname, datname FROM pg_stat_activity GROUP BY datname;
More info:
http://chrismiles.info/systemsadmin/databases/articles/viewing-current-postgresql-queries/
https://support.pivotal.io/hc/en-us/articles/201595093-Script-Session-level-information
@alonisser
alonisser / Installation
Last active August 29, 2015 14:25
Ansible role for setting cloudwatch reporting script on ubuntu servers
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
mkdir automation && cd automation
touch ansible.cfg && hosts
mkdir -pv roles/aws_monitoring/tasks/main.yml
{
"title": "Nginx Web",
"services": {
"query": {
"list": {
"0": {
"query": "response:[200 TO 299]",
"alias": "OK",
"color": "#7EB26D",
"id": 0,
@alonisser
alonisser / ubuntu 14.04 server security setup
Last active August 29, 2015 14:06
Setting server security patches
1. replace apt-get upgrade to install only security patches:
http://askubuntu.com/questions/194/how-can-i-install-just-security-updates-from-the-command-line
2. use unattended-upgrade
3. automate unattended-upgrade with cron
https://help.ubuntu.com/community/AutomaticSecurityUpdates
4. get alerts about pending updates:
@alonisser
alonisser / solution_redis_misconf
Created September 17, 2014 08:37
Fixing redis "ISCONF Redis is configured to save RDB snapshots"
check redis log /var/logs/redis/redis-server.log for write errors
can be permissions on the redis dbump dir or memory conditions or not enough place on disk
check place on disks:
http://www.cyberciti.biz/faq/check-free-space/
```
$ df -h
```