Skip to content

Instantly share code, notes, and snippets.

class Solution {
func fib(_ N: Int) -> Int {
return self.recursiveWay(N)
}
func recursiveWay(_ N: Int) -> Int {
if N == 0 { return 0 }
@CodingDoug
CodingDoug / README.md
Last active December 14, 2022 09:48
Realtime Database triggers with Cloud Functions for Firebase - source

Realtime Database triggers with Cloud Functions for Firebase - source

This gist contains the source code in my video series about Realtime Database triggers. You can watch the three parts here:

  1. Part 1 (intro, onCreate)
  2. Part 2 (onUpdate, infinite loops)
  3. Part 3 (onDelete, transactions)

index.ts contains the Cloud Functions code, and dialog.ts contains the script to run

@ranmyfriend
ranmyfriend / String+Validation
Created March 6, 2017 21:47
Phone Number validation in Swift 3
extension String {
public func isPhone()->Bool {
if self.isAllDigits() == true {
let phoneRegex = "[235689][0-9]{6}([0-9]{3})?"
let predicate = NSPredicate(format: "SELF MATCHES %@", phoneRegex)
return predicate.evaluate(with: self)
}else {
return false
}
@NikolaiRuhe
NikolaiRuhe / NRLabel.swift
Last active April 9, 2020 05:01
A UILabel subclass that adds padding around the text and handles layout properly.
import UIKit
class NRLabel : UILabel {
var textInsets = UIEdgeInsets.zero {
didSet { invalidateIntrinsicContentSize() }
}
override func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect {
let insetRect = UIEdgeInsetsInsetRect(bounds, textInsets)
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@syneart
syneart / Constellation_main.java
Last active March 31, 2016 17:28
星座判斷
public class Constellation_main {
public static void main(String[] args) {
System.out.println(getConstellationFromDate("10/01"));
}
private static String getConstellationFromDate(String strBirthday) {
int intBirthday = Integer.valueOf(strBirthday.replace("/",""));
if (intBirthday < 11 | intBirthday > 1231) {
<div ng-app="wizardApp">
<div ng-controller="WizardSignupController">
<h2>Signup wizard</h2>
<div ui-view></div>
</div>
</div>
<script type="text/javascript" src="/js/vendor/angular-ui-router/release/angular-ui-router.min.js"></script>
<script type="text/javascript">
angular.module('wizardApp', [
'ui.router',
@auser
auser / d3.js
Last active August 23, 2018 12:31
angular.module('d3', [])
.factory('d3Service', ['$document', '$window', '$q', '$rootScope',
function($document, $window, $q, $rootScope) {
var d = $q.defer(),
d3service = {
d3: function() { return d.promise; }
};
function onScriptLoad() {
// Load client in the browser
$rootScope.$apply(function() { d.resolve($window.d3); });
@zenorocha
zenorocha / README.md
Last active April 6, 2024 16:59
A template for Github READMEs (Markdown) + Sublime Snippet

Project Name

TODO: Write a project description

Installation

TODO: Describe the installation process

Usage