This file contains hidden or 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 palindrome(str) { | |
| str = str.toLowerCase(); | |
| str = str.replace(/\.+|\,+|\s+|\_+|\-|\(|\)/gi,''); | |
| rev_str = str.split('').reverse().join(''); | |
| console.log(str +" "+ rev_str); | |
| if (str === rev_str) { | |
| return true; | |
| } else { | |
| return false; | |
| } |
This file contains hidden or 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 factorialize(num) { | |
| var neu=1; | |
| var old=1; | |
| for (i=1; i < num+1; i++) { | |
| old=neu; | |
| neu=old*i; | |
| } | |
| return neu; | |
| } |
This file contains hidden or 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 reverseString(str) { | |
| return str.split('').reverse().join(''); | |
| } | |
| reverseString("hello"); |
This file contains hidden or 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/bash | |
| CONSOLE_RED="\033[2;31m" | |
| CONSOLE_GREEN="\033[2;32m" | |
| CONSOLE_CLEAR="\033[0m" | |
| JENKINS_SERVER=http://my_jenkins_server | |
| JOB=$1 | |
| JOB_QUERY=/job/${JOB} |
This file contains hidden or 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
| >>> import pyes | |
| >>> conn = pyes.es.ES("localhost:9200") | |
| >>> all = conn.scan(pyes.query.MatchAllQuery(), 'index', 'type') | |
| >>> for a in all: | |
| ... hits = a['hits']['hits'] | |
| ... for hit in hits: | |
| ... conn.index(hit['_source'], 'new_index', 'type', hit['_id'], bulk=True) |
This file contains hidden or 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
| """''.format_map() in Python 2.x""" | |
| try: | |
| ''.format_map({}) | |
| except AttributeError: # Python < 3.2 | |
| import string | |
| def format_map(format_string, mapping, _format=string.Formatter().vformat): | |
| return _format(format_string, None, mapping) | |
| del string |
This file contains hidden or 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 | |
| # ### README #### | |
| # | |
| # Check if the river is updating and alert if not | |
| # | |
| # gem install elasticsearch | |
| # gem install couchrest | |
| # |
This file contains hidden or 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
| # assumes you've done a pretty basic 7.4 install, I used http://cdimage.debian.org/debian-cd/7.4.0/amd64/bt-cd/ | |
| # add wheezy-backports repo, http://backports.debian.org/Instructions/ | |
| sudo sh -c "echo deb http://ftp.us.debian.org/debian wheezy-backports main > /etc/apt/sources.list.d/wheezy-backports.list" | |
| sudo apt-get update -y | |
| sudo apt-get -t wheezy-backports install linux-image-amd64 -y | |
| sudo reboot |
This file contains hidden or 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 python | |
| import sys, paramiko | |
| if len(sys.argv) < 5: | |
| print "args missing" | |
| sys.exit(1) | |
| hostname = sys.argv[1] | |
| password = sys.argv[2] |
This file contains hidden or 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
| import unittest | |
| from pyramid import testing | |
| from paste.deploy.loadwsgi import appconfig | |
| from webtest import TestApp | |
| from mock import Mock | |
| from sqlalchemy import engine_from_config | |
| from sqlalchemy.orm import sessionmaker | |
| from app.db import Session |
NewerOlder