Skip to content

Instantly share code, notes, and snippets.

View MosheBerman's full-sized avatar

Moshe MosheBerman

View GitHub Profile
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
}
@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:
@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 / fcm_test_literature.py
Created September 21, 2016 22:06
A way to send the best and worst of classical literature over APNs.
import requests
import json
url = "https://fcm.googleapis.com/fcm/send"
project_key = "token"
def send(title, text):
headers = {
"Authorization": "key={}".format(project_key),
"Content-Type": "application/json"
@MosheBerman
MosheBerman / StatusBarHack.swift
Created March 20, 2017 01:32
Set the Status Bar Color on iOS...
func setStatusBarColor(color: UIColor) {
let statusBarWindow = UIApplication.sharedApplication().valueForKey("statusBarWindow")
let statusBar = statusBarWindow!.valueForKey("statusBar")
let selector = Selector("setForegroundColor:")
if statusBar!.respondsToSelector(selector) {
statusBar!.performSelector(selector, withObject: color)
}
}
@MosheBerman
MosheBerman / locator-arrow.js
Last active July 24, 2017 16:09
A JS object/function to locate a user with `navigator.geolocation`.
function Locator(successCallback, errorCallback)
{
this.success = (location) =>
{
console.dir(location);
this.pauseLocationUpdates();
successCallback(location);
};
function Locator(successCallback, errorCallback)
{
var _this = this;
this.success = function(location)
{
console.dir(location);
_this.pauseLocationUpdates();
successCallback(location);
@MosheBerman
MosheBerman / statusBarTint.swift
Created November 1, 2017 01:10
UIStatusBar Tint
// Untested on iOS 11, untested with App Review. YMMV.
// MARK: - Theming the Status Bar
private func set(statusBar color: UIColor) {
guard let statusBarWindow = UIApplication.shared.value(forKey: "statusBarWindow") as? UIWindow else
{
print("Failed to get status bar window.")
return
}
@MosheBerman
MosheBerman / gcoco.py
Last active January 10, 2019 03:42
Too many "pro" tier repos?
import requests
print "####################################"
print "# GitHub Collaborator Counter v1.0 #"
print "####################################"
access_token = None
if access_token is None:
@MosheBerman
MosheBerman / ancestry_clustering_ui_driver.js
Last active June 4, 2020 19:16
Automate DNA Clustering on Ancestry.com
/**
Tested in Google Chrome on macOS.
How to use:
Step 1: Navigate to Ancestry.com > DNA Matches > {A match} > Shared Matches
Step 2: Add a new custom group. (If you don't, the bottom group will be used.)
Step 2, optional: scroll down to load more shared matches. (Only loaded matches can be seen by the script.)
Step 3: Open the Developer Console.
Step 4: Paste this code into the console.
Step 5: Wait. The script is manually clicking buttons and it will take some time.