Skip to content

Instantly share code, notes, and snippets.

Alex Singleton alexanderjsingleton

Block or report user

Report or block alexanderjsingleton

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:a7e7cad8d04b62df3cb2
Executed w/ Vim:
```
%s/src="\(img\/.\+\)"/<?php echo get_template_directory_uri(); ?>\/\1/g
%s/src="\(js\/.\+\)"/<?php echo get_template_directory_uri(); ?>\/\1/g
%s/href="\(css\/.\+\)"/<?php echo get_template_directory_uri(); ?>\/\1/g
```
@alexanderjsingleton
alexanderjsingleton / keybase.md
Created Sep 22, 2015
verification for keybase.io
View keybase.md

Keybase proof

I hereby claim:

  • I am alexanderjsingleton on github.
  • I am alexjsingleton (https://keybase.io/alexjsingleton) on keybase.
  • I have a public key whose fingerprint is 6F14 7DB7 2CC6 E71B 8549 4155 8F99 C823 52A2 277E

To claim this, I am signing this object:

View Greenfoot_Wombat
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
/**
* Wombat. A Wombat moves forward until it hits the edge of the world, at
* which point it turns left. If a wombat finds a leaf, it eats it.
*
* @author Michael Kölling
* @version 2.0
*/
public class Wombat extends Actor
@alexanderjsingleton
alexanderjsingleton / gitPruner.sh
Last active Oct 8, 2015
For the derpy, albeit accidental, push to origin including your secrets.yml file...
View gitPruner.sh
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch config/secrets.yml' --prune-empty --tag-name-filter cat -- --all
@alexanderjsingleton
alexanderjsingleton / FizzBuzz_ExtendedCommentaryEdition.rb
Last active Nov 16, 2015
For my blog post describing optimal alogrithm design for performance-commentary included for n00bs :)
View FizzBuzz_ExtendedCommentaryEdition.rb
# *NOTE*, case statements are preferred over standard conditionals-this has been confirmed according to my very
# own academic research and engagements with CS professors-BUT-here is an outstanding explanation by [@DanielleSucher](http://www.daniellesucher.com/2013/07/ruby-case-versus-if/)
# define method 'fizzbuzz' initialized by single-variable argument 'number'
def fizzbuzz(number)
# define local method 'divisibleby3' defining a function checking divisibility of initialized by single-variable 'number' using the modulus and case-equality operators checking for remainder of 0 when divided by 3
divisibleBy3 = (number % 3 == 0)
# define local method 'divisibleby5' defining a function checking divisibility of initialized by single-variable 'number' using the modulus and case-equality operators checking for remainder of 0 when divided by 5
divisibleBy5 = (number % 5 == 0)
# construct case statement according to fizzbuzz specifications for 3 and 5, only 3 and only 5
case
@alexanderjsingleton
alexanderjsingleton / benchmark.rb
Last active Dec 16, 2015
An experiment supporting the most efficient fizzbuzz solution.
View benchmark.rb
require 'benchmark'
def fizzbuzz(array)
array.map do |number|
divisibleBy3 = (number % 3 == 0)
divisibleBy5 = (number % 5 == 0)
case
when divisibleBy3 && divisibleBy5
puts "FizzBuzz"
@alexanderjsingleton
alexanderjsingleton / terminalOutput.txt
Created Oct 18, 2015
Benchmark test results for most efficient fizzbuzz solution.
View terminalOutput.txt
Desktop ruby fizzbuzz.rb | grep 0.0
0.010000 0.000000 0.010000 ( 0.010018)
0.010000 0.000000 0.010000 ( 0.011353)
View RubyVMterminalOutput.txt
➜ Desktop ruby fizzbuzz.rb
fizzbuzz
== disasm: <RubyVM::InstructionSequence:fizzbuzz@fizzbuzz.rb>===========
== catch table
| catch type: break st: 0004 ed: 0008 sp: 0000 cont: 0008
|------------------------------------------------------------------------
local table (size: 2, argc: 1 [opts: 0, rest: -1, post: 0, block: -1] s1)
[ 2] array<Arg>
0000 trace 8 ( 3)
0002 trace 1 ( 4)
View FlambinoFizzBuzzChallenge.rb
require 'benchmark'
N = Array(1..10_000_000)
def no_op(*a); end
def fizzbuzz(array)
array.each do |number|
divisibleBy3 = (number % 3 == 0)
divisibleBy5 = (number % 5 == 0)
@alexanderjsingleton
alexanderjsingleton / .htaccess.txt
Last active Dec 6, 2015
An example for redirecting WordPress instance via .htaccess (public_html/)
View .htaccess.txt
# Redirect traffic to https
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} !^[REDACTED]$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
RewriteOptions inherit
# BEGIN WordPress
<IfModule mod_rewrite.c>
You can’t perform that action at this time.