Skip to content

Instantly share code, notes, and snippets.

View pbojinov's full-sized avatar

Petar Bojinov pbojinov

View GitHub Profile
@pbojinov
pbojinov / summary.md
Last active August 20, 2022 19:42
useReducer vs useState vs useContext – https://www.robinwieruch.de/react-usereducer-vs-usestate/

Summary

Use useState:

  1. if you manage JavaScript primitives as state
  2. if you have simple state transitions
  3. if you want to have business logic within your component
  4. if you have different properties that don’t change in any correlated manner and can be managed by multiple useState hooks
  5. if your state is co-located to your component
  6. if you’ve got a small application (but the lines are blurry here)
@pbojinov
pbojinov / webrtc-internals.txt
Last active June 4, 2022 05:14
UberConference - chrome://webrtc-internals/
Create Dump
Download the PeerConnection updates and stats data
Enable diagnostic audio recordings
A diagnostic audio recording is used for analyzing audio problems. It consists of several files and contains the audio played out to the speaker (output) and captured from the microphone (input). The data is saved locally. Checking this box will enable recordings of all ongoing input and output audio streams (including non-WebRTC streams) and for future audio streams. When the box is unchecked or this page is closed, all ongoing recordings will be stopped and this recording functionality disabled. Recording audio from multiple tabs is supported as well as multiple recordings from the same tab.
When enabling, select a base filename to which the following suffixes will be added:
<base filename>.<render process ID>.aec_dump.<AEC dump recording ID>
<base filename>.input.<stream recording ID>.wav
SOPA Emergency IP list:
Here’s how to access your favorite sites in the event of a DNS takedown
tumblr.com 174.121.194.34
wikipedia.org 208.80.152.201
# News
bbc.co.uk 212.58.241.131
aljazeera.com 198.78.201.252
@pbojinov
pbojinov / # Sublime Emmet JSX Reactjs.md
Last active September 29, 2021 02:28 — forked from max-mykhailenko/# Sublime Emmet JSX Reactjs.md
Sublime text 3. Enable Emmet in JSX files with Sublime React plugin

Problem

  • Using emmet in jsx files
  • Emmet expands text when js autocomplete needed
  • Using className instead of class

How it works

  • Install plugin RegReplace
  • Install plugin Chain Of Command
@pbojinov
pbojinov / getting-started.md
Last active June 27, 2021 08:26
Getting Started with React Native Android
@pbojinov
pbojinov / text_to_image.py
Created March 19, 2015 00:26
Using Python's PIL to render text to image - http://effbot.org/imagingbook/overview.htm
import os
from PIL import Image, ImageDraw, ImageFont
# make sure you have the fonts locally in a fonts/ directory
georgia_bold = 'fonts/georgia_bold.ttf'
georgia_bold_italic = 'fonts/georgia_bold_italic.ttf'
# W, H = (1280, 720) # image size
W, H = (720, 405) # image size
txt = 'Hello Petar this is my test image' # text to render
var errors = {
// JSHint options
E001: "Bad option: '{a}'.",
E002: "Bad option value.",
// JSHint input
E003: "Expected a JSON value.",
E004: "Input is neither a string nor an array of strings.",
E005: "Input is empty.",
E006: "Unexpected early end of program.",

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@pbojinov
pbojinov / multipleDeferredAjax.js
Created February 19, 2014 20:46
Multiple Simultaneous Ajax Requests (with one callback) in jQuery
// http://css-tricks.com/multiple-simultaneous-ajax-requests-one-callback-jquery/?utm_source=javascriptweekly&utm_medium=email
$.when(
// Get the HTML
$.get("/feature/", function(html) {
globalStore.html = html;
}),
// Get the CSS
$.get("/assets/feature.css", function(css) {
@pbojinov
pbojinov / data-action.js
Last active September 4, 2020 20:56
manually bind an event listener for each value that data-action might hold - http://alexkinnee.com/2013/11/binding-js-events-using-data-action-selectors/
// Using [data-action=""] selectors instead of class selectors when binding events in JavaScript
var actions = {
action1: function() {},
action2: function() {}
//....
};
$('body').on('click', '[data-action]', function() {
var action = $(this).data('action');
if (action in actions) {