Skip to content

Instantly share code, notes, and snippets.

View rawnly's full-sized avatar
🧨
fixing my printer

Federico rawnly

🧨
fixing my printer
View GitHub Profile
from statistics import median
d={}
flag=True
def load_from_file(filename):
try:
# Load data from file
f=open(filename, "r")
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/services.dart';
import 'package:google_sign_in/google_sign_in.dart';
class SignInUtility {
static final FirebaseAuth _auth = FirebaseAuth.instance;
static final GoogleSignIn googleSignIn = GoogleSignIn();
static Future<FirebaseUser> signInWithGoogle() async {
final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
import { useRef, useEffect, useCallback, useState } from 'react';
const useIsMounted = (): () => boolean => {
const ref = useRef(false);
useEffect(() => {
ref.current = true;
return () => {
ref.current = false;
};
import { useState } from 'react'
const Card = ({ title, onClick }) => (
<div onClick={onClick} className="card">
<h1>{title}</h1>
</div>
)
const Modal = ({ title, onClose }) => (
<div>
import escape from 'sql-template-strings';
import { Except } from 'type-fest';
import { query } from '../lib/db';
import { QueryOutput } from '@interfaces/util';
export interface Schoolr_Partner {
id?: number;
name: string;
deleted: boolean;
}
extension URL {
var canBeOpened: Bool {
return UIApplication.shared.canOpenURL(self)
}
init(string main: String, fallback secondary: String) {
let url = URL(string: main)
@rawnly
rawnly / Field.tsx
Created February 14, 2020 13:46
FormGenerator
import { ValidationOptions, useFormContext, ErrorMessage } from 'react-hook-form';
import {FunctionComponent, useEffect} from 'react';
import cx from 'classnames';
import { ClassValue } from 'classnames/types';
import Select from "./Select";
export interface Props {
label?: string;
name: string;
placeholder?: string;
@rawnly
rawnly / useStorage.ts
Last active February 11, 2020 00:11
Use Session/Local Storage in your react application throught this hook
import { useState } from 'react';
type StorageType = 'local' | 'session';
type SetValueFn<T> = ((item: T) => T) | T;
interface StorageModifiers<T extends {}> {
set: <K extends keyof T = keyof T>(key: K, value: SetValueFn<T[K]>) => void;
get: <K extends keyof T = keyof T>(key?: K) => T[K];
}
function toTS(text: string): string {
return text
.replace(/\n/, '')
.split(';')
.map((row) =>
row
.replace(/public|private|internal|static/gi, '')
.trim()
.replace(/String|Boolean/gi, (v) => v.toLowerCase())
.replace(/Int|Long|Double/gi, 'number')
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
enum Section: CaseIterable {
case one
case two
}