Skip to content

Instantly share code, notes, and snippets.

Avatar

Fabio Cigliano lidio601

View GitHub Profile
@lidio601
lidio601 / mac_vendors.dart
Last active Mar 2, 2020
API integration for macvendors.com API
View mac_vendors.dart
///
/// Wrapper around Macvendors API
/// https://macvendors.com/api
///
import 'package:http/http.dart' as http;
import "zmac_address.dart";
const BASE_URL = "https://api.macvendors.com";
@lidio601
lidio601 / mac_address.dart
Created Mar 2, 2020
simple function to normalize mac addresses
View mac_address.dart
final d = "([0-9A-F]{2})";
final s = "[:\.-]?";
final RegExp re = RegExp(
"$d$s$d$s$d$s$d$s$d$s$d",
multiLine: false,
);
/// MAC addresses will come in the following shape or form:
@lidio601
lidio601 / loadScript.js
Last active Jan 18, 2020
Load custom script into DOM (with Promise)
View loadScript.js
/**
* Dinamically load script into DOM
* @see https://gist.github.com/lidio601/81974ecf4564dbf257f80a969dcbdd5c
*
* Example usage:
* {code}
require('./loadScript');
console.log('starting');
@lidio601
lidio601 / block-signup.md
Created Jan 14, 2020
Google Cloud function to automatically disable new users
View block-signup.md

Firebase Authentication

Via this Cloud Function you can automatically disable new users.

To deploy this, replace with yours and deploy via command line with:

gcloud functions deploy block-signup --runtime nodejs10 --trigger-event providers/firebase.auth/eventTypes/user.create --trigger-resource <PROJECT-ID>
View logger.js
/* eslint-disable no-console */
import _ from "lodash";
const DEBUG = !process.env.NODE_ENV || process.env.NODE_ENV === "development";
class ConfigHolder {
constructor(initialValue) {
this.value = initialValue;
}
@lidio601
lidio601 / solution.c
Created Nov 28, 2019
C test to check if a number is prime
View solution.c
#include <stdbool.h>
#ifndef Solution_INCLUDED
#define Solution_INCLUDED
bool IsPrime(int input);
#endif
@lidio601
lidio601 / react_native_starter.sh
Last active Oct 2, 2019
React Native app starter kit
View react_native_starter.sh
# ensure right cli is installed
npm uninstall -g react-native-cli
npm i -g @react-native-community/cli
# create app from template
APPNAME=myapp
npx react-native init ${APPNAME} --template react-native-template-typescript
cd ${APPNAME}
@lidio601
lidio601 / AppDelegate.m
Last active Jul 31, 2019
React Native - native module started kit (iOs)
View AppDelegate.m
// ...
#import "FooModule.h"
// ...
@interface AppDelegate ()
// ...
@property (nonatomic, strong) FooModule *fooModule;
// ...
@end
View fibonacci.js
function fibonacci (n) {
if (n < 1) return 0;
var a = [1, 1];
var sum = 1;
while (n-- > 2) {
sum += a[0];
a = a.slice(1).concat(sum);
}
return sum;
}
View update.20181121.log
This file has been truncated, but you can view the full file.
23:19:37 stopping lamassu-server
lamassu-server: stopped
lamassu-admin-server: stopped
23:19:37 archiving old lamassu-server installation located in /usr/lib/node_modules/lamassu-server
tar: Removing leading `/' from member names
removed '/usr/lib/node_modules/lamassu-server/todo.txt'
removed '/usr/lib/node_modules/lamassu-server/.jshintrc'
removed '/usr/lib/node_modules/lamassu-server/currencies.json'
removed '/usr/lib/node_modules/lamassu-server/data-notes.txt'
You can’t perform that action at this time.