Skip to content

Instantly share code, notes, and snippets.

View tmosest's full-sized avatar

Tyler Moses tmosest

View GitHub Profile
@tmosest
tmosest / Gruntfile.js
Created March 9, 2017 00:18
Example of a grunt file
module.exports = function(grunt) {
//1. Configurations
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
coffee: {
dist: {
files: {
'src/js/global.js': 'src/coffee/global.coffee'
}
@tmosest
tmosest / header.php
Last active February 13, 2017 19:44
Header Social Media Options
<?php
$twitterURL = get_theme_mod('twitter_setting');
$linkedinURL = get_theme_mod('linkined_setting');
$rssURL = get_theme_mod('rss_setting');
$googleURL = get_theme_mod('googleplus_setting');
$facebookURL = get_theme_mod('facebook_setting');
$youTubeURL = get_theme_mod('youtube_setting');
$githubURL = get_theme_mod('github_setting');
$hasAdminLinks = get_theme_mod('adminLinkSetting');
?>
@tmosest
tmosest / functions.php
Last active February 13, 2017 22:13
Wordpress Social Media Theme Options
<?php
/**
* Add Custom theme options
*/
class tmosestBlog_Customize {
public static function register ( $wp_customize ) {
tmosestBlog_Customize::addSocialLinks($wp_customize);
tmosestBlog_Customize::addCopyRightText($wp_customize);
}
@tmosest
tmosest / createarray.java
Created February 7, 2017 21:40
Space Complexity != Time Complexity
public static void createArray(int n)
{
int[] array = new int[n];
}
@tmosest
tmosest / linear.java
Created February 7, 2017 21:37
Linear Space Time
/**
* This time we are create a variable over and over again in a for loop so we see linear space complexity.
*/
public static void printMultiplesOfFive(int n)
{
for(int i = 1; i <= n; i++) {
int multiple = i * 5;
System.out.println(multiple);
}
}
@tmosest
tmosest / constant.java
Created February 7, 2017 21:29
Constant Theta Complexity
/**
* This function has a constant space complexity.
* The function call and the variable declaration both take some memory but they don't grow with x.
*/
public static int addThree(int x)
{
int y = 3;
return x + y;
}
@tmosest
tmosest / DeviceUtil.java
Last active February 7, 2017 15:08 — forked from espinchi/DeviceUtil.java
Check if the running device is an emulator
import android.os.Build;
/**
* Utility methods related to physical devies and emulators.
*/
public class DeviceUtil {
public static boolean isEmulator() {
return Build.FINGERPRINT.startsWith("generic")
|| Build.FINGERPRINT.startsWith("unknown")
@tmosest
tmosest / hide.js
Last active March 28, 2017 16:52
Mobile Device Fix Blur Hide Keyboard iPhone Android Angular JS
function isTextInput(node) {
return ['INPUT', 'TEXTAREA'].indexOf(node.nodeName) !== -1;
}
angular.element($document[0]).on('touchstart', function(e) {
var activeElement = angular.element($document[0].activeElement)[0];
if(!isTextInput(e.target) && isTextInput(activeElement)) {
activeElement.blur();
}
});
@tmosest
tmosest / BubbleSort.java
Created January 31, 2017 22:13
Bubble Sort in Java
// Worste case is n^2 best case is n;
public static void BubbleSort(int[] array)
{
int j;
boolean flag = true;
int temp;
while(flag) {
flag = false;
for(j = 0; j < num.lenght - 1; j++) {
@tmosest
tmosest / comparison.java
Created January 27, 2017 01:29
Example 1 Big O vs Big Theta
// Same worst case and best case
public static boolean detectCharacter(String s, char c)
{
boolean hasCharacter = false;
for(int i = 0; i < s.length(); i++) {
if(s.charAt(i) == c) hasCharacter = true;
}
return hasCharacter;
}
// Different best case and worse case