Skip to content

Instantly share code, notes, and snippets.

View Quaggie's full-sized avatar

Jonathan Bijos Quaggie

  • Route
  • Rio de Janeiro
View GitHub Profile
function factorialize(num) {
if (num === 1 || num === 0) return 1;
else if (num === 2) return 2;
else if (num > 2) {
return num * factorialize(num-1);
}
}
factorialize(5);
/*
* Adds zeros to the beginning of the cnpj in case of database deletion
*/
function verifyCnpj (cnpj) {
var strCnpj = cnpj.toString();
if (cnpj.length === 14) return strCnpj;
if (strCnpj.length < 14) {
return verifyCnpj("0" + strCnpj);
Array.prototype.concatAll = function() {
var results = [];
this.forEach(function(subArray) {
results.push.apply(results, subArray);
});
return results;
};
Array.prototype.concatMap = function(fn) {
function diffArray(arr1, arr2) {
var arr1Diff = arr1.filter( i => arr2.filter( y => i === y).length === 0);
var arr2Diff = arr2.filter( i => arr1.filter( y => i === y).length === 0);
return arr2Diff.concat(arr1Diff);
}
console.log(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]))
//
// Extensions.swift
// Swift 3 compatible
//
// Created by Quaggie.
// Copyright © 2017 Quaggie. All rights reserved.
//
import UIKit
import UIKit
import Foundation
class GradientView: UIView, Gradientable {}
protocol Gradientable: class {}
extension Gradientable where Self: UIView {
private func getCGPoints (for position: GradientPosition, start at: StartAt) -> (CGPoint, CGPoint)? {
switch position{
'use strict';
const moment = require('moment');
const { CronJob } = require('cron');
function callback (job) {
}
exports.callback = function () {
const spawn = require('child_process').spawn; // child_process spawn function
const app = require('express')(); // new express http server
app.use('/', (req, res) => {
const ls = spawn('ls', ['-lh', '/usr']); // here would be the mysqldump command
ls.stdout.pipe(res);
}); // piping the stdout (the output from the mysqldump command, in this case the ls command) to the response object
// using fs
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if textField == cellPhoneTextField {
let newString = (textField.text! as NSString).replacingCharacters(in: range, with: string)
let components = (newString as NSString).components(separatedBy: NSCharacterSet.decimalDigits.inverted)
let decimalString = components.joined(separator: "") as NSString
let length = decimalString.length
// ...
@property (weak, nonatomic) IBOutlet UITextView *thankYoutTextView;
// ...
// thankYouTextView
NSString *userName = [[PFUser currentUser] objectForKey:@"name"];
NSString *thankYouString = [[NSString stringWithFormat:@"Lorem Ipsum....., %@, Lorem.......", userName] uppercaseString];
NSRange nameRange = [thankYouString rangeOfString: [userName uppercaseString]];
NSDictionary *thankYouAttributes = @{