Skip to content

Instantly share code, notes, and snippets.

View nobitagit's full-sized avatar
🕸️
The less I know the better

Aurelio nobitagit

🕸️
The less I know the better
View GitHub Profile
declare module "vue-instantsearch" {
import Vue from "vue";
import { InstantSearch, InstantSearchOptions } from "instantsearch.js/es/types/instantsearch";
import { SearchClient } from "instantsearch.js/es/types/algoliasearch";
export interface SearchItem {
value: string;
count: number;
label: string;
isRefined: boolean;
@busypeoples
busypeoples / FlowTutorial.js
Last active July 17, 2023 10:12
Flow Fundamentals For JavaScript Developers
//
// MIT License
//
// Copyright (c) 2018 Ali Sharif
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
import React from 'react'
const enhancedForm = Component =>
class HigherOrderComponent extends React.Component {
constructor(props) {
super(props)
this.state = { form: props.initialState }
this.handleSubmit = this.handleSubmit.bind(this)
this.handleChange = this.handleChange.bind(this)
enum TaskState {
TASK_INBOX
TASK_PINNED
TASK_SNOOZED
TASK_ARCHIVED
}
type Task {
id: ID!
title: String!
@souporserious
souporserious / react-scrollspy.js
Last active May 2, 2021 06:24
Two simple components to build a ScrollSpy in React
import React, { Component, PropTypes, createElement } from 'react'
import { findDOMNode } from 'react-dom'
// usage:
// import { ScrollSpy, Link } = './wherever-this-file-is'
//
// <ScrollSpy>
// <Link ref={c => this._firstLink = c} section="1">Section 1</Link>
// <Link section="2">Section 2</Link>
// <Link section="3">Section 3</Link>
function translateError(msg) {
var newErr = new Error(msg); // placed here to get correct stack
return e => {
newErr.originalError = e;
throw newErr;
}
}
async function asyncTask() {
const user = await UserModel.findById(1).catch(translateError('No user found'))
@IbeVanmeenen
IbeVanmeenen / timeago.js
Last active April 12, 2022 14:03
TimeAgo - ES6
// Epochs
const epochs = [
['year', 31536000],
['month', 2592000],
['day', 86400],
['hour', 3600],
['minute', 60],
['second', 1]
];
@Zodiase
Zodiase / es6-abstract-class-example.js
Last active July 18, 2022 11:03
ES6 Abstract Class Example
'use strict';
class Abstract {
// A static abstract method.
static foo() {
if (this === Abstract) {
// Error Type 2. Abstract methods can not be called directly.
throw new TypeError("Can not call static abstract method foo.");
} else if (this.foo === Abstract.foo) {
// Error Type 3. The child has not implemented this method.
throw new TypeError("Please implement static abstract method foo.");
@prasadsilva
prasadsilva / fresh-chrome-with-custom-tz.sh
Last active June 4, 2023 12:54 — forked from stuartsierra/fresh-chrome.sh
Launch new instances of Google Chrome on OS X with isolated cache, cookies, user config and custom Timezone
#!/usr/bin/env bash
# fresh-chrome
#
# Use this script on OS X to launch a new instance of Google Chrome
# with its own empty cache, cookies, and user configuration.
#
# The first time you run this script, it will launch a new Google
# Chrome instance with a permanent user-data directory, which you can
# customize below. Perform any initial setup you want to keep on every
@priyajeet
priyajeet / gist:c2731789d3a688ee85a9
Last active August 29, 2015 14:19
T3/React usage rough hack
// todo-list module
Application.addModule('todo-list', function(context) {
var xhr;
var TodoList = React.createClass({
render: function() {
return (
<div>
<TodoItems />