Skip to content

Instantly share code, notes, and snippets.

@apphands
apphands / sprinklers.ino
Last active September 13, 2020 03:16
NodeMCU esp8266 home irrigation script
// Load Wi-Fi library
#include <ESP8266WiFi.h>
// Replace with your network credentials
const char* ssid = "<YOUR WIFI NAME HERE>";
const char* password = "<YOUR WIFI PASSWORD HERE>";
// Load Wi-Fi library
@apphands
apphands / gist:2757efa1b8e4fcce69cbd55ff4acea44
Created August 19, 2019 22:26
NodeMCU esp8266 home irrigation script
// Load Wi-Fi library
#include <ESP8266WiFi.h>
// Replace with your network credentials
const char* ssid = "edmonds";
const char* password = "jennyjenny";
WiFiServer server(80);
@apphands
apphands / Sort NSDictionary descending
Last active June 23, 2016 00:53
Sort NSDictionary keys in descending order
NSDictionary *dict = @{@"a":@1, @"b":@3, @"z":@24};
NSArray *sortedArray = [dict keysSortedByValueUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
return [obj1 integerValue] < [obj2 integerValue];
}];
NSLog(@"dict: %@", sortedArray);
@apphands
apphands / Fibonacci.swift
Last active June 12, 2016 05:07
Calculate Fibonacci numbers in Swift
// https://en.wikipedia.org/wiki/Fibonacci_number
// 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55 ...
func fib(n:Int)->Int {
if n > 2 {
return fib(n-1) + fib(n-2)
} else {
return n
}
}
import Foundation
public extension NSDate {
public class func ISOStringFromDate(date: NSDate) -> String {
var dateFormatter = NSDateFormatter()
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
dateFormatter.timeZone = NSTimeZone(abbreviation: "GMT")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"
@apphands
apphands / GH001 fixed
Last active October 12, 2023 12:21
To fix the Git error: "remote: error: GH001: Large files detected."
git filter-branch -f --index-filter 'git rm -r -f --ignore-unmatch <FILE_TO_REMOVE>' HEAD