Skip to content

Instantly share code, notes, and snippets.

View apherio's full-sized avatar
🎯
Focusing

Sahil Mhapsekar apherio

🎯
Focusing
View GitHub Profile
@apherio
apherio / useDebounce.ts
Created February 28, 2021 14:03
debouncing functionality.
import { useState, useEffect } from 'react';
function useDebounce<T>(
initialValue: T,
time: number
): [T, T, React.Dispatch<T>] {
const [value, setValue] = useState<T>(initialValue);
const [debouncedValue, setDebouncedValue] = useState<T>(initialValue);
useEffect(() => {
{
"response_code": 0,
"results": [
{
"category": "RiskQuestions",
"type": "multiple",
"question": "I have previously put money in a risky investment",
"options": [
"Strongly Agree",
"Agree",
@apherio
apherio / mailchimp-allthefun
Created February 10, 2019 13:42
sample integration
<!-- Begin Mailchimp Signup Form -->
<link href="//cdn-images.mailchimp.com/embedcode/classic-10_7.css" rel="stylesheet" type="text/css">
<style type="text/css">
#mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }
/* Add your own Mailchimp form style overrides in your site stylesheet or in this style block.
We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
</style>
<style type="text/css">
#mc-embedded-subscribe-form input[type=checkbox]{display: inline; width: auto;margin-right: 10px;}
#mergeRow-gdpr {margin-top: 20px;}
import serial, time
ser = serial.Serial()
ser.port = '/dev/ttyACM1'
#ser.port = 'COM10'
ser.baudrate = 115200
ser.bytesize = serial.EIGHTBITS
ser.parity =serial.PARITY_NONE
ser.stopbits = serial.STOPBITS_ONE
ser.timeout = 1
ser.open()
@apherio
apherio / Broadcast.py
Created November 16, 2018 08:04
Gateway broadcast for Pubnub
# importing pubnub libraries
from pubnub.pubnub import PubNub, SubscribeListener, SubscribeCallback, PNStatusCategory
from pubnub.pnconfiguration import PNConfiguration
from pubnub.exceptions import PubNubException
import pubnub
import serial
import json
import csv
import simplejson
import time
@apherio
apherio / map.geojson
Last active October 14, 2018 06:17 — forked from iotakodali/map.geojson
Basic plotting for sample view generation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@apherio
apherio / wp-author-import-auto-select.js
Created September 11, 2018 21:12 — forked from webercoder/wp-author-import-auto-select.js
Auto-select authors for posts during WordPress import. They must already be assigned to the project. Enable jQuery in a plugin or functions.php, and paste this in the browser console.
(function($){
$('#authors li').each(function(key, value) {
var name = $(this).children('strong').first().html();
var re = /\s\([^\)]+\)/gi;
name = name.replace(re, '');
$(this).find('select').first().children('option').each(function(){
if ($(this).html() == name) {
console.log('Comparing ' + $(this).html() + ' to ' + name + ".\n");
$(this).attr('selected', 'selected');
@apherio
apherio / TweakingAnimationfragments.txt
Last active April 29, 2016 21:12
How to know when enter transition / onEnterAnimationComplete() ended on Fragment?
***Tweaking the animation timing****
From Lollipop, we can use onEnterAnimationComplete to check animation.So, in onCreate, if the SDK version is older than Lollipop, the RecyclerView can be populated.In Lollipop and newer, onEnterAnimationComplete will be called. Time to populate the RecyclerView and request a new layout animation is done like this
@Override public void onEnterAnimationComplete() {
super.onEnterAnimationComplete();
setRecyclerAdapter(recyclerView);
recyclerView.scheduleLayoutAnimation();
}
@apherio
apherio / gist:02895e32ea7ff578a34700d73e0447a5
Created April 29, 2016 20:26
How to know when enter transition ended on Fragment?
Tweaking the animation timing
@apherio
apherio / gist:4b2cc08c625e85ce3a67027bf3f08bc7
Created April 29, 2016 20:26
How to know when enter transition ended on Fragment?
Tweaking the animation timing