Skip to content

Instantly share code, notes, and snippets.

View MosheBerman's full-sized avatar

Moshe MosheBerman

View GitHub Profile
@MosheBerman
MosheBerman / fcm_test.py
Created September 15, 2016 20:28
A testbed for Firebase Cloud Messaging.
import requests
import json
url = "https://fcm.googleapis.com/fcm/send"
project_key = "firebase-dashboard-project-key"
headers = {
"Authorization": "key={}".format(project_key),
"Content-Type": "application/json"
}
@MosheBerman
MosheBerman / URLParser.js
Created July 18, 2016 20:38
A collection of JavaSscript functions to parse out URLs into distinct data points.
// URL Here:
var sampleURL = "http://domain.com/#order/food=chicken/drink=coke";
// Function to parse the URL
function parseURL(inputURL) {
/**
Strategy:
func textForToday() -> NSAttributedString
{
let sefira = Sefira()
let day = sefira.dayToUseForDisplay()
let prayers : KCSefiraPrayerAddition = self.flagsForPrayerComponentsEnabledByUser()
let storedCustom = SettingsManager.sharedManager.custom()
if let custom = KCSefiraCustom(rawValue: storedCustom) {
sefiraFormatter.custom = custom
}
#!/bin/sh
#
####################################
# iTunes Command Line Control v1.0
# written by David Schlosnagle
# created 2001.11.08
####################################
showHelp () {
echo "-----------------------------";
@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:
@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 / 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 / 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 / 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 / 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