Skip to content

Instantly share code, notes, and snippets.

Avatar

Oshane Bailey b4oshany

View GitHub Profile
@b4oshany
b4oshany / christmas_weekend_dates.py
Created Jan 2, 2016
Print the next 100 Christmas weekend dates
View christmas_weekend_dates.py
from datetime import datetime, timedelta, date
dates = []
today = datetime.today()
years = ["25/12/%d" % x for x in xrange(today.year, today.year + 101) if date(x, 12, 25).weekday() == 3]
print years
@b4oshany
b4oshany / .gitignore
Created Jan 14, 2016
kotti gitignore
View .gitignore
# Ignore files
*.pyc
*.pyo
*.db
*.log
*.swp
*.swo
*~
*.orig
*.eggs
@b4oshany
b4oshany / postgress-install.sh
Last active Jan 23, 2016
Postgres Installation Script
View postgress-install.sh
#!/bin/bash
# Install postgress server locally
sudo apt-get install postgresql postgresql-contrib
# Install PostGIS, procedural languages, client interfaces, etc
sudo apt-cache search postgres
# Install PGAdmin or Postgres UI, which is similar to PHPMyAdmin.
sudo apt-get install pgadmin3
View binary_search.py
def binary_search(lst, comparator):
"""Perform a binary search of the given list based on the given comparator
Arguments:
lst (list):
List of items to search through.
comparator (function):
Reference pointer for the function or method. This function should
only accept one parameter which is a signle list item. In addition,
this function should return a boolean value or none.
View python_node_bower_package_install.sh
#!/bin/bash
function base_installer {
# Install virtualenv
if [ -z $(which virtualenv) ]; then \
sudo apt-get install python-virtualenv; \
fi
# Create virtualenv for project
if [ ! -e "bin/pip" ]; then \
virtualenv .
View ctolabel.js
//new chart type LineBar - its a bit like bar and line were slammed together at high speed, not pretty, but they are part of each other now
(function(){
"use strict";
var root = this,
Chart = root.Chart,
helpers = Chart.helpers;
var defaultConfig = {
@b4oshany
b4oshany / install_appengine.sh
Last active May 10, 2016
Appengine Installer.
View install_appengine.sh
#!/bin/bash
APPENGINE_PATH=/usr/local/google_appengine
APPENGINE_APPCFG=/usr/local/google_appengine/appcfg.py
APP_PATH=$(pwd)
USER=$(whoami)
USER_HOME=/home/${USER}
APPENGINE_DLOAD=${USER_HOME}/google_appengine_1.9.37.zip
if [ -z $(which curl) ]; then \
View subprocess.php
<?php
/**
* @author Ashraf M Kaabi
* @name Advance Linux Exec
*/
class Process {
/**
* Run Application in background
*
* @param unknown_type $Command
@b4oshany
b4oshany / importer.py
Created Sep 9, 2016
Modified zopyx.plone.migration importer script for plone 5
View importer.py
################################################################
# Poor men's Plone export
# (C) 2013, ZOPYX Ltd, D-72074 Tuebingen
################################################################
import os
import shutil
import tempfile
import glob
import transaction
View Regex.txt
>>> import re
>>> data = """1foo bar
... 2bing baz
... 3spam eggs
... nomatch
... """
>>> pattern = r"(.)(\w+)\s(\w+)"
>>> {x[0]: x[1] for x in (m.group(3, 2) for m in (re.search(pattern, line) for line in data.splitlines()) if m)}
{'baz': 'bing', 'eggs': 'spam', 'bar': 'foo'}
share improve t