Skip to content

Instantly share code, notes, and snippets.

View unigazer's full-sized avatar
🔭
Gazing at the wonders of the universe!

Vladimir Jovanović unigazer

🔭
Gazing at the wonders of the universe!
View GitHub Profile
@unigazer
unigazer / Component.jsx
Created February 8, 2021 14:39
Click outside React with hooks
import useOutsideClick from './useOutsideClick';
export default () => {
useOutsideClick(useRef, () => {
// Update state or whatever
})
return <></>
}
@unigazer
unigazer / debounce_search_react.jsx
Created February 7, 2021 00:02
Debounce function for remote search using React Hooks
// Credits: https://stackoverflow.com/a/61629055/5981004
useEffect(() => {
const delayDebounceFn = setTimeout(() => {
// HTTP
}, 500)
return () => clearTimeout(delayDebounceFn)
}, [input])
@unigazer
unigazer / wuauserv.reg
Created January 7, 2021 13:49
Fix for Windows 10 update service not running/currupted (wuauserv.reg)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv]
"DependOnService"=hex(7):72,00,70,00,63,00,73,00,73,00,00,00,00,00
"Description"="@%systemroot%\\system32\\wuaueng.dll,-106"
"DisplayName"="@%systemroot%\\system32\\wuaueng.dll,-105"
"ErrorControl"=dword:00000001
"FailureActions"=hex:80,51,01,00,00,00,00,00,00,00,00,00,03,00,00,00,14,00,00,\
00,01,00,00,00,60,ea,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"ImagePath"=hex(2):25,00,73,00,79,00,73,00,74,00,65,00,6d,00,72,00,6f,00,6f,00,\
@unigazer
unigazer / functions.php
Created February 20, 2019 17:42
Get featured image for WordPress RESTful API
// Add to theme functions.php (Tested on WordPress 5.0.3)
<?php
function post_fetured_image_json( $data, $post, $context ) {
$featured_image_id = $data->data['featured_media']; // get featured image id
$featured_image_url = wp_get_attachment_image_src( $featured_image_id, 'original' ); // get url of the original size
if( $featured_image_url ) {
$data->data['featured_image_url'] = $featured_image_url[0];
const http = require('https')
// Nanoseconds per second 1000000
const NS_PER_SEC = 1e6
// In order to convert to ms, process.hrtime() must be declared previously
const time = process.hrtime();
// Gather the data
const req = http.request(process.argv[2], res => {
res.setEncoding('utf8')