Skip to content

Instantly share code, notes, and snippets.

@sschizas
sschizas / DoHConfigurarion.swift
Created December 23, 2020 20:03
DNS-over-HTTPS (DoH) configuration enumeration to be used in `NWParameters.PrivacyContext`.
enum DoHConfigurarion: Hashable {
case adGuard
case alibaba
case cloudflare
case google
case openDNS
case quad9
var httpsURL: URL {
switch self {
@abhinav272
abhinav272 / KeyboardHeightProvider.java
Created March 20, 2018 10:05
Keyboard height provider for android
import android.app.Activity;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.util.DisplayMetrics;
@cohenadair
cohenadair / firebase-sandbox.md
Last active September 26, 2023 05:39
Setting up development and production Firebase environments for iOS

Firebase Environments

Last updated: October 21st, 2019.

At the time of writing this gist (January 4th, 2017), I was unable to find true sandboxing to separate development and production environments for a Firebase project. The closest we can get is to create two separate Firebase projects -- one for development and one for production.

Pros

  • Complete separation and isolation of all Firebase features.
  • Freedom to experiment without risking the corruption of production data.

Cons

@gkoehler
gkoehler / ViewController.swift
Created November 12, 2015 13:23
UICollectionView: performBatchUpdates example
//
// ViewController.swift
// collView2
//
// Created by Gavin Koehler on 11/11/15.
// Copyright © 2015 From Now On, LLC. All rights reserved.
//
import UIKit
@toddheasley
toddheasley / UIImage.swift
Last active December 2, 2020 15:32
Animated GIF Support for UIImage
import UIKit
extension UIImage {
public enum GIFBehavior {
case unclamped, clamped(TimeInterval), webkit
fileprivate func duration(_ properties: Any?) -> TimeInterval? {
// Look for specified image duration; always prefer unclamped delay time
guard let properties: [String: Any] = (properties as? [String: Any])?["{GIF}"] as? [String: Any],
@BlakeGardner
BlakeGardner / compact.js
Last active February 19, 2024 16:55
Compact all collections inside of a MongoDB database
// This script loops though the list of collection names in a MongoDB and runs the compact operation on them
// Simply paste this into the Mongo shell
use testDbName;
db.getCollectionNames().forEach(function (collectionName) {
print('Compacting: ' + collectionName);
db.runCommand({ compact: collectionName });
});
@rantav
rantav / README.md
Created August 23, 2012 06:13
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...