Skip to content

Instantly share code, notes, and snippets.

View MosheBerman's full-sized avatar

Moshe MosheBerman

View GitHub Profile
@MosheBerman
MosheBerman / ExtendedStack.java
Created November 4, 2013 22:42
The output is: [a, b, c] [a, b, c, c] Why is the output left to right? Is the insertElementAt 1-based instead of zero based?
/**
* This class extends the Stack
* so that there's a pushdown(i)
* method which copies the elements
* at index 0 and inserts it and index i.
* All items beneath index i are pushed down.
*
*/
import java.util.Stack;
@MosheBerman
MosheBerman / How Not To Style UISearchBar
Created August 5, 2014 16:31
What I tried before using a solid image.
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
[self colorAllTheViews:self.searchDisplayController.searchBar.superview];
}
- (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller
{
[self fungeBackdrop];
}
<!DOCTYPE html><!--HTML5 doctype-->
<html>
<!--Rifka Rabinowitz lab2 file-->
<head>
<title> Rifka Rabinowitz CISC 1600 Lab #2 </title>
<link rel="stylesheet" href="./CSS/Rabinowitz-style.css">
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"/>
<script src='intelxdk.js'></script>
<script type="text/javascript">
@MosheBerman
MosheBerman / AgreementView.swift
Created January 20, 2016 17:41
A textview that can interpolating text with input ranges.
//
// AgreementInput.swift
// Intake
//
// Created by Moshe Berman on 1/14/16.
// Copyright © 2016 Moshe Berman. All rights reserved.
//
import Foundation
@MosheBerman
MosheBerman / BrokenAgreementView.swift
Created January 20, 2016 17:43
A broken agreement view class that its supposed to interpolate text fields with the form text.
//
// AgreementView.swift
// Intake
//
// Created by Moshe Berman on 12/11/15.
// Copyright © 2015 Moshe Berman. All rights reserved.
//
import UIKit
@MosheBerman
MosheBerman / recycleQueue.swift
Last active February 2, 2016 17:28
A queue for object recycling, similar to UITableView/UICollectionView recycling.
class ObjectQueue<T : NSObject> {
private var used : [T] = []
private var free : [T] = []
/** Recycle or create object. */
func dequeueObject () -> T {
var object : T
@MosheBerman
MosheBerman / testTask.swift
Created February 19, 2016 16:53
A method that creates an NSURLSessionDataTask
func testTask() -> NSURLSessionDataTask? {
let components = NSURLComponents()
components.scheme = self.serverURLComponents.scheme
components.host = self.serverURLComponents.host
components.port = self.serverURLComponents.port
components.path = "/"
guard let url = components.URL else {
print("Failed to build URL from components. \(components)")
@MosheBerman
MosheBerman / SubmissionManager.swift
Created February 19, 2016 16:55
Submission Manager
import UIKit
class SubmissionManager: NSObject {
static let sharedManager = SubmissionManager()
var serverURLComponents : NSURLComponents = NSURLComponents()
private let keyDefaultsServerAddress : String = "com.company.serverURL"
@MosheBerman
MosheBerman / hash.py
Last active June 20, 2018 08:40
A Python script to hash domain names.
import hashlib
import sys
try:
website_name = sys.argv[1]
hash_value = hashlib.md5(website_name)
print(hash_value.hexdigest().upper() + ".png")
except Exception, e:
#!/bin/sh
#
####################################
# iTunes Command Line Control v1.0
# written by David Schlosnagle
# created 2001.11.08
####################################
showHelp () {
echo "-----------------------------";