Skip to content

Instantly share code, notes, and snippets.

View bhalash's full-sized avatar
💭
🌈

Mark bhalash

💭
🌈
  • Ireland
View GitHub Profile
@bhalash
bhalash / CompareDate.java
Created April 23, 2016 14:08
Date comparison
import java.text.SimpleDateFormat;
import java.util.Date;
public class AskDate {
public static void main(String args[]) {
Date today = new Date();
Date birthday = stringToDate("May 8, 1981");
// Date birthday = stringToDate("April 23, 2016");
System.out.println(today);
@bhalash
bhalash / functions.php
Last active March 20, 2016 20:56
WordPress post content content replacement
add_filter('the_content', function($content) {
$bindings = [
'<img' => ['click: lightbox.show']
];
foreach ($bindings as $tag => $directives) {
$directive = sprintf('%s data-bind="%s" ', $tag, implode(', ', $directives));
$content = str_replace($tag, $directive, $content);
// <img data-bind="click: lightbox.show"
@bhalash
bhalash / evil_string.rb
Last active January 21, 2016 20:57
Ruby regex test
#! /usr/bin/env ruby
# http://rubular.com/r/2Z6twnqiB7
# http://rubyfiddle.com/riddles/d4d27
only_letters_regex = /^[A-Za-z]+$/
evil_string = 'Good
123456789
"1" = "1"))/*
@bhalash
bhalash / .tigrc
Last active March 10, 2016 12:21
.tigrc
# See: http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html
# See: http://jonas.nitro.dk/tig/tigrc.5.html
#
# Area Foreground Background Options
# ==============================================================================
# Main UI
# ==============================================================================
color default 250 234
color 'Author ' 15 default
@bhalash
bhalash / instasort_1.sh
Last active January 1, 2016 09:35
Instagram Sorter
#!/bin/bash
# https://www.bhalash.com/archives/13544793955
# April 23, 2013
# Need to escape the source path both as when we declare and use it, or Errors Occur.
IFS=' '
src="/home/bhalash/Dropbox/Camera Uploads/"
destination="/home/bhalash/Dropbox/Photos/Instagram"
temp=/tmp/instafind
@bhalash
bhalash / dropbox_sort.sh
Created December 19, 2015 23:12
Image Import Sorter
#!/usr/bin/env bash
# Blame Mark ([email protected]) for this.
function trim_spaces() {
# Safely remove spaces in the file name.
new_name=$(sed 's/[[:space:]]/_/g' <<< "${1}")
mv "$1" $new_name && echo $new_name
}
function test_aspect_ratio() {
@bhalash
bhalash / capybara_authlogic.md
Last active January 17, 2019 07:13
Capybara, RSpec and AuthLogic

RSpec, Capybara and AuthLogic

This gist is dedicated to all of my fellow clueless n00bs who are frightened by the combination of [RSpec][1], [Capybara][2] and [Authlogic][3].

This gist will not tell you how to install Ruby, Rails, RSpec, Capybara or Authlogic. For the most part, you can install any of these by running either:

brew install <packagename>
bundle install <packagename>

At the point in time that you reach this gist, you should have all of them installed.

@bhalash
bhalash / batch_rename.sh
Last active December 1, 2015 20:27
Batch French-> English rename
#!/usr/bin/env zsh
if [ ! -d "${1}" ]; then
echo "'${1}' is not a valid directory!"
exit 1
fi
cd "${1}"
# Months
@bhalash
bhalash / branches.md
Last active December 1, 2015 14:36
How to Branch a Git Repository

Git Branches

[![][2]][1]

An active git repository will look like a tree:

  • The master branch is the trunk of the tree.
  • The side branches are...branches of the tree.

Branching a Repository

Before a branch can be created on the server, it must first be created on your computer. All branches in a repository are instigated in a client computer, in your local copy.

@bhalash
bhalash / avatars.md
Created November 27, 2015 11:42
Avatars