Skip to content

Instantly share code, notes, and snippets.

View juandc's full-sized avatar
🏠

Juan David Castro juandc

🏠
View GitHub Profile
@arvi
arvi / sublime-settings-osx.json
Last active March 28, 2022 06:07
Sublime Settings OSX
{
"auto_complete_triggers":
[
{
"characters": "<",
"selector": "text.html"
},
{
"characters": ".",
"selector": "source.js"
@alexcasalboni
alexcasalboni / amazon-rekognition.md
Last active October 11, 2024 16:44
Amazon Rekognition - Python Code Samples

Amazon Rekognition - Python Code Samples

  1. Labels Detection
  2. Faces Detection
  3. Faces Comparison
  4. Faces Indexing
  5. Faces Search
const header = document.querySelector('.header');
const pageWrap = document.querySelector('.wrapper');
var lastScrollTop = 0;
function debounce(func, wait) {
let timeout;
return function(...args) {
const context = this;
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(context, args), wait);
@vmasto
vmasto / twitter-react-redux-email.txt
Last active August 3, 2023 22:34 — forked from fat/email.txt
Twitter's React/Redux application architecture
Hey,
This is the redux video series that helped me learn how to use it: https://egghead.io/courses/getting-started-with-redux. And here's a section on react "stateless functions": https://facebook.github.io/react/docs/reusable-components.html#stateless-functions
Later you might want to play around with React Native
React Native for Web: https://github.com/necolas/react-native-web
Try it out here: http://codepen.io/necolas/pen/PZzwBR/?editors=0010
And I thought you might get some ideas from what we're doing for mobile.twitter.com, which is a bit like this...
@scottdomes
scottdomes / FunctionalComponent.js
Last active February 15, 2018 13:49
React Component Best Practices: Functional Component
import React from 'react'
import { observer } from 'mobx-react'
import { func, bool } from 'prop-types'
// Separate local imports from dependencies
import './styles/Form.css'
// Declare propTypes here, before the component (taking advantage of JS function hoisting)
// You want these to be as visible as possible
ExpandableForm.propTypes = {
onSubmit: func.isRequired,
@alexandrenicol
alexandrenicol / index.js
Created February 2, 2017 11:21
Facebook Messenger Bot - Handle postback payload
const Facebook = require('Facebook');
exports.handler = (event, context, callback) => {
/* ...
Get messaging event // see https://gist.github.com/alexandrenicol/f01f867cb175cd89e3e100c508cc6f4a#file-index-js
... */
// Iterate over each messaging event
entry.messaging.forEach(function(event) {
if (event.message) {
const message = event.message.text;
const senderID = event.sender.id;
@developit
developit / unistore.js
Last active September 8, 2020 15:13
Update: the newer & better version of this is published: https://github.com/developit/unistore
import { h, Component } from 'preact';
/** Creates a new store, which is a tiny evented state container.
* @example
* let store = createStore();
* store.subscribe( state => console.log(state) );
* store.setState({ a: 'b' }); // logs { a: 'b' }
* store.setState({ c: 'd' }); // logs { c: 'd' }
*/
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// πŸ”₯ Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('β˜•'), 2000); // it takes 2 seconds to make coffee
});
}
@Atrix1987
Atrix1987 / firebase_function_feed.js
Created April 23, 2017 09:19
Firebase Function snippet for populating a user feed
exports.updateFeed = functions.database.ref('/stories/{userId}/{storyId}').onWrite(event => {
const userId = event.params.userId;
const storyId = event.params.storyId;
let followersRef = admin.database().ref('/followers/'+userId);
if(!event.data.val()){
//post was deleted
followersRef.once("value", function(snap) {
snap.forEach(function(childSnapshot) {
let followerId = childSnapshot.key;
@wagyu298
wagyu298 / detectmotionurl.js
Created May 12, 2017 05:41
AWS Rekognition detectModerationLabels example for Node.js
#!/usr/bin/env node
const request = require('request');
const AWS = require('aws-sdk');
const rekognition = new AWS.Rekognition({
// Detect moderation labels is available on AWS region us-east-1, us-west-2 and eu-west-1
region: "us-west-2",
accessKeyId: "YOUR accessKeyId",
secretAccessKey: "YOUR secretAccessKey"