Skip to content

Instantly share code, notes, and snippets.

View 0xch4z's full-sized avatar
🪣

Charlie Kenney 0xch4z

🪣
View GitHub Profile
//
// main.swift
// Open Applications
//
// Created by Charles Kenney on 10/16/17.
// Copyright © 2017 Charles Kenney. All rights reserved.
//
import Foundation
import Cocoa
@0xch4z
0xch4z / foo.html
Last active October 14, 2017 17:15
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery Calculator</title>
<!-- Added link to the jQuery Library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- Added a link to Bootstrap-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="wrapper">
@0xch4z
0xch4z / InputMapper.swift
Created September 26, 2017 02:09
Concise snippets for mapping strings from standard input to arrays
// Given a string of space seperated components,
// you can use the following lines to map the
// components to arrays. Useful for reading input
// from the standard input stream in problem sets.
// (Swift 4)
//: Read an array of strings
let strings = readLine()!.split(separator: " ").map { String($0) }
//: Read an array of characters
func isPalindrome(_ s: String) -> Bool {
return s == Array(s.characters).reversed().map{String($0)}.reduce("",+)
}
@0xch4z
0xch4z / main.cpp
Created September 13, 2017 01:17
Queue Implementation (C++14)
#include "main.h"
using namespace std;
int main() {
Queue q;
for (int i = 1; i < 4; ++i) {
q.enqueue(i);
}
@0xch4z
0xch4z / ValidBraces.js
Created July 1, 2017 19:44
Solution to the CodeWars 'Valid Braces' problem, in Javascript.
// Charles Kenney
const isOpening = (b) => b === '{' || b === '[' || b === '(';
const closing = (b) => {
switch(b) {
case '{':
return '}';
case '[':
return ']';
@0xch4z
0xch4z / linearSearch.swift
Created May 9, 2017 17:00
Swift 3 Linear Search Algorithm
func linearSearch<T:Equatable>(onArray array: Array<T>, forItem item: T) -> Int {
for (index, i) in array.enumerated() where i == item {
return index
}
return -1
}