Skip to content

Instantly share code, notes, and snippets.

View h0arry's full-sized avatar

Harald-Alfred Wurpts h0arry

View GitHub Profile
@h0arry
h0arry / gist:185668da85a2a1d885a5
Created November 14, 2015 21:49
http://www.freecodecamp.com/h0arry 's solution for Bonfire: Check for Palindromes
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;
}
@h0arry
h0arry / gist:c928d2a02c99a093a4da
Created November 14, 2015 20:55
http://www.freecodecamp.com/h0arry 's solution for Bonfire: Factorialize a Number
function factorialize(num) {
var neu=1;
var old=1;
for (i=1; i < num+1; i++) {
old=neu;
neu=old*i;
}
return neu;
}
@h0arry
h0arry / gist:a64f9d7a1b5bc7727a7b
Last active November 14, 2015 17:02
Bonfire: Reverse a String
function reverseString(str) {
return str.split('').reverse().join('');
}
reverseString("hello");
#!/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}
@h0arry
h0arry / reindex.py
Created September 1, 2014 08:52 — forked from bracki/reindex.py
>>> 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)
"""''.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
#!/usr/bin/env ruby
# ### README ####
#
# Check if the river is updating and alert if not
#
# gem install elasticsearch
# gem install couchrest
#
# 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
#!/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]
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