Skip to content

Instantly share code, notes, and snippets.

View SIRHAMY's full-sized avatar
🐷
Loading...

Hamilton Greene SIRHAMY

🐷
Loading...
View GitHub Profile
@SIRHAMY
SIRHAMY / app.js
Created July 28, 2015 01:45
P5.js in Angular Application Example
angular.module('sirhamy', ['ngRoute', 'projects']);
angular.module('sirhamy').config( function($routeProvider) {
$routeProvider
.when('/main', {
templateUrl: 'views/main.html',
controller: 'MainCtrl',
controllerAs: 'control'
})
.when('/phantsaver', {
<select ng-model="rightPdfChart"
ng-options="option.name for option in options">
</select>
@SIRHAMY
SIRHAMY / AngularCSSHide.css
Created July 30, 2015 03:38
Angular example using CSS to hide elements instead of ng-show and ng-hide
.chartdisplay img {
display: block;
height: 100%;
width: 100%;
}
.hide {
visibility: hidden;
opacity: 1;
}
<button class="btn" ng-click="toggleVisible('left')"
ng-class="{ active : isVisible('left') }">Toggle Left
</button>
<button class="btn" ng-click="toggleVisible('right')"
ng-class="{ active : isVisible('right') }">Toggle Right
</button>
@SIRHAMY
SIRHAMY / isPalindrome.java
Created December 15, 2015 05:08
Java: Decides if given string is a Palindrome
public boolean isPalindrome(String s) {
for(int i = 0; i < s.length()/2; i++) {
if(s.charAt(i) != s.charAt(s.length() - i - 1)) {
return false;
}
}
return true;
}
@SIRHAMY
SIRHAMY / Main.java
Created January 8, 2016 04:09
WorldProblem Constructor Example
public class Main {
public static void main(String[] args) {
World myWorld = new World(
new Country("USA",
new State("NY",
new City("New York", 8143197)),
new City("LA", 3844829),
new City("Chicago", 2842518),
new District("Washington D.C.", 658893)),
new Country("Germany",
@SIRHAMY
SIRHAMY / City.java
Created January 8, 2016 04:17
My WorldProblem solution.
public class City implements Municipality{
private int population;
private String name;
public City(String name, int population) {
this.name = name;
this.population = population;
}
@Override
@SIRHAMY
SIRHAMY / WhatsWrong.java
Created January 8, 2016 05:03
Little function used for debugging exercises.
public int x(String z) {
if(z.toLowerCase().equals("Airplane")) {
return 5;
} else if(z.toLowerCase().equals("Car")){
return 3;
} else if(z.toLowerCase().equals("Boat")){
return 3;
}
}
@SIRHAMY
SIRHAMY / ZeroesToTheRight.java
Created January 8, 2016 05:40
Short method that takes in an integer array and moves all the zeroes to the right-most indices.
public static void zeroRightShift(int[] A) {
if(A == null) return;
int zeroPtr = A.length - 1;
while(zeroPtr >= 0) {
if(A[zeroPtr] != 0) break;
zeroPtr--;
}
@SIRHAMY
SIRHAMY / LongestCharSeq.java
Last active January 8, 2016 19:45
Finds and returns the longest sequence of consecutive characters (as per ASCII) in given string.
public class LongestCharSeq {
public String findLongest(String s) {
StringBuffer result = new StringBuffer();
s.toLowerCase();
int lastChar = getAsciiVal(s.charAt(0)) - 1;
StringBuffer currentSeq = new StringBuffer();
for(int i = 0; i<s.length(); i++) {