Skip to content

Instantly share code, notes, and snippets.

View peterkos's full-sized avatar
:octocat:

Peter Kos peterkos

:octocat:
View GitHub Profile
@peterkos
peterkos / Hello, Worlds!
Created September 12, 2014 01:19
"Hello, World" by appending strings in a variety of languages. Just thought it would be fun to compare syntaxes.
//Objective-C
NSMutableString *str = [[NSMutableString alloc] initWithFormat:@"Hello "]; //NSMutableString *str = @"Hello,";
str = [str stringByAppendingString:@" world!"];
NSLog(@"%@", str); //Output: Hello, world!
//Java
String newString = "Hello, ";
String secondString = " world!";
@peterkos
peterkos / .gitconfig
Created September 23, 2014 01:16
My ~/.gitconfig aliases - good for viewing history!
[alias]
today = !git log --since=midnight --author=\"$(git config user.name)\" --oneline
hist = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
@peterkos
peterkos / .bash_profile
Last active August 29, 2015 14:07
My ~/.bash_profile Aliases
#-----------------------------------------------------------------------------------------------------
#Aliases becuause typing out directories sucks
#-----------------------------------------------------------------------------------------------------
alias speedtest='wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip'
alias renew='sudo ipconfig set en0 BOOTP && sudo ipconfig set en0 DHCP'
alias websvr='python -m SimpleHTTPServer 8000'
alias sbg='/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &'
@peterkos
peterkos / gist:ee145a59cd6325476aa2
Created November 22, 2014 11:22
The Golden Input Method
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public static void askForInputFile() throws FileNotFoundException {
Scanner in = new Scanner(new File("src/input.txt"));
int positionInquiry = in.nextInt();
position = new int[positionInquiry];
for (int i = 0; i < positionInquiry; i++) {
@peterkos
peterkos / gulpfile.js
Created December 19, 2014 16:49
My Gulpfile used for a variety of projects
var gulp = require('gulp');
var rename = require('gulp-rename');
var browserSync = require('browser-sync');
var notify = require('gulp-notify');
var sass = require('gulp-sass');
var minifycss = require('gulp-minify-css');
var autoprefixer = require('gulp-autoprefixer');
gulp.task('browser-sync', function() {
browserSync({
@peterkos
peterkos / StringOps.swift
Last active June 16, 2016 01:19
Adds -=, /=, and *= operation to Strings in Swift.
func -= ( left: inout String, right: String) -> String {
let index = left.index(left.endIndex, offsetBy: -right.characters.count)
return left.substring(to: index)
}
func *= ( left: inout String, right: String) -> String {
var finalString = left
// My hack
ArrayList<Integer> arrayListOfIntegers = new ArrayList<Integer>();
for (char numAsChar : tempArray1AsChar) {
if (numAsChar != ' ') {
arrayListOfIntegers.add(Character.getNumericValue(numAsChar));
}
}
// Julian's hack
@peterkos
peterkos / Fake double division with Integers.java
Last active September 24, 2016 18:03
Inputs two integers and outputs an integer with a fake decimal, i.e. (int division result).(remainder)
private static int addTwoIntegers(int firstValue, int secondValue) {
int intResult = 0;
int remainderResult = 0;
intResult = firstValue / secondValue;
remainderResult = firstValue % secondValue;
System.out.printf("firstValue divided by secondVlaue is %s.%s\n", intResult, remainderResult);
//Same as above statement, but with println instead of printf
//System.out.println("firstValue divided by secondValue is " + intResult + "." + remainderResult);
@peterkos
peterkos / PCTree.java
Created April 25, 2017 16:18
Generic tree with breadth-first search.
import static java.lang.System.*;
import java.util.ArrayList;
public class PCBTree {
public static void main(String[] args) {
@peterkos
peterkos / PCBinaryTree.java
Created April 25, 2017 17:41
Binary tree with inorder traversal.
import static java.lang.System.*;
import java.util.ArrayList;
public class PCLegitBinaryTree {
public static void main(String[] args) {